summaryrefslogtreecommitdiff
path: root/src/pkg/net/dnsconfig.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/net/dnsconfig.go')
-rw-r--r--src/pkg/net/dnsconfig.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/pkg/net/dnsconfig.go b/src/pkg/net/dnsconfig.go
index 4be207603..26f0e04e9 100644
--- a/src/pkg/net/dnsconfig.go
+++ b/src/pkg/net/dnsconfig.go
@@ -8,7 +8,7 @@ package net
import "os"
-type _DNS_Config struct {
+type dnsConfig struct {
servers []string // servers to use
search []string // suffixes to append to local name
ndots int // number of dots in name to trigger absolute lookup
@@ -17,18 +17,30 @@ type _DNS_Config struct {
rotate bool // round robin among servers
}
-var _DNS_configError os.Error
+var dnsconfigError os.Error
+
+type DNSConfigError struct {
+ Error os.Error
+}
+
+func (e *DNSConfigError) String() string {
+ return "error reading DNS config: " + e.Error.String()
+}
+
+func (e *DNSConfigError) Timeout() bool { return false }
+func (e *DNSConfigError) Temporary() bool { return false }
+
// See resolv.conf(5) on a Linux machine.
// TODO(rsc): Supposed to call uname() and chop the beginning
// of the host name to get the default search domain.
// We assume it's in resolv.conf anyway.
-func _DNS_ReadConfig() (*_DNS_Config, os.Error) {
+func dnsReadConfig() (*dnsConfig, os.Error) {
file, err := open("/etc/resolv.conf")
if err != nil {
- return nil, err
+ return nil, &DNSConfigError{err}
}
- conf := new(_DNS_Config)
+ conf := new(dnsConfig)
conf.servers = make([]string, 3)[0:0] // small, but the standard limit
conf.search = make([]string, 0)
conf.ndots = 1