]> Cypherpunks repositories - nncp.git/commitdiff
Combine all excutables
authorSergey Matveev <stargrave@stargrave.org>
Fri, 19 Sep 2025 12:44:12 +0000 (15:44 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 19 Sep 2025 13:50:14 +0000 (16:50 +0300)
34 files changed:
build [moved from bin/build with 68% similarity]
cmd.list [moved from bin/cmd.list with 100% similarity]
doc/building.texi
doc/news.ru.texi
doc/news.texi
install
install-strip
makedist
src/cmd/nncp/ack.go [moved from src/cmd/nncp-ack/main.go with 98% similarity]
src/cmd/nncp/bundle.go [moved from src/cmd/nncp-bundle/main.go with 99% similarity]
src/cmd/nncp/call.go [moved from src/cmd/nncp-call/main.go with 98% similarity]
src/cmd/nncp/caller.go [moved from src/cmd/nncp-caller/main.go with 99% similarity]
src/cmd/nncp/cfgdir.go [moved from src/cmd/nncp-cfgdir/main.go with 96% similarity]
src/cmd/nncp/cfgenc.go [moved from src/cmd/nncp-cfgenc/main.go with 97% similarity]
src/cmd/nncp/cfgmin.go [moved from src/cmd/nncp-cfgmin/main.go with 97% similarity]
src/cmd/nncp/cfgnew.go [moved from src/cmd/nncp-cfgnew/main.go with 99% similarity]
src/cmd/nncp/check.go [moved from src/cmd/nncp-check/main.go with 97% similarity]
src/cmd/nncp/cronexpr.go [moved from src/cmd/nncp-cronexpr/main.go with 96% similarity]
src/cmd/nncp/daemon.go [moved from src/cmd/nncp-daemon/main.go with 99% similarity]
src/cmd/nncp/exec.go [moved from src/cmd/nncp-exec/main.go with 98% similarity]
src/cmd/nncp/file.go [moved from src/cmd/nncp-file/main.go with 97% similarity]
src/cmd/nncp/freq.go [moved from src/cmd/nncp-freq/main.go with 97% similarity]
src/cmd/nncp/hash.go [moved from src/cmd/nncp-hash/main.go with 98% similarity]
src/cmd/nncp/log.go [moved from src/cmd/nncp-log/main.go with 97% similarity]
src/cmd/nncp/main.go [new file with mode: 0644]
src/cmd/nncp/pkt.go [moved from src/cmd/nncp-pkt/main.go with 99% similarity]
src/cmd/nncp/reass.go [moved from src/cmd/nncp-reass/main.go with 96% similarity]
src/cmd/nncp/rm.go [moved from src/cmd/nncp-rm/main.go with 99% similarity]
src/cmd/nncp/stat.go [moved from src/cmd/nncp-stat/main.go with 98% similarity]
src/cmd/nncp/toss.go [moved from src/cmd/nncp-toss/main.go with 98% similarity]
src/cmd/nncp/trns.go [moved from src/cmd/nncp-trns/main.go with 98% similarity]
src/cmd/nncp/xfer.go [moved from src/cmd/nncp-xfer/main.go with 99% similarity]
src/nncp.go
uninstall

diff --git a/bin/build b/build
similarity index 68%
rename from bin/build
rename to build
index 340f1fed54cfaa3208fe790ddb547ec7bab5f48a..bab31e267eb8d69dac4f998c7ad9adb3fbe39beb 100755 (executable)
--- a/bin/build
+++ b/build
@@ -1,6 +1,7 @@
 #!/bin/sh -e
 
-cd "$(realpath -- $(dirname "$0"))"/../src
+cd "$(realpath -- $(dirname "$0"))"/src
+mkdir -p ../bin
 GO=${GO:-go}
 . ../config
 [ -d vendor ] && vendor="-mod=vendor" || :
@@ -9,7 +10,9 @@ GO_LDFLAGS="$GO_LDFLAGS -X $mod.DefaultCfgPath=$CFGPATH"
 GO_LDFLAGS="$GO_LDFLAGS -X $mod.DefaultSendmailPath=$SENDMAIL"
 GO_LDFLAGS="$GO_LDFLAGS -X $mod.DefaultSpoolPath=$SPOOLPATH"
 GO_LDFLAGS="$GO_LDFLAGS -X $mod.DefaultLogPath=$LOGPATH"
-for cmd in `cat ../bin/cmd.list` ; do
-    $GO build $vendor -o ../bin/$cmd $GO_CFLAGS -ldflags "$GO_LDFLAGS" ./cmd/$cmd
-done
+$GO build $vendor -o ../bin/nncp $GO_CFLAGS -ldflags "$GO_LDFLAGS" ./cmd/nncp
 $GO build $vendor -o ../bin/hjson-cli $GO_CFLAGS github.com/hjson/hjson-go/v4/hjson-cli
+cd ../bin
+for cmd in `cat ../cmd.list` ; do
+    ln -fs nncp $cmd
+done
similarity index 100%
rename from bin/cmd.list
rename to cmd.list
index 4da6a676e2541d029e89dc91ff70cbeebaa2096b..78c8945331ccff8c3eef2006e12e02892fa4369f 100644 (file)
@@ -20,7 +20,7 @@ $ [fetch|wget] http://www.nncpgo.org/download/nncp-@value{VERSION}.tar.xz.@{asc,
 $ xz -d <nncp-@value{VERSION}.tar.xz | tar xf -
 $ cd nncp-@value{VERSION}
 [optionally edit config]
-$ bin/build
+$ ./build
 @end example
 
 @pindex info
@@ -77,7 +77,7 @@ either broken or unsupported ones. You can still build NNCP with
 usage at all:
 
 @example
-$ GO_CFLAGS="-tags nofsnotify" bin/build
+$ GO_CFLAGS="-tags nofsnotify" ./build
 @end example
 
 @vindex noyggdrasil
index 4fe9c0246ff2ede17a7feea7bde720a3e789b095..37fae65b0b5bbe503c849cf055b825a471e512c9 100644 (file)
@@ -1,6 +1,16 @@
 @node Новости
 @section Новости
 
+@node Релиз 8.12.0
+@subsection Релиз 8.12.0
+@itemize
+
+@item
+Объединить все исполняемые файлы в одну @command{nncp} команду.
+Вам стоит добавить символические ссылки всех @command{nncp-*} команд на неё.
+
+@end itemize
+
 @node Релиз 8.11.0
 @subsection Релиз 8.11.0
 @itemize
index 279c3a315abdb9ad75c8bf6c980b5ae2f13731e5..2abbb377e5456d43d8e008bd0d92bd07d3985d93 100644 (file)
@@ -4,6 +4,16 @@
 
 See also this page @ref{Новости, in russian}.
 
+@node Release 8_12_0
+@section Release 8.12.0
+@itemize
+
+@item
+Combine all executables in single @command{nncp}.
+You should symlink all @command{nncp-*} commands to it.
+
+@end itemize
+
 @node Release 8_11_0
 @section Release 8.11.0
 @itemize
diff --git a/install b/install
index 0b5c8c31e77fd3c3b4c864b2378f07f685586e82..417725c1c97a11843b9a1dee386b51723510494e 100755 (executable)
--- a/install
+++ b/install
@@ -4,9 +4,10 @@ cd "$(realpath -- $(dirname "$0"))"
 . ./config
 
 mkdir -p "$BINDIR"
-for cmd in `cat bin/cmd.list` ; do
-    cp -f bin/$cmd "$BINDIR"
-    chmod 755 "$BINDIR"/$cmd
+cp -f bin/nncp "$BINDIR"
+chmod 755 "$BINDIR"/nncp
+for cmd in `cat cmd.list` ; do
+    ln -fs nncp "$BINDIR"/$cmd
 done
 
 mkdir -p "$INFODIR"
index 9b7875a0f60595490bc733319a2bc06f23ac7490..a06ffcbf9e5b44aa7de80068bb547f15a774f03f 100755 (executable)
@@ -4,6 +4,4 @@ root="$(realpath -- $(dirname "$0"))"
 cd "$root"
 ./install
 . ./config
-for cmd in `cat bin/cmd.list` ; do
-    strip "$BINDIR"/$cmd
-done
+strip "$BINDIR"/nncp
index 3c84be6c04dd9a72178ac9d01198109d13935c7a..d54e7f5ff0cd71af130b011af785954f76fc6e46 100755 (executable)
--- a/makedist
+++ b/makedist
@@ -109,7 +109,7 @@ redo-cleanup full
 find . -type d -exec chmod 755 {} +
 find . -type f -exec chmod 644 {} +
 find . -type f -name "*.sh" -exec chmod +x {} +
-chmod +x bin/build install install-strip uninstall
+chmod +x build install install-strip uninstall
 
 cd ..
 detpax nncp-"$release" | xz -9v >nncp-"$release".tar.xz
similarity index 98%
rename from src/cmd/nncp-ack/main.go
rename to src/cmd/nncp/ack.go
index b45a8ab34620ddde5bccff37695b171b63465479..f97fbaad178e9cf009de52c794921c93bd29723a 100644 (file)
@@ -31,7 +31,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageACK() {
        fmt.Fprint(os.Stderr, "nncp-ack -- send packet receipt acknowledgement\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] -all\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "Usage: %s [options] -node NODE[,...]\n", os.Args[0])
@@ -40,7 +40,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainACK() {
        var (
                cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq),
@@ -60,7 +60,7 @@ func main() {
                warranty    = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageACK
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -105,14 +105,14 @@ func main() {
        }
        if *doAll {
                if len(nodes) != 0 {
-                       usage()
+                       usageACK()
                        os.Exit(1)
                }
                for _, node := range ctx.Neigh {
                        nodes = append(nodes, node)
                }
        } else if len(nodes) == 0 {
-               usage()
+               usageACK()
                os.Exit(1)
        }
 
@@ -123,7 +123,7 @@ func main() {
 
        if *pktRaw != "" {
                if len(nodes) != 1 {
-                       usage()
+                       usageACK()
                        os.Exit(1)
                }
                nncp.ViaOverride(*viaOverride, ctx, nodes[0])
similarity index 99%
rename from src/cmd/nncp-bundle/main.go
rename to src/cmd/nncp/bundle.go
index d7ec8fc3118c59fb99890d2bece9fa17d09ef4b7..841a8311eed917e22746d91bf035a311844ce682 100644 (file)
@@ -35,7 +35,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageBundle() {
        fmt.Fprint(os.Stderr, "nncp-bundle -- Create/digest stream of NNCP encrypted packets\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] -tx [-delete] NODE [NODE ...] >...\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] -rx -delete [-dryrun] [NODE ...] <...\n", os.Args[0])
@@ -44,7 +44,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainBundle() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw   = flag.String("nice", nncp.NicenessFmt(255), "Minimal required niceness")
@@ -63,7 +63,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageBundle
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 98%
rename from src/cmd/nncp-call/main.go
rename to src/cmd/nncp/call.go
index b7e1dad6472f36f5d72a45fd1b1b3c2bb51e6fe3..f2d17f2b4fdd714fd0f5aa08f9240d4f901c37c9 100644 (file)
@@ -29,14 +29,14 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCall() {
        fmt.Fprint(os.Stderr, "nncp-call -- call TCP daemon\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE[:ADDR] [FORCEADDR]\n", os.Args[0])
        fmt.Fprintln(os.Stderr, "Options:")
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCall() {
        var (
                cfgPath     = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                ucspi       = flag.Bool("ucspi", false, "Is it started as UCSPI-TCP client")
@@ -83,7 +83,7 @@ func main() {
                        "Generate ACK packets")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCall
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -94,7 +94,7 @@ func main() {
                return
        }
        if flag.NArg() < 1 {
-               usage()
+               usageCall()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
similarity index 99%
rename from src/cmd/nncp-caller/main.go
rename to src/cmd/nncp/caller.go
index 029b676710a5d9a10193c764abd6ebcee7c03266..43027a76e4814bd6c3f07ca43ee8864061022d42 100644 (file)
@@ -30,14 +30,14 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCaller() {
        fmt.Fprint(os.Stderr, "nncp-caller -- croned NNCP TCP daemon caller\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] [NODE ...]\n", os.Args[0])
        fmt.Fprintln(os.Stderr, "Options:")
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCaller() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                spoolPath = flag.String("spool", "", "Override path to spool")
@@ -69,7 +69,7 @@ func main() {
                        "Generate ACK packets")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCaller
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 96%
rename from src/cmd/nncp-cfgdir/main.go
rename to src/cmd/nncp/cfgdir.go
index 7df37682d9c58eba0fcfd8f195b02e2bf03f40b5..8e40d2fbbda3801b0a4fe2cec766ee76ae524b56 100644 (file)
@@ -26,14 +26,14 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCfgDir() {
        fmt.Fprint(os.Stderr, "nncp-cfgdir -- Convert configuration file to the directory layout.\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] [-cfg ...] -dump /path/to/dir\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] -load /path/to/dir >cfg.hjson\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCfgDir() {
        var (
                doDump   = flag.Bool("dump", false, "Dump configuration file to the directory")
                doLoad   = flag.Bool("load", false, "Load directory to create configuration file")
@@ -42,7 +42,7 @@ func main() {
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCfgDir
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -54,7 +54,7 @@ func main() {
        }
 
        if (!*doDump && !*doLoad) || flag.NArg() != 1 {
-               usage()
+               usageCfgDir()
                os.Exit(1)
        }
 
similarity index 97%
rename from src/cmd/nncp-cfgenc/main.go
rename to src/cmd/nncp/cfgenc.go
index 122f90d45ce8f13efa10e4f6976cc5ae35c0e775..4fed530c295e57ee0301dafe8b63e079e11b2ca7 100644 (file)
@@ -30,7 +30,7 @@ import (
        "golang.org/x/term"
 )
 
-func usage() {
+func usageCfgEnc() {
        fmt.Fprint(os.Stderr, "nncp-cfgenc -- encrypt/decrypt configuration file\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] cfg.hjson >cfg.hjson.eblob\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] -d cfg.hjson.eblob >cfg.hjson\n", os.Args[0])
@@ -39,7 +39,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCfgEnc() {
        var (
                decrypt  = flag.Bool("d", false, "Decrypt the file")
                dump     = flag.Bool("dump", false, "Print human-readable eblob information")
@@ -50,7 +50,7 @@ func main() {
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCfgEnc
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -62,7 +62,7 @@ func main() {
        }
 
        if flag.NArg() != 1 {
-               usage()
+               usageCfgEnc()
                os.Exit(1)
        }
 
similarity index 97%
rename from src/cmd/nncp-cfgmin/main.go
rename to src/cmd/nncp/cfgmin.go
index 862456eabed5907c00817c4fc584f10c828a8d35..00bfa3354038ffc9a67ea53fd3ea658f234577ce 100644 (file)
@@ -26,20 +26,20 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCfgMin() {
        fmt.Fprint(os.Stderr, "nncp-cfgmin -- print stripped configuration\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCfgMin() {
        var (
                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")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCfgMin
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 99%
rename from src/cmd/nncp-cfgnew/main.go
rename to src/cmd/nncp/cfgnew.go
index 7e4d73a99117a0823c852a65db0d7c6e09b2a5b7..13cb63f01b022187b511ab59cd3fc6e679413e9e 100644 (file)
@@ -33,12 +33,12 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCfgNew() {
        fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:")
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCfgNew() {
        var (
                areaName   = flag.String("area", "", "Generate area's keypairs")
                yggdrasil  = flag.Bool("yggdrasil", false, "Generate Yggdrasil keypair")
@@ -47,7 +47,7 @@ func main() {
                warranty   = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCfgNew
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 97%
rename from src/cmd/nncp-check/main.go
rename to src/cmd/nncp/check.go
index 0e891359aacd4801fd8031387bab487cab599f5b..dcef5c63319a2245166bad9e66070ecf8b760b76 100644 (file)
@@ -27,13 +27,13 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCheck() {
        fmt.Fprint(os.Stderr, "nncp-check -- verify Rx/Tx packets checksum\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [-nock] [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCheck() {
        var (
                nock      = flag.Bool("nock", false, "Process .nock files")
                cycle     = flag.Uint("cycle", 0, "Repeat check after N seconds in infinite loop")
@@ -49,7 +49,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCheck
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 96%
rename from src/cmd/nncp-cronexpr/main.go
rename to src/cmd/nncp/cronexpr.go
index 00d5661822913227c7ed6026e9d90d2b201a978d..3942ee6c357253aa77ae266dcd50fab1b32de27d 100644 (file)
@@ -28,20 +28,20 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageCronExpr() {
        fmt.Fprint(os.Stderr, "nncp-cronexpr -- cron expression checker\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [-num XXX] CRON-EXPRESSION\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainCronExpr() {
        var (
                num      = flag.Uint("num", 10, "Number of future entries to print")
                version  = flag.Bool("version", false, "Print version information")
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageCronExpr
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 99%
rename from src/cmd/nncp-daemon/main.go
rename to src/cmd/nncp/daemon.go
index ab58bff795ca325aad3914739cf77a39f1bf9f4d..39c08b55e34416bff358ec167487d92a8006da7b 100644 (file)
@@ -33,7 +33,7 @@ import (
        "golang.org/x/net/netutil"
 )
 
-func usage() {
+func usageDaemon() {
        fmt.Fprint(os.Stderr, "nncp-daemon -- TCP daemon\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
@@ -128,7 +128,7 @@ func startMCDTx(ctx *nncp.Ctx, port int, zeroInterval bool) error {
        return nil
 }
 
-func main() {
+func mainDaemon() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw   = flag.String("nice", nncp.NicenessFmt(255), "Minimal required niceness")
@@ -169,7 +169,7 @@ func main() {
                        "Generate ACK packets")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageDaemon
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 98%
rename from src/cmd/nncp-exec/main.go
rename to src/cmd/nncp/exec.go
index 70963376e7c70b03b7db55d46571155dbc1fc661..c2649178ac93933082db615000fc737d41b1b797 100644 (file)
@@ -27,7 +27,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageExec() {
        fmt.Fprint(os.Stderr, "nncp-exec -- send execution command\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE HANDLE [ARG0 ARG1 ...]\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] %s:AREA HANDLE [ARG0 ARG1 ...]\nOptions:\n",
@@ -35,7 +35,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainExec() {
        var (
                noCompress = flag.Bool("nocompress", false, "Do not compress input data")
                cfgPath    = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
@@ -56,7 +56,7 @@ func main() {
                warranty    = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageExec
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -67,7 +67,7 @@ func main() {
                return
        }
        if flag.NArg() < 2 {
-               usage()
+               usageExec()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
similarity index 97%
rename from src/cmd/nncp-file/main.go
rename to src/cmd/nncp/file.go
index 4b691e9aacc426367168c28bc49516105fd90720..876e36ee4a604f25fe5543e474e6d21fa8fdba1f 100644 (file)
@@ -26,7 +26,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageFile() {
        fmt.Fprint(os.Stderr, "nncp-file -- send file\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] SRC NODE:[DST]\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] SRC %s:AREA:[DST]\nOptions:\n",
@@ -41,7 +41,7 @@ options by default. You can forcefully turn them off by specifying 0 value.
 `)
 }
 
-func main() {
+func mainFile() {
        var (
                cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile),
@@ -60,7 +60,7 @@ func main() {
                warranty     = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageFile
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -71,7 +71,7 @@ func main() {
                return
        }
        if flag.NArg() != 2 {
-               usage()
+               usageFile()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
@@ -97,14 +97,14 @@ func main() {
 
        splitted := strings.Split(flag.Arg(1), ":")
        if len(splitted) < 2 {
-               usage()
+               usageFile()
                os.Exit(1)
        }
        var areaId *nncp.AreaId
        var node *nncp.Node
        if splitted[0] == nncp.AreaDir {
                if len(splitted) < 3 {
-                       usage()
+                       usageFile()
                        os.Exit(1)
                }
                areaId = ctx.AreaName2Id[splitted[1]]
similarity index 97%
rename from src/cmd/nncp-freq/main.go
rename to src/cmd/nncp/freq.go
index f2ef467532a987877bd689169051fc4d6c884af3..21fcb7c714d3f274021bd8400703314b69c99750 100644 (file)
@@ -27,13 +27,13 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageFreq() {
        fmt.Fprint(os.Stderr, "nncp-freq -- send file request\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE:SRC [DST]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainFreq() {
        var (
                cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq),
@@ -52,7 +52,7 @@ func main() {
                warranty    = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageFreq
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -63,7 +63,7 @@ func main() {
                return
        }
        if flag.NArg() == 0 {
-               usage()
+               usageFreq()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
@@ -93,7 +93,7 @@ func main() {
 
        splitted := strings.SplitN(flag.Arg(0), ":", 2)
        if len(splitted) != 2 {
-               usage()
+               usageFreq()
                os.Exit(1)
        }
        node, err := ctx.FindNode(splitted[0])
similarity index 98%
rename from src/cmd/nncp-hash/main.go
rename to src/cmd/nncp/hash.go
index b2c57a530de5bef2e7769c554aa2ee04511bb9c9..a166461b536510a511470cca3a9a93e410c11a72 100644 (file)
@@ -29,13 +29,13 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageHash() {
        fmt.Fprint(os.Stderr, "nncp-hash -- calculate MTH hash of the file\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [-file ...] [-seek X] [-debug] [-progress] [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainHash() {
        var (
                fn        = flag.String("file", "", "Read the file instead of stdin")
                seek      = flag.Uint64("seek", 0, "Seek the file, hash, rewind, hash remaining")
@@ -46,7 +46,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageHash
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 97%
rename from src/cmd/nncp-log/main.go
rename to src/cmd/nncp/log.go
index 3ec6feaa483b2f9cab7eb1a346bf32e87a863beb..77f1c94df7f5ebb988524a008343a2b05949b89a 100644 (file)
@@ -27,13 +27,13 @@ import (
        "go.cypherpunks.su/recfile/v3"
 )
 
-func usage() {
+func usageLog() {
        fmt.Fprint(os.Stderr, "nncp-log -- read logs\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainLog() {
        var (
                cfgPath  = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                logPath  = flag.String("log", "", "Override path to logfile")
@@ -42,7 +42,7 @@ func main() {
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageLog
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
diff --git a/src/cmd/nncp/main.go b/src/cmd/nncp/main.go
new file mode 100644 (file)
index 0000000..3970de1
--- /dev/null
@@ -0,0 +1,101 @@
+package main
+
+import (
+       "flag"
+       "fmt"
+       "os"
+       "path"
+
+       "go.cypherpunks.su/nncp/v8"
+)
+
+const (
+       CmdNameACK      = "nncp-ack"
+       CmdNameBundle   = "nncp-bundle"
+       CmdNameCall     = "nncp-call"
+       CmdNameCaller   = "nncp-caller"
+       CmdNameCfgDir   = "nncp-cfgdir"
+       CmdNameCfgEnc   = "nncp-cfgenc"
+       CmdNameCfgMin   = "nncp-cfgmin"
+       CmdNameCfgNew   = "nncp-cfgnew"
+       CmdNameCheck    = "nncp-check"
+       CmdNameCronExpr = "nncp-cronexpr"
+       CmdNameDaemon   = "nncp-daemon"
+       CmdNameExec     = "nncp-exec"
+       CmdNameFile     = "nncp-file"
+       CmdNameFreq     = "nncp-freq"
+       CmdNameHash     = "nncp-hash"
+       CmdNameLog      = "nncp-log"
+       CmdNameMain     = "nncp-main"
+       CmdNamePkt      = "nncp-pkt"
+       CmdNameReass    = "nncp-reass"
+       CmdNameRm       = "nncp-rm"
+       CmdNameStat     = "nncp-stat"
+       CmdNameToss     = "nncp-toss"
+       CmdNameTrns     = "nncp-trns"
+       CmdNameXfer     = "nncp-xfer"
+)
+
+func main() {
+       cmdName := path.Base(os.Args[0])
+       switch cmdName {
+       case CmdNameACK:
+               mainACK()
+       case CmdNameBundle:
+               mainBundle()
+       case CmdNameCall:
+               mainCall()
+       case CmdNameCaller:
+               mainCaller()
+       case CmdNameCfgDir:
+               mainCfgDir()
+       case CmdNameCfgEnc:
+               mainCfgEnc()
+       case CmdNameCfgMin:
+               mainCfgMin()
+       case CmdNameCfgNew:
+               mainCfgNew()
+       case CmdNameCheck:
+               mainCheck()
+       case CmdNameCronExpr:
+               mainCronExpr()
+       case CmdNameDaemon:
+               mainDaemon()
+       case CmdNameExec:
+               mainExec()
+       case CmdNameFile:
+               mainFile()
+       case CmdNameFreq:
+               mainFreq()
+       case CmdNameHash:
+               mainHash()
+       case CmdNameLog:
+               mainLog()
+       case CmdNamePkt:
+               mainPkt()
+       case CmdNameReass:
+               mainReass()
+       case CmdNameRm:
+               mainRm()
+       case CmdNameStat:
+               mainStat()
+       case CmdNameToss:
+               mainToss()
+       case CmdNameTrns:
+               mainTrns()
+       case CmdNameXfer:
+               mainXfer()
+       default:
+               version := flag.Bool("version", false, "Print version information")
+               warranty := flag.Bool("warranty", false, "Print warranty information")
+               flag.Parse()
+               if *warranty {
+                       fmt.Println(nncp.Warranty)
+                       return
+               }
+               if *version {
+                       fmt.Println(nncp.VersionGet())
+                       return
+               }
+       }
+}
similarity index 99%
rename from src/cmd/nncp-pkt/main.go
rename to src/cmd/nncp/pkt.go
index 7a51fd1076d0eb398067f58a76b8598746af81bc..70ace986aee9284fe771ee5cd017540ffca95d88 100644 (file)
@@ -30,7 +30,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usagePkt() {
        fmt.Fprint(os.Stderr, "nncp-pkt -- parse raw packet\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
@@ -167,7 +167,7 @@ Recipient: %s (%s)
        }
 }
 
-func main() {
+func mainPkt() {
        var (
                overheads  = flag.Bool("overheads", false, "Print packet overheads")
                dump       = flag.Bool("dump", false, "Write decrypted/parsed payload to stdout")
@@ -177,7 +177,7 @@ func main() {
                warranty   = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usagePkt
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 96%
rename from src/cmd/nncp-reass/main.go
rename to src/cmd/nncp/reass.go
index e1271cb5ddd805d4e69a64c9587053977e379aea..b61113d528bbe94730ef632440837d233dd82dc5 100644 (file)
@@ -37,7 +37,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageReass() {
        fmt.Fprint(os.Stderr, "nncp-reass -- reassemble chunked files\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] [FILE.nncp.meta]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
@@ -47,7 +47,7 @@ but at least one of them must be specified.
 `)
 }
 
-func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bool {
+func reassProcess(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bool {
        fd, err := os.Open(path)
        if err != nil {
                log.Fatalln("Can not open file:", err)
@@ -313,7 +313,7 @@ func findMetas(ctx *nncp.Ctx, dirPath string) []string {
        return metaPaths
 }
 
-func main() {
+func mainReass() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                allNodes  = flag.Bool("all", false, "Process all found chunked files for all nodes")
@@ -332,7 +332,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageReass
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -365,22 +365,22 @@ func main() {
        }
 
        if !(*allNodes || nodeOnly != nil || flag.NArg() > 0) {
-               usage()
+               usageReass()
                os.Exit(1)
        }
        if flag.NArg() > 0 && (*allNodes || nodeOnly != nil) {
-               usage()
+               usageReass()
                os.Exit(1)
        }
        if *allNodes && nodeOnly != nil {
-               usage()
+               usageReass()
                os.Exit(1)
        }
 
        ctx.Umask()
 
        if flag.NArg() > 0 {
-               if process(ctx, flag.Arg(0), *keep, *dryRun, *stdout, *dumpMeta) {
+               if reassProcess(ctx, flag.Arg(0), *keep, *dryRun, *stdout, *dumpMeta) {
                        return
                }
                os.Exit(1)
@@ -397,7 +397,7 @@ func main() {
                                if _, seen := seenMetaPaths[metaPath]; seen {
                                        continue
                                }
-                               if !process(ctx, metaPath, *keep, *dryRun, false, false) {
+                               if !reassProcess(ctx, metaPath, *keep, *dryRun, false, false) {
                                        hasErrors = true
                                }
                                seenMetaPaths[metaPath] = struct{}{}
@@ -408,7 +408,7 @@ func main() {
                        log.Fatalln("Specified -node does not allow incoming")
                }
                for _, metaPath := range findMetas(ctx, *nodeOnly.Incoming) {
-                       if !process(ctx, metaPath, *keep, *dryRun, false, false) {
+                       if !reassProcess(ctx, metaPath, *keep, *dryRun, false, false) {
                                hasErrors = true
                        }
                }
similarity index 99%
rename from src/cmd/nncp-rm/main.go
rename to src/cmd/nncp/rm.go
index b5802367558b9bc8c74750452ce705e5f5a752da..d087285be9a1502a52aea07e46e3e7a4e965ab9f 100644 (file)
@@ -33,7 +33,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageRm() {
        fmt.Fprint(os.Stderr, "nncp-rm -- remove packet\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] [-older X] -tmp\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       %s [options] -lock\n", os.Args[0])
@@ -49,7 +49,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainRm() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                doTmp     = flag.Bool("tmp", false, "Remove temporary files")
@@ -74,7 +74,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageRm
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -189,7 +189,7 @@ func main() {
        var nodeId *nncp.NodeId
        if *nodeRaw == "" {
                if !*doAll {
-                       usage()
+                       usageRm()
                        os.Exit(1)
                }
        } else {
similarity index 98%
rename from src/cmd/nncp-stat/main.go
rename to src/cmd/nncp/stat.go
index c3f4ea17f3a617297c048afb23f8e0a7a98bc0d8..fc62d7aa2bce47593d071365a3efd60d8afa044a 100644 (file)
@@ -27,7 +27,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageStat() {
        fmt.Fprint(os.Stderr, "nncp-stat -- show queued Rx/Tx stats\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] [-pkt] [-node NODE]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
@@ -43,7 +43,7 @@ func jobPrint(xx nncp.TRxTx, job nncp.Job, suffix string) {
        )
 }
 
-func main() {
+func mainStat() {
        var (
                showPkt   = flag.Bool("pkt", false, "Show packets listing")
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
@@ -54,7 +54,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageStat
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 98%
rename from src/cmd/nncp-toss/main.go
rename to src/cmd/nncp/toss.go
index b5eb4972fa9ca9035e74841348b1448d4d6d5b9a..d3ec8c0f7ed73a3efb19268df1af1e4ecc94fe98 100644 (file)
@@ -27,13 +27,13 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageToss() {
        fmt.Fprint(os.Stderr, "nncp-toss -- process inbound packets\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainToss() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                nodeRaw   = flag.String("node", "", "Process only that node")
@@ -58,7 +58,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageToss
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
similarity index 98%
rename from src/cmd/nncp-trns/main.go
rename to src/cmd/nncp/trns.go
index e879d4691f87898d59282a852fae793084519ce1..5d11ab86e81efae7316a961e8d6fbe0675ef593e 100644 (file)
@@ -28,7 +28,7 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageTrns() {
        fmt.Fprint(os.Stderr, "nncp-trns -- transit existing encrypted packet\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] -via NODEx[,...] NODE:PKT\n", os.Args[0])
        fmt.Fprintf(os.Stderr, "       (to transit SPOOL/NODE/tx/PKT)\n")
@@ -37,7 +37,7 @@ func usage() {
        flag.PrintDefaults()
 }
 
-func main() {
+func mainTrns() {
        var (
                cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile),
@@ -53,7 +53,7 @@ func main() {
                warranty    = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageTrns
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -64,7 +64,7 @@ func main() {
                return
        }
        if flag.NArg() != 1 {
-               usage()
+               usageTrns()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
similarity index 99%
rename from src/cmd/nncp-xfer/main.go
rename to src/cmd/nncp/xfer.go
index aed001eb8e08a1eda3fd1f0f7884d84c22919885..46bb39798bd9ba3ccd09559864dee2ca48e52aee 100644 (file)
@@ -31,13 +31,13 @@ import (
        "go.cypherpunks.su/nncp/v8"
 )
 
-func usage() {
+func usageXfer() {
        fmt.Fprint(os.Stderr, "nncp-xfer -- copy inbound and outbounds packets\n\n")
        fmt.Fprintf(os.Stderr, "Usage: %s [options] DIR\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
-func main() {
+func mainXfer() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                nodeRaw   = flag.String("node", "", "Process only that node")
@@ -56,7 +56,7 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
        log.SetFlags(log.Lshortfile)
-       flag.Usage = usage
+       flag.Usage = usageXfer
        flag.Parse()
        if *warranty {
                fmt.Println(nncp.Warranty)
@@ -67,7 +67,7 @@ func main() {
                return
        }
        if flag.NArg() != 1 {
-               usage()
+               usageXfer()
                os.Exit(1)
        }
        nice, err := nncp.NicenessParse(*niceRaw)
index c29efbb999af74399fccc10539c85bd3a30a188d..97ca23b8b34b183d4bc503c41adb8f6bcd4f7f6e 100644 (file)
@@ -39,7 +39,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 )
 
 var (
-       Version string = "8.11.0"
+       Version string = "8.12.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )
index 68641575cc2556a35f164f5e520b233122fe384c..39fed12d6bf370dcf11a99552e36553001c9481a 100755 (executable)
--- a/uninstall
+++ b/uninstall
@@ -3,6 +3,7 @@
 root="$(realpath -- $(dirname "$0"))"
 . "$root"/config
 cd "$BINDIR"
-rm -f `cat "$root"/bin/cmd.list`
+xargs rm -f <"$root"/cmd.list
+rm -f nncp
 rm -f "$INFODIR"/nncp.info
 rm -fr "$DOCDIR"