aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-12-30 15:27:39 +0100
committerMartin Polden <mpolden@mpolden.no>2019-12-30 15:29:05 +0100
commit6c3aeec9d232e40406bc3e977441fc9a16d5d99a (patch)
tree413506f3426a7840ad505f25190526071d0c34ee
parent5cc54e27335d24b51561818ea3f4a165f095e466 (diff)
Add support for prefetching
-rw-r--r--README.md3
-rw-r--r--cmd/zdns/main.go6
-rw-r--r--config.go1
-rw-r--r--zdnsrc8
4 files changed, 16 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4aeb9d6..fbbf057 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,8 @@ configure.
* **Control**: Filter unwanted content at the DNS-level. Similar to
[Pi-hole](https://github.com/pi-hole/pi-hole).
-* **Fast**: Efficient filtering and caching of DNS requests.
+* **Fast**: Efficient filtering and caching of DNS requests. With pre-fetching
+ enabled, cached requests will never block waiting for the upstream resolver.
* **Reliable**: Built with Go and [miekg/dns](https://github.com/miekg/dns) - a
mature DNS library.
* **Secure**: Protect your DNS requests from snooping and tampering using [DNS
diff --git a/cmd/zdns/main.go b/cmd/zdns/main.go
index fef8455..03fdb26 100644
--- a/cmd/zdns/main.go
+++ b/cmd/zdns/main.go
@@ -94,7 +94,11 @@ func (c *cli) run() {
client := dnsutil.NewClient(config.Resolver.Protocol, config.Resolver.Timeout, config.DNS.Resolvers...)
// Cache
- cache := cache.New(config.DNS.CacheSize, nil)
+ var cclient *dnsutil.Client
+ if config.DNS.CachePrefetch {
+ cclient = client
+ }
+ cache := cache.New(config.DNS.CacheSize, cclient)
sigHandler.OnClose(cache)
// DNS server
diff --git a/config.go b/config.go
index e74413f..3d581f1 100644
--- a/config.go
+++ b/config.go
@@ -25,6 +25,7 @@ type DNSOptions struct {
Listen string
Protocol string `toml:"protocol"`
CacheSize int `toml:"cache_size"`
+ CachePrefetch bool `toml:"cache_prefetch"`
HijackMode string `toml:"hijack_mode"`
hijackMode int
RefreshInterval string `toml:"hosts_refresh_interval"`
diff --git a/zdnsrc b/zdnsrc
index 449a2b3..35daa0b 100644
--- a/zdnsrc
+++ b/zdnsrc
@@ -14,6 +14,14 @@
#
# cache_size = 4096
+# Cache pre-fetching.
+#
+# If enabled, cached entries will be re-resolved asynchronously. Note that this
+# may lead to slightly stale entries, but cached requests will never block
+# waiting for the upstream resolver.
+#
+# cache_prefetch = false
+
# Upstream DNS servers to use when answering queries.
#
# The default is Cloudflare DNS servers, which support DNS-over-TLS.