Config: Remove more legacy fields (#3817)

This commit is contained in:
Kobe Arthur Scofield 2024-09-19 09:05:59 +08:00 committed by GitHub
parent f406b2dee0
commit 57a41f3b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 569 additions and 1157 deletions

View file

@ -2,7 +2,6 @@ package conf
import (
"encoding/json"
"strings"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/protocol"
@ -33,7 +32,6 @@ type SocksServerConfig struct {
Accounts []*SocksAccount `json:"accounts"`
UDP bool `json:"udp"`
Host *Address `json:"ip"`
Timeout uint32 `json:"timeout"`
UserLevel uint32 `json:"userLevel"`
}
@ -61,7 +59,6 @@ func (v *SocksServerConfig) Build() (proto.Message, error) {
config.Address = v.Host.Build()
}
config.Timeout = v.Timeout
config.UserLevel = v.UserLevel
return config, nil
}
@ -74,22 +71,11 @@ type SocksRemoteConfig struct {
type SocksClientConfig struct {
Servers []*SocksRemoteConfig `json:"servers"`
Version string `json:"version"`
}
func (v *SocksClientConfig) Build() (proto.Message, error) {
config := new(socks.ClientConfig)
config.Server = make([]*protocol.ServerEndpoint, len(v.Servers))
switch strings.ToLower(v.Version) {
case "4":
config.Version = socks.Version_SOCKS4
case "4a":
config.Version = socks.Version_SOCKS4A
case "", "5":
config.Version = socks.Version_SOCKS5
default:
return nil, errors.New("failed to parse socks server version: ", v.Version).AtError()
}
for idx, serverConfig := range v.Servers {
server := &protocol.ServerEndpoint{
Address: serverConfig.Address.Build(),
@ -104,9 +90,6 @@ func (v *SocksClientConfig) Build() (proto.Message, error) {
if err := json.Unmarshal(rawUser, account); err != nil {
return nil, errors.New("failed to parse socks account").Base(err).AtError()
}
if config.Version != socks.Version_SOCKS5 && account.Password != "" {
return nil, errors.New("password is only supported in socks5").AtError()
}
user.Account = serial.ToTypedMessage(account.Build())
server.User = append(server.User, user)
}