|
@@ -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
|
|
|
}
|