diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 12 |
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) |
