diff options
author | Russ Cox <rsc@golang.org> | 2010-02-10 16:35:35 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-02-10 16:35:35 -0800 |
commit | 84536b45a0341ab02c3438f6058bf967a668f52f (patch) | |
tree | 3dff5f73a595d898c03246f1240b18ce3781aa47 /src/pkg/net | |
parent | f73b19e403c5d0ae641053cb4c127ccb02304030 (diff) | |
download | golang-84536b45a0341ab02c3438f6058bf967a668f52f.tar.gz |
net: use slightly less predictable dns request id
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
http://codereview.appspot.com/207051
Diffstat (limited to 'src/pkg/net')
-rw-r--r-- | src/pkg/net/dnsclient.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pkg/net/dnsclient.go b/src/pkg/net/dnsclient.go index 7820244b2..0a6fca011 100644 --- a/src/pkg/net/dnsclient.go +++ b/src/pkg/net/dnsclient.go @@ -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}, } |