mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Fix AnyTLS UDP outbound
This commit is contained in:
parent
f1de6ebddb
commit
3755c0f543
@ -35,7 +35,7 @@ type Outbound struct {
|
|||||||
|
|
||||||
func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.AnyTLSOutboundOptions) (adapter.Outbound, error) {
|
func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.AnyTLSOutboundOptions) (adapter.Outbound, error) {
|
||||||
outbound := &Outbound{
|
outbound := &Outbound{
|
||||||
Adapter: outbound.NewAdapterWithDialerOptions(C.TypeAnyTLS, tag, []string{N.NetworkTCP}, options.DialerOptions),
|
Adapter: outbound.NewAdapterWithDialerOptions(C.TypeAnyTLS, tag, []string{N.NetworkTCP, N.NetworkUDP}, options.DialerOptions),
|
||||||
server: options.ServerOptions.Build(),
|
server: options.ServerOptions.Build(),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
@ -71,12 +71,22 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
|||||||
outbound.client = client
|
outbound.client = client
|
||||||
|
|
||||||
outbound.uotClient = &uot.Client{
|
outbound.uotClient = &uot.Client{
|
||||||
Dialer: outbound,
|
Dialer: (anytlsDialer)(client.CreateProxy),
|
||||||
Version: uot.Version,
|
Version: uot.Version,
|
||||||
}
|
}
|
||||||
return outbound, nil
|
return outbound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type anytlsDialer func(ctx context.Context, destination M.Socksaddr) (net.Conn, error)
|
||||||
|
|
||||||
|
func (d anytlsDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||||
|
return d(ctx, destination)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d anytlsDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
||||||
|
return nil, os.ErrInvalid
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Outbound) dialOut(ctx context.Context) (net.Conn, error) {
|
func (h *Outbound) dialOut(ctx context.Context) (net.Conn, error) {
|
||||||
conn, err := h.dialer.DialContext(ctx, N.NetworkTCP, h.server)
|
conn, err := h.dialer.DialContext(ctx, N.NetworkTCP, h.server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user