Subject: [PATCH 6/6] Drop Shadowsocks 2022 and the GPL/LGPL modules behind it * proxy/shadowsocks_2022 and common/singbridge are built on github.com/sagernet/sing and sing-shadowsocks (GPL-3.0). The prepare script deletes both directories (patches/xray-core/removed.list); this patch drops the remaining references: infra/conf now rejects "2022-*" methods with a clear error, the API command loses its SS2022 inbound case. * go.mod no longer requires sing, sing-shadowsocks or juju/ratelimit (LGPL-3.0, only used by github.com/xtls/reality, patched separately in patches/reality/). --- --- a/go.mod +++ b/go.mod @@ -17,8 +17,6 @@ github.com/pires/go-proxyproto v0.15.0 github.com/refraction-networking/utls v1.8.3-0.20260301010127-aa6edf4b11af github.com/robfig/cron/v3 v3.0.1 - github.com/sagernet/sing v0.5.1 - github.com/sagernet/sing-shadowsocks v0.2.7 github.com/stretchr/testify v1.11.1 github.com/vishvananda/netlink v1.3.1 github.com/xtls/reality v0.0.0-20260322125925-9234c772ba8f @@ -42,7 +40,6 @@ github.com/andybalholm/brotli v1.0.6 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/btree v1.1.3 // indirect - github.com/juju/ratelimit v1.0.2 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/kr/text v0.2.0 // indirect github.com/pion/dtls/v3 v3.1.4 // indirect --- a/infra/conf/shadowsocks.go +++ b/infra/conf/shadowsocks.go @@ -3,17 +3,21 @@ import ( "strings" - "github.com/sagernet/sing-shadowsocks/shadowaead_2022" - C "github.com/sagernet/sing/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/proxy/shadowsocks" - "github.com/xtls/xray-core/proxy/shadowsocks_2022" "google.golang.org/protobuf/proto" ) +// Shadowsocks 2022 is not built in: its implementation depends on GPL-licensed +// modules. Its method names are rejected explicitly instead of being reported +// as unknown ciphers. +func isShadowsocks2022(c string) bool { + return strings.HasPrefix(strings.ToLower(c), "2022-") +} + func cipherFromString(c string) shadowsocks.CipherType { switch strings.ToLower(c) { case "aes-128-gcm", "aead_aes_128_gcm": @@ -55,8 +59,8 @@ v.Users = v.Clients } - if C.Contains(shadowaead_2022.List, v.Cipher) { - return buildShadowsocks2022(v) + if isShadowsocks2022(v.Cipher) { + return nil, errors.New("shadowsocks 2022 is not supported in this build: ", v.Cipher) } config := new(shadowsocks.ServerConfig) @@ -110,72 +114,6 @@ return config, nil } -func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) { - if len(v.Users) == 0 { - config := new(shadowsocks_2022.ServerConfig) - config.Method = v.Cipher - config.Key = v.Password - config.Network = v.NetworkList.Build() - config.Email = v.Email - return config, nil - } - - if v.Cipher == "" { - return nil, errors.New("shadowsocks 2022 (multi-user): missing server method") - } - if !strings.Contains(v.Cipher, "aes") { - return nil, errors.New("shadowsocks 2022 (multi-user): only blake3-aes-*-gcm methods are supported") - } - - if v.Users[0].Address == nil { - config := new(shadowsocks_2022.MultiUserServerConfig) - config.Method = v.Cipher - config.Key = v.Password - config.Network = v.NetworkList.Build() - - config.Users = make([]*protocol.User, len(v.Users)) - processUser := func(idx int) error { - user := v.Users[idx] - if user.Cipher != "" { - return errors.New("shadowsocks 2022 (multi-user): users must have empty method") - } - account := &shadowsocks_2022.Account{ - Key: user.Password, - } - config.Users[idx] = &protocol.User{ - Email: user.Email, - Level: uint32(user.Level), - Account: serial.ToTypedMessage(account), - } - return nil - } - if err := task.ParallelForN(len(v.Users), processUser); err != nil { - return nil, err - } - return config, nil - } - - config := new(shadowsocks_2022.RelayServerConfig) - config.Method = v.Cipher - config.Key = v.Password - config.Network = v.NetworkList.Build() - for _, user := range v.Users { - if user.Cipher != "" { - return nil, errors.New("shadowsocks 2022 (relay): users must have empty method") - } - if user.Address == nil { - return nil, errors.New("shadowsocks 2022 (relay): all users must have relay address") - } - config.Destinations = append(config.Destinations, &shadowsocks_2022.RelayDestination{ - Key: user.Password, - Email: user.Email, - Address: user.Address.Build(), - Port: uint32(user.Port), - }) - } - return config, nil -} - type ShadowsocksServerTarget struct { Address *Address `json:"address"` Port uint16 `json:"port"` @@ -214,32 +152,10 @@ return nil, errors.New(`Shadowsocks settings: "servers" should have one and only one member. Multiple endpoints in "servers" should use multiple Shadowsocks outbounds and routing balancer instead`) } - if len(v.Servers) == 1 { - server := v.Servers[0] - if C.Contains(shadowaead_2022.List, server.Cipher) { - if server.Address == nil { - return nil, errors.New("Shadowsocks server address is not set.") - } - if server.Port == 0 { - return nil, errors.New("Invalid Shadowsocks port.") - } - if server.Password == "" { - return nil, errors.New("Shadowsocks password is not specified.") - } - - config := new(shadowsocks_2022.ClientConfig) - config.Address = server.Address.Build() - config.Port = uint32(server.Port) - config.Method = server.Cipher - config.Key = server.Password - return config, nil - } - } - config := new(shadowsocks.ClientConfig) for _, server := range v.Servers { - if C.Contains(shadowaead_2022.List, server.Cipher) { - return nil, errors.New("Shadowsocks 2022 accept no multi servers") + if isShadowsocks2022(server.Cipher) { + return nil, errors.New("shadowsocks 2022 is not supported in this build: ", server.Cipher) } if server.Address == nil { return nil, errors.New("Shadowsocks server address is not set.") --- a/main/commands/all/api/inbound_user_add.go +++ b/main/commands/all/api/inbound_user_add.go @@ -13,7 +13,6 @@ "github.com/xtls/xray-core/infra/conf" "github.com/xtls/xray-core/infra/conf/serial" "github.com/xtls/xray-core/proxy/shadowsocks" - "github.com/xtls/xray-core/proxy/shadowsocks_2022" "github.com/xtls/xray-core/proxy/trojan" vlessin "github.com/xtls/xray-core/proxy/vless/inbound" vmessin "github.com/xtls/xray-core/proxy/vmess/inbound" @@ -86,8 +85,6 @@ return ty.Users case *shadowsocks.ServerConfig: return ty.Users - case *shadowsocks_2022.MultiUserServerConfig: - return ty.Users default: fmt.Println("unsupported inbound type") }