Update webpage

This commit is contained in:
Melody Becker 2024-12-30 15:20:25 +01:00
parent 29d8bb96ea
commit d03b4a98f8
12 changed files with 215 additions and 197 deletions

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 # syntax=docker/dockerfile:1
FROM golang:1.21 AS build-stage FROM golang:1.23 AS build-stage
WORKDIR /app WORKDIR /app
COPY go.mod ./ COPY go.mod ./
@ -15,7 +15,7 @@ COPY robots.txt ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /mstar 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 / WORKDIR /
@ -25,4 +25,4 @@ EXPOSE 8080
USER nonroot:nonroot USER nonroot:nonroot
ENTRYPOINT [ "/mstar" ] ENTRYPOINT [ "/mstar" ]

13
go.mod
View file

@ -1,10 +1,15 @@
module gitlab.com/evilthings-services/mstar module gitlab.com/evilthings-services/mstar
go 1.21.5 go 1.23.4
require ( require (
github.com/sirupsen/logrus v1.9.3 git.mstar.dev/mstar/goutils v1.6.1
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d 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= git.mstar.dev/mstar/goutils v1.5.4 h1:l/4oQe/fBk9zyXplQkGXbmQndnm0aRdHuy4wgQfNrFo=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= git.mstar.dev/mstar/goutils v1.5.4/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= git.mstar.dev/mstar/goutils v1.6.0 h1:2K0KqoymJoEJUIYVHkjJ0GJKGNeWVfHMmpeRMtNiG3Q=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= git.mstar.dev/mstar/goutils v1.6.0/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= git.mstar.dev/mstar/goutils v1.6.1 h1:2yr9GYN8CJByZsJRu1pZ6WBp51Nn+3zJq49ky54xYDk=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= git.mstar.dev/mstar/goutils v1.6.1/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d h1:ixTYuViFIDQh9fs3xyc8sPKBr7dU7T98rs4kqM0q51k= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
gitlab.com/mstarongitlab/weblogger v0.0.0-20240123135616-d64461e3b20d/go.mod h1:8G+BrXVs97wI7W+Z4E8M2MXFFKKy01cVnFazoCpNg9Y= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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 package main
import ( import (
"context"
"embed" "embed"
"flag"
"fmt" "fmt"
"html/template" "html/template"
"net/http" "net/http"
"os" "os"
"os/signal"
"time"
"github.com/sirupsen/logrus" "git.mstar.dev/mstar/goutils/middleware"
"gitlab.com/mstarongitlab/weblogger" "git.mstar.dev/mstar/goutils/other"
"github.com/rs/zerolog/hlog"
"github.com/rs/zerolog/log"
) )
const HTML_PREFIX = "<!-- " const HTML_PREFIX = "<!-- "
@ -30,38 +36,59 @@ var embed_robots_txt string
var embed_humans_txt string var embed_humans_txt string
func main() { func main() {
port := os.Getenv("PORT") other.SetupFlags()
if port == "" { portFlag := flag.String("port", "8080", "Set the port. Overwrites env vars")
port = "8080" flag.Parse()
} other.ConfigureLoggingFromCliArgs()
logrus.WithField("port", port).Info("starting server")
// Custom-ish paths. Includes templates mux := http.NewServeMux()
http.HandleFunc("/", handleRoot) 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 mux.HandleFunc("/cat/awawawa", awawaStream)
http.HandleFunc("/cat/awawawa", awawaStream)
// static files in /static // 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 // .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 // Static files not in /static or /.well-known
http.HandleFunc("/robots.txt", buildHTTPFileReader(embed_robots_txt)) mux.HandleFunc("/robots.txt", buildHTTPFileReader(embed_robots_txt))
http.HandleFunc("/humans.txt", buildHTTPFileReader(embed_humans_txt)) mux.HandleFunc("/humans.txt", buildHTTPFileReader(embed_humans_txt))
default_mux := http.DefaultServeMux server := http.Server{
logger := weblogger.LoggingMiddleware(default_mux) Addr: ":" + *portFlag,
Handler: middleware.ChainMiddlewares(mux, middleware.LoggingMiddleware),
if err := http.ListenAndServe(":"+port, logger); err != nil {
logrus.WithField("event", "stop server").Fatal(err)
} }
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) { func handleRoot(w http.ResponseWriter, r *http.Request) {
// logRequestInfo(r)
tmpl, err := template.ParseFS(embed_templates, "templates/index.html") tmpl, err := template.ParseFS(embed_templates, "templates/index.html")
if err != nil { if err != nil {
http.Error(w, "Couldn't parse template file", http.StatusInternalServerError) 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) { func buildHTTPFileReader(embed_content string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
// logRequestInfo(r)
fmt.Fprintf(w, "%s", embed_content) 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.Header().Set("Content-Type", "text/html")
w.WriteHeader(206) w.WriteHeader(206)
w.Header().Set("Status", "206") w.Header().Set("Status", "206")
genStub(1024, w) // Hardcoded. Firefox & Chrome both have this value and a len of 0 wouldn't work genStub(
fmt.Println("Starting awawawa stream") 1024,
i := 0 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 { for {
select { select {
case <-r.Context().Done(): case <-r.Context().Done():
fmt.Println("awawawa Stream done") hlog.FromRequest(r).Debug().Msg("Stream done")
return return
default: case <-timer:
if i%2 == 0 { if i {
fmt.Fprint(w, "a") fmt.Fprint(w, "a")
} else { } else {
fmt.Fprint(w, "w") fmt.Fprint(w, "w")
} }
i += 1 i = !i
} }
} }
} }

View file

@ -14,4 +14,7 @@ User-agent: Omgilibot
Disallow: / Disallow: /
User-Agent: FacebookBot User-Agent: FacebookBot
Disallow: / Disallow: /
User-Agent: Googlebot
Disallow: /cat/awawawa

View file

@ -1,116 +1,121 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<link rel="stylesheet" href="/static/styles/index.css" />
<meta charset="UTF-8" />
<title>m*</title>
</head>
<body class="add-background"> <head>
<div class="center-inner"> <link rel="stylesheet" href="/static/styles/index.css" />
<div class="size-to-max-inner-content"> <meta charset="UTF-8" />
<h1>Welcome to my personal webpage</h1> <title>m*</title>
<p> </head>
Here you'll be able to find various information about me, including
social network links/names <body class="add-background">
</p> <div class="center-inner">
<h3>Some information about me</h3> <div class="size-to-max-inner-content">
<table> <h1>Welcome to my personal webpage</h1>
<tr> <p>
<td>Pronouns</td> Here you'll be able to find various information about me, including
<td>She/Her</td> social network links/names
</tr> </p>
<tr> <h3>Some information about me</h3>
<td>Egg cracked</td> <table>
<td>Jan/Feb 2023</td> <tr>
</tr> <td>Pronouns</td>
<tr> <td>She/Her</td>
<td>Lang</td> </tr>
<td>German, English</td> <tr>
</tr> <td>Egg cracked</td>
</table> <td>Jan/Feb 2023</td>
<br /> </tr>
<h3>You can find me on:</h3> <tr>
<table> <td>Lang</td>
<tr> <td>German, English</td>
<th>Service</th> </tr>
<th>Link/Username</th> </table>
</tr> <br />
<tr> <h3>You can find me on:</h3>
<td>Fedi</td> <table>
<td> <tr>
<a rel="me" href="https://woem.men/@mstar" <th>Service</th>
>https://woem.men/@mstar</a <th>Link/Username</th>
> </tr>
</td> <tr>
</tr> <td>Fedi (woem)</td>
<tr> <td>
<td>Discord</td> <a rel="me" href="https://woem.men/@mstar">https://woem.men/@mstar</a>
<td> </td>
<p>m_star</p> <tr>
</td> <td>Fedi (mkab, backup)</td>
</tr> <td>
<tr> <a rel="me" href="https://mk.absturztau.be/@mstar">https://mk.absturztau.be/@mstar</a>
<td>Pronouns page</td> </td>
<td> </tr>
<a href="https://en.pronouns.page/@m_evil" </tr>
>https://en.pronouns.page/@m_evil</a <tr>
> <td>Discord</td>
</td> <td>
</tr> <p>m_star</p>
<tr> </td>
<td>Gitlab</td> </tr>
<td> <tr>
<a href="https://gitlab.com/mstarongitlab" <td>Pronouns page</td>
>https://gitlab.com/mstarongitlab</a <td>
> <a href="https://en.pronouns.page/@m_evil">https://en.pronouns.page/@m_evil</a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Github</td> <td>Forgejo</td>
<td> <td>
<a href="https://github.com/mstarongithub/" <a href="https://git.mstar.dev/mstar">https://git.mstar.dev/mstar</a>
>https://github.com/mstarongithub/</a </td>
> </tr>
</td> <tr>
</tr> <td>Gitlab (not actively used anymore)</td>
<tr> <td>
<td>Twitch</td> <a href="https://gitlab.com/mstarongitlab">https://gitlab.com/mstarongitlab</a>
<td> </td>
<a href="https://twitch.tv/mstarontwitch" </tr>
>https://twitch.tv/mstarontwitch</a <tr>
> <td>Github (same as Gitlab)</td>
</td> <td>
</tr> <a href="https://github.com/mstarongithub/">https://github.com/mstarongithub/</a>
<tr> </td>
<td>Youtube</td> </tr>
<td> <tr>
<a href="https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg" <td>Twitch</td>
>https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg</a <td>
> <a href="https://twitch.tv/mstarontwitch">https://twitch.tv/mstarontwitch</a>
</td> </td>
</tr> </tr>
<tr> <tr>
<!-- Rickroll --> <td>Youtube</td>
<td>Twitter</td> <td>
<td> <a
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">https://twitter.com/mstar</a> href="https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg">https://www.youtube.com/channel/UC-LklY_wt004i_30xcVohbg</a>
</td> </td>
</tr> </tr>
</table> <tr>
<ul> <!-- Rickroll -->
<li><a href="https://foxgirls.love/web">Fren Erika</a></li> <td>Bluesky</td>
<li><a href="https://linktr.ee/akijam">Fren Aki</a></li> <td>
</ul> <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">https://bsky.app/profile/mstar.dev</a>
<hr /> </td>
<p>Todo: Add proper styling</p> </tr>
</div> </table>
<ul>
<li><a href="https://foxgirls.love/web">Fren Erika</a></li>
<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> </div>
<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> <footer>
<p>Last updated: 20.04.2024</p> <p>Contact: <a href="mailto:me@mstar.dev">me@mstar.dev (<a
<p>Privacy notice: This webserver stores no information</p> href="/static/files/other/publickey.me@mstar.dev-27fcaabd3022acff023e6e2a053a2d9af0f03260.asc">Public PGP
</footer> key</a>)</p>
</body> <p>Last updated: 30.12.2024</p>
</html> </footer>
</body>
</html>

View file

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