awl/conf/unix.go
Sam Therapy 49ea09a251
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
another refactor :^)
Signed-off-by: Sam Therapy <sam@samtherapy.net>
2022-08-04 01:29:20 +02:00

26 lines
507 B
Go

// SPDX-License-Identifier: BSD-3-Clause
//go:build !windows
package conf
import (
"fmt"
"os"
"runtime"
"github.com/miekg/dns"
)
// Get the DNS configuration, either from /etc/resolv.conf or somewhere else
func GetDNSConfig() (*dns.ClientConfig, error) {
if runtime.GOOS == "plan9" {
dat, err := os.ReadFile("/net/ndb")
if err != nil {
return nil, fmt.Errorf("plan9 ndb: %w", err)
}
return GetPlan9Config(string(dat))
} else {
return dns.ClientConfigFromFile("/etc/resolv.conf")
}
}