diff --git a/README.md b/README.md index 2c42fea..5a47f76 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,14 @@ DNS queries are resolved in the style of the GNU libc resolver: | --default-resolver, -d | Update resolv.conf to make go-dnsmasq the host's nameserver | False | $DNSMASQ_DEFAULT | | --nameservers, -n | Comma separated list of nameservers `host[:port]` | - | $DNSMASQ_SERVERS | | --stubzones, -z | Use different nameservers for specific domains `domain[,domain]/host[:port]` | - | $DNSMASQ_STUB | -| --hostsfile, -f | Path to a hosts file (e.g. ‘/etc/hosts‘) | - | $DNSMASQ_HOSTSFILE | -| --hostsfile-poll, -p | How frequently to poll hosts file for changes (seconds, ‘0‘ to disable) | 0 | $DNSMASQ_POLL | +| --hostsfile, -f | Path to a hosts file (e.g. ‘/etc/hosts‘) | - | $DNSMASQ_HOSTSFILE | +| --hostsfile-poll, -p | How frequently to poll hosts file for changes (seconds, ‘0‘ to disable) | 0 | $DNSMASQ_POLL | | --search-domains, -s | Specify search domains (overrides /etc/resolv.conf) `domain[,domain]` | - | $DNSMASQ_SEARCH | | --append-search-domains, -a | Resolve queries using search domains | False | $DNSMASQ_APPEND | | --rcache, -r | Capacity of the response cache (‘0‘ to disable cache) | 0 | $DNSMASQ_RCACHE | | --rcache-ttl | TTL for entries in the response cache | 60 | $DNSMASQ_RCACHE_TTL | | --no-rec | Disable recursion | False | $DNSMASQ_NOREC | +| --ndots | Minimum number of labels a name must have before the query is forwarded | 2 | $DNSMASQ_NDOTS | | --round-robin | Enable round robin of A/AAAA records | False | $DNSMASQ_RR | | --systemd | Bind to socket(s) activated by Systemd (ignores --listen) | False | $DNSMASQ_SYSTEMD | | --verbose | Enable verbose logging | False | $DNSMASQ_VERBOSE | diff --git a/main.go b/main.go index 3b2a0bb..43c7744 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ import ( ) // var Version string -const Version = "1.0.2" +const Version = "1.0.3" var ( nameservers = []string{} @@ -100,6 +100,12 @@ func main() { Usage: "Disable recursion", EnvVar: "DNSMASQ_NOREC", }, + cli.IntFlag{ + Name: "ndots", + Value: 2, + Usage: "Minimum number of labels a name must have before the query is forwarded", + EnvVar: "DNSMASQ_NDOTS", + }, cli.BoolFlag{ Name: "round-robin", Usage: "Enable round robin of A/AAAA records", @@ -194,6 +200,7 @@ func main() { PollInterval: c.Int("hostsfile-poll"), RoundRobin: c.Bool("round-robin"), NoRec: c.Bool("no-rec"), + Ndots: c.Int("ndots"), ReadTimeout: 0, Verbose: c.Bool("verbose"), } diff --git a/server/forwarding.go b/server/forwarding.go index 78031ab..16bfd17 100644 --- a/server/forwarding.go +++ b/server/forwarding.go @@ -65,8 +65,7 @@ func (s *server) ServeDNSForward(w dns.ResponseWriter, req *dns.Msg) *dns.Msg { } Redo: - if dns.CountLabel(name) < 2 { - // Always qualify single-label names + if dns.CountLabel(name) < s.config.Ndots { if !doingSearch && canSearch { doingSearch = true sdIndex = 0