mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 21:39:55 +00:00
fix: shadowsocks2022 user manager not working
This commit is contained in:
parent
5397720430
commit
fc16cb0972
@ -3,6 +3,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -105,10 +106,16 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
|||||||
|
|
||||||
proxySetting, _ := proxySetting.(*conf.ShadowsocksServerConfig)
|
proxySetting, _ := proxySetting.(*conf.ShadowsocksServerConfig)
|
||||||
// shadowsocks must have a random password
|
// shadowsocks must have a random password
|
||||||
if !C.Contains(shadowaead_2022.List, cipher) {
|
// shadowsocks2022's password == user PSK, thus should a length of string >= 32 and base64 encoder
|
||||||
b := make([]byte, 16)
|
b := make([]byte, 16)
|
||||||
rand.Read(b)
|
rand.Read(b)
|
||||||
proxySetting.Password = hex.EncodeToString(b)
|
randPasswd := hex.EncodeToString(b)
|
||||||
|
if C.Contains(shadowaead_2022.List, cipher) {
|
||||||
|
proxySetting.Users = append(proxySetting.Users, &conf.ShadowsocksUserConfig{
|
||||||
|
Password: base64.StdEncoding.EncodeToString([]byte(randPasswd)),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
proxySetting.Password = randPasswd
|
||||||
}
|
}
|
||||||
|
|
||||||
proxySetting.NetworkList = &conf.NetworkList{"tcp", "udp"}
|
proxySetting.NetworkList = &conf.NetworkList{"tcp", "udp"}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ import (
|
|||||||
"github.com/xtls/xray-core/common/serial"
|
"github.com/xtls/xray-core/common/serial"
|
||||||
"github.com/xtls/xray-core/infra/conf"
|
"github.com/xtls/xray-core/infra/conf"
|
||||||
"github.com/xtls/xray-core/proxy/shadowsocks"
|
"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/trojan"
|
||||||
"github.com/xtls/xray-core/proxy/vless"
|
"github.com/xtls/xray-core/proxy/vless"
|
||||||
|
|
||||||
@ -78,11 +80,14 @@ func (c *Controller) buildSSUser(userInfo *[]api.UserInfo, method string) (users
|
|||||||
for i, user := range *userInfo {
|
for i, user := range *userInfo {
|
||||||
// todo waiting xray-core complete proxy.UserManager in shadowsocks2022
|
// todo waiting xray-core complete proxy.UserManager in shadowsocks2022
|
||||||
if C.Contains(shadowaead_2022.List, strings.ToLower(method)) {
|
if C.Contains(shadowaead_2022.List, strings.ToLower(method)) {
|
||||||
|
e := c.buildUserTag(&user)
|
||||||
users[i] = &protocol.User{
|
users[i] = &protocol.User{
|
||||||
Level: 0,
|
Level: 0,
|
||||||
Email: c.buildUserTag(&user),
|
Email: e,
|
||||||
Account: serial.ToTypedMessage(&shadowsocks.Account{
|
Account: serial.ToTypedMessage(&shadowsocks_2022.User{
|
||||||
Password: user.Passwd,
|
Key: base64.StdEncoding.EncodeToString([]byte(user.Passwd)),
|
||||||
|
Email: e,
|
||||||
|
Level: 0,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -105,11 +110,14 @@ func (c *Controller) buildSSPluginUser(userInfo *[]api.UserInfo) (users []*proto
|
|||||||
for i, user := range *userInfo {
|
for i, user := range *userInfo {
|
||||||
// todo waiting xray-core complete proxy.UserManager in shadowsocks2022
|
// todo waiting xray-core complete proxy.UserManager in shadowsocks2022
|
||||||
if C.Contains(shadowaead_2022.List, strings.ToLower(user.Method)) {
|
if C.Contains(shadowaead_2022.List, strings.ToLower(user.Method)) {
|
||||||
|
e := c.buildUserTag(&user)
|
||||||
users[i] = &protocol.User{
|
users[i] = &protocol.User{
|
||||||
Level: 0,
|
Level: 0,
|
||||||
Email: c.buildUserTag(&user),
|
Email: e,
|
||||||
Account: serial.ToTypedMessage(&shadowsocks.Account{
|
Account: serial.ToTypedMessage(&shadowsocks_2022.User{
|
||||||
Password: user.Passwd,
|
Key: base64.StdEncoding.EncodeToString([]byte(user.Passwd)),
|
||||||
|
Email: e,
|
||||||
|
Level: 0,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user