fix random pw strength

This commit is contained in:
yuzuki999 2023-08-07 10:00:36 +08:00
parent d37f1ecded
commit 45099f6056

View File

@ -4,7 +4,6 @@ import (
"context"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"fmt"
"net/netip"
"net/url"
@ -106,7 +105,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
case "2022-blake3-aes-256-gcm":
keyLength = 32
default:
keyLength = 8
keyLength = 16
}
in.ShadowsocksOptions = option.ShadowsocksInboundOptions{
ListenOptions: listen,
@ -114,7 +113,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
}
p := make([]byte, keyLength)
_, _ = rand.Read(p)
randomPasswd := hex.EncodeToString(p)
randomPasswd := string(p)
if strings.Contains(info.Cipher, "2022") {
in.ShadowsocksOptions.Password = info.ServerKey
randomPasswd = base64.StdEncoding.EncodeToString([]byte(randomPasswd))