aboutsummaryrefslogtreecommitdiff
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
parent042cee634ce03427f902f0561f8517c510bae07c (diff)
downloadx-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.tar.xz
x-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.zip
cmd: add uncle-ted
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--Earthfile10
-rw-r--r--cmd/uncle-ted/bomb.txt.gz.gzbin0 -> 84876 bytes
-rw-r--r--cmd/uncle-ted/main.go38
3 files changed, 48 insertions, 0 deletions
diff --git a/Earthfile b/Earthfile
index a7e464a..44c9710 100644
--- a/Earthfile
+++ b/Earthfile
@@ -170,6 +170,16 @@ todayinmarch2020:
SAVE IMAGE --push ghcr.io/xe/x/todayinmarch2020:latest
+uncle-ted:
+ FROM +runtime
+
+ COPY +everything/bin/uncle-ted /app/bin/uncle-ted
+ CMD ["/app/bin/uncle-ted"]
+
+ LABEL org.opencontainers.image.source="https://github.com/Xe/x"
+
+ SAVE IMAGE --push ghcr.io/xe/x/uncle-ted:latest
+
within-website:
FROM +runtime
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)
+}