diff options
| author | Xe Iaso <me@xeiaso.net> | 2025-01-17 12:26:11 -0500 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2025-01-17 12:26:11 -0500 |
| commit | 34c659d51ba2fc3b05af2a762fb3dfcb70ec5170 (patch) | |
| tree | 867ef00d150c1f23974a5c97043b602cbd46fa2b | |
| parent | 042cee634ce03427f902f0561f8517c510bae07c (diff) | |
| download | x-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.tar.xz x-34c659d51ba2fc3b05af2a762fb3dfcb70ec5170.zip | |
cmd: add uncle-ted
Signed-off-by: Xe Iaso <me@xeiaso.net>
| -rw-r--r-- | Earthfile | 10 | ||||
| -rw-r--r-- | cmd/uncle-ted/bomb.txt.gz.gz | bin | 0 -> 84876 bytes | |||
| -rw-r--r-- | cmd/uncle-ted/main.go | 38 |
3 files changed, 48 insertions, 0 deletions
@@ -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 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) +} |
