Compare commits

...

17 commits
dev ... main

Author SHA1 Message Date
26a1452485
u
All checks were successful
/ docker (push) Successful in 46s
2025-01-11 12:51:45 +01:00
94de945eff
b
Some checks failed
/ docker (push) Failing after 9s
2025-01-11 12:51:06 +01:00
4cdd27e7a6
a
Some checks failed
/ docker (push) Failing after 46s
2025-01-11 12:38:38 +01:00
ce76eb77bf
add debug print
Some checks failed
/ docker (push) Failing after 48s
2025-01-11 12:32:11 +01:00
87356409ec b
Some checks failed
/ docker (push) Failing after 45s
2024-12-30 17:56:06 +01:00
2cd8bfdd25 a
Some checks failed
/ docker (push) Failing after 46s
2024-12-30 17:48:13 +01:00
1f4d412055 Now push is the problem
Some checks failed
/ docker (push) Failing after 10s
2024-12-30 17:46:41 +01:00
7e0dd539b1 Fix runner target
Some checks failed
/ docker (push) Failing after 55s
/ test_docker (push) Successful in 0s
2024-12-30 17:32:47 +01:00
2a1690b79c Test docker run
Some checks failed
/ test_docker (push) Successful in 1s
/ docker (push) Has been cancelled
2024-12-30 17:18:20 +01:00
f68e39d130 more
Some checks failed
/ docker (push) Failing after 6s
2024-12-30 15:53:14 +01:00
592455c6fe next try
Some checks failed
/ docker (push) Failing after 29s
2024-12-30 15:44:02 +01:00
6abe480eee Next try
Some checks failed
/ docker (push) Failing after 8s
2024-12-30 15:29:59 +01:00
716b64de2f try things
Some checks failed
/ docker (push) Failing after 56s
2024-12-30 15:26:56 +01:00
d808ddfe14 Add build and push action
Some checks are pending
/ docker (push) Waiting to run
2024-12-30 15:20:35 +01:00
d03b4a98f8 Update webpage 2024-12-30 15:20:25 +01:00
mStar aka a person
29d8bb96ea Merge branch 'dev' into 'main'
New updates

See merge request evilthings-services/mstar!2
2024-04-21 15:45:39 +00:00
mStar aka a person
8f75427e8c Merge branch 'dev' into 'main'
Add logging

See merge request evilthings-services/mstar!1
2024-01-23 14:01:30 +00:00
13 changed files with 244 additions and 197 deletions

View file

@ -0,0 +1,29 @@
on:
push:
branches:
- main
jobs:
docker:
runs-on: ubuntu-22.04
steps:
# - run: "echo reg: ${{ env.GITHUB_SERVER_URL }}, act: ${{ github.actor }}, sec: ${{ github.token }}"
-
name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_SERVER_URL }}
username: ${{ github.actor }}
password: ${{ secrets.REG_TOKEN }}
# -
# name: Set up QEMU
# uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: git.mstar.dev/${{ env.GITHUB_REPOSITORY }}:latest

View file

8
.idea/.gitignore vendored
View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mstar.iml" filepath="$PROJECT_DIR$/.idea/mstar.iml" />
</modules>
</component>
</project>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM golang:1.21 AS build-stage
FROM golang:1.23 AS build-stage
WORKDIR /app
COPY go.mod ./
@ -15,7 +15,7 @@ COPY robots.txt ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /mstar
FROM gcr.io/distroless/base-debian11 AS build-release-stage
FROM scratch AS build-release-stage
WORKDIR /

13
go.mod
View file

@ -1,10 +1,15 @@
module gitlab.com/evilthings-services/mstar
go 1.21.5
go 1.23.4
require (
github.com/sirupsen/logrus v1.9.3
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d
git.mstar.dev/mstar/goutils v1.6.1
github.com/rs/zerolog v1.33.0
)
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/rs/xid v1.5.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)

39
go.sum
View file

@ -1,17 +1,22 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d h1:ixTYuViFIDQh9fs3xyc8sPKBr7dU7T98rs4kqM0q51k=
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d/go.mod h1:8G+BrXVs97wI7W+Z4E8M2MXFFKKy01cVnFazoCpNg9Y=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
git.mstar.dev/mstar/goutils v1.5.4 h1:l/4oQe/fBk9zyXplQkGXbmQndnm0aRdHuy4wgQfNrFo=
git.mstar.dev/mstar/goutils v1.5.4/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
git.mstar.dev/mstar/goutils v1.6.0 h1:2K0KqoymJoEJUIYVHkjJ0GJKGNeWVfHMmpeRMtNiG3Q=
git.mstar.dev/mstar/goutils v1.6.0/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
git.mstar.dev/mstar/goutils v1.6.1 h1:2yr9GYN8CJByZsJRu1pZ6WBp51Nn+3zJq49ky54xYDk=
git.mstar.dev/mstar/goutils v1.6.1/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

