awl/conf/unix.go
Sam Therapy 59a7fe6d7d
All checks were successful
continuous-integration/drone/push Build is passing
Modularity(?)
Reviewed-on: #77
2022-08-31 01:05:17 +00:00

23 lines
524 B
Go

// SPDX-License-Identifier: BSD-3-Clause
//go:build unix || (!windows && !plan9 && !js && !zos)
// FIXME: Can remove the or on the preprocessor when Go 1.18 becomes obsolete
package conf
import (
"fmt"
"github.com/miekg/dns"
)
// GetDNSConfig gets the DNS configuration, either from /etc/resolv.conf or somewhere else.
func GetDNSConfig() (*dns.ClientConfig, error) {
conf, err := dns.ClientConfigFromFile("/etc/resolv.conf")
if err != nil {
return nil, fmt.Errorf("unix config: %w", err)
}
return conf, nil
}