mirror of
https://github.com/miekg/dns.git
synced 2025-10-18 13:21:15 +02:00
play with pkt compression
This commit is contained in:
parent
64080d4c37
commit
9d6d5ff3f7
@ -4,6 +4,8 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"dns"
|
"dns"
|
||||||
"dns/resolver"
|
"dns/resolver"
|
||||||
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"os"
|
"os"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -105,6 +107,13 @@ FLAGS:
|
|||||||
}
|
}
|
||||||
fmt.Printf("%v\n", in.Dns)
|
fmt.Printf("%v\n", in.Dns)
|
||||||
fmt.Printf("%s\n", in.Meta)
|
fmt.Printf("%s\n", in.Meta)
|
||||||
|
// zip the message
|
||||||
|
msgbuf, _ := in.Dns.Pack()
|
||||||
|
var zbuff bytes.Buffer
|
||||||
|
w, _ := gzip.NewWriterLevel(&zbuff, gzip.BestCompression)
|
||||||
|
w.Write(msgbuf)
|
||||||
|
w.Close()
|
||||||
|
fmt.Printf(";; Compressed: %d\n", zbuff.Len())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%v\n", in.Error.String())
|
fmt.Printf("%v\n", in.Error.String())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user