From 8cc24a1b9b621bed04c66ba3f1c39dc4b830ea64 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 10 Jan 2012 10:54:39 +0100 Subject: [PATCH] Some tweaks --- rawmsg.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rawmsg.go b/rawmsg.go index c2ad5c61..4c963900 100644 --- a/rawmsg.go +++ b/rawmsg.go @@ -4,6 +4,10 @@ package dns +import ( + "fmt" +) + const maxPointer = 2 << 13 // We have 14 bits for the offset // Function defined in this subpackage work on []byte and but still @@ -96,6 +100,12 @@ Loop: // How to handle well known records here // NS, MX, CNAME? eatName() function? // In the "body" of the msg + t, _ := unpackUint16(msg, off+1) + switch t { + case TypeMX: + println("MX") + // get the labels n check + } off += 2 + 2 + 4 + 1 // type, class, ttl + 1 // we are at the rdlength rdlength, _ := unpackUint16(msg, off) @@ -130,11 +140,11 @@ Loop: saved := 0 // Start at the back, easier to move for i := len(moves) - 1; i >= 0; i-- { - // fmt.Printf("%v\n", moves[i]) + fmt.Printf("%v\n", moves[i]) // move the bytes copy(msg[moves[i].from+1:], msg[moves[i].from+moves[i].length-1:]) // Now set the pointer at moves[i].from and moves[i].from+1 - // fmt.Printf("bits %b\n", moves[i].offset^0xC000) + fmt.Printf("bits %b\n", moves[i].offset^0xC000) msg[moves[i].from], msg[moves[i].from+1] = packUint16(uint16(moves[i].offset ^ 0xC000)) saved += (moves[i].length - 2) // minus something }