Merge pull request #891 from gravitl/feature_0.12.0_host_dns

eliminate the need for a tmp file to update dns
This commit is contained in:
dcarns 2022-03-13 20:43:04 -04:00 committed by GitHub
commit 8e000cb552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,6 @@ package functions
import (
"encoding/json"
"fmt"
"os"
"runtime"
"strings"
"time"
@ -219,17 +218,7 @@ func setHostDNS(dns []byte, windows bool) error {
if windows {
etchosts = "c:\\windows\\system32\\drivers\\etc\\hosts"
}
tmpfile := "/tmp/dnsdata"
if windows {
tmpfile = "c:\\windows\\temp\\dnsdata"
}
if err := os.WriteFile(tmpfile, dns, 0600); err != nil {
return err
}
dnsdata, err := os.Open(tmpfile)
if err != nil {
return err
}
dnsdata := strings.NewReader(string(dns))
profile, err := parser.ParseProfile(dnsdata)
if err != nil {
return err