summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-11-02 16:32:45 -0800
committerRose Hogenson <rosehogenson@posteo.net>2025-11-02 16:39:14 -0800
commit171119fa753ea82eb36e79559cb333b732d4cc60 (patch)
treea5b30074e4fcbd9558dc99bf52ab048d2edf436b /roseh.moe.go
parentd087f7d33e083a4f70a98d3a4cbfa636c7c173e6 (diff)
downloadroseh.moe-171119fa753ea82eb36e79559cb333b732d4cc60.tar.zst
Add QR code
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go12
1 files changed, 12 insertions, 0 deletions
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)