mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-25 06:25:44 +03:00
fa49d74aa8
Merge in DNS/adguard-home from upd-all to master Squashed commit of the following: commit 8fe5f029f2092ff1b23c6b734fef35937658c6d3 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Dec 7 16:13:04 2022 +0300 aghos: fix windows root dir commit 57237df1d95c7c72cc02103eb869590a2b8fe50c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Dec 7 15:18:59 2022 +0300 all: upd go, i18n, svcs
32 lines
780 B
Go
32 lines
780 B
Go
//go:build windows
|
|
|
|
package aghnet
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/AdguardTeam/golibs/log"
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func defaultHostsPaths() (paths []string) {
|
|
sysDir, err := windows.GetSystemDirectory()
|
|
if err != nil {
|
|
log.Error("aghnet: getting system directory: %s", err)
|
|
|
|
return []string{}
|
|
}
|
|
|
|
// Split all the elements of the path to join them afterwards. This is
|
|
// needed to make the Windows-specific path string returned by
|
|
// windows.GetSystemDirectory to be compatible with fs.FS.
|
|
pathElems := strings.Split(sysDir, string(os.PathSeparator))
|
|
if len(pathElems) > 0 && pathElems[0] == filepath.VolumeName(sysDir) {
|
|
pathElems = pathElems[1:]
|
|
}
|
|
|
|
return []string{path.Join(append(pathElems, "drivers/etc/hosts")...)}
|
|
}
|