X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fnncp%2Fcmd%2Fnncp-pkt%2Fmain.go;h=bdb18ad0d6ff94b6c41be187b06cb888ef275185;hb=dd92823db3d72fb21a4c712a7fb052dce16443dd;hp=ff77eb45195ac188be4a0872aeaa5ddb3768ca47;hpb=febf067a4f2c09c465190d1ddd2839ffc2c2405a;p=nncp.git diff --git a/src/cypherpunks.ru/nncp/cmd/nncp-pkt/main.go b/src/cypherpunks.ru/nncp/cmd/nncp-pkt/main.go index ff77eb4..bdb18ad 100644 --- a/src/cypherpunks.ru/nncp/cmd/nncp-pkt/main.go +++ b/src/cypherpunks.ru/nncp/cmd/nncp-pkt/main.go @@ -1,11 +1,10 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2018 Sergey Matveev +Copyright (C) 2016-2019 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -// Parse raw NNCP packet +// Parse raw NNCP packet. package main import ( @@ -31,7 +30,6 @@ import ( "cypherpunks.ru/nncp" "github.com/davecgh/go-xdr/xdr2" - "golang.org/x/crypto/blake2b" ) func usage() { @@ -44,6 +42,7 @@ func usage() { func main() { var ( + overheads = flag.Bool("overheads", false, "Print packet overheads") 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") @@ -61,8 +60,18 @@ func main() { return } + if *overheads { + fmt.Printf( + "Plain: %d\nEncrypted: %d\nSize: %d\n", + nncp.PktOverhead, + nncp.PktEncOverhead, + nncp.PktSizeOverhead, + ) + return + } + var err error - beginning := make([]byte, nncp.PktOverhead-8-2*blake2b.Size256) + beginning := make([]byte, nncp.PktOverhead) if _, err = io.ReadFull(os.Stdin, beginning); err != nil { log.Fatalln("Not enough data to read") } @@ -121,7 +130,7 @@ func main() { } var pktEnc nncp.PktEnc _, err = xdr.Unmarshal(bytes.NewReader(beginning), &pktEnc) - if err == nil && pktEnc.Magic == nncp.MagicNNCPEv3 { + if err == nil && pktEnc.Magic == nncp.MagicNNCPEv4 { if *dump { ctx, err := nncp.CtxFromCmdline(*cfgPath, "", "", false, false) if err != nil {