Skip to content

Commit

Permalink
all: imp naming
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed May 26, 2021
1 parent 771b7a3 commit 9a69183
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 47 deletions.
72 changes: 36 additions & 36 deletions internal/dnsforward/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ type dnsConfig struct {
UpstreamsFile *string `json:"upstream_dns_file"`
Bootstraps *[]string `json:"bootstrap_dns"`

ProtectionEnabled *bool `json:"protection_enabled"`
RateLimit *uint32 `json:"ratelimit"`
BlockingMode *string `json:"blocking_mode"`
BlockingIPv4 net.IP `json:"blocking_ipv4"`
BlockingIPv6 net.IP `json:"blocking_ipv6"`
EDNSCSEnabled *bool `json:"edns_cs_enabled"`
DNSSECEnabled *bool `json:"dnssec_enabled"`
DisableIPv6 *bool `json:"disable_ipv6"`
UpstreamMode *string `json:"upstream_mode"`
CacheSize *uint32 `json:"cache_size"`
CacheMinTTL *uint32 `json:"cache_ttl_min"`
CacheMaxTTL *uint32 `json:"cache_ttl_max"`
ResolveClients *bool `json:"resolve_clients"`
UsePrivateResolvers *bool `json:"local_ips_rdns"`
LocalPTRUpstreams *[]string `json:"local_ptr_upstreams"`
ProtectionEnabled *bool `json:"protection_enabled"`
RateLimit *uint32 `json:"ratelimit"`
BlockingMode *string `json:"blocking_mode"`
BlockingIPv4 net.IP `json:"blocking_ipv4"`
BlockingIPv6 net.IP `json:"blocking_ipv6"`
EDNSCSEnabled *bool `json:"edns_cs_enabled"`
DNSSECEnabled *bool `json:"dnssec_enabled"`
DisableIPv6 *bool `json:"disable_ipv6"`
UpstreamMode *string `json:"upstream_mode"`
CacheSize *uint32 `json:"cache_size"`
CacheMinTTL *uint32 `json:"cache_ttl_min"`
CacheMaxTTL *uint32 `json:"cache_ttl_max"`
ResolveClients *bool `json:"resolve_clients"`
LocalIPsRDNS *bool `json:"local_ips_rdns"`
LocalPTRUpstreams *[]string `json:"local_ptr_upstreams"`
}

