mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-18 09:24:07 +02:00
Fix: DNS_KEEP_NAMESERVER
This commit is contained in:
@@ -26,7 +26,7 @@ func (c *configurator) UseDNSInternally(ip net.IP) {
|
||||
func (c *configurator) UseDNSSystemWide(ip net.IP, keepNameserver bool) error {
|
||||
c.logger.Info("using DNS address %s system wide", ip.String())
|
||||
const filepath = string(constants.ResolvConf)
|
||||
file, err := c.openFile(filepath, os.O_RDWR|os.O_TRUNC, 0644)
|
||||
file, err := c.openFile(filepath, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -35,6 +35,9 @@ func (c *configurator) UseDNSSystemWide(ip net.IP, keepNameserver bool) error {
|
||||
_ = file.Close()
|
||||
return err
|
||||
}
|
||||
if err := file.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s := strings.TrimSuffix(string(data), "\n")
|
||||
|
||||
@@ -50,6 +53,11 @@ func (c *configurator) UseDNSSystemWide(ip net.IP, keepNameserver bool) error {
|
||||
}
|
||||
|
||||
s = strings.Join(lines, "\n") + "\n"
|
||||
|
||||
file, err = c.openFile(filepath, os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = file.WriteString(s)
|
||||
if err != nil {
|
||||
_ = file.Close()
|
||||
|
||||
Reference in New Issue
Block a user