Make Funkensturm somewhat better

This commit is contained in:
Miek Gieben 2011-07-31 16:09:48 +02:00
parent 7cf37d9d6f
commit 9bee591bc0
2 changed files with 15 additions and 10 deletions

View File

@ -55,7 +55,9 @@ func (c Cache) lookup(q *dns.Msg) []byte {
if im, ok := c[q.Question[0].Name]; ok { if im, ok := c[q.Question[0].Name]; ok {
// we have the name // we have the name
if d, ok := im[i]; ok { if d, ok := im[i]; ok {
return d e := make([]byte, len(d))
copy(e, d)
return e
} }
} }
return nil return nil
@ -73,6 +75,7 @@ func checkcache(m *dns.Msg, ok bool) (o []byte) {
o[1] = byte(m.MsgHdr.Id) o[1] = byte(m.MsgHdr.Id)
return return
} }
println("Cache miss")
var p *dns.Msg var p *dns.Msg
// nothing found // nothing found
for _, c := range qr { for _, c := range qr {

View File

@ -99,6 +99,7 @@ func doFunkensturm(pkt *dns.Msg) ([]byte, os.Error) {
// change is cumulative. // change is cumulative.
ok, ok1 := true, true ok, ok1 := true, true
pkt1 := pkt pkt1 := pkt
if len(f.Matches) > 0 {
for _, m := range f.Matches { for _, m := range f.Matches {
pkt1, ok1 = m.Func(pkt1, IN) pkt1, ok1 = m.Func(pkt1, IN)
switch m.Op { switch m.Op {
@ -108,6 +109,7 @@ func doFunkensturm(pkt *dns.Msg) ([]byte, os.Error) {
ok = ok || ok1 ok = ok || ok1
} }
} }
}
if *verbose { //modified if *verbose { //modified
verboseprint(pkt1, ">> ") verboseprint(pkt1, ">> ")
} }