Skip to content

Commit

Permalink
all: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Feb 22, 2023
1 parent d2b1528 commit 8724f37
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ In this release, the schema version has changed from 16 to 17.
'edns_client_subnet': false

# AFTER:
'edns_client_subnet':
'dns':
#
'enabled': false
'edns_client_subnet':
'enabled': false
'custom_ip': ''
```
To rollback this change, rename and move the property back into the `dns`
Expand Down
75 changes: 36 additions & 39 deletions internal/dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
// The zero FilteringConfig is empty and ready for use.
type FilteringConfig struct {
// Callbacks for other modules
//

// FilterHandler is an optional additional filtering callback.
FilterHandler func(
clientAddr net.IP,
Expand All @@ -62,43 +62,41 @@ type FilteringConfig struct {
) `yaml:"-"`

// GetCustomUpstreamByClient is a callback that returns upstreams
// configuration based on the client IP address or ClientID. It
// returns nil if there are no custom upstreams for the client.
// configuration based on the client IP address or ClientID. It returns
// nil if there are no custom upstreams for the client.
GetCustomUpstreamByClient func(id string) (conf *proxy.UpstreamConfig, err error) `yaml:"-"`

// Protection configuration
//
// ProtectionEnabled defines whether or not use any of filtering
// features.

// ProtectionEnabled defines whether or not use any of filtering features.
ProtectionEnabled bool `yaml:"protection_enabled"`

// BlockingMode defines the way how blocked responses are constructed.
BlockingMode BlockingMode `yaml:"blocking_mode"`

// BlockingIPv4 is the IP address to be returned for a blocked A
// request.
// BlockingIPv4 is the IP address to be returned for a blocked A request.
BlockingIPv4 net.IP `yaml:"blocking_ipv4"`

// BlockingIPv6 is the IP address to be returned for a blocked AAAA
// request.
BlockingIPv6 net.IP `yaml:"blocking_ipv6"`

// BlockedResponseTTL is the time-to-live value for blocked responses.
// If 0, then default value is used (3600).
// BlockedResponseTTL is the time-to-live value for blocked responses. If
// 0, then default value is used (3600).
BlockedResponseTTL uint32 `yaml:"blocked_response_ttl"`

// ParentalBlockHost is the IP (or domain name) which is used to
// respond to DNS requests blocked by parental control.
// ParentalBlockHost is the IP (or domain name) which is used to respond to
// DNS requests blocked by parental control.
ParentalBlockHost string `yaml:"parental_block_host"`

// SafeBrowsingBlockHost is the IP (or domain name) which is used to
// respond to DNS requests blocked by safe-browsing.
SafeBrowsingBlockHost string `yaml:"safebrowsing_block_host"`

// Anti-DNS amplification
//
// Ratelimit is the maximum number of requests per second from a given
// IP (0 to disable).

// Ratelimit is the maximum number of requests per second from a given IP
// (0 to disable).
Ratelimit uint32 `yaml:"ratelimit"`

// RatelimitWhitelist is the list of whitelisted client IP addresses.
Expand All @@ -108,20 +106,20 @@ type FilteringConfig struct {
RefuseAny bool `yaml:"refuse_any"`

// Upstream DNS servers configuration
//

// UpstreamDNS is the list of upstream DNS servers.
UpstreamDNS []string `yaml:"upstream_dns"`

// UpstreamDNSFileName, if set, points to the file which contains
// upstream DNS servers.
// UpstreamDNSFileName, if set, points to the file which contains upstream
// DNS servers.
UpstreamDNSFileName string `yaml:"upstream_dns_file"`

// BootstrapDNS is the list of bootstrap DNS servers for DoH and DoT
// resolvers (plain DNS only).
BootstrapDNS []string `yaml:"bootstrap_dns"`

// AllServers, if true, parallel queries to all configured upstream
// servers are enabled.
// AllServers, if true, parallel queries to all configured upstream servers
// are enabled.
AllServers bool `yaml:"all_servers"`

// FastestAddr, if true, use Fastest Address algorithm.
Expand All @@ -132,7 +130,7 @@ type FilteringConfig struct {
FastestTimeout timeutil.Duration `yaml:"fastest_timeout"`

// Access settings
//

// AllowedClients is the slice of IP addresses, CIDR networks, and
// ClientIDs of allowed clients. If not empty, only these clients are
// allowed, and [FilteringConfig.DisallowedClients] are ignored.
Expand All @@ -145,33 +143,32 @@ type FilteringConfig struct {
// BlockedHosts is the list of hosts that should be blocked.
BlockedHosts []string `yaml:"blocked_hosts"`

// TrustedProxies is the list of IP addresses and CIDR networks to
// detect proxy servers addresses the DoH requests from which should be
// handled. The value of nil or an empty slice for this field makes
// Proxy not trust any address.
// TrustedProxies is the list of IP addresses and CIDR networks to detect
// proxy servers addresses the DoH requests from which should be handled.
// The value of nil or an empty slice for this field makes Proxy not trust
// any address.
TrustedProxies []string `yaml:"trusted_proxies"`

// DNS cache settings
//

// CacheSize is the DNS cache size (in bytes).
CacheSize uint32 `yaml:"cache_size"`

// CacheMinTTL is the override TTL value (minimum) received from
// upstream server.
// CacheMinTTL is the override TTL value (minimum) received from upstream
// server.
CacheMinTTL uint32 `yaml:"cache_ttl_min"`

// CacheMaxTTL is the override TTL value (maximum) received from
// upstream server.
// CacheMaxTTL is the override TTL value (maximum) received from upstream
// server.
CacheMaxTTL uint32 `yaml:"cache_ttl_max"`

// CacheOptimistic defines if optimistic cache mechanism should be
// used.
// CacheOptimistic defines if optimistic cache mechanism should be used.
CacheOptimistic bool `yaml:"cache_optimistic"`

// Other settings
//
// BogusNXDomain is the list of IP addresses, responses with them will
// be transformed to NXDOMAIN.

// BogusNXDomain is the list of IP addresses, responses with them will be
// transformed to NXDOMAIN.
BogusNXDomain []string `yaml:"bogus_nxdomain"`

// AAAADisabled, if true, respond with an empty answer to all AAAA
Expand All @@ -184,15 +181,15 @@ type FilteringConfig struct {
// EDNSClientSubnet is the settings list for EDNS Client Subnet.
EDNSClientSubnet EDNSClientSubnet `yaml:"edns_client_subnet"`

// MaxGoroutines is the max number of parallel goroutines for
// processing incoming requests.
// MaxGoroutines is the max number of parallel goroutines for processing
// incoming requests.
MaxGoroutines uint32 `yaml:"max_goroutines"`

// HandleDDR, if true, handle DDR requests
HandleDDR bool `yaml:"handle_ddr"`

// IpsetList is the ipset configuration that allows AdGuard Home to add
// IP addresses of the specified domain names to an ipset list. Syntax:
// IpsetList is the ipset configuration that allows AdGuard Home to add IP
// addresses of the specified domain names to an ipset list. Syntax:
//
// DOMAIN[,DOMAIN].../IPSET_NAME
//
Expand Down
11 changes: 5 additions & 6 deletions internal/home/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,9 +913,10 @@ func upgradeSchema15to16(diskConf yobj) (err error) {
// 'edns_client_subnet': false
//
// # AFTER:
// 'edns_client_subnet':
// 'enabled': false
// 'custom_ip': ""
// 'dns':
// 'edns_client_subnet':
// 'enabled': false
// 'custom_ip': ""
func upgradeSchema16to17(diskConf yobj) (err error) {
log.Printf("Upgrade yaml: 16 to 17")
diskConf["schema_version"] = 17
Expand All @@ -937,9 +938,7 @@ func upgradeSchema16to17(diskConf yobj) (err error) {
"custom_ip": "",
}

delete(dns, field)

diskConf[field] = edns
dns[field] = edns

return nil
}
Expand Down
9 changes: 5 additions & 4 deletions internal/home/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,12 @@ func TestUpgradeSchema16to17(t *testing.T) {
const newSchemaVer = 17

defaultWantObj := yobj{
"edns_client_subnet": map[string]any{
"enabled": false,
"custom_ip": "",
"dns": map[string]any{
"edns_client_subnet": map[string]any{
"enabled": false,
"custom_ip": "",
},
},
"dns": map[string]any{},
"schema_version": newSchemaVer,
}

Expand Down

0 comments on commit 8724f37

Please sign in to comment.