2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // Send packet receipt acknowledgement via NNCP.
28 "go.cypherpunks.ru/nncp/v8"
32 fmt.Fprintf(os.Stderr, nncp.UsageHeader())
33 fmt.Fprintf(os.Stderr, "nncp-ack -- send packet receipt acknowledgement\n\n")
34 fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE [PKT|rx]\nOptions:\n", os.Args[0])
40 cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
41 niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq), "Outbound packet niceness")
42 minSizeRaw = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB")
43 viaOverride = flag.String("via", "", "Override Via path to destination node")
44 spoolPath = flag.String("spool", "", "Override path to spool")
45 logPath = flag.String("log", "", "Override path to logfile")
46 quiet = flag.Bool("quiet", false, "Print only errors")
47 showPrgrs = flag.Bool("progress", false, "Force progress showing")
48 omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing")
49 debug = flag.Bool("debug", false, "Print debug messages")
50 version = flag.Bool("version", false, "Print version information")
51 warranty = flag.Bool("warranty", false, "Print warranty information")
53 log.SetFlags(log.Lshortfile)
57 fmt.Println(nncp.Warranty)
61 fmt.Println(nncp.VersionGet())
68 nice, err := nncp.NicenessParse(*niceRaw)
73 ctx, err := nncp.CtxFromCmdline(
83 log.Fatalln("Error during initialization:", err)
86 log.Fatalln("Config lacks private keys")
89 node, err := ctx.FindNode(flag.Arg(0))
91 log.Fatalln("Invalid NODE specified:", err)
94 nncp.ViaOverride(*viaOverride, ctx, node)
96 minSize := int64(*minSizeRaw) * 1024
98 if flag.Arg(1) == string(nncp.TRx) {
99 for job := range ctx.Jobs(node.Id, nncp.TRx) {
100 pktName := filepath.Base(job.Path)
101 if err = ctx.TxACK(node, nice, pktName, minSize); err != nil {
106 if err = ctx.TxACK(node, nice, flag.Arg(1), minSize); err != nil {