- Using custom DNS internally (without TLS) to download Unbound files
- Using then Unbound with DNS over TLS internally and system wide
- Works even if you host system DNS is broken
- Waits a few milliseconds for Unbound to start up
This commit is contained in:
Quentin McGaw (desktop)
2020-02-08 17:47:25 +00:00
parent a40f68f1df
commit e527f14bd2
7 changed files with 91 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"net"
"time"
"github.com/qdm12/golibs/command"
@@ -75,6 +76,8 @@ func main() {
e.FatalOnError(err)
if allSettings.DNS.Enabled {
initialDNSToUse := constants.DNSProviderMapping()[allSettings.DNS.Providers[0]]
dnsConf.UseDNSInternally(initialDNSToUse.IPs[0])
err = dnsConf.DownloadRootHints(uid, gid)
e.FatalOnError(err)
err = dnsConf.DownloadRootKey(uid, gid)
@@ -84,7 +87,10 @@ func main() {
stream, err := dnsConf.Start(allSettings.DNS.VerbosityDetailsLevel)
e.FatalOnError(err)
go streamMerger.Merge("unbound", stream)
err = dnsConf.SetLocalNameserver()
dnsConf.UseDNSInternally(net.IP{127, 0, 0, 1}) // use Unbound
err = dnsConf.UseDNSSystemWide(net.IP{127, 0, 0, 1}) // use Unbound
e.FatalOnError(err)
err = dnsConf.WaitForUnbound()
e.FatalOnError(err)
}