Add some redirect paths and disable awawawa stream
All checks were successful
/ docker (push) Successful in 45s
All checks were successful
/ docker (push) Successful in 45s
This commit is contained in:
parent
26a1452485
commit
34b8ca9c3c
1 changed files with 18 additions and 1 deletions
19
main.go
19
main.go
|
@ -35,6 +35,15 @@ var embed_robots_txt string
|
||||||
// go: embed humans.txt
|
// go: embed humans.txt
|
||||||
var embed_humans_txt string
|
var embed_humans_txt string
|
||||||
|
|
||||||
|
var redirectMapping = map[string]string{
|
||||||
|
"/twitch": "https://twitch.tv/mstarontwitch",
|
||||||
|
"/bsky": "https://bsky.app/profile/mstar.dev",
|
||||||
|
"/bluesky": "https://bsky.app/profile/mstar.dev",
|
||||||
|
"/git": "https://git.mstar.dev",
|
||||||
|
"/gitlab": "https://gitlab.com/mstarongitlab",
|
||||||
|
"/github": "https://github.com/mstarongithub",
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
other.SetupFlags()
|
other.SetupFlags()
|
||||||
portFlag := flag.String("port", "8080", "Set the port. Overwrites env vars")
|
portFlag := flag.String("port", "8080", "Set the port. Overwrites env vars")
|
||||||
|
@ -50,6 +59,10 @@ func main() {
|
||||||
http.RedirectHandler("https://hil-speed.hetzner.com/10GB.bin", http.StatusMovedPermanently),
|
http.RedirectHandler("https://hil-speed.hetzner.com/10GB.bin", http.StatusMovedPermanently),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for k, v := range redirectMapping {
|
||||||
|
mux.Handle(k, http.RedirectHandler(v, http.StatusMovedPermanently))
|
||||||
|
}
|
||||||
|
|
||||||
mux.HandleFunc("/cat/awawawa", awawaStream)
|
mux.HandleFunc("/cat/awawawa", awawaStream)
|
||||||
|
|
||||||
// static files in /static
|
// static files in /static
|
||||||
|
@ -107,6 +120,8 @@ func buildHTTPFileReader(embed_content string) func(w http.ResponseWriter, r *ht
|
||||||
}
|
}
|
||||||
|
|
||||||
func awawaStream(w http.ResponseWriter, r *http.Request) {
|
func awawaStream(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Fprint(w, "Disabled until I can find a good way to rate limit the stream")
|
||||||
|
return
|
||||||
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")
|
||||||
|
@ -116,14 +131,16 @@ func awawaStream(w http.ResponseWriter, r *http.Request) {
|
||||||
) // Hardcoded. Firefox & Chrome both have this value and a len of 0 wouldn't work
|
) // Hardcoded. Firefox & Chrome both have this value and a len of 0 wouldn't work
|
||||||
hlog.FromRequest(r).Debug().Msg("Starting stream")
|
hlog.FromRequest(r).Debug().Msg("Starting stream")
|
||||||
i := true
|
i := true
|
||||||
|
fmt.Fprint(w, "awawaw")
|
||||||
// Only run every 0.2 seconds, aka 5 times a second
|
// Only run every 0.2 seconds, aka 5 times a second
|
||||||
timer := time.Tick(time.Millisecond * 200)
|
timer := time.Tick(time.Millisecond * 100)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-r.Context().Done():
|
case <-r.Context().Done():
|
||||||
hlog.FromRequest(r).Debug().Msg("Stream done")
|
hlog.FromRequest(r).Debug().Msg("Stream done")
|
||||||
return
|
return
|
||||||
case <-timer:
|
case <-timer:
|
||||||
|
hlog.FromRequest(r).Debug().Msg("Stream elem")
|
||||||
if i {
|
if i {
|
||||||
fmt.Fprint(w, "a")
|
fmt.Fprint(w, "a")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue