From 4f768e630d18e85049100210e34f7ec8bd37f98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 23 Oct 2024 23:06:08 +0800 Subject: [PATCH] Add custom DNS servers --- option/template.go | 13 +++++++------ template/render_dns.go | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/option/template.go b/option/template.go index 59f2940..14e6e12 100644 --- a/option/template.go +++ b/option/template.go @@ -23,12 +23,13 @@ type _Template struct { RemoteResolve bool `json:"remote_resolve,omitempty"` // DNS - DNS string `json:"dns,omitempty"` - DNSLocal string `json:"dns_local,omitempty"` - EnableFakeIP bool `json:"enable_fakeip,omitempty"` - DisableDNSLeak bool `json:"disable_dns_leak,omitempty"` - PreDNSRules []option.DNSRule `json:"pre_dns_rules,omitempty"` - CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"` + Servers []option.DNSServerOptions `json:"servers,omitempty"` + DNS string `json:"dns,omitempty"` + DNSLocal string `json:"dns_local,omitempty"` + EnableFakeIP bool `json:"enable_fakeip,omitempty"` + DisableDNSLeak bool `json:"disable_dns_leak,omitempty"` + PreDNSRules []option.DNSRule `json:"pre_dns_rules,omitempty"` + CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"` // Inbound Inbounds []option.Inbound `json:"inbounds,omitempty"` diff --git a/template/render_dns.go b/template/render_dns.go index b0009be..5411d2b 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -36,6 +36,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error domainStrategyLocal = 0 } options.DNS = &option.DNSOptions{ + Servers: t.Servers, ReverseMapping: !t.DisableTrafficBypass && metadata.Platform != M.PlatformUnknown && !metadata.Platform.IsApple(), DNSClientOptions: option.DNSClientOptions{ Strategy: domainStrategy,