all: unify handling user home directory logic

This commit is contained in:
Cuong Manh Le
2025-05-05 23:28:49 +07:00
committed by Cuong Manh Le
parent 6286a71f2a
commit 47c04bf0f6
4 changed files with 10 additions and 43 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ func setDNS(iface *net.Interface, nameservers []string) error {
if hasLocalDnsServerRunning() {
mainLog.Load().Debug().Msg("Local DNS server detected, configuring forwarders")
file := absHomeDir(windowsForwardersFilename)
file := ctrld.AbsHomeDir(windowsForwardersFilename)
mainLog.Load().Debug().Msgf("Using forwarders file: %s", file)
oldForwardersContent, err := os.ReadFile(file)
@@ -131,7 +131,7 @@ func resetDNS(iface *net.Interface) error {
resetDNSOnce.Do(func() {
// See corresponding comment in setDNS.
if hasLocalDnsServerRunning() {
file := absHomeDir(windowsForwardersFilename)
file := ctrld.AbsHomeDir(windowsForwardersFilename)
content, err := os.ReadFile(file)
if err != nil {
mainLog.Load().Error().Err(err).Msg("could not read forwarders settings")