mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-26 21:16:56 +00:00
tailscale: Fix handle peer DNS query
This commit is contained in:
@@ -165,46 +165,45 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
|
|||||||
}
|
}
|
||||||
dialerQueryOptions := outboundDialer.(dialer.ResolveDialer).QueryOptions()
|
dialerQueryOptions := outboundDialer.(dialer.ResolveDialer).QueryOptions()
|
||||||
dnsRouter := service.FromContext[adapter.DNSRouter](ctx)
|
dnsRouter := service.FromContext[adapter.DNSRouter](ctx)
|
||||||
server := &tsnet.Server{
|
return &Endpoint{
|
||||||
Dir: stateDirectory,
|
Adapter: endpoint.NewAdapter(C.TypeTailscale, tag, []string{N.NetworkTCP, N.NetworkUDP, N.NetworkICMP}, nil),
|
||||||
Hostname: hostname,
|
ctx: ctx,
|
||||||
Logf: func(format string, args ...any) {
|
router: router,
|
||||||
logger.Trace(fmt.Sprintf(format, args...))
|
logger: logger,
|
||||||
},
|
dnsRouter: dnsRouter,
|
||||||
UserLogf: func(format string, args ...any) {
|
network: service.FromContext[adapter.NetworkManager](ctx),
|
||||||
logger.Debug(fmt.Sprintf(format, args...))
|
platformInterface: service.FromContext[adapter.PlatformInterface](ctx),
|
||||||
},
|
server: &tsnet.Server{
|
||||||
Ephemeral: options.Ephemeral,
|
Dir: stateDirectory,
|
||||||
AuthKey: options.AuthKey,
|
Hostname: hostname,
|
||||||
ControlURL: options.ControlURL,
|
Logf: func(format string, args ...any) {
|
||||||
AdvertiseTags: options.AdvertiseTags,
|
logger.Trace(fmt.Sprintf(format, args...))
|
||||||
Dialer: &endpointDialer{Dialer: outboundDialer, logger: logger},
|
},
|
||||||
LookupHook: func(ctx context.Context, host string) ([]netip.Addr, error) {
|
UserLogf: func(format string, args ...any) {
|
||||||
return dnsRouter.Lookup(ctx, host, dialerQueryOptions)
|
logger.Debug(fmt.Sprintf(format, args...))
|
||||||
},
|
},
|
||||||
DNS: &dnsConfigurtor{},
|
Ephemeral: options.Ephemeral,
|
||||||
HTTPClient: &http.Client{
|
AuthKey: options.AuthKey,
|
||||||
Transport: &http.Transport{
|
ControlURL: options.ControlURL,
|
||||||
ForceAttemptHTTP2: true,
|
AdvertiseTags: options.AdvertiseTags,
|
||||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
Dialer: &endpointDialer{Dialer: outboundDialer, logger: logger},
|
||||||
return outboundDialer.DialContext(ctx, network, M.ParseSocksaddr(address))
|
LookupHook: func(ctx context.Context, host string) ([]netip.Addr, error) {
|
||||||
},
|
return dnsRouter.Lookup(ctx, host, dialerQueryOptions)
|
||||||
TLSClientConfig: &tls.Config{
|
},
|
||||||
RootCAs: adapter.RootPoolFromContext(ctx),
|
DNS: &dnsConfigurtor{},
|
||||||
Time: ntp.TimeFuncFromContext(ctx),
|
HTTPClient: &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
return outboundDialer.DialContext(ctx, network, M.ParseSocksaddr(address))
|
||||||
|
},
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
RootCAs: adapter.RootPoolFromContext(ctx),
|
||||||
|
Time: ntp.TimeFuncFromContext(ctx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
return &Endpoint{
|
|
||||||
Adapter: endpoint.NewAdapter(C.TypeTailscale, tag, []string{N.NetworkTCP, N.NetworkUDP, N.NetworkICMP}, nil),
|
|
||||||
ctx: ctx,
|
|
||||||
router: router,
|
|
||||||
logger: logger,
|
|
||||||
dnsRouter: dnsRouter,
|
|
||||||
network: service.FromContext[adapter.NetworkManager](ctx),
|
|
||||||
platformInterface: service.FromContext[adapter.PlatformInterface](ctx),
|
|
||||||
server: server,
|
|
||||||
acceptRoutes: options.AcceptRoutes,
|
acceptRoutes: options.AcceptRoutes,
|
||||||
exitNode: options.ExitNode,
|
exitNode: options.ExitNode,
|
||||||
exitNodeAllowLANAccess: options.ExitNodeAllowLANAccess,
|
exitNodeAllowLANAccess: options.ExitNodeAllowLANAccess,
|
||||||
|
|||||||
Reference in New Issue
Block a user