func (s *Server) getDNSConfig() dnsConfig {
Expand All @@ -64,7 +64,7 @@ func (s *Server) getDNSConfig() dnsConfig {
cacheMinTTL := s.conf.CacheMinTTL
cacheMaxTTL := s.conf.CacheMaxTTL
resolveClients := s.conf.ResolveClients
usePrivateResolvers := s.conf.UsePrivateResolvers
localIPsRDNS := s.conf.UsePrivateResolvers
localPTRUpstreams := aghstrings.CloneSliceOrEmpty(s.conf.LocalPTRResolvers)
var upstreamMode string
if s.conf.FastestAddr {
Expand All @@ -74,24 +74,24 @@ func (s *Server) getDNSConfig() dnsConfig {
}

return dnsConfig{
Upstreams: &upstreams,
UpstreamsFile: &upstreamFile,
Bootstraps: &bootstraps,
ProtectionEnabled: &protectionEnabled,
BlockingMode: &blockingMode,
BlockingIPv4: blockingIPv4,
BlockingIPv6: blockingIPv6,
RateLimit: &ratelimit,
EDNSCSEnabled: &enableEDNSClientSubnet,
DNSSECEnabled: &enableDNSSEC,
DisableIPv6: &aaaaDisabled,
CacheSize: &cacheSize,
CacheMinTTL: &cacheMinTTL,
CacheMaxTTL: &cacheMaxTTL,
UpstreamMode: &upstreamMode,
ResolveClients: &resolveClients,
UsePrivateResolvers: &usePrivateResolvers,
LocalPTRUpstreams: &localPTRUpstreams,
Upstreams: &upstreams,
UpstreamsFile: &upstreamFile,
Bootstraps: &bootstraps,
ProtectionEnabled: &protectionEnabled,
BlockingMode: &blockingMode,
BlockingIPv4: blockingIPv4,
BlockingIPv6: blockingIPv6,
RateLimit: &ratelimit,
EDNSCSEnabled: &enableEDNSClientSubnet,
DNSSECEnabled: &enableDNSSEC,
DisableIPv6: &aaaaDisabled,
CacheSize: &cacheSize,
CacheMinTTL: &cacheMinTTL,
CacheMaxTTL: &cacheMaxTTL,
UpstreamMode: &upstreamMode,
ResolveClients: &resolveClients,
LocalIPsRDNS: &localIPsRDNS,
LocalPTRUpstreams: &localPTRUpstreams,
}
}

Expand Down Expand Up @@ -315,8 +315,8 @@ func (s *Server) setConfig(dc dnsConfig) (restart bool) {
s.conf.ResolveClients = *dc.ResolveClients
}

if dc.UsePrivateResolvers != nil {
s.conf.UsePrivateResolvers = *dc.UsePrivateResolvers
if dc.LocalIPsRDNS != nil {
s.conf.UsePrivateResolvers = *dc.LocalIPsRDNS
}

return s.setConfigRestartable(dc)
Expand Down
11 changes: 5 additions & 6 deletions internal/home/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ type dnsConfig struct {
// ResolveClients enables and disables resolving clients with RDNS.
ResolveClients bool `yaml:"resolve_clients"`

// UsePrivateResolvers defines if the PTR requests for unknown addresses
// from locally-served networks should be resolved via private PTR
// resolvers.
UsePrivateResolvers bool `yaml:"use_private_ptr_resolvers"`
// UsePrivateRDNS defines if the PTR requests for unknown addresses from
// locally-served networks should be resolved via private PTR resolvers.
UsePrivateRDNS bool `yaml:"use_private_ptr_resolvers"`

// LocalPTRResolvers is the slice of addresses to be used as upstreams
// for PTR queries for locally-served networks.
Expand Down Expand Up @@ -171,7 +170,7 @@ var config = configuration{
FiltersUpdateIntervalHours: 24,
LocalDomainName: "lan",
ResolveClients: true,
UsePrivateResolvers: true,
UsePrivateRDNS: true,
},
TLS: tlsConfigSettings{
PortHTTPS: 443,
Expand Down Expand Up @@ -324,7 +323,7 @@ func (c *configuration) write() error {
dns.FilteringConfig = c
dns.LocalPTRResolvers,
dns.ResolveClients,
dns.UsePrivateResolvers = s.RDNSSettings()
dns.UsePrivateRDNS = s.RDNSSettings()
}

if Context.dhcpServer != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/home/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func initDNSServer() error {
return fmt.Errorf("dnsServer.Prepare: %w", err)
}

Context.rdns = NewRDNS(Context.dnsServer, &Context.clients, config.DNS.UsePrivateResolvers)
Context.rdns = NewRDNS(Context.dnsServer, &Context.clients, config.DNS.UsePrivateRDNS)
Context.whois = initWhois(&Context.clients)

Context.filters.Init()
Expand Down Expand Up @@ -200,7 +200,7 @@ func generateServerConfig() (newConf dnsforward.ServerConfig, err error) {
newConf.GetCustomUpstreamByClient = Context.clients.FindUpstreams

newConf.ResolveClients = dnsConf.ResolveClients
newConf.UsePrivateResolvers = dnsConf.UsePrivateResolvers
newConf.UsePrivateResolvers = dnsConf.UsePrivateRDNS
newConf.LocalPTRResolvers = dnsConf.LocalPTRResolvers

return newConf, nil
Expand Down
6 changes: 3 additions & 3 deletions openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

## v0.107: API changes

### The field `"use_private_ptr_resolvers"` in DNS configuration
### The field `"local_ips_rdns"` in DNS configuration

* The new optional field `"use_private_ptr_resolvers"` of `"DNSConfig"`
specifies if the DNS server should use `"local_ptr_upstreams"` at all.
* The new optional field `"local_ips_rdns"` of `"DNSConfig"` specifies if the
DNS server should use `"local_ptr_upstreams"` at all.

## v0.106: API changes

Expand Down

0 comments on commit 9a69183

Please sign in to comment.