89
main.go
View file

@ -1,14 +1,20 @@
package main
import (
"context"
"embed"
"flag"
"fmt"
"html/template"
"net/http"
"os"
"os/signal"
"time"
"github.com/sirupsen/logrus"
"gitlab.com/mstarongitlab/weblogger"
"git.mstar.dev/mstar/goutils/middleware"
"git.mstar.dev/mstar/goutils/other"
"github.com/rs/zerolog/hlog"
"github.com/rs/zerolog/log"
)
const HTML_PREFIX = "<!-- "
@ -30,38 +36,59 @@ var embed_robots_txt string
var embed_humans_txt string
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
logrus.WithField("port", port).Info("starting server")
other.SetupFlags()
portFlag := flag.String("port", "8080", "Set the port. Overwrites env vars")
flag.Parse()
other.ConfigureLoggingFromCliArgs()
// Custom-ish paths. Includes templates
http.HandleFunc("/", handleRoot)
mux := http.NewServeMux()
mux.HandleFunc("/{$}", handleRoot)
// Catchall that just redirects to Hetzner's 10GB speedtest file
// TODO: Maybe swap that for a forced zip bomb?
mux.Handle(
"/",
http.RedirectHandler("https://hil-speed.hetzner.com/10GB.bin", http.StatusMovedPermanently),
)
// Funny awawawa stream
http.HandleFunc("/cat/awawawa", awawaStream)
mux.HandleFunc("/cat/awawawa", awawaStream)
// static files in /static
http.Handle("/static/", http.FileServer(http.FS(embed_static)))
mux.Handle("/static/", http.FileServer(http.FS(embed_static)))
// .well-known from /well-known
http.Handle("/.well-known/", http.StripPrefix("/.well-known/", http.FileServer(http.FS(embed_well_known))))
mux.Handle(
"/.well-known/",
http.StripPrefix("/.well-known/", http.FileServer(http.FS(embed_well_known))),
)
// Static files not in /static or /.well-known
http.HandleFunc("/robots.txt", buildHTTPFileReader(embed_robots_txt))
http.HandleFunc("/humans.txt", buildHTTPFileReader(embed_humans_txt))
mux.HandleFunc("/robots.txt", buildHTTPFileReader(embed_robots_txt))
mux.HandleFunc("/humans.txt", buildHTTPFileReader(embed_humans_txt))
default_mux := http.DefaultServeMux
logger := weblogger.LoggingMiddleware(default_mux)
if err := http.ListenAndServe(":"+port, logger); err != nil {
logrus.WithField("event", "stop server").Fatal(err)
server := http.Server{
Addr: ":" + *portFlag,
Handler: middleware.ChainMiddlewares(mux, middleware.LoggingMiddleware),
}
exitChan := make(chan os.Signal, 1)
signal.Notify(exitChan, os.Interrupt)
go func() {
log.Info().Str("addr", server.Addr).Msg("Starting server")
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal().Err(err).Msg("Server exited unexpectedly")
}
}()
<-exitChan
log.Info().Msg("Shutting down server due to Interrupt")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
err := server.Shutdown(ctx)
if err != nil {
log.Fatal().Err(err).Msg("Failed to cleanly shut down")
}
log.Info().Msg("Clean shutdown complete")
}
func handleRoot(w http.ResponseWriter, r *http.Request) {
// logRequestInfo(r)
tmpl, err := template.ParseFS(embed_templates, "templates/index.html")
if err != nil {
http.Error(w, "Couldn't parse template file", http.StatusInternalServerError)
@ -75,7 +102,6 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
func buildHTTPFileReader(embed_content string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
// logRequestInfo(r)
fmt.Fprintf(w, "%s", embed_content)
}
}
@ -84,21 +110,26 @@ func awawaStream(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(206)
w.Header().Set("Status", "206")
genStub(1024, w) // Hardcoded. Firefox & Chrome both have this value and a len of 0 wouldn't work
fmt.Println("Starting awawawa stream")
i := 0
genStub(
1024,
w,
) // Hardcoded. Firefox & Chrome both have this value and a len of 0 wouldn't work
hlog.FromRequest(r).Debug().Msg("Starting stream")
i := true
// Only run every 0.2 seconds, aka 5 times a second
timer := time.Tick(time.Millisecond * 200)
for {
select {
case <-r.Context().Done():
fmt.Println("awawawa Stream done")
hlog.FromRequest(r).Debug().Msg("Stream done")
return
default:
if i%2 == 0 {
case <-timer:
if i {
fmt.Fprint(w, "a")
} else {
fmt.Fprint(w, "w")
}
i += 1
i = !i
}
}
}

View file

@ -15,3 +15,6 @@ Disallow: /
User-Agent: FacebookBot
Disallow: /
User-Agent: Googlebot
Disallow: /cat/awawawa

View file

@ -1,12 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<head>
<link rel="stylesheet" href="/static/styles/index.css" />
<meta charset="UTF-8" />
<title>m*</title>
</head>
</head>
<body class="add-background">
<body class="add-background">
<div class="center-inner">
<div class="size-to-max-inner-content">
<h1>Welcome to my personal webpage</h1>
@ -37,12 +38,16 @@
<th>Link/Username</th>
</tr>
<tr>
<td>Fedi</td>
<td>Fedi (woem)</td>
<td>
<a rel="me" href="https://woem.men/@mstar"
>https://woem.men/@mstar</a
>
<a rel="me" href="https://woem.men/@mstar">https://woem.men/@mstar</a>
</td>
<tr>
<td>Fedi (mkab, backup)</td>
<td>
<a rel="me" href="https://mk.absturztau.be/@mstar">https://mk.absturztau.be/@mstar</a>
</td>
</tr>
</tr>
<tr>
<td>Discord</td>
@ -53,48 +58,45 @@
<tr>
<td>Pronouns page</td>
<td>
<a href="https://en.pronouns.page/@m_evil"
>https://en.pronouns.page/@m_evil</a
>
<a href="https://en.pronouns.page/@m_evil">https://en.pronouns.page/@m_evil</a>
</td>
</tr>
<tr>
<td>Gitlab</td>
<td>Forgejo</td>
<td>
<a href="https://gitlab.com/mstarongitlab"
>https://gitlab.com/mstarongitlab</a
>
<a href="https://git.mstar.dev/mstar">https://git.mstar.dev/mstar</a>
</td>
</tr>
<tr>
<td>Github</td>
<td>Gitlab (not actively used anymore)</td>
<td>
<a href="https://github.com/mstarongithub/"
>https://github.com/mstarongithub/</a
>
<a href="https://gitlab.com/mstarongitlab">https://gitlab.com/mstarongitlab</a>
</td>
</tr>
<tr>
<td>Github (same as Gitlab)</td>
<td>
<a href="https://github.com/mstarongithub/">https://github.com/mstarongithub/</a>
</td>
</tr>
<tr>
<td>Twitch</td>
<td>
<a href="https://twitch.tv/mstarontwitch"
>https://twitch.tv/mstarontwitch</a
>
<a href="https://twitch.tv/mstarontwitch">https://twitch.tv/mstarontwitch</a>
</td>
</tr>
<tr>
<td>Youtube</td>
<td>
<a href="https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg"
>https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg</a
>
<a
href="https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg">https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg</a>
</td>
</tr>
<tr>
<!-- Rickroll -->
<td>Twitter</td>
<td>Bluesky</td>
<td>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">https://twitter.com/mstar</a>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">https://bsky.app/profile/mstar.dev</a>
</td>
</tr>
</table>
@ -103,14 +105,17 @@
<li><a href="https://linktr.ee/akijam">Fren Aki</a></li>
</ul>
<hr />
<p>I'm also working on a Fediverse server, <a href="https://git.mstar.dev/mstar/linstrom">Linstrom</a></p>
<br>
<p>Todo: Add proper styling</p>
</div>
</div>
<footer>
<p>Contact: <a href="mailto:me@mstar.dev">me@mstar.dev</> (<a href="/static/files/other/publickey.me@mstar.dev-27fcaabd3022acff023e6e2a053a2d9af0f03260.asc">Public PGP key</a>)</p>
<p>Last updated: 20.04.2024</p>
<p>Privacy notice: This webserver stores no information</p>
<p>Contact: <a href="mailto:me@mstar.dev">me@mstar.dev (<a
href="/static/files/other/publickey.me@mstar.dev-27fcaabd3022acff023e6e2a053a2d9af0f03260.asc">Public PGP
key</a>)</p>
<p>Last updated: 30.12.2024</p>
</footer>
</body>
</html>
</body>
</html>

View file

@ -1 +1 @@
https://cloud.google.com
https://ionos.com