diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index c9cbbc5..9f63d65 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -8,6 +8,7 @@ import ( "crypto/subtle" "embed" "encoding/base64" + "encoding/binary" "encoding/hex" "flag" "fmt" @@ -20,8 +21,8 @@ import ( "sync" "time" - "roseh.moe/pkg/roseh.moe/internal/hole" "roseh.moe/pkg/roseh.moe/internal/pwhash" + "roseh.moe/pkg/wordlist" ) var ( @@ -131,8 +132,19 @@ type wormholeTemplateArgs struct { Hole string } +func makeHole() string { + const nWords = 10 + buf := make([]byte, 2*nWords) + rand.Read(buf) + words := make([]string, nWords) + for i := range words { + words[i] = wordlist.Words[binary.NativeEndian.Uint16(buf[2*i:])&0x1fff] + } + return strings.Join(words, "-") +} + func wormhole(w http.ResponseWriter, r *http.Request) { - if err := wormholeTemplate.Execute(w, wormholeTemplateArgs{Self: *selfURL, Hole: hole.New()}); err != nil { + if err := wormholeTemplate.Execute(w, wormholeTemplateArgs{Self: *selfURL, Hole: makeHole()}); err != nil { log.Printf("Warning: wormhole: %s", err) } } |
