2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2023 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 execution command via NNCP.
29 "go.cypherpunks.ru/nncp/v8"
33 fmt.Fprint(os.Stderr, "nncp-exec -- send execution command\n\n")
34 fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE HANDLE [ARG0 ARG1 ...]\n", os.Args[0])
35 fmt.Fprintf(os.Stderr, " %s [options] %s:AREA HANDLE [ARG0 ARG1 ...]\nOptions:\n",
36 os.Args[0], nncp.AreaDir)
42 noCompress = flag.Bool("nocompress", false, "Do not compress input data")
43 cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
44 niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceExec),
45 "Outbound packet niceness")
46 replyNiceRaw = flag.String("replynice", nncp.NicenessFmt(nncp.DefaultNiceFile),
47 "Possible reply packet niceness")
48 minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB")
49 argMaxSize = flag.Uint64("maxsize", 0, "Maximal allowable resulting packet size, in KiB")
50 viaOverride = flag.String("via", "", "Override Via path to destination node")
51 spoolPath = flag.String("spool", "", "Override path to spool")
52 logPath = flag.String("log", "", "Override path to logfile")
53 quiet = flag.Bool("quiet", false, "Print only errors")
54 showPrgrs = flag.Bool("progress", false, "Force progress showing")
55 omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing")
56 debug = flag.Bool("debug", false, "Print debug messages")
57 version = flag.Bool("version", false, "Print version information")
58 warranty = flag.Bool("warranty", false, "Print warranty information")
60 log.SetFlags(log.Lshortfile)
64 fmt.Println(nncp.Warranty)
68 fmt.Println(nncp.VersionGet())
75 nice, err := nncp.NicenessParse(*niceRaw)
79 replyNice, err := nncp.NicenessParse(*replyNiceRaw)
84 ctx, err := nncp.CtxFromCmdline(
94 log.Fatalln("Error during initialization:", err)
97 log.Fatalln("Config lacks private keys")
100 var areaId *nncp.AreaId
102 if strings.HasPrefix(flag.Arg(0), nncp.AreaDir+":") {
103 areaId = ctx.AreaName2Id[flag.Arg(0)[len(nncp.AreaDir)+1:]]
105 log.Fatalln("Unknown area specified")
107 node = ctx.Neigh[*ctx.SelfId]
109 node, err = ctx.FindNode(flag.Arg(0))
111 log.Fatalln("Invalid NODE specified:", err)
115 maxSize := int64(nncp.MaxFileSize)
117 maxSize = int64(*argMaxSize) * 1024
120 nncp.ViaOverride(*viaOverride, ctx, node)
129 bufio.NewReaderSize(os.Stdin, nncp.MTHBlockSize),
130 int64(*minSize)*1024,