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:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-07-27 11:04:46 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-07-27 11:04:46 +0300
commit4cfed17650a2aa22346a4aee7aacf3ef6d0c667a (patch)
tree85e64f525e4db028b7441d0277a84986590be420 /xray/api.go
parentc2b1fb485534ad1c0be5a3ba65761751526d29e5 (diff)
[api] fix actions for shadowsocks
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'xray/api.go')
-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
}