More test functions
Minor tweaks for timeouts in client.go
This commit is contained in:
parent
956ec9b962
commit
2f74133d6a
|
@ -7,7 +7,7 @@ import (
|
||||||
// Check if the server responds at all
|
// Check if the server responds at all
|
||||||
func dnsAlive(l *lexer) stateFn {
|
func dnsAlive(l *lexer) stateFn {
|
||||||
l.verbose("Alive")
|
l.verbose("Alive")
|
||||||
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,z,1,0,0,0,do,0")
|
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,z,0,0,0,0,do,0")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
|
||||||
f := l.probe()
|
f := l.probe()
|
||||||
|
@ -22,7 +22,7 @@ func dnsAlive(l *lexer) stateFn {
|
||||||
// Check if the server returns the DO-bit when set in the request.
|
// Check if the server returns the DO-bit when set in the request.
|
||||||
func dnsDoBitMirror(l *lexer) stateFn {
|
func dnsDoBitMirror(l *lexer) stateFn {
|
||||||
l.verbose("DoBitMirror")
|
l.verbose("DoBitMirror")
|
||||||
l.setString("QUERY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,1,0,0,0,DO,0")
|
l.setString("QUERY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,0,0,0,0,DO,0")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
|
||||||
f := l.probe()
|
f := l.probe()
|
||||||
|
@ -36,7 +36,7 @@ func dnsDoBitMirror(l *lexer) stateFn {
|
||||||
|
|
||||||
func dnsEDNS0Mangler(l *lexer) stateFn {
|
func dnsEDNS0Mangler(l *lexer) stateFn {
|
||||||
l.verbose("EDNS0Mangler")
|
l.verbose("EDNS0Mangler")
|
||||||
l.setString("NOTIFY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,1,0,0,0,do,0")
|
l.setString("NOTIFY,NOERROR,qr,aa,tc,RD,ra,ad,cd,z,0,0,0,0,do,0")
|
||||||
l.setQuestion("012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.0123456789012345678901234567890123456789012345678901234567890.", dns.TypeA, dns.ClassINET)
|
l.setQuestion("012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.012345678901234567890123456789012345678901234567890123456789012.0123456789012345678901234567890123456789012345678901234567890.", dns.TypeA, dns.ClassINET)
|
||||||
f := l.probe()
|
f := l.probe()
|
||||||
// MaraDNS does not set the QR bit in the reply... but only with this question is seems
|
// MaraDNS does not set the QR bit in the reply... but only with this question is seems
|
||||||
|
@ -49,39 +49,80 @@ func dnsEDNS0Mangler(l *lexer) stateFn {
|
||||||
|
|
||||||
func dnsTcEnable(l *lexer) stateFn {
|
func dnsTcEnable(l *lexer) stateFn {
|
||||||
l.verbose("TcEnable")
|
l.verbose("TcEnable")
|
||||||
l.setString("QUERY,NOERROR,qr,aa,TC,rd,ra,ad,cd,z,1,0,0,0,do,0")
|
l.setString("QUERY,NOERROR,qr,aa,TC,rd,ra,ad,cd,z,0,0,0,0,do,0")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
f := l.probe()
|
|
||||||
f = f
|
|
||||||
return dnsUDPSize
|
return dnsUDPSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func dnsUDPSize(l *lexer) stateFn {
|
func dnsUDPSize(l *lexer) stateFn {
|
||||||
l.verbose("UDPSize")
|
l.verbose("UDPSize")
|
||||||
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,z,1,0,0,0,DO,4097")
|
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,z,0,0,0,0,DO,4097")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
f := l.probe()
|
l.probe()
|
||||||
f = f
|
|
||||||
return dnsZero
|
return dnsZero
|
||||||
}
|
}
|
||||||
|
|
||||||
func dnsZero(l *lexer) stateFn {
|
func dnsZero(l *lexer) stateFn {
|
||||||
l.verbose("Zero")
|
l.verbose("Zero")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,1,0,0,0,do,0")
|
l.setString("QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
f := l.probe()
|
l.probe()
|
||||||
f = f
|
|
||||||
return dnsAll
|
return dnsAll
|
||||||
}
|
}
|
||||||
|
|
||||||
func dnsAll(l *lexer) stateFn {
|
func dnsAll(l *lexer) stateFn {
|
||||||
l.verbose("All")
|
l.verbose("All")
|
||||||
l.setString("NOTIFY,NOERROR,qr,AA,TC,RD,RA,AD,CD,Z,1,0,0,0,DO,0")
|
l.setString("QUERY,NOERROR,qr,AA,TC,RD,RA,AD,CD,Z,0,0,0,0,DO,8192")
|
||||||
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
f := l.probe()
|
l.probe()
|
||||||
f = f
|
return dnsIquery
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dnsIquery(l *lexer) stateFn {
|
||||||
|
l.verbose("Iquery")
|
||||||
|
l.setString("IQUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return dnsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
func dnsUpdate(l *lexer) stateFn {
|
||||||
|
l.verbose("Update")
|
||||||
|
l.setString("UPDATE,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return dnsStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
func dnsStatus(l *lexer) stateFn {
|
||||||
|
l.verbose("Status")
|
||||||
|
l.setString("STATUS,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return dnsOpcodeWhacky
|
||||||
|
}
|
||||||
|
|
||||||
|
func dnsOpcodeWhacky(l *lexer) stateFn {
|
||||||
|
l.verbose("OpcodeWhacky")
|
||||||
|
l.setString("12,NOERROR,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return dnsRcodeWhacky
|
||||||
|
}
|
||||||
|
|
||||||
|
func dnsRcodeWhacky(l *lexer) stateFn {
|
||||||
|
l.verbose("RcodeWhacky")
|
||||||
|
l.setString("QUERY,31,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return dnsRcodeNotZone
|
||||||
|
}
|
||||||
|
|
||||||
|
func dnsRcodeNotZone(l *lexer) stateFn {
|
||||||
|
l.verbose("RcodeNotZone")
|
||||||
|
l.setString("QUERY,NOTZONE,qr,aa,tc,rd,ra,ad,cd,Z,0,0,0,0,do,0")
|
||||||
|
l.setQuestion(".", dns.TypeNS, dns.ClassINET)
|
||||||
|
l.probe()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -84,8 +84,19 @@ func (f *fingerprint) String() string {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
// Use the same order as in Perl's fpdns. But use more flags.
|
// Use the same order as in Perl's fpdns. But use more flags.
|
||||||
s := dns.Opcode_str[f.Opcode]
|
var s string
|
||||||
s += "," + dns.Rcode_str[f.Rcode]
|
if op, ok := dns.Opcode_str[f.Opcode]; ok {
|
||||||
|
s = op
|
||||||
|
} else { // number
|
||||||
|
s = valueOfInt(f.Opcode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if op, ok := dns.Rcode_str[f.Rcode]; ok {
|
||||||
|
s += "," + op
|
||||||
|
} else { // number
|
||||||
|
s += "," + valueOfInt(f.Rcode)
|
||||||
|
}
|
||||||
|
|
||||||
s += valueOfBool(f.Response, ",qr")
|
s += valueOfBool(f.Response, ",qr")
|
||||||
s += valueOfBool(f.Authoritative, ",aa")
|
s += valueOfBool(f.Authoritative, ",aa")
|
||||||
s += valueOfBool(f.Truncated, ",tc")
|
s += valueOfBool(f.Truncated, ",tc")
|
||||||
|
@ -95,13 +106,13 @@ func (f *fingerprint) String() string {
|
||||||
s += valueOfBool(f.CheckingDisabled, ",cd")
|
s += valueOfBool(f.CheckingDisabled, ",cd")
|
||||||
s += valueOfBool(f.Zero, ",z")
|
s += valueOfBool(f.Zero, ",z")
|
||||||
|
|
||||||
s += valueOfInt(f.Question)
|
s += ","+valueOfInt(f.Question)
|
||||||
s += valueOfInt(f.Answer)
|
s += ","+valueOfInt(f.Answer)
|
||||||
s += valueOfInt(f.Ns)
|
s += ","+valueOfInt(f.Ns)
|
||||||
s += valueOfInt(f.Extra)
|
s += ","+valueOfInt(f.Extra)
|
||||||
|
|
||||||
s += valueOfBool(f.Do, ",do")
|
s += valueOfBool(f.Do, ",do")
|
||||||
s += valueOfInt(f.UDPSize)
|
s += ","+valueOfInt(f.UDPSize)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,58 +121,38 @@ func (f *fingerprint) setString(str string) {
|
||||||
for i, s := range strings.Split(str, ",") {
|
for i, s := range strings.Split(str, ",") {
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
f.Opcode = dns.Str_opcode[s]
|
if op, ok := dns.Str_opcode[s]; ok {
|
||||||
|
f.Opcode = op
|
||||||
|
} else { // number
|
||||||
|
f.Opcode = valueOfString(s)
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
f.Rcode = dns.Str_rcode[s]
|
if op, ok := dns.Str_rcode[s]; ok {
|
||||||
|
f.Rcode = op
|
||||||
|
} else { // number
|
||||||
|
f.Rcode = valueOfString(s)
|
||||||
|
}
|
||||||
case 2:
|
case 2:
|
||||||
f.Response = false
|
f.Response = s == strings.ToUpper("qr")
|
||||||
if s == strings.ToUpper("qr") {
|
|
||||||
f.Response = true
|
|
||||||
}
|
|
||||||
case 3:
|
case 3:
|
||||||
f.Authoritative = false
|
f.Authoritative = s == strings.ToUpper("aa")
|
||||||
if s == strings.ToUpper("aa") {
|
|
||||||
f.Authoritative = true
|
|
||||||
}
|
|
||||||
case 4:
|
case 4:
|
||||||
f.Truncated = false
|
f.Truncated = s == strings.ToUpper("tc")
|
||||||
if s == strings.ToUpper("tc") {
|
|
||||||
f.Truncated = true
|
|
||||||
}
|
|
||||||
case 5:
|
case 5:
|
||||||
f.RecursionDesired = false
|
f.RecursionDesired = s == strings.ToUpper("rd")
|
||||||
if s == strings.ToUpper("rd") {
|
|
||||||
f.RecursionDesired = true
|
|
||||||
}
|
|
||||||
case 6:
|
case 6:
|
||||||
f.RecursionAvailable = false
|
f.RecursionAvailable = s == strings.ToUpper("ra")
|
||||||
if s == strings.ToUpper("ra") {
|
|
||||||
f.RecursionAvailable = true
|
|
||||||
}
|
|
||||||
case 7:
|
case 7:
|
||||||
f.AuthenticatedData = false
|
f.AuthenticatedData = s == strings.ToUpper("ad")
|
||||||
if s == strings.ToUpper("ad") {
|
|
||||||
f.AuthenticatedData = true
|
|
||||||
}
|
|
||||||
case 8:
|
case 8:
|
||||||
f.CheckingDisabled = false
|
f.CheckingDisabled = s == strings.ToUpper("cd")
|
||||||
if s == strings.ToUpper("cd") {
|
|
||||||
f.CheckingDisabled = true
|
|
||||||
}
|
|
||||||
case 9:
|
case 9:
|
||||||
f.Zero = false
|
f.Zero = s == strings.ToUpper("z")
|
||||||
if s == strings.ToUpper("z") {
|
|
||||||
f.Zero = true
|
|
||||||
}
|
|
||||||
case 10, 11, 12, 13:
|
case 10, 11, 12, 13:
|
||||||
// Can not set content of the message
|
// Can not set content of the message
|
||||||
case 14:
|
case 14:
|
||||||
f.Do = false
|
f.Do = s == strings.ToUpper("do")
|
||||||
if s == strings.ToUpper("do") {
|
|
||||||
f.Do = true
|
|
||||||
}
|
|
||||||
case 15:
|
case 15:
|
||||||
f.UDPSize = 0
|
|
||||||
f.UDPSize = valueOfString(s)
|
f.UDPSize = valueOfString(s)
|
||||||
default:
|
default:
|
||||||
panic("unhandled fingerprint")
|
panic("unhandled fingerprint")
|
||||||
|
@ -257,7 +248,7 @@ func valueOfBool(b bool, w string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func valueOfInt(i int) string {
|
func valueOfInt(i int) string {
|
||||||
return "," + strconv.Itoa(i)
|
return strconv.Itoa(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func valueOfString(s string) int {
|
func valueOfString(s string) int {
|
||||||
|
|
|
@ -142,8 +142,8 @@ func NewClient() *Client {
|
||||||
c.Attempts = 1
|
c.Attempts = 1
|
||||||
c.ReplyChan = DefaultReplyChan
|
c.ReplyChan = DefaultReplyChan
|
||||||
c.QueryChan = DefaultQueryChan
|
c.QueryChan = DefaultQueryChan
|
||||||
c.ReadTimeout = 5000
|
c.ReadTimeout = 0.5 * 1e9
|
||||||
c.WriteTimeout = 5000
|
c.WriteTimeout = 0.5 * 1e9
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue