awl/internal/conf/unix.go
Sam Therapy ed0cdf6a6f
Some checks failed
continuous-integration/drone/push Build is failing
refactor: move config and cmd to internal
They don't need to be exposed to the outside world
2023-04-18 16:36:37 +02: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
}