dns/dns.go
Miek Gieben 0e00511c31 Make the resolver a goroutine
Fits more nicely with DNS, async. for free
Renamed the files: dropped the dns prefix
2010-12-18 20:31:26 +01:00

38 lines
997 B
Go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// DNS client: see RFC 1035.
// Has to be linked into package net for Dial.
// TODO(rsc):
// Check periodically whether /etc/resolv.conf has changed.
// Could potentially handle many outstanding lookups faster.
// Could have a small cache.
// Random UDP source port (net.Dial should do that for us).
// Random request IDs.
package dns
// DnsError represents a DNS lookup error.
type DnsError struct {
Error string // description of the error
Name string // name looked for
Server string // server used
IsTimeout bool
}
func (e *DnsError) String() string {
s := "lookup " + e.Name
if e.Server != "" {
s += " on " + e.Server
}
s += ": " + e.Error
return s
}
func (e *DnsError) Timeout() bool { return e.IsTimeout }
func (e *DnsError) Temporary() bool { return e.IsTimeout }
const noSuchHost = "no such host"