-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package cmd | ||
package netutil | ||
|
||
// DefaultHostsPaths returns the slice of default paths to system hosts files. | ||
// | ||
// TODO(s.chzhen): Since [fs.FS] is no longer needed, update the | ||
// [hostsfile.DefaultHostsPaths] from golibs. | ||
func DefaultHostsPaths() (paths []string, err error) { | ||
return defaultHostsPaths() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build unix | ||
|
||
package netutil | ||
|
||
import "github.com/AdguardTeam/golibs/hostsfile" | ||
|
||
// defaultHostsPaths returns default paths to hosts files for UNIX. | ||
func defaultHostsPaths() (paths []string, err error) { | ||
paths, err = hostsfile.DefaultHostsPaths() | ||
if err != nil { | ||
// Should not happen because error is always nil. | ||
panic(err) | ||
} | ||
|
||
res := make([]string, 0, len(paths)) | ||
for _, p := range paths { | ||
res = append(res, "/"+p) | ||
} | ||
|
||
return res, nil | ||
} |
2 changes: 1 addition & 1 deletion
2
internal/cmd/paths_windows.go → internal/netutil/paths_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//go:build windows | ||
|
||
package cmd | ||
package netutil | ||
|
||
import ( | ||
"fmt" | ||
|