Documentation and make the random better

This commit is contained in:
Miek Gieben 2011-12-16 19:28:35 +01:00
parent 9aa41a5de3
commit de3f0f3903
3 changed files with 9 additions and 7 deletions

View File

@ -63,10 +63,12 @@ func newQueryChan() chan *Request { return make(chan *Request) }
// Default channels to use for the resolver // Default channels to use for the resolver
var ( var (
DefaultReplyChan = newQueryChanSlice() // DefaultReplyChan is the channel on which the replies are // DefaultReplyChan is the channel on which the replies are
// coming back. Is it a channel of *Exchange, so that the original // coming back. Is it a channel of *Exchange, so that the original
// question is included with the answer. // question is included with the answer.
DefaultQueryChan = newQueryChan() // DefaultQueryChan is the channel were you can send the questions to. DefaultReplyChan = newQueryChanSlice()
// DefaultQueryChan is the channel were you can send the questions to.
DefaultQueryChan = newQueryChan()
) )
// The HandlerQueryFunc type is an adapter to allow the use of // The HandlerQueryFunc type is an adapter to allow the use of

6
dns.go
View File

@ -27,10 +27,10 @@
// m := new(Msg) // m := new(Msg)
// m.SetQuestion("miek.nl.", TypeMX) // m.SetQuestion("miek.nl.", TypeMX)
// //
// The message m is now a messages with the Question section set to ask // The message m is now a message with the question section set to ask
// the MX records for the miek.nl. zone. // the MX records for the miek.nl. zone.
// //
// This is slightly more verbose, but more flexible: // The following is slightly more verbose, but more flexible:
// //
// m1 := new(Msg) // m1 := new(Msg)
// m1.MsgHdr.Id = Id() // m1.MsgHdr.Id = Id()
@ -47,7 +47,7 @@
// // c.Net = "tcp" // If you want to use TCP // // c.Net = "tcp" // If you want to use TCP
// in := c.Exchange(m, "127.0.0.1:53") // in := c.Exchange(m, "127.0.0.1:53")
// //
// An asynchronous query ... TODO(mg) // An asynchronous query is also possible. The Basic use pattern is: TODO(mg)
package dns package dns
import ( import (

4
msg.go
View File

@ -1079,8 +1079,8 @@ func (dns *Msg) String() string {
return s return s
} }
// Return a 16 bits random number to be used as a // Id return a 16 bits random number to be used as a
// message id. The random provided should be good enough. // message id. The random provided should be good enough.
func Id() uint16 { func Id() uint16 {
return uint16(rand.Int()) ^ uint16(time.Now().UnixNano()) return uint16(rand.Int()) ^ uint16(time.Now().Nanosecond())
} }