NSEC3 is starting to work

This commit is contained in:
Miek Gieben 2012-01-15 12:15:05 +01:00
parent 03a8ee13a2
commit dc6c6d7c9e
4 changed files with 24 additions and 13 deletions

View File

@ -47,7 +47,7 @@ func dnsServer(l *lexer) stateFn {
l.emit(&item{itemVendor, POWER})
return dnsPowerdnsLike
case !f.Do && f.UDPSize == 0 && f.Rcode == dns.RcodeServerFailure:
// Neustar
// Neustar or UltraDNS Resolver
l.emit(&item{itemVendor, NEUSTAR})
return dnsNeustarLike
case !f.Do && f.UDPSize == 0 && f.Rcode == dns.RcodeNotImplemented:
@ -169,6 +169,9 @@ func dnsYadifaLike(l *lexer) stateFn {
func dnsNeustarLike(l *lexer) stateFn {
l.debug("NeustarLike")
l.debug("UltraDNS")
l.setString(".,CLASS42,TXT,QUERY,NOERROR,qr,aa,tc,rd,ra,ad,cd,z,0,0,0,0,do,0,nsid")
l.probe()
return nil
}

View File

@ -17,6 +17,7 @@ const (
MARADNS = "MaraDNS"
NEUSTARDNS = "Neustar DNS"
ATLAS = "Atlas"
ULTRADNS = "UltraDNS"
// Vendors
ISC = "ISC"
@ -26,6 +27,7 @@ const (
POWER = "PowerDNS.com"
NEUSTAR = "Neustar"
VERISIGN = "Verisign"
ULTRA = "UltraDNS"
)
func startParse(addr string) {
@ -137,7 +139,9 @@ func (f *fingerprint) StringNoSections() string {
// SetString set the string to fp.. todo
func (f *fingerprint) setString(str string) {
println("STR:", str)
for i, s := range strings.Split(str, ",") {
println("I", i, "S", s)
switch i {
case 0:
if op, ok := dns.Str_opcode[s]; ok {

View File

@ -85,7 +85,7 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
nsec3.NextDomain = "miek.nl."
// nsec3.TypeBitMap = []uint16{dns.TypeA, dns.TypeNS, dns.TypeMX, dns.TypeTXT, 4000, 4001}
// nsec3.TypeBitMap = []uint16{dns.TypeA, dns.TypeNS, dns.TypeMX, dns.TypeTXT}
nsec3.TypeBitMap = []uint16{dns.TypeA, dns.TypeNS, dns.TypeSOA}
nsec3.TypeBitMap = []uint16{dns.TypeA, dns.TypeNS, dns.TypeSOA, dns.TypeTXT}
nsec3.HashNames("miek.nl.")
m.Extra = append(m.Extra, nsec3)

26
msg.go
View File

@ -412,30 +412,34 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
// This is the uint16 type bitmap
// TODO(mg): overflow
lastwindow := uint16(0)
octet := uint16(0)
length := uint16(0)
if off+2 > len(msg) {
println("dns: overflow packing NSECx bitmap")
return lenmsg, false
}
for j := 0; j < val.Field(i).Len(); j++ {
t := uint16((fv.Index(j).Uint()))
window := uint16(t / 256)
if lastwindow != window {
// New window
off += 2 + int(octet)
off += 2 + int(length)
}
octet := (t - window*256) / 8
bit := t - (window * 256) - (octet * 8)
length := (t - window*256) / 8
bit := t - (window * 256) - (length * 8)
println("Setting window", off, "to", byte(window))
msg[off] = byte(window)
println("Setting octet", off+1, "to", byte(octet+1))
msg[off+1] = byte(octet+1)
println("Setting value", off+1+1+int(octet), "to", byte(1<<bit))
msg[off+1+1+int(octet)] |= byte(1 << bit)
println("Setting length", off+1, "to", byte(length+1))
msg[off+1] = byte(length+1)
println("Setting value", off+1+1+int(length), "to", byte(1<<bit))
msg[off+1+1+int(length)] |= byte(1 << bit)
println(t, window, octet, bit, 1<<bit)
fmt.Printf("%b\n", msg[off+2+int(octet)])
println(t, window, length, bit, 1<<bit)
fmt.Printf("%b\n", msg[off+2+int(length)])
lastwindow = window
}
// off++
off += 3
println("off", off)
}
case reflect.Struct: