doggo/pkg/config/config_unix.go
2021-01-19 20:00:05 +08:00

19 lines
478 B
Go

// +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
}