From 34c659d51ba2fc3b05af2a762fb3dfcb70ec5170 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 17 Jan 2025 12:26:11 -0500 Subject: cmd: add uncle-ted Signed-off-by: Xe Iaso --- cmd/uncle-ted/bomb.txt.gz.gz | Bin 0 -> 84876 bytes cmd/uncle-ted/main.go | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 cmd/uncle-ted/bomb.txt.gz.gz create mode 100644 cmd/uncle-ted/main.go (limited to 'cmd') diff --git a/cmd/uncle-ted/bomb.txt.gz.gz b/cmd/uncle-ted/bomb.txt.gz.gz new file mode 100644 index 0000000..7dacf06 Binary files /dev/null and b/cmd/uncle-ted/bomb.txt.gz.gz differ 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) +} -- cgit v1.2.3