diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/uncle-ted/bomb.txt.gz.gz | bin | 0 -> 84876 bytes | |||
| -rw-r--r-- | cmd/uncle-ted/main.go | 38 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cmd/uncle-ted/bomb.txt.gz.gz b/cmd/uncle-ted/bomb.txt.gz.gz Binary files differnew file mode 100644 index 0000000..7dacf06 --- /dev/null +++ b/cmd/uncle-ted/bomb.txt.gz.gz diff --git a/cmd/uncle-ted/main.go b/cmd/uncle-ted/main.go new file mode 100644 index 0000000..c3865ce --- /dev/null +++ b/cmd/uncle-ted/main.go @@ -0,0 +1,38 @@ +package main + +import ( + _ "embed" + "flag" + "fmt" + "log" + "log/slog" + "net/http" + + "within.website/x/internal" +) + +var ( + bind = flag.String("bind", ":2836", "TCP port to bind on") + + //go:embed bomb.txt.gz.gz + kaboom []byte +) + +func main() { + internal.HandleStartup() + + http.HandleFunc("/", defenseHandler) + + slog.Info("started up", "url", "http://localhost"+*bind) + log.Fatal(http.ListenAndServe(*bind, nil)) +} + +func defenseHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Content-Encoding", "gzip") + w.Header().Set("Transfer-Encoding", "gzip") + w.Header().Set("Content-Length", fmt.Sprint(len(kaboom))) + + w.WriteHeader(http.StatusOK) + w.Write(kaboom) +} |
