Skip to content

Commit 9a5995f

Browse files
committed
hotfix(dns): DNS_UPSTREAM_RESOLVERS defaults to empty if DNS_UPSTREAM_PLAIN_ADDRESSES is not empty
1 parent 2438fc2 commit 9a5995f

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ ENV VPN_SERVICE_PROVIDER=pia \
224224
HEALTH_RESTART_VPN=on \
225225
# DNS
226226
DNS_UPSTREAM_RESOLVER_TYPE=DoT \
227-
DNS_UPSTREAM_RESOLVERS=cloudflare \
227+
# Note: DNS_UPSTREAM_RESOLVERS defaults to cloudflare in code if DNS_UPSTREAM_PLAIN_ADDRESSES is empty
228+
DNS_UPSTREAM_RESOLVERS= \
228229
DNS_BLOCK_IPS= \
229230
DNS_BLOCK_IP_PREFIXES= \
230231
DNS_CACHING=on \

internal/configuration/settings/dns.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ type DNS struct {
4444
Blacklist DNSBlacklist
4545
// UpstreamPlainAddresses are the upstream plaintext DNS resolver
4646
// addresses to use by the built-in DNS server forwarder.
47-
// Note, if the upstream type is [dnsUpstreamTypePlain] these are merged
48-
// together with provider names set in the Providers field.
49-
// If this field is set, the Providers field will default to the empty slice.
47+
// Note, if the upstream type is [dnsUpstreamTypePlain] and this field is set,
48+
// the Providers field will default to the empty slice. If the Providers field
49+
// is set by the user, then the content of this field will be merged together
50+
// with the plain addresses of the providers set in the Providers field.
5051
UpstreamPlainAddresses []netip.AddrPort
5152
}
5253

@@ -133,13 +134,15 @@ func (d *DNS) setDefaults() {
133134
d.UpstreamType = gosettings.DefaultComparable(d.UpstreamType, DNSUpstreamTypeDot)
134135
const defaultUpdatePeriod = 24 * time.Hour
135136
d.UpdatePeriod = gosettings.DefaultPointer(d.UpdatePeriod, defaultUpdatePeriod)
136-
d.Providers = gosettings.DefaultSlice(d.Providers, []string{
137-
provider.Cloudflare().Name,
138-
})
137+
d.UpstreamPlainAddresses = gosettings.DefaultSlice(d.UpstreamPlainAddresses, []netip.AddrPort{})
138+
defaultProviders := defaultDNSProviders()
139+
if d.UpstreamType == DNSUpstreamTypePlain && len(d.UpstreamPlainAddresses) == 0 {
140+
defaultProviders = []string{}
141+
}
142+
d.Providers = gosettings.DefaultSlice(d.Providers, defaultProviders)
139143
d.Caching = gosettings.DefaultPointer(d.Caching, true)
140144
d.IPv6 = gosettings.DefaultPointer(d.IPv6, false)
141145
d.Blacklist.setDefaults()
142-
d.UpstreamPlainAddresses = gosettings.DefaultSlice(d.UpstreamPlainAddresses, []netip.AddrPort{})
143146
}
144147

145148
func defaultDNSProviders() []string {

0 commit comments

Comments
 (0)