Skip to content

Commit

Permalink
Merge branch 'master' into feature/1421
Browse files Browse the repository at this point in the history
  • Loading branch information
ameshkov committed Jun 17, 2020
2 parents 9d9787f + b1c951f commit 801d281
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
2 changes: 2 additions & 0 deletions AGHTechDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,8 @@ Response:

The most recent entries are at the top of list.

If there are no more older entries, `"oldest":""` is returned.


### API: Set querylog parameters

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ AdGuard Home provides a lot of features out-of-the-box with no need to install a
| Encrypted DNS upstream servers (DNS-over-HTTPS, DNS-over-TLS, DNSCrypt) || ❌ (requires additional software) |
| Cross-platform || ❌ (not natively, only via Docker) |
| Running as a DNS-over-HTTPS or DNS-over-TLS server || ❌ (requires additional software) |
| Blocking phishing and malware domains || |
| Blocking phishing and malware domains ||(requires non-default blocklists) |
| Parental control (blocking adult domains) |||
| Force Safe search on search engines |||
| Per-client (device) configuration || |
| Per-client (device) configuration || |
| Access settings (choose who can use AGH DNS) |||

<a id="comparison-adblock"></a>
Expand Down
7 changes: 5 additions & 2 deletions dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
Ratelimit: int(s.conf.Ratelimit),
RatelimitWhitelist: s.conf.RatelimitWhitelist,
RefuseAny: s.conf.RefuseAny,
CacheEnabled: true,
CacheSizeBytes: int(s.conf.CacheSize),
CacheMinTTL: s.conf.CacheMinTTL,
CacheMaxTTL: s.conf.CacheMaxTTL,
UpstreamConfig: s.conf.UpstreamConfig,
Expand All @@ -148,6 +146,11 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
}

if s.conf.CacheSize != 0 {
proxyConfig.CacheEnabled = true
proxyConfig.CacheSizeBytes = int(s.conf.CacheSize)
}

proxyConfig.UpstreamMode = proxy.UModeLoadBalance
if s.conf.AllServers {
proxyConfig.UpstreamMode = proxy.UModeParallel
Expand Down
7 changes: 6 additions & 1 deletion openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,14 @@ paths:
schema:
type: string
enum:
- ""
- all
- filtered
- blocked
- blocked_safebrowsing
- blocked_parental
- whitelisted
- rewritten
- safe_search
- processed
responses:
"200":
Expand Down
4 changes: 3 additions & 1 deletion querylog/querylog_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ func (l *queryLog) searchFiles(params *searchParams) ([]*logEntry, time.Time, in
}
}

oldest = time.Unix(0, oldestNano)
if oldestNano != 0 {
oldest = time.Unix(0, oldestNano)
}
return entries, oldest, total
}

Expand Down
10 changes: 10 additions & 0 deletions util/auto_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,18 @@ func (a *AutoHosts) load(table map[string][]net.IP, tableRev map[string]string,
if len(host) == 0 {
break
}
sharp := strings.IndexByte(host, '#')
if sharp == 0 {
break // skip the rest of the line after #
} else if sharp > 0 {
host = host[:sharp]
}

a.updateTable(table, host, ipAddr)
a.updateTableRev(tableRev, host, ipAddr)
if sharp >= 0 {
break // skip the rest of the line after #
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions util/auto_hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestAutoHostsResolution(t *testing.T) {
defer func() { _ = os.Remove(f.Name()) }()
defer f.Close()

_, _ = f.WriteString(" 127.0.0.1 host localhost \n")
_, _ = f.WriteString(" ::1 localhost \n")
_, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n")

ah.Init(f.Name())

Expand All @@ -47,6 +47,10 @@ func TestAutoHostsResolution(t *testing.T) {
ips = ah.Process("newhost", dns.TypeA)
assert.Nil(t, ips)

// Unknown host (comment)
ips = ah.Process("comment", dns.TypeA)
assert.Nil(t, ips)

// Test hosts file
table := ah.List()
name, ok := table["127.0.0.1"]
Expand Down

0 comments on commit 801d281

Please sign in to comment.