Add some more functions
This commit is contained in:
parent
9e2bec0041
commit
47beef5d45
|
@ -3,7 +3,7 @@
|
|||
Must of the stuff is working, but there is a list of smaller
|
||||
things that need to be fixed.
|
||||
|
||||
* Use the Exchange structure to deal with errors when resolving
|
||||
* Use the Exchange structure to deal with errors when resolving, esp. Timeout
|
||||
* encoding NSEC3/NSEC bitmaps, DEcoding works;
|
||||
* add functions to operate on []byte messages (raw packets) see rawmsg.go
|
||||
* HIP RR (needs list of domain names, need slice for that);
|
||||
|
|
|
@ -22,15 +22,37 @@ func dnsAlive(l *lexer) stateFn {
|
|||
// Check if the server returns the DO-bit when set in the request.
|
||||
func dnsDoBitMirror(l *lexer) stateFn {
|
||||
l.verbose("DoBitMirror")
|
||||
// The important part here is that the DO bit is on in the reply
|
||||
l.setString("QUERY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,1,0,0,0,DO,0")
|
||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||
|
||||
f := l.probe()
|
||||
if !f.Do {
|
||||
// NSD doesn't set the DO bit, but does set the UDPMsg size to 4096.
|
||||
if !f.Do && f.UDPSize == 4096 {
|
||||
l.emit(&item{itemSoftware, NSD})
|
||||
return nil
|
||||
return dnsEDNS0Mangler
|
||||
}
|
||||
l.emit(&item{itemSoftware, BIND})
|
||||
return dnsEDNS0Mangler
|
||||
}
|
||||
|
||||
func dnsEDNS0Mangler(l *lexer) stateFn {
|
||||
l.verbose("EDNS0Mangler")
|
||||
l.setString("NOTIFY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,1,0,0,0,do,0")
|
||||
l.setQuestion("012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.0123456789012345678901234567890123456789012345678901234567890.", dns.TypeA, dns.ClassINET)
|
||||
f := l.probe()
|
||||
// MaraDNS does not set the QR bit in the reply... but only with this question is seems
|
||||
// QUERY,NOERROR,qr,aa,t
|
||||
if !f.Response && f.Opcode == dns.OpcodeQuery && f.Rcode == dns.RcodeSuccess {
|
||||
l.emit(&item{itemSoftware, MARADNS})
|
||||
}
|
||||
return dnsTcEnable
|
||||
}
|
||||
|
||||
func dnsTcEnable(l *lexer) stateFn {
|
||||
l.verbose("TcEnable")
|
||||
l.setString("QUERY,NOERROR,qr,aa,TC,rd,ra,ad,cd,z,1,0,0,0,do,0")
|
||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||
|
||||
f := l.probe()
|
||||
f = f
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -13,9 +13,11 @@ const (
|
|||
// Detected software types
|
||||
NSD = "NSD"
|
||||
BIND = "BIND"
|
||||
MARADNS = "MaraDNS"
|
||||
|
||||
// Vendors
|
||||
ISC = "ISC"
|
||||
MARA = "MaraDNS.org" // check
|
||||
NLNETLABS = "NLnet Labs"
|
||||
MICROSOFT = "Microsoft"
|
||||
)
|
||||
|
|
|
@ -18,8 +18,8 @@ type item struct {
|
|||
|
||||
const (
|
||||
itemError itemType = iota
|
||||
itemVender // software vendor
|
||||
itemSoftware // the name of the DNS server software
|
||||
itemVendor // vendor of the DNS software
|
||||
itemVersionMin // the minimum version of the software (empty if not determined)
|
||||
itemVersionMax // the maximum version of the software (empty if not determined)
|
||||
)
|
||||
|
@ -40,7 +40,7 @@ type lexer struct {
|
|||
func (l *lexer) probe() *fingerprint {
|
||||
f := sendProbe(l.client, l.addr, l.fp, l.q)
|
||||
if l.debug {
|
||||
fmt.Printf(" QR fp: %s\n", f)
|
||||
fmt.Printf(" QR fp: %s\n", f)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
@ -52,12 +52,15 @@ func (l *lexer) emit(i *item) {
|
|||
func (l *lexer) setString(s string) {
|
||||
l.fp.setString(s)
|
||||
if l.debug {
|
||||
fmt.Printf(" Q fp: %s\n", s)
|
||||
fmt.Printf(" Q fp: %s\n", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lexer) setQuestion(name string, t uint16, c uint16) {
|
||||
l.q = dns.Question{name, t, c}
|
||||
// if l.debug {
|
||||
// fmt.Printf(" Question: %v\n", l.q)
|
||||
// }
|
||||
}
|
||||
|
||||
func (l *lexer) run() {
|
||||
|
@ -70,5 +73,7 @@ func (l *lexer) run() {
|
|||
}
|
||||
|
||||
func (l *lexer) verbose(s string) {
|
||||
fmt.Printf("running: dns%s\n", s)
|
||||
if l.debug {
|
||||
fmt.Printf("running: dns%s\n", s)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue