]> Cypherpunks repositories - gostls13.git/commitdiff
net: use slightly less predictable dns request id
authorRuss Cox <rsc@golang.org>
Thu, 11 Feb 2010 00:35:35 +0000 (16:35 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 11 Feb 2010 00:35:35 +0000 (16:35 -0800)
not trying to be secure, just not repetitive
(sending with the same id repeatedly makes
some resolvers stop replying.)

eventually we'll replace this with linking against
the system's native resolver.

R=p
CC=golang-dev
https://golang.org/cl/207051

src/pkg/net/dnsclient.go

index 7820244b280d49399e98f60b462609081fbfaffc..0a6fca0115220bda56a420e1fdaef42f3fe82115 100644 (file)
@@ -17,6 +17,8 @@ package net
 import (
        "once"
        "os"
+       "rand"
+       "time"
 )
 
 // DNSError represents a DNS lookup error.
@@ -44,7 +46,7 @@ func _Exchange(cfg *_DNS_Config, c Conn, name string) (m *_DNS_Msg, err os.Error
                return nil, &DNSError{"name too long", name, ""}
        }
        out := new(_DNS_Msg)
-       out.id = 0x1234
+       out.id = uint16(rand.Int()) ^ uint16(time.Nanoseconds())
        out.question = []_DNS_Question{
                _DNS_Question{name, _DNS_TypeA, _DNS_ClassINET},
        }