Fixes #72
- 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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user