Add custom DNS servers

This commit is contained in:
世界 2024-10-23 23:06:08 +08:00
parent fe3c2b4bdf
commit 4f768e630d
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
2 changed files with 8 additions and 6 deletions

View File

@ -23,12 +23,13 @@ type _Template struct {
RemoteResolve bool `json:"remote_resolve,omitempty"` RemoteResolve bool `json:"remote_resolve,omitempty"`
// DNS // DNS
DNS string `json:"dns,omitempty"` Servers []option.DNSServerOptions `json:"servers,omitempty"`
DNSLocal string `json:"dns_local,omitempty"` DNS string `json:"dns,omitempty"`
EnableFakeIP bool `json:"enable_fakeip,omitempty"` DNSLocal string `json:"dns_local,omitempty"`
DisableDNSLeak bool `json:"disable_dns_leak,omitempty"` EnableFakeIP bool `json:"enable_fakeip,omitempty"`
PreDNSRules []option.DNSRule `json:"pre_dns_rules,omitempty"` DisableDNSLeak bool `json:"disable_dns_leak,omitempty"`
CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"` PreDNSRules []option.DNSRule `json:"pre_dns_rules,omitempty"`
CustomDNSRules []option.DNSRule `json:"custom_dns_rules,omitempty"`
// Inbound // Inbound
Inbounds []option.Inbound `json:"inbounds,omitempty"` Inbounds []option.Inbound `json:"inbounds,omitempty"`

View File

@ -36,6 +36,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error
domainStrategyLocal = 0 domainStrategyLocal = 0
} }
options.DNS = &option.DNSOptions{ options.DNS = &option.DNSOptions{
Servers: t.Servers,
ReverseMapping: !t.DisableTrafficBypass && metadata.Platform != M.PlatformUnknown && !metadata.Platform.IsApple(), ReverseMapping: !t.DisableTrafficBypass && metadata.Platform != M.PlatformUnknown && !metadata.Platform.IsApple(),
DNSClientOptions: option.DNSClientOptions{ DNSClientOptions: option.DNSClientOptions{
Strategy: domainStrategy, Strategy: domainStrategy,