- 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

@@ -1,13 +1,14 @@
package dns
import (
"net"
"strings"
"github.com/qdm12/private-internet-access-docker/internal/constants"
)
func (c *configurator) SetLocalNameserver() error {
c.logger.Info("%s: setting local nameserver to 127.0.0.1", logPrefix)
func (c *configurator) SetNameserver(IP net.IP) error {
c.logger.Info("%s: setting local nameserver to %s", logPrefix, IP.String())
data, err := c.fileManager.ReadFile(string(constants.ResolvConf))
if err != nil {
return err
@@ -20,12 +21,12 @@ func (c *configurator) SetLocalNameserver() error {
found := false
for i := range lines {
if strings.HasPrefix(lines[i], "nameserver ") {
lines[i] = "nameserver 127.0.0.1"
lines[i] = "nameserver " + IP.String()
found = true
}
}
if !found {
lines = append(lines, "nameserver 127.0.0.1")
lines = append(lines, "nameserver "+IP.String())
}
data = []byte(strings.Join(lines, "\n"))
return c.fileManager.WriteToFile(string(constants.ResolvConf), data)