aboutsummaryrefslogtreecommitdiff
path: root/cmd/uncle-ted
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-01-17 12:26:11 -0500
committerXe Iaso <me@xeiaso.net>2025-01-17 12:26:11 -0500
commit34c659d51ba2fc3b05af2a762fb3dfcb70ec5170 (patch)
tree867ef00d150c1f23974a5c97043b602cbd46fa2b /cmd/uncle-ted
parent042cee634ce03427f902f0561f8517c510bae07c (diff)
downloadx-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.tar.xz
x-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.zip
cmd: add uncle-ted
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/uncle-ted')
-rw-r--r--cmd/uncle-ted/bomb.txt.gz.gzbin0 -> 84876 bytes
-rw-r--r--cmd/uncle-ted/main.go38
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
new file mode 100644
index 0000000..7dacf06
--- /dev/null
+++ b/cmd/uncle-ted/bomb.txt.gz.gz
Binary files 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)
+}