qdm12 / dns

Docker DNS server on steroids to access DNS-over-TLS from Cloudflare, Google, Quad9, Quadrant or CleanBrowsing
https://hub.docker.com/r/qmcgaw/cloudflare-dns-server
MIT License
231 stars 38 forks source link

unbound config error when PRIVATE_ADDRESS is empty #36

Closed wei closed 4 years ago

wei commented 4 years ago

With the new go version, it seems like unbound configuration is broken if PRIVATE_ADDRESS is set to empty.

cfdns    | Private addresses: 
cfdns    |  |--
cfdns    | Check Unbound: enabled
cfdns    | 2020-04-26T05:18:15.221Z     INFO    using DNS address 1.1.1.1 internally
cfdns    | 2020-04-26T05:18:15.221Z     INFO    downloading root hints from https://raw.githubusercontent.com/qdm12/files/master/named.root.updated
cfdns    | 2020-04-26T05:18:15.496Z     INFO    downloading root key from https://raw.githubusercontent.com/qdm12/files/master/root.key.updated
cfdns    | 2020-04-26T05:18:15.555Z     INFO    generating Unbound configuration
cfdns    | 2020-04-26T05:18:16.689Z     INFO    129837 hostnames blocked overall
cfdns    | 2020-04-26T05:18:16.689Z     INFO    265482 IP addresses blocked overall
cfdns    | 2020-04-26T05:18:16.998Z     INFO    starting unbound
cfdns    | 2020-04-26T05:18:16.998Z     INFO    using DNS address 127.0.0.1 internally
cfdns    | 2020-04-26T05:18:16.999Z     WARN    could not resolve github.com (try 1 of 10): lookup github.com on 192.168.1.1:53: read udp 127.0.0.1:53895->127.0.0.1:53: read: connection refused
cfdns    | 2020-04-26T05:18:17.151Z     INFO    unbound: /unbound/unbound.conf:129870: error: unknown keyword '1.0.1.4'
cfdns    | 2020-04-26T05:18:17.340Z     INFO    unbound: read /unbound/unbound.conf failed: 1 errors in configuration file
cfdns    | 2020-04-26T05:18:17.340Z     INFO    unbound: [1587878297] unbound[12:0] fatal error: Could not read config file: /unbound/unbound.conf. Maybe try unbound -dd, it stays on the commandline to see more errors, or unbound-checkconf
cfdns    | 2020-04-26T05:18:17.502Z     WARN    could not resolve github.com (try 2 of 10): lookup github.com on 192.168.1.1:53: read udp 127.0.0.1:41835->127.0.0.1:53: read: connection refused

It looks like the error is due to the handling of "" on this line: https://github.com/qdm12/cloudflare-dns-server/blob/080a1c62a3ed64b6114d6085c74d9eca31357502/internal/params/dns.go#L42

An empty string "" is appended to privateAddresses when s is "" causing unbound configuration to fail.