system default nameserver in windows
This commit is contained in:
parent
250591098b
commit
d873dc5b35
4 changed files with 149 additions and 18 deletions
19
pkg/config/config_unix.go
Normal file
19
pkg/config/config_unix.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
// +build !windows
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
//DefaultResolvConfPath specifies path to default resolv config file on UNIX.
|
||||
const DefaultResolvConfPath = "/etc/resolv.conf"
|
||||
|
||||
func GetDefaultServers() ([]string, int, []string, error) {
|
||||
// if no nameserver is provided, take it from `resolv.conf`
|
||||
cfg, err := dns.ClientConfigFromFile(DefaultResolvConfPath)
|
||||
if err != nil {
|
||||
return nil, 0, nil, err
|
||||
}
|
||||
return cfg.Servers, cfg.Ndots, cfg.Search, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue