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