Fix subnet stuff
This commit is contained in:
parent
025d0cecf4
commit
c326309d62
3
edns.go
3
edns.go
|
@ -178,11 +178,12 @@ func (e *EDNS0_SUBNET) Pack() ([]byte, error) {
|
|||
case 1:
|
||||
// just copy? TODO (also in msg.go...)
|
||||
ip := make([]byte, net.IPv4len)
|
||||
a := e.Address.To4()
|
||||
for i := 0; i < net.IPv4len; i++ {
|
||||
if i+1 > len(e.Address) {
|
||||
break
|
||||
}
|
||||
ip[i] = e.Address[i]
|
||||
ip[i] = a[i]
|
||||
}
|
||||
b = append(b, ip...)
|
||||
case 2:
|
||||
|
|
|
@ -181,16 +181,17 @@ Flags:
|
|||
if *client != "" {
|
||||
e := new(dns.EDNS0_SUBNET)
|
||||
e.Code = dns.EDNS0SUBNET
|
||||
e.SourceNetmask = 0
|
||||
e.SourceScope = 0
|
||||
e.Address = net.ParseIP(*client)
|
||||
if e.Address == nil {
|
||||
fmt.Fprintf(os.Stderr, "Failure to parse IP address: %s\n", *client)
|
||||
return
|
||||
}
|
||||
e.Family = 1 // IP4
|
||||
if len(e.Address) > net.IPv4len {
|
||||
e.Family = 1 // IP4
|
||||
e.SourceNetmask = 32
|
||||
if e.Address.To4() == nil {
|
||||
e.Family = 2 // IP6
|
||||
e.SourceNetmask = 128
|
||||
}
|
||||
o.Option = append(o.Option, e)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue