From 171119fa753ea82eb36e79559cb333b732d4cc60 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 2 Nov 2025 16:32:45 -0800 Subject: Add QR code --- roseh.moe.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'roseh.moe.go') diff --git a/roseh.moe.go b/roseh.moe.go index 3a53208..19d6109 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -21,6 +21,7 @@ import ( "sync" "time" + "github.com/skip2/go-qrcode" "roseh.moe/pkg/ccl" "roseh.moe/pkg/roseh.moe/internal/pwhash" "roseh.moe/pkg/wordlist" @@ -284,6 +285,16 @@ func wormholeRecv(w http.ResponseWriter, r *http.Request) { } } +func wormholeQR(w http.ResponseWriter, r *http.Request) { + qr, err := qrcode.Encode(*selfURL+"/wormhole/"+r.PathValue("hole"), qrcode.Medium, 200) + if err != nil { + http.Error(w, fmt.Sprintf("failed to encode QR code: %s", err), http.StatusInternalServerError) + return + } + w.Header().Set("Content-Type", "image/png") + w.Write(qr) +} + func mac(msg []byte) []byte { mac := hmac.New(sha256.New, secretKey) mac.Write(msg) @@ -534,6 +545,7 @@ func main() { http.HandleFunc("GET /wormhole/{hole}/upload", wormhole) http.HandleFunc("POST /wormhole/{hole}/upload", wormholeSend) http.HandleFunc("GET /wormhole/{hole}", wormholeRecv) + http.HandleFunc("GET /wormhole/{hole}/qr.png", wormholeQR) http.HandleFunc("POST /login", login) http.HandleFunc("GET /notepad", notepad) http.HandleFunc("POST /notepad", autosave) -- cgit v1.3.1