X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-check%2Fmain.go;h=6575ded385ef07b06ef5d78aa634b5b9482c6f02;hb=0fad171c0d79ad583c0faf5427e22d1d62a0a52d;hp=252f79aa8bb5cafc875493e1d031e71f33989605;hpb=271870ad4f56253e0918f673b90615e4749cf201;p=nncp.git diff --git a/src/cmd/nncp-check/main.go b/src/cmd/nncp-check/main.go index 252f79a..6575ded 100644 --- a/src/cmd/nncp-check/main.go +++ b/src/cmd/nncp-check/main.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2020 Sergey Matveev +Copyright (C) 2016-2021 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 @@ -23,19 +23,21 @@ import ( "fmt" "log" "os" + "path/filepath" - "go.cypherpunks.ru/nncp/v5" + "go.cypherpunks.ru/nncp/v7" ) func usage() { fmt.Fprintf(os.Stderr, nncp.UsageHeader()) fmt.Fprintf(os.Stderr, "nncp-check -- verify Rx/Tx packets checksum\n\n") - fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "Usage: %s [-nock] [options]\nOptions:\n", os.Args[0]) flag.PrintDefaults() } func main() { var ( + nock = flag.Bool("nock", false, "Process .nock files") cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") nodeRaw = flag.String("node", "", "Process only that node") spoolPath = flag.String("spool", "", "Override path to spool") @@ -47,6 +49,7 @@ func main() { version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") ) + log.SetFlags(log.Lshortfile) flag.Usage = usage flag.Parse() if *warranty { @@ -85,7 +88,20 @@ func main() { if nodeOnly != nil && nodeId != *nodeOnly.Id { continue } - if !ctx.Check(node.Id) { + if *nock { + for job := range ctx.JobsNoCK(node.Id) { + if _, err = ctx.CheckNoCK(node.Id, job.HshValue, nil); err != nil { + pktName := nncp.Base32Codec.EncodeToString(job.HshValue[:]) + log.Println(filepath.Join( + ctx.Spool, + nodeId.String(), + string(nncp.TRx), + pktName+nncp.NoCKSuffix, + ), err) + isBad = true + } + } + } else if !ctx.Check(node.Id) { isBad = true } }