parent
de832dd7c0
commit
b8c9280cc4
4
README
4
README
|
@ -5,6 +5,10 @@ to send it.
|
|||
|
||||
The library is asynchronise (thanks to Go) from the get go.
|
||||
|
||||
Implemented RFCS
|
||||
|
||||
* RFC2671, EDNS
|
||||
|
||||
* ldns
|
||||
* NSD
|
||||
* Net::DNS
|
||||
|
|
|
@ -60,6 +60,10 @@ func main() {
|
|||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
m.Question[0] = dns.Question{"xxxx.nlnetlabs.nl", dns.TypeDNSKEY, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
ch <- dns.DnsMsg{nil, nil}
|
||||
time.Sleep(1.0e9) // wait for Go routine to do something
|
||||
|
|
45
msg.go
45
msg.go
|
@ -491,6 +491,9 @@ type MsgHdr struct {
|
|||
Truncated bool
|
||||
Recursion_desired bool
|
||||
Recursion_available bool
|
||||
Z bool
|
||||
Authenticated_data bool
|
||||
Checking_disabled bool
|
||||
Rcode int
|
||||
}
|
||||
|
||||
|
@ -506,6 +509,9 @@ func (h *MsgHdr) String() string {
|
|||
s += ", id: " + strconv.Itoa(int(h.Id)) + "\n"
|
||||
|
||||
s += ";; flags: "
|
||||
if h.Response {
|
||||
s += "qr "
|
||||
}
|
||||
if h.Authoritative {
|
||||
s += "aa "
|
||||
}
|
||||
|
@ -518,6 +524,16 @@ func (h *MsgHdr) String() string {
|
|||
if h.Recursion_available {
|
||||
s += "ra "
|
||||
}
|
||||
if h.Z {
|
||||
s += "z "
|
||||
}
|
||||
if h.Authenticated_data {
|
||||
s += "ad "
|
||||
}
|
||||
if h.Checking_disabled {
|
||||
s += "cd "
|
||||
}
|
||||
|
||||
s += ";"
|
||||
return s
|
||||
}
|
||||
|
@ -538,20 +554,29 @@ func (dns *Msg) Pack() (msg []byte, ok bool) {
|
|||
// Convert convenient Msg into wire-like Header.
|
||||
dh.Id = dns.Id
|
||||
dh.Bits = uint16(dns.Opcode)<<11 | uint16(dns.Rcode)
|
||||
if dns.Recursion_available {
|
||||
dh.Bits |= _RA
|
||||
}
|
||||
if dns.Recursion_desired {
|
||||
dh.Bits |= _RD
|
||||
}
|
||||
if dns.Truncated {
|
||||
dh.Bits |= _TC
|
||||
if dns.Response {
|
||||
dh.Bits |= _QR
|
||||
}
|
||||
if dns.Authoritative {
|
||||
dh.Bits |= _AA
|
||||
}
|
||||
if dns.Response {
|
||||
dh.Bits |= _QR
|
||||
if dns.Truncated {
|
||||
dh.Bits |= _TC
|
||||
}
|
||||
if dns.Recursion_desired {
|
||||
dh.Bits |= _RD
|
||||
}
|
||||
if dns.Recursion_available {
|
||||
dh.Bits |= _RA
|
||||
}
|
||||
if dns.Z {
|
||||
dh.Bits |= _Z
|
||||
}
|
||||
if dns.Authenticated_data {
|
||||
dh.Bits |= _AD
|
||||
}
|
||||
if dns.Checking_disabled {
|
||||
dh.Bits |= _CD
|
||||
}
|
||||
|
||||
// Prepare variable sized arrays.
|
||||
|
|
|
@ -44,6 +44,4 @@ func main() {
|
|||
msg, _ = out.Pack()
|
||||
in.Unpack(msg)
|
||||
fmt.Printf("%v\n", in)
|
||||
|
||||
|
||||
}
|
||||
|
|
35
restest.go
35
restest.go
|
@ -25,38 +25,13 @@ func main() {
|
|||
m.MsgHdr.Recursion_desired = true //only set this bit
|
||||
m.Question = make([]dns.Question, 1)
|
||||
|
||||
for i:=0; i< NLOOP; i++ {
|
||||
// ask something
|
||||
m.Question[0] = dns.Question{"miek.nl", dns.TypeSOA, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
m.Question[0] = dns.Question{"forfunsec.org", dns.TypeRRSIG, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
|
||||
// wait for an reply
|
||||
in := <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
// wait for an reply
|
||||
in := <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
m.Question[0] = dns.Question{"a.miek.nl", dns.TypeTXT, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
m.Question[0] = dns.Question{"miek.nl", dns.TypeTXT, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
m.Question[0] = dns.Question{"nl", dns.TypeDNSKEY, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
m.Question[0] = dns.Question{"pa1ton.nl", dns.TypeDS, dns.ClassINET}
|
||||
ch <- dns.DnsMsg{m, nil}
|
||||
in = <-ch
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
|
||||
|
||||
|
||||
}
|
||||
ch <- dns.DnsMsg{nil, nil}
|
||||
|
||||
time.Sleep(2.0e9) // wait for Go routine to do something
|
||||
|
|
6
types.go
6
types.go
|
@ -84,8 +84,10 @@ const (
|
|||
_TC = 1 << 9 // truncated
|
||||
_RD = 1 << 8 // recursion desired
|
||||
_RA = 1 << 7 // recursion available
|
||||
// _AD = 1 << ? // authenticated data
|
||||
// _CD = 1 << ? // checking disabled
|
||||
_Z = 1 << 6 // Z
|
||||
_AD = 1 << 5 // authticated data
|
||||
_CD = 1 << 4 // checking disabled
|
||||
// EDNS
|
||||
// _DO = 1 << ? // dnssec ok
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue