@verbatim
% nncp-pkt [options] < pkt
-% nncp-pkt [options] -dump < pkt > payload
+% nncp-pkt [options] [-decompress] -dump < pkt > payload
@end verbatim
Low level packet parser. Normally it should not be used, but can help in
@end verbatim
And with the @option{-dump} option it will give you the actual payload
-(the whole file, mail message, and so on).
+(the whole file, mail message, and so on). @option{-decompress} option
+tries to zlib-decompress the data from plain packet (useful for mail
+packets).
@node nncp-stat
@section nncp-stat
@item @option{-maxonlinetime} option gives ability to set maximal
allowable online connection alive time.
@item @ref{nncp-caller} command appeared: cron-ed TCP daemon caller.
+@item @ref{nncp-pkt} command can decompress the data.
@end itemize
import (
"bufio"
"bytes"
+ "compress/zlib"
"flag"
"fmt"
"io"
func main() {
var (
- dump = flag.Bool("dump", false, "Write decrypted/parsed payload to stdout")
- cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
- version = flag.Bool("version", false, "Print version information")
- warranty = flag.Bool("warranty", false, "Print warranty information")
+ dump = flag.Bool("dump", false, "Write decrypted/parsed payload to stdout")
+ decompress = flag.Bool("decompress", false, "Try to zlib decompress dumped data")
+ cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
+ version = flag.Bool("version", false, "Print version information")
+ warranty = flag.Bool("warranty", false, "Print warranty information")
)
flag.Usage = usage
flag.Parse()
if err == nil && pkt.Magic == nncp.MagicNNCPPv1 {
if *dump {
bufW := bufio.NewWriter(os.Stdout)
- if _, err = io.Copy(bufW, bufio.NewReader(os.Stdin)); err != nil {
+ var r io.Reader
+ r = bufio.NewReader(os.Stdin)
+ if *decompress {
+ decompressor, err := zlib.NewReader(r)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ r = decompressor
+ }
+ if _, err = io.Copy(bufW, r); err != nil {
log.Fatalln(err)
}
if err = bufW.Flush(); err != nil {