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

@ -14,7 +14,6 @@ import (
"github.com/xtls/xray-core/common/signal"
"github.com/xtls/xray-core/common/task"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/features/dns"
"github.com/xtls/xray-core/features/policy"
"github.com/xtls/xray-core/transport"
"github.com/xtls/xray-core/transport/internet"
@ -25,8 +24,6 @@ import (
type Client struct {
serverPicker protocol.ServerPicker
policyManager policy.Manager
version Version
dns dns.Client
}
// NewClient create a new Socks5 client based on the given config.
@ -47,12 +44,8 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
c := &Client{
serverPicker: protocol.NewRoundRobinServerPicker(serverList),
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
version: config.Version,
}
if config.Version == Version_SOCKS4 {
c.dns = v.GetFeature(dns.ClientType()).(dns.Client)
}
return c, nil
}
@ -104,30 +97,6 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
Port: destination.Port,
}
switch c.version {
case Version_SOCKS4:
if request.Address.Family().IsDomain() {
ips, err := c.dns.LookupIP(request.Address.Domain(), dns.IPOption{
IPv4Enable: true,
})
if err != nil {
return err
} else if len(ips) == 0 {
return dns.ErrEmptyResponse
}
request.Address = net.IPAddress(ips[0])
}
fallthrough
case Version_SOCKS4A:
request.Version = socks4Version
if destination.Network == net.Network_UDP {
return errors.New("udp is not supported in socks4")
} else if destination.Address.Family().IsIPv6() {
return errors.New("ipv6 is not supported in socks4")
}
}
if destination.Network == net.Network_UDP {
request.Command = protocol.RequestCommandUDP
}