Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xray/api.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/xray/api.go b/xray/api.go
index 99335076..f39361f2 100644
--- a/xray/api.go
+++ b/xray/api.go
@@ -15,6 +15,7 @@ import (
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/infra/conf"
"github.com/xtls/xray-core/proxy/shadowsocks"
+ "github.com/xtls/xray-core/proxy/shadowsocks_2022"
"github.com/xtls/xray-core/proxy/trojan"
"github.com/xtls/xray-core/proxy/vless"
"github.com/xtls/xray-core/proxy/vmess"
@@ -99,9 +100,31 @@ func (x *XrayAPI) AddUser(Protocol string, inboundTag string, user map[string]in
Password: user["password"].(string),
})
case "shadowsocks":
- account = serial.ToTypedMessage(&shadowsocks.Account{
- Password: user["password"].(string),
- })
+ var ssCipherType shadowsocks.CipherType
+ switch user["cipher"].(string) {
+ case "aes-128-gcm":
+ ssCipherType = shadowsocks.CipherType_AES_128_GCM
+ case "aes-256-gcm":
+ ssCipherType = shadowsocks.CipherType_AES_256_GCM
+ case "chacha20-poly1305":
+ ssCipherType = shadowsocks.CipherType_CHACHA20_POLY1305
+ case "xchacha20-poly1305":
+ ssCipherType = shadowsocks.CipherType_XCHACHA20_POLY1305
+ default:
+ ssCipherType = shadowsocks.CipherType_NONE
+ }
+
+ if ssCipherType != shadowsocks.CipherType_NONE {
+ account = serial.ToTypedMessage(&shadowsocks.Account{
+ Password: user["password"].(string),
+ CipherType: ssCipherType,
+ })
+ } else {
+ account = serial.ToTypedMessage(&shadowsocks_2022.User{
+ Key: user["password"].(string),
+ Email: user["email"].(string),
+ })
+ }
default:
return nil
}