feat(shadowsocks): implement support for SIP022 AEAD-2022 ciphers

This commit is contained in:
Chang lue Tsen
2025-05-31 11:28:06 -04:00
parent 1a21984c27
commit 0fb0aac2fa
10 changed files with 85 additions and 28 deletions
+1 -16
View File
@@ -6,8 +6,6 @@ import (
"strings"
"github.com/perfect-panel/server/pkg/adapter/proxy"
"github.com/perfect-panel/server/pkg/tool"
"github.com/perfect-panel/server/pkg/uuidx"
)
func buildShadowsocks(data proxy.Proxy, password string) string {
@@ -18,7 +16,7 @@ func buildShadowsocks(data proxy.Proxy, password string) string {
}
if strings.Contains(shadowsocks.Method, "2022") {
serverKey, userKey := generateShadowsocks2022Password(shadowsocks, password)
serverKey, userKey := proxy.GenerateShadowsocks2022Password(shadowsocks, password)
password = fmt.Sprintf("%s:%s", serverKey, userKey)
}
@@ -34,16 +32,3 @@ func buildShadowsocks(data proxy.Proxy, password string) string {
uri := strings.Join(configs, ",")
return uri + "\r\n"
}
func generateShadowsocks2022Password(ss proxy.Shadowsocks, password string) (string, string) {
// server key
var serverKey string
if ss.Method == "2022-blake3-aes-128-gcm" {
serverKey = tool.GenerateCipher(ss.ServerKey, 16)
password = uuidx.UUIDToBase64(password, 16)
} else {
serverKey = tool.GenerateCipher(ss.ServerKey, 32)
password = uuidx.UUIDToBase64(password, 32)
}
return serverKey, password
}