Make Id a variable to points to id (renamed from Id())
This way the Id function can be overruled by clients to have another implementation for the Id function: To make it static: dns.Id = func() uint16 { return 1234 }
This commit is contained in:
parent
fb3a1585ad
commit
1243dcbc89
9
msg.go
9
msg.go
|
@ -51,6 +51,11 @@ var (
|
|||
ErrRRset error = &Error{err: "bad rrset"}
|
||||
)
|
||||
|
||||
// Id, by default, returns a 16 bits random number to be used as a
|
||||
// message id. The random provided should be good enough. This being a
|
||||
// variable the function can be overridden with another implementation.
|
||||
var Id func() uint16 = id
|
||||
|
||||
// A manually-unpacked version of (id, bits).
|
||||
// This is in its own struct for easy printing.
|
||||
type MsgHdr struct {
|
||||
|
@ -1782,9 +1787,9 @@ func compressionLenSearchType(c map[string]int, r RR) (int, bool) {
|
|||
return 0, false
|
||||
}
|
||||
|
||||
// Id return a 16 bits random number to be used as a
|
||||
// id returns a 16 bits random number to be used as a
|
||||
// message id. The random provided should be good enough.
|
||||
func Id() uint16 {
|
||||
func id() uint16 {
|
||||
return uint16(rand.Int()) ^ uint16(time.Now().Nanosecond())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue