Some tweaks
This commit is contained in:
parent
28f5e6c1ed
commit
d7a57ee174
|
@ -26,7 +26,7 @@ type rawmove struct {
|
||||||
length int // used in calculating how much to shrink the message
|
length int // used in calculating how much to shrink the message
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress performs name comression in the dns message contained in buf.
|
// Compress performs name compression in the dns message contained in buf.
|
||||||
// It returns the shortened buffer.
|
// It returns the shortened buffer.
|
||||||
func Compress(msg []byte) []byte {
|
func Compress(msg []byte) []byte {
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ func Compress(msg []byte) []byte {
|
||||||
// moves.
|
// moves.
|
||||||
// TODO: Maybe it should be optimized.
|
// TODO: Maybe it should be optimized.
|
||||||
// TODO: put this in the packRR function
|
// TODO: put this in the packRR function
|
||||||
|
// TODO: only compresses owner names, not the well known RR
|
||||||
|
// These all those defined in 1035, important ones: CNAME, MX, NS, PTR, SOA
|
||||||
|
|
||||||
// Map the labels to the offset in the message
|
// Map the labels to the offset in the message
|
||||||
table := make(map[string]int)
|
table := make(map[string]int)
|
||||||
|
@ -111,7 +113,7 @@ Loop:
|
||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
// If we are too deep in the message we cannot point to
|
// If we are too deep in the message we cannot point to
|
||||||
// it, so skip this label.
|
// it, otherwise we can just save it.
|
||||||
if off < maxPointer {
|
if off < maxPointer {
|
||||||
l[i] = rawlabel{offset: off, name: string(msg[off : off+c+1])}
|
l[i] = rawlabel{offset: off, name: string(msg[off : off+c+1])}
|
||||||
i++
|
i++
|
||||||
|
|
Loading…
Reference in New Issue