]> Cypherpunks repositories - gostls13.git/commitdiff
net: correct DNS configuration
authorStephen Ma <stephenm@golang.org>
Wed, 3 Mar 2010 04:25:26 +0000 (15:25 +1100)
committerStephen Ma <stephenm@golang.org>
Wed, 3 Mar 2010 04:25:26 +0000 (15:25 +1100)
Set defaults to the same values as various C DNS resolver libraries.
Use the timeout value from the configuration.
Fixes #632.

R=rsc
CC=golang-dev
https://golang.org/cl/223094

src/pkg/net/dnsclient.go
src/pkg/net/dnsconfig.go

index 0a6fca0115220bda56a420e1fdaef42f3fe82115..387a9bbf9cfceafa765ff5f2f679f318354829b4 100644 (file)
@@ -62,7 +62,7 @@ func _Exchange(cfg *_DNS_Config, c Conn, name string) (m *_DNS_Msg, err os.Error
                        return nil, err
                }
 
-               c.SetReadTimeout(1e9) // nanoseconds
+               c.SetReadTimeout(int64(cfg.timeout) * 1e9) // nanoseconds
 
                buf := make([]byte, 2000) // More than enough.
                n, err = c.Read(buf)
index b2153e07dae6ccbd6102a656ef117edc68bbb42a..7d098583df262763d7d65ba6b583ddaa51a980c9 100644 (file)
@@ -32,8 +32,8 @@ func _DNS_ReadConfig() (*_DNS_Config, os.Error) {
        conf.servers = make([]string, 3)[0:0] // small, but the standard limit
        conf.search = make([]string, 0)
        conf.ndots = 1
-       conf.timeout = 1
-       conf.attempts = 1
+       conf.timeout = 5
+       conf.attempts = 2
        conf.rotate = false
        for line, ok := file.readLine(); ok; line, ok = file.readLine() {
                f := getFields(line)