mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Fix socks4 client
This commit is contained in:
parent
eaf1ace681
commit
5a9913eca5
|
@ -21,6 +21,7 @@ var _ adapter.Outbound = (*Socks)(nil)
|
||||||
type Socks struct {
|
type Socks struct {
|
||||||
myOutboundAdapter
|
myOutboundAdapter
|
||||||
client *socks.Client
|
client *socks.Client
|
||||||
|
resolve bool
|
||||||
uot bool
|
uot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ func NewSocks(router adapter.Router, logger log.ContextLogger, tag string, optio
|
||||||
tag: tag,
|
tag: tag,
|
||||||
},
|
},
|
||||||
socks.NewClient(detour, options.ServerOptions.Build(), version, options.Username, options.Password),
|
socks.NewClient(detour, options.ServerOptions.Build(), version, options.Username, options.Password),
|
||||||
|
version == socks.Version4,
|
||||||
options.UoT,
|
options.UoT,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -72,6 +74,13 @@ func (h *Socks) DialContext(ctx context.Context, network string, destination M.S
|
||||||
default:
|
default:
|
||||||
return nil, E.Extend(N.ErrUnknownNetwork, network)
|
return nil, E.Extend(N.ErrUnknownNetwork, network)
|
||||||
}
|
}
|
||||||
|
if destination.IsFqdn() {
|
||||||
|
addrs, err := h.router.LookupDefault(ctx, destination.Fqdn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return N.DialSerial(ctx, h.client, network, destination, addrs)
|
||||||
|
}
|
||||||
return h.client.DialContext(ctx, network, destination)
|
return h.client.DialContext(ctx, network, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue