aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-23 12:03:21 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-23 12:03:21 +0800
commitcbc0a16ea659ae5e045a8c94f0ce862bf7065b5e (patch)
tree9f5cac020826876748634885bc1f299a7ff904e0
parentSeparate flags (diff)
downloadpowxy-cbc0a16ea659ae5e045a8c94f0ce862bf7065b5e.tar.gz
powxy-cbc0a16ea659ae5e045a8c94f0ce862bf7065b5e.tar.zst
powxy-cbc0a16ea659ae5e045a8c94f0ce862bf7065b5e.zip
Separate privkey stuff
-rw-r--r--main.go15
-rw-r--r--privkey.go21
2 files changed, 21 insertions, 15 deletions
diff --git a/main.go b/main.go
index 61fa133..10794ab 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,6 @@ package main
import (
"crypto/hmac"
- "crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
@@ -16,20 +15,6 @@ import (
"time"
)
-var (
- privkey = make([]byte, 32)
- privkeyHash = make([]byte, 0, sha256.Size)
-)
-
-func init() {
- if _, err := rand.Read(privkey); err != nil {
- log.Fatal(err)
- }
- h := sha256.New()
- h.Write(privkey)
- privkeyHash = h.Sum(nil)
-}
-
var reverseProxy *httputil.ReverseProxy
func init() {
diff --git a/privkey.go b/privkey.go
new file mode 100644
index 0000000..bad6f80
--- /dev/null
+++ b/privkey.go
@@ -0,0 +1,21 @@
+package main
+
+import (
+ "crypto/rand"
+ "crypto/sha256"
+ "log"
+)
+
+var (
+ privkey = make([]byte, 32)
+ privkeyHash = make([]byte, 0, sha256.Size)
+)
+
+func init() {
+ if _, err := rand.Read(privkey); err != nil {
+ log.Fatal(err)
+ }
+ h := sha256.New()
+ h.Write(privkey)
+ privkeyHash = h.Sum(nil)
+}