mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-03 20:07:36 +03:00
documentation: Add Tailscale DNS
This commit is contained in:
parent
25e71023dc
commit
1412e17bd9
4 changed files with 86 additions and 7 deletions
|
@ -174,7 +174,6 @@ func (r *Router) matchDNS(ctx context.Context, allowFakeIP bool, ruleIndex int,
|
|||
options.ClientSubnet = legacyTransport.LegacyClientSubnet()
|
||||
}
|
||||
}
|
||||
r.logger.DebugContext(ctx, "match[", displayRuleIndex, "] => ", currentRule.Action())
|
||||
return transport, currentRule, currentRuleIndex
|
||||
case *R.RuleActionDNSRouteOptions:
|
||||
if action.Strategy != C.DomainStrategyAsIS {
|
||||
|
@ -189,9 +188,7 @@ func (r *Router) matchDNS(ctx context.Context, allowFakeIP bool, ruleIndex int,
|
|||
if action.ClientSubnet.IsValid() {
|
||||
options.ClientSubnet = action.ClientSubnet
|
||||
}
|
||||
r.logger.DebugContext(ctx, "match[", displayRuleIndex, "] => ", currentRule.Action())
|
||||
case *R.RuleActionReject:
|
||||
r.logger.DebugContext(ctx, "match[", displayRuleIndex, "] => ", currentRule.Action())
|
||||
return nil, currentRule, currentRuleIndex
|
||||
}
|
||||
}
|
||||
|
|
83
docs/configuration/dns/server/tailscale.md
Normal file
83
docs/configuration/dns/server/tailscale.md
Normal file
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.12.0"
|
||||
|
||||
# Tailscale
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"type": "tailscale",
|
||||
"tag": "",
|
||||
|
||||
"endpoint": "ts-ep",
|
||||
"accept_default_resolvers": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
#### endpoint
|
||||
|
||||
==Required==
|
||||
|
||||
The tag of the Tailscale endpoint.
|
||||
|
||||
#### accept_default_resolvers
|
||||
|
||||
Indicates whether default DNS resolvers should be accepted for fallback queries in addition to MagicDNS。
|
||||
|
||||
if not enabled, NXDOMAIN will be returned for non-Tailscale domain queries.
|
||||
|
||||
### Examples
|
||||
|
||||
=== "MagicDNS only"
|
||||
|
||||
```json
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"type": "local",
|
||||
"tag": "local"
|
||||
},
|
||||
{
|
||||
"type": "tailscale",
|
||||
"tag": "ts",
|
||||
"endpoint": "ts-ep"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"ip_accept_any": true,
|
||||
"server": "ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
=== "Use as global DNS"
|
||||
|
||||
```json
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"type": "tailscale",
|
||||
"endpoint": "ts-ep",
|
||||
"accept_default_resolvers": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
|
@ -93,6 +93,7 @@ nav:
|
|||
- Predefined: configuration/dns/server/predefined.md
|
||||
- DHCP: configuration/dns/server/dhcp.md
|
||||
- FakeIP: configuration/dns/server/fakeip.md
|
||||
- Tailscale: configuration/dns/server/tailscale.md
|
||||
- DNS Rule: configuration/dns/rule.md
|
||||
- DNS Rule Action: configuration/dns/rule_action.md
|
||||
- FakeIP: configuration/dns/fakeip.md
|
||||
|
|
|
@ -81,10 +81,10 @@ func (t *DNSTransport) Start(stage adapter.StartStage) error {
|
|||
}
|
||||
ep, isTailscale := rawOutbound.(*Endpoint)
|
||||
if !isTailscale {
|
||||
return E.New("endpoint is not tailscale: ", t.endpointTag)
|
||||
return E.New("endpoint is not Tailscale: ", t.endpointTag)
|
||||
}
|
||||
if ep.onReconfig != nil {
|
||||
return E.New("only one tailscale DNS server is allowed for single endpoint")
|
||||
return E.New("only one Tailscale DNS server is allowed for single endpoint")
|
||||
}
|
||||
ep.onReconfig = t.onReconfig
|
||||
t.endpoint = ep
|
||||
|
@ -133,14 +133,12 @@ func (t *DNSTransport) updateDNSServers(routeConfig *router.Config, dnsConfig *n
|
|||
}
|
||||
var defaultResolvers []adapter.DNSTransport
|
||||
for _, resolver := range dnsConfig.DefaultResolvers {
|
||||
t.logger.Warn("create default resolver: ", resolver.Addr)
|
||||
myResolver, err := t.createResolver(directDialerOnce, resolver)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defaultResolvers = append(defaultResolvers, myResolver)
|
||||
}
|
||||
t.logger.Error("create ", len(dnsConfig.DefaultResolvers), " default resolvers")
|
||||
t.routes = routes
|
||||
t.hosts = hosts
|
||||
t.defaultResolvers = defaultResolvers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue