mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-14 12:48:28 +10:00
Fix Tailscale DNS
This commit is contained in:
@@ -39,6 +39,7 @@ import (
|
||||
"github.com/sagernet/sing/service"
|
||||
"github.com/sagernet/sing/service/filemanager"
|
||||
"github.com/sagernet/tailscale/ipn"
|
||||
tsDNS "github.com/sagernet/tailscale/net/dns"
|
||||
"github.com/sagernet/tailscale/net/netmon"
|
||||
"github.com/sagernet/tailscale/net/tsaddr"
|
||||
"github.com/sagernet/tailscale/tsnet"
|
||||
@@ -145,6 +146,7 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
LookupHook: func(ctx context.Context, host string) ([]netip.Addr, error) {
|
||||
return dnsRouter.Lookup(ctx, host, outboundDialer.(dialer.ResolveDialer).QueryOptions())
|
||||
},
|
||||
DNS: &dnsConfigurtor{},
|
||||
}
|
||||
return &Endpoint{
|
||||
Adapter: endpoint.NewAdapter(C.TypeTailscale, tag, []string{N.NetworkTCP, N.NetworkUDP}, nil),
|
||||
@@ -471,3 +473,24 @@ func (d *endpointDialer) ListenPacket(ctx context.Context, destination M.Socksad
|
||||
d.logger.InfoContext(ctx, "output packet connection")
|
||||
return d.Dialer.ListenPacket(ctx, destination)
|
||||
}
|
||||
|
||||
type dnsConfigurtor struct {
|
||||
baseConfig tsDNS.OSConfig
|
||||
}
|
||||
|
||||
func (c *dnsConfigurtor) SetDNS(cfg tsDNS.OSConfig) error {
|
||||
c.baseConfig = cfg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *dnsConfigurtor) SupportsSplitDNS() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *dnsConfigurtor) GetBaseConfig() (tsDNS.OSConfig, error) {
|
||||
return c.baseConfig, nil
|
||||
}
|
||||
|
||||
func (c *dnsConfigurtor) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user