]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' v5.6.0
authorSergey Matveev <stargrave@stargrave.org>
Sun, 17 Jan 2021 18:03:15 +0000 (21:03 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 17 Jan 2021 18:03:15 +0000 (21:03 +0300)
24 files changed:
.gitignore
bin/default.do
clean.do
doc/call.texi
doc/cfg.texi
doc/cmds.texi
doc/comparison.texi
doc/download.texi
doc/integration.texi
doc/news.ru.texi
doc/news.texi
gopath.do [deleted file]
makedist.sh
module-name.do [deleted file]
ports/nncp/Makefile
src/call.go
src/cfg.go
src/cmd/nncp-call/main.go
src/cmd/nncp-caller/main.go
src/cmd/nncp-cfgnew/main.go
src/cmd/nncp-daemon/main.go
src/nncp.go
src/toss.go
test.do

index b7ee15f622947caa97a0128dc3439d819ad1fa5e..fd85e304082171b555e68c4a0ff99cf1004d9e2b 100644 (file)
@@ -1,3 +1 @@
-gopath
-module-name
 VERSION
index bda5482d13c257e5af603ebd17e3d37652d12d9b..352b014bd5aed5b9eca8d6e6f7bb315639ef43d5 100644 (file)
@@ -1,12 +1,10 @@
-cd ..
-redo-ifchange config gopath module-name
-. ./config
-. ./gopath
-mod=`cat module-name`
-redo-ifchange src/*.go src/cmd/$1/*.go
+cd ../src
+redo-ifchange ../config *.go cmd/$1/*.go
+. ../config
+GO=${GO:-go}
+mod=`$GO list -m`
 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"
-cd src
-GOPATH=$GOPATH ${GO:-go} build -o ../bin/$3 -ldflags "$GO_LDFLAGS" $mod/cmd/$1
+$GO build -o ../bin/$3 -ldflags "$GO_LDFLAGS" ./cmd/$1
index 8ccd8cfe6d88bf82a22a4ebbfa1e04ec3a4e455b..ebefc3e5a33fc23bde517ee8b5a74c8fc7b50559 100644 (file)
--- a/clean.do
+++ b/clean.do
@@ -1,2 +1,2 @@
 redo bin/clean
-rm -f gopath module-name VERSION
+rm -f VERSION
index 447b764615af969e24ec8917fbbc50b8f5f00c28..ac24b2a98764ee79838b36561fb46d44791bcf2c 100644 (file)
@@ -11,6 +11,9 @@ calls: [
         cron: "*/1 * * * MON-FRI"
         onlinedeadline: 3600
         nice: PRIORITY+10
+
+        autotoss: true
+        autotoss-doseen: true
     },
     {
         cron: "30 * * * SAT,SUN"
@@ -185,4 +188,9 @@ configuration option when calling.
 Optional. Override @ref{CfgMaxOnlineTime, @emph{maxonlinetime}}
 configuration option when calling.
 
+@item autotoss, -doseen, -nofile, -nofreq, -noexec, -notrns
+Optionally enable auto tossing: run tosser on node's spool every second
+during the call. You can control either are @file{.seen} files must be
+created, or skip any kind of packet processing.
+
 @end table
index f918385be8ed9e95555d3e8da69a5ab4eef0b2d5..3e0b882b0582f7c16792b9ed057e18d1b4c46d07 100644 (file)
@@ -142,7 +142,7 @@ Dictionary consisting of handles and corresponding command line
 arguments. In example above there are @command{sendmail} handles,
 @command{warcer}, @command{wgeter} and @command{flag} one. Remote node
 can queue some handle execution with providing additional command line
-arguments and the body fed to command's stdin.
+arguments and the body fed to command's @code{stdin}.
 
 @verb{|sendmail: ["/usr/sbin/sendmail", "-t"]|} handle, when called by
 @verb{|echo hello world | nncp-exec OURNODE sendmail ARG0 ARG1 ARG2|}
@@ -190,9 +190,9 @@ human-readable name of the address. For direct TCP connections use
 @verb{|host:port|} format, pointing to @ref{nncp-daemon}'s listening
 instance. Also you can pipe connection through the external command
 using @verb{#|some command#} format. @code{/bin/sh -c "some command"}
-will start and its stdin/stdout used as a connection. May be omitted if
-either no direct connection exists, or @ref{nncp-call} is used with
-forced address specifying.
+will start and its @code{stdin}/@code{stdout} used as a connection. May
+be omitted if either no direct connection exists, or @ref{nncp-call} is
+used with forced address specifying.
 
 @anchor{CfgXxRate}
 @item rxrate/txrate
index 575807af676e230feda3fd1de28c02383f9088d3..ae7bd52824db6b5346220341612a1bfa223719ee 100644 (file)
@@ -53,10 +53,10 @@ $ nncp-bundle [options] -rx [-check] [-dryrun] [NODE ...] < ...
 
 With @option{-tx} option, this command creates @ref{Bundles, bundle} of
 @ref{Encrypted, encrypted packets} from the spool directory and writes
-it to stdout.
+it to @code{stdout}.
 
-With @option{-rx} option, this command takes bundle from stdin and
-copies all found packets for our node to the spool directory. Pay
+With @option{-rx} option, this command takes bundle from @code{stdin}
+and copies all found packets for our node to the spool directory. Pay
 attention that @strong{no} integrity checking is done by default. Modern
 tape drives could easily provide too much throughput your CPU won't be
 able to verify on the fly. So if you won't @ref{nncp-toss, toss}
@@ -73,7 +73,7 @@ When packets are sent through the stream, they are still kept in the
 spool directory, because there is no assurance that they are transferred
 to the media (media (CD-ROM, tape drive, raw hard drive) can end). If
 you want to forcefully delete them (after they are successfully flushed
-to stdout) anyway, use @option{-delete} option.
+to @code{stdout}) anyway, use @option{-delete} option.
 
 But you can verify produced stream after, by digesting it by yourself
 with @option{-rx} and @option{-delete} options -- in that mode, stream
@@ -139,8 +139,8 @@ file is renamed from @file{.part} one and when you rerun
 @command{nncp-call} again, remote node will receive completion
 notification.
 
-@option{-autotoss} options runs tosser on node's spool after call
-is finished. All @option{-autotoss-*} options is the same as in
+@option{-autotoss} option runs tosser on node's spool every second
+during the call. All @option{-autotoss-*} options is the same as in
 @ref{nncp-toss} command.
 
 @node nncp-caller
@@ -219,8 +219,8 @@ $ nncp-cfgnew [options] [-nocomments] > new.hjson
 @end example
 
 Generate new node configuration: private keys, example configuration
-file and print it to stdout. You must use this command when you setup
-the new node. @option{-nocomments} will create configuration file
+file and print it to @code{stdout}. You must use this command when you
+setup the new node. @option{-nocomments} will create configuration file
 without descriptive huge comments -- useful for advanced users.
 
 Pay attention that private keys generation consumes an entropy from your
@@ -255,16 +255,17 @@ can handle. @option{-bind} option specifies @option{addr:port} it must
 bind to and listen.
 
 It could be run as @command{inetd} service, by specifying
-@option{-inetd} option. Pay attention that because it uses stdin/stdout,
-it can not effectively work with IO timeouts and connection closing can
-propagate up to 5 minutes in practice. Example inetd-entry:
+@option{-inetd} option. Pay attention that because it uses
+@code{stdin}/@code{stdout}, it can not effectively work with IO timeouts
+and connection closing can propagate up to 5 minutes in practice.
+Example inetd-entry:
 
 @verbatim
 uucp   stream  tcp6    nowait  nncpuser        /usr/local/bin/nncp-daemon      nncp-daemon -quiet -inetd
 @end verbatim
 
-@option{-autotoss} options runs tosser on node's spool after call
-is finished. All @option{-autotoss-*} options is the same as in
+@option{-autotoss} option runs tosser on node's spool every second
+during the call. All @option{-autotoss-*} options is the same as in
 @ref{nncp-toss} command.
 
 @node nncp-exec
@@ -275,11 +276,15 @@ $ nncp-exec [options] [-use-tmp] [-nocompress] NODE HANDLE [ARG0 ARG1 ...]
 @end example
 
 Send execution command to @option{NODE} for specified @option{HANDLE}.
-Body is read from stdin (either into memory, or into encrypted temporary
-file if @option{-use-tmp} is specified) and compressed (unless
+Body is read from @code{stdin} into memory and compressed (unless
 @option{-nocompress} is specified). After receiving, remote side will
 execute specified @ref{CfgExec, handle} command with @option{ARG*}
-appended and decompressed body fed to command's stdin.
+appended and decompressed body fed to command's @code{stdin}.
+
+If @option{-use-tmp} option is specified, then @code{stdin} data is read
+into temporary file first, requiring twice more disk space, but no
+memory requirements. @ref{StdinTmpFile, Same temporary file} rules
+applies as with @ref{nncp-file, nncp-file -} command.
 
 For example, if remote side has following configuration file for your
 node:
@@ -325,16 +330,19 @@ This command queues file in @ref{Spool, spool} directory immediately
 (through the temporary file of course) -- so pay attention that sending
 2 GiB file will create 2 GiB outbound encrypted packet.
 
+@anchor{StdinTmpFile}
 If @file{SRC} equals to @file{-}, then create an encrypted temporary
-file and copy everything taken from stdin to it and use for outbound
+file and copy everything taken from @code{stdin} to it and use for outbound
 packet creation. Pay attention that if you want to send 1 GiB of data
-taken from stdin, then you have to have more than 2 GiB of disk space
+taken from @code{stdin}, then you have to have more than 2 GiB of disk space
 for that temporary file and resulting encrypted packet. You can control
-where temporary file will be stored using @env{TMPDIR} environment
+temporary file location directory with @env{TMPDIR} environment
 variable. Encryption is performed in AEAD mode with
 @url{https://cr.yp.to/chacha.html, ChaCha20}-@url{https://en.wikipedia.org/wiki/Poly1305, Poly1305}
 algorithms. Data is splitted on 128 KiB blocks. Each block is encrypted
-with increasing nonce counter.
+with increasing nonce counter. File is deletes immediately after
+creation, so even if program crashes -- disk space will be reclaimed, no
+need in cleaning it up later.
 
 If @file{SRC} points to directory, then
 @url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01, pax archive}
@@ -402,7 +410,7 @@ Sender: 2WHBV3TPZHDOZGUJEH563ZEK7M33J4UESRFO4PDKWD5KZNPROABQ
 @end example
 
 If you specify @option{-dump} option and provide an @ref{Encrypted,
-encrypted} packet, then it will verify and decrypt it to stdout.
+encrypted} packet, then it will verify and decrypt it to @code{stdout}.
 Encrypted packets contain @ref{Plain, plain} ones, that also can be fed
 to @command{nncp-pkt}:
 
@@ -461,10 +469,10 @@ If @option{-keep} option is specified, then no
 @file{.nncp.meta}/@file{.nncp.chunkXXX} files are deleted during
 reassembly process.
 
-@option{-stdout} option outputs reassembled file to stdout, instead of
-saving to temporary file with renaming after. This could be useful for
-reassembling on separate filesystem to lower fragmentation effect,
-and/or separate storage device for higher performance.
+@option{-stdout} option outputs reassembled file to @code{stdout},
+instead of saving to temporary file with renaming after. This could be
+useful for reassembling on separate filesystem to lower fragmentation
+effect, and/or separate storage device for higher performance.
 
 @option{-dump} option prints meta-file contents in human-friendly form.
 It is useful mainly for debugging purposes. For example:
index 1cb366448c26a8063b5dc8184eab707234f842f2..7bf4e53d84401651ab246602fa076475deeff6cc 100644 (file)
@@ -120,7 +120,7 @@ comparable commands of UUCP and NNCP, just for the interest:
 @item Receive connection (pipe, daemon, etc)
     @tab @command{uucico} (@option{-l} or similar)
     @tab @command{nncp-daemon}
-@item Request remote execution, stdin piped in
+@item Request remote execution, @code{stdin} piped in
     @tab @command{uux}
     @tab @command{nncp-exec}
 @item Copy file to remote machine
index 7c4cd67ee1b809bfb17a563122f5e9bc3261b1c7..e372436f2ec96cea81b79dba9e5685c5c078b48b 100644 (file)
@@ -25,6 +25,10 @@ Tarballs include all necessary required libraries:
 @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {link sign} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 @headitem Version @tab Date @tab Size @tab Tarball @tab SHA256 checksum
 
+@item @ref{Release 5.5.1, 5.5.1} @tab 2021-01-11 @tab 1165 KiB
+@tab @url{download/nncp-5.5.1.tar.xz, link} @url{download/nncp-5.5.1.tar.xz.sig, sign}
+@tab @code{E7DEED7A D3BA696C F64359C0 DC0A93AD 109950C5 6660D028 5FD7BB57 120C9CF7}
+
 @item @ref{Release 5.5.0, 5.5.0} @tab 2021-01-07 @tab 1161 KiB
 @tab @url{download/nncp-5.5.0.tar.xz, link} @url{download/nncp-5.5.0.tar.xz.sig, sign}
 @tab @code{EF0CBEE1 520BE97D A210794C 172BF444 E6F75DB2 84F5BD05 66919193 326AED77}
index c9b3a71e0f9f95475a223d31d3374dad5399be00..3359a3a72b25534eaf7e419a169128928433d908 100644 (file)
@@ -243,7 +243,7 @@ exec: @{
 @}
 @end example
 
-The -bS option is what tells Exim to receive BSMTP on stdin.
+The -bS option is what tells Exim to receive BSMTP on @code{stdin}.
 
 Now, you need to tell Exim that nncp is a trusted user (able to set From
 headers arbitrarily). Assuming you are running NNCP as the nncp user,
index c4ce41d4a408ead9657f51239e8142b8c15aec68..97c108c2a2d05d78f47ffe616000feaa926cc26d 100644 (file)
@@ -1,6 +1,28 @@
 @node Новости
 @section Новости
 
+@node Релиз 5.6.0
+@subsection Релиз 5.6.0
+@itemize
+
+@item
+@option{-autotoss*} опции запускают tosser не после завершения вызова, а
+во время него ежесекундно.
+
+@item
+В @option{calls} секции конфигурации появились опции
+@option{autotoss}, @option{autotoss-doseen},
+@option{autotoss-nofile}, @option{autotoss-nofreq},
+@option{autotoss-noexec}, @option{autotoss-notrns}.
+Вы можете настраивать опции автоматического tosser для каждого вызова.
+
+@item
+Использовать vendoring вместо переопределения @env{GOPATH} во время
+установки tarball, так как текущая минимальная версия Go это 1.12,
+поддерживающая модули.
+
+@end itemize
+
 @node Релиз 5.5.1
 @subsection Релиз 5.5.1
 @itemize
@@ -446,9 +468,10 @@ HKDF-BLAKE2b-256 KDF алгоритм заменён на BLAKE2Xb XOF. Ещё 
 
 @item
 @command{nncp-bundle} команда может создавать потоки зашифрованных
-пакетов или потреблять их. Это полезно когда речь идёт о stdin/stdout
-методах передачи (например запись на CD-ROM без создания промежуточного
-подготовленного ISO образа или работа с ленточными накопителями).
+пакетов или потреблять их. Это полезно когда речь идёт о
+@code{stdin}/@code{stdout} методах передачи (например запись на CD-ROM
+без создания промежуточного подготовленного ISO образа или работа с
+ленточными накопителями).
 
 @item
 @command{nncp-toss} команда может создавать @file{.seen} файлы,
index a24704fe104f9fbe27eefe4f30d56a3b46dbe8c5..83b6f960419631b56e5ab2977ce1f3816819317f 100644 (file)
@@ -3,6 +3,28 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 5.6.0
+@section Release 5.6.0
+@itemize
+
+@item
+@option{-autotoss*} option runs tosser not after the call, but every
+second while it is active.
+
+@item
+@option{autotoss}, @option{autotoss-doseen},
+@option{autotoss-nofile}, @option{autotoss-nofreq},
+@option{autotoss-noexec}, @option{autotoss-notrns} options available in
+@option{calls} configuration section. You can configure per-call
+automatic tosser options.
+
+@item
+Use vendoring, instead of @env{GOPATH} overriding during tarball
+installation, because current minimal Go's version is 1.12 and it
+supports modules.
+
+@end itemize
+
 @node Release 5.5.1
 @section Release 5.5.1
 @itemize
@@ -435,9 +457,10 @@ are not supported.
 
 @item
 @command{nncp-bundle} command can either create stream of encrypted
-packets, or digest it. It is useful when dealing with stdin/stdout based
-transmission methods (like writing to CD-ROM without intermediate
-prepared ISO image and working with tape drives).
+packets, or digest it. It is useful when dealing with
+@code{stdin}/@code{stdout} based transmission methods (like writing to
+CD-ROM without intermediate prepared ISO image and working with tape
+drives).
 
 @item
 @command{nncp-toss} is able to create @file{.seen} files preventing
@@ -499,8 +522,8 @@ option for unchunked transfer was not in KiBs, but in bytes.
 @itemize
 
 @item
-Ability to feed @command{nncp-file} from stdin, that uses an encrypted
-temporary file for that.
+Ability to feed @command{nncp-file} from @code{stdin}, that uses an
+encrypted temporary file for that.
 
 @item
 Chunked files transmission appeared with corresponding
diff --git a/gopath.do b/gopath.do
deleted file mode 100644 (file)
index 141e16d..0000000
--- a/gopath.do
+++ /dev/null
@@ -1 +0,0 @@
-echo GOPATH=${GOPATH:-`pwd`}
index e62491ff0df2426f7037e2a3c0b9dc4fed832375..8537c9e24bceab1ccd61e900d9e79d2393f9e0fa 100755 (executable)
@@ -8,109 +8,26 @@ release=$1
 git clone . $tmp/nncp-$release
 cd $tmp/nncp-$release
 git checkout v$release
-redo module-name VERSION
-rm -r .redo
-mod_name=`cat module-name`
-rm -fr .git
-
-mv src src.orig
-mkdir -p src/$mod_name
-mv src.orig/* src/$mod_name
-rmdir src.orig
-
-mods="
-github.com/davecgh/go-xdr
-github.com/dustin/go-humanize
-github.com/flynn/noise
-github.com/gorhill/cronexpr
-github.com/hjson/hjson-go
-github.com/klauspost/compress
-go.cypherpunks.ru/balloon
-golang.org/x/crypto
-golang.org/x/net
-golang.org/x/sys
-golang.org/x/term
-"
-for mod in $mods; do
-    mod_path=$(sed -n "s# // indirect## ; s#^  \($mod\) \(.*\)\$#\1@\2#p" src/$mod_name/go.mod)
-    [ -n "$mod_path" ]
-    mkdir -p src/$mod
-    ( cd $GOPATH/pkg/mod/$mod_path ; tar cf - --exclude ".git*" * ) | tar xfC - src/$mod
-    chmod -R +w src/$mod
-done
-
-cat > $tmp/includes <<EOF
-golang.org/x/crypto/AUTHORS
-golang.org/x/crypto/blake2b
-golang.org/x/crypto/blake2s
-golang.org/x/crypto/chacha20
-golang.org/x/crypto/chacha20poly1305
-golang.org/x/crypto/CONTRIBUTORS
-golang.org/x/crypto/curve25519
-golang.org/x/crypto/ed25519
-golang.org/x/crypto/go.mod
-golang.org/x/crypto/go.sum
-golang.org/x/crypto/internal/subtle
-golang.org/x/crypto/LICENSE
-golang.org/x/crypto/nacl
-golang.org/x/crypto/PATENTS
-golang.org/x/crypto/poly1305
-golang.org/x/crypto/README.md
-golang.org/x/crypto/salsa20
-golang.org/x/net/AUTHORS
-golang.org/x/net/CONTRIBUTORS
-golang.org/x/net/go.mod
-golang.org/x/net/go.sum
-golang.org/x/net/LICENSE
-golang.org/x/net/netutil
-golang.org/x/net/PATENTS
-golang.org/x/net/README.md
-golang.org/x/sys/AUTHORS
-golang.org/x/sys/CONTRIBUTORS
-golang.org/x/sys/cpu
-golang.org/x/sys/go.mod
-golang.org/x/sys/internal/unsafeheader
-golang.org/x/sys/LICENSE
-golang.org/x/sys/PATENTS
-golang.org/x/sys/README.md
-golang.org/x/sys/unix
-golang.org/x/term
-EOF
-tar cfCI - src $tmp/includes | tar xfC - $tmp
-rm -fr src/golang.org $tmp/includes
-mv $tmp/golang.org src
-
-cat > $tmp/includes <<EOF
-compress/compressible.go
-compress/fse
-compress/huff0
-compress/LICENSE
-compress/README.md
-compress/zstd
-EOF
-cat > $tmp/excludes <<EOF
-*testdata*
-*_test.go
-snappy.go
-EOF
-tar cfCIX - src/github.com/klauspost $tmp/includes $tmp/excludes | tar xfC - $tmp
-rm -fr src/github.com/klauspost/compress $tmp/includes $tmp/excludes
-mv $tmp/compress src/github.com/klauspost
-
-find src -name .travis.yml -delete
-rm -fr src/github.com/davecgh/go-xdr/xdr
-rm -r src/github.com/flynn/noise/vector*
-rm src/github.com/hjson/hjson-go/build_release.sh
-rm src/github.com/gorhill/cronexpr/APLv2
-rm -fr ports
-find . -name .gitignore -delete
-rm makedist.sh module-name.do VERSION.do
+redo VERSION
+cd src
+go mod vendor
+modvendor -v -copy="**/*_test.go **/words.go **/README.md **/main.go"
+cd vendor
+rm -r \
+    github.com/flynn/noise/vector* \
+    github.com/gorhill/cronexpr/APLv2 \
+    github.com/hjson/hjson-go/build_release.sh \
+    github.com/klauspost/compress/snappy \
+    github.com/klauspost/compress/zstd/snappy.go \
+    golang.org/x/sys/plan9 \
+    golang.org/x/sys/windows
+find github.com/klauspost/compress golang.org/x/sys -name "*_test.go" -delete
+cd ../..
+rm -r ports
+find . \( -name .gitignore -o -name .travis.yml \) -delete
 
 mkdir contrib
 cp ~/work/redo/minimal/do contrib/do
-echo echo GOPATH=\`pwd\` > gopath.do
-
-perl -p -i -e "s#src/#src/$mod_name/#g" bin/default.do
 
 cat > doc/download.texi <<EOF
 @node Tarballs
@@ -181,11 +98,16 @@ rm -r doc/.well-known doc/nncp.html/.well-known
 
 ########################################################################
 
-rm -r .redo doc/.redo
+perl -i -npe "s/GO build/GO build -mod=vendor/" bin/default.do
+perl -i -npe "s/GO list/GO list -mod=vendor/" bin/default.do
+perl -i -npe "s/GO test/GO test -mod=vendor/" test.do
+rm makedist.sh VERSION.do
+rm -r .git
+redo-cleanup full
 find . -type d -exec chmod 755 {} \;
 find . -type f -exec chmod 644 {} \;
-find . -type f -name "*.sh" -exec chmod 755 {} \;
-chmod 755 contrib/do
+find . -type f -name "*.sh" -exec chmod +x {} \;
+chmod +x contrib/do
 
 cd ..
 tar cvf nncp-"$release".tar --uid=0 --gid=0 --numeric-owner nncp-"$release"
diff --git a/module-name.do b/module-name.do
deleted file mode 100644 (file)
index 4de5370..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-redo-ifchange src/go.mod
-sed -n 's/^module //p' < src/go.mod
index 792703f1aa2e34589d3a66c08af7c1b74e449c8e..b846f49bc4ace307aadfaf62075f6425e2f65747 100644 (file)
@@ -1,7 +1,7 @@
 # $FreeBSD: $
 
 PORTNAME=      nncp
-DISTVERSION=   5.4.0
+DISTVERSION=   5.5.1
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
 
@@ -16,6 +16,7 @@ USES=         go:no_targets tar:xz
 USE_RC_SUBR=   nncp-caller nncp-daemon nncp-toss
 
 MAKE_ARGS=     INFODIR=${STAGEDIR}${PREFIX}/${INFO_PATH}
+MAKE_ENV=      ${GO_ENV}
 INSTALL_TARGET=        install-strip
 
 SUB_FILES=     pkg-message pkg-install pkg-deinstall
index f859167550741e30109990558f9ae4b948a633b5..87fb5aeef9a76769163ee6f78be87790c39e6404 100644 (file)
@@ -33,6 +33,13 @@ type Call struct {
        Addr           *string
        OnlineDeadline time.Duration
        MaxOnlineTime  time.Duration
+
+       AutoToss       bool
+       AutoTossDoSeen bool
+       AutoTossNoFile bool
+       AutoTossNoFreq bool
+       AutoTossNoExec bool
+       AutoTossNoTrns bool
 }
 
 func (ctx *Ctx) CallNode(
index 50ad498d647c1af91dacf9d1e5376f0acc73e7a6..a72d371c141fecd588e8762fa2a758ece1ed18bd 100644 (file)
@@ -81,6 +81,13 @@ type CallJSON struct {
        Addr           *string `json:"addr,omitempty"`
        OnlineDeadline *uint   `json:"onlinedeadline,omitempty"`
        MaxOnlineTime  *uint   `json:"maxonlinetime,omitempty"`
+
+       AutoToss       *bool `json:"autotoss,omitempty"`
+       AutoTossDoSeen *bool `json:"autotoss-doseen,omitempty"`
+       AutoTossNoFile *bool `json:"autotoss-nofile,omitempty"`
+       AutoTossNoFreq *bool `json:"autotoss-nofreq,omitempty"`
+       AutoTossNoExec *bool `json:"autotoss-noexec,omitempty"`
+       AutoTossNoTrns *bool `json:"autotoss-notrns,omitempty"`
 }
 
 type NodeOurJSON struct {
@@ -260,12 +267,7 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                        onlineDeadline = time.Duration(*callCfg.OnlineDeadline) * time.Second
                }
 
-               var maxOnlineTime time.Duration
-               if callCfg.MaxOnlineTime != nil {
-                       maxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
-               }
-
-               calls = append(calls, &Call{
+               call := Call{
                        Cron:           expr,
                        Nice:           nice,
                        Xx:             xx,
@@ -273,8 +275,31 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                        TxRate:         txRate,
                        Addr:           addr,
                        OnlineDeadline: onlineDeadline,
-                       MaxOnlineTime:  maxOnlineTime,
-               })
+               }
+
+               if callCfg.MaxOnlineTime != nil {
+                       call.MaxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
+               }
+               if callCfg.AutoToss != nil {
+                       call.AutoToss = *callCfg.AutoToss
+               }
+               if callCfg.AutoTossDoSeen != nil {
+                       call.AutoTossDoSeen = *callCfg.AutoTossDoSeen
+               }
+               if callCfg.AutoTossNoFile != nil {
+                       call.AutoTossNoFile = *callCfg.AutoTossNoFile
+               }
+               if callCfg.AutoTossNoFreq != nil {
+                       call.AutoTossNoFreq = *callCfg.AutoTossNoFreq
+               }
+               if callCfg.AutoTossNoExec != nil {
+                       call.AutoTossNoExec = *callCfg.AutoTossNoExec
+               }
+               if callCfg.AutoTossNoTrns != nil {
+                       call.AutoTossNoTrns = *callCfg.AutoTossNoTrns
+               }
+
+               calls = append(calls, &call)
        }
 
        node := Node{
index 52e0fcb2887dd8a247d7e057ed20ca30463b0c8a..9762d9216cd950f00390d1ea9a2ba1422eeb03a5 100644 (file)
@@ -59,12 +59,12 @@ func main() {
                onlineDeadlineSec = flag.Uint("onlinedeadline", 0, "Override onlinedeadline option")
                maxOnlineTimeSec  = flag.Uint("maxonlinetime", 0, "Override maxonlinetime option")
 
-               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
-               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
-               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
-               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
-               autotossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
-               autotossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
+               autoToss       = flag.Bool("autotoss", false, "Toss after call is finished")
+               autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autoTossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
+               autoTossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
+               autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
+               autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
        flag.Usage = usage
        flag.Parse()
@@ -160,6 +160,21 @@ func main() {
        }
 
        ctx.Umask()
+
+       var autoTossFinish chan struct{}
+       var autoTossBadCode chan bool
+       if *autoToss {
+               autoTossFinish, autoTossBadCode = ctx.AutoToss(
+                       node.Id,
+                       nice,
+                       *autoTossDoSeen,
+                       *autoTossNoFile,
+                       *autoTossNoFreq,
+                       *autoTossNoExec,
+                       *autoTossNoTrns,
+               )
+       }
+
        badCode := !ctx.CallNode(
                node,
                addrs,
@@ -172,17 +187,10 @@ func main() {
                *listOnly,
                onlyPkts,
        )
-       if *autotoss {
-               badCode = ctx.Toss(
-                       node.Id,
-                       nice,
-                       false,
-                       *autotossDoSeen,
-                       *autotossNoFile,
-                       *autotossNoFreq,
-                       *autotossNoExec,
-                       *autotossNoTrns,
-               ) || badCode
+
+       if *autoToss {
+               close(autoTossFinish)
+               badCode = (<-autoTossBadCode) || badCode
        }
        if badCode {
                os.Exit(1)
index 421f0faa08d3593c94933dfb76f3b7776aa1584f..826033c334526166c530c1c8330226dac055080c 100644 (file)
@@ -49,13 +49,6 @@ func main() {
                debug     = flag.Bool("debug", false, "Print debug messages")
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
-
-               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
-               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
-               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
-               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
-               autotossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
-               autotossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
        flag.Usage = usage
        flag.Parse()
@@ -140,6 +133,21 @@ func main() {
                                        } else {
                                                node.Busy = true
                                                node.Unlock()
+
+                                               var autoTossFinish chan struct{}
+                                               var autoTossBadCode chan bool
+                                               if call.AutoToss {
+                                                       autoTossFinish, autoTossBadCode = ctx.AutoToss(
+                                                               node.Id,
+                                                               call.Nice,
+                                                               call.AutoTossDoSeen,
+                                                               call.AutoTossNoFile,
+                                                               call.AutoTossNoFreq,
+                                                               call.AutoTossNoExec,
+                                                               call.AutoTossNoTrns,
+                                                       )
+                                               }
+
                                                ctx.CallNode(
                                                        node,
                                                        addrs,
@@ -152,17 +160,10 @@ func main() {
                                                        false,
                                                        nil,
                                                )
-                                               if *autotoss {
-                                                       ctx.Toss(
-                                                               node.Id,
-                                                               call.Nice,
-                                                               false,
-                                                               *autotossDoSeen,
-                                                               *autotossNoFile,
-                                                               *autotossNoFreq,
-                                                               *autotossNoExec,
-                                                               *autotossNoTrns,
-                                                       )
+
+                                               if call.AutoToss {
+                                                       close(autoTossFinish)
+                                                       <-autoTossBadCode
                                                }
 
                                                node.Lock()
index a1358add583e3fd0fadb6124047d70e243bc9e04..93f3749df41be8180fc10f9c4261c76dce389666 100644 (file)
@@ -210,6 +210,13 @@ func main() {
     #   #     txrate: 20
     #   #     xx: rx
     #   #     addr: lan
+    #   #
+    #   #     autotoss: false
+    #   #     autotoss-doseen: true
+    #   #     autotoss-nofile: true
+    #   #     autotoss-nofreq: true
+    #   #     autotoss-noexec: true
+    #   #     autotoss-notrns: true
     #   #   },
     #   # ]
     # }
index b7aceb75e11f90eb1f99f26c7da7915c981739b8..b2b8911ec21b2abbbc6daaf30b40d253d7b9fcc0 100644 (file)
@@ -66,13 +66,19 @@ func (c InetdConn) Close() error {
        return c.w.Close()
 }
 
-func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) *nncp.SPState {
+func performSP(
+       ctx *nncp.Ctx,
+       conn nncp.ConnDeadlined,
+       nice uint8,
+       nodeIdC chan *nncp.NodeId,
+) {
        state := nncp.SPState{
                Ctx:  ctx,
                Nice: nice,
        }
        if err := state.StartR(conn); err == nil {
                ctx.LogI("call-start", nncp.SDS{"node": state.Node.Id}, "connected")
+               nodeIdC <- state.Node.Id
                state.Wait()
                ctx.LogI("call-finish", nncp.SDS{
                        "node":     state.Node.Id,
@@ -84,12 +90,15 @@ func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) *nncp.SPState
                }, "")
        } else {
                nodeId := "unknown"
-               if state.Node != nil {
+               if state.Node == nil {
+                       nodeIdC <- nil
+               } else {
+                       nodeIdC <- state.Node.Id
                        nodeId = state.Node.Id.String()
                }
                ctx.LogE("call-start", nncp.SDS{"node": nodeId}, err, "")
        }
-       return &state
+       close(nodeIdC)
 }
 
 func main() {
@@ -108,12 +117,12 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
 
-               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
-               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
-               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
-               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
-               autotossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
-               autotossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
+               autoToss       = flag.Bool("autotoss", false, "Toss after call is finished")
+               autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autoTossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
+               autoTossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
+               autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
+               autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
        flag.Usage = usage
        flag.Parse()
@@ -150,7 +159,10 @@ func main() {
        if *inetd {
                os.Stderr.Close() // #nosec G104
                conn := &InetdConn{os.Stdin, os.Stdout}
-               performSP(ctx, conn, nice)
+               nodeIdC := make(chan *nncp.NodeId)
+               go performSP(ctx, conn, nice, nodeIdC)
+               <-nodeIdC    // nodeId
+               <-nodeIdC    // call completion
                conn.Close() // #nosec G104
                return
        }
@@ -167,20 +179,28 @@ func main() {
                }
                ctx.LogD("daemon", nncp.SDS{"addr": conn.RemoteAddr()}, "accepted")
                go func(conn net.Conn) {
-                       state := performSP(ctx, conn, nice)
-                       conn.Close() // #nosec G104
-                       if *autotoss && state.Node != nil {
-                               ctx.Toss(
-                                       state.Node.Id,
+                       nodeIdC := make(chan *nncp.NodeId)
+                       go performSP(ctx, conn, nice, nodeIdC)
+                       nodeId := <-nodeIdC
+                       var autoTossFinish chan struct{}
+                       var autoTossBadCode chan bool
+                       if *autoToss && nodeId != nil {
+                               autoTossFinish, autoTossBadCode = ctx.AutoToss(
+                                       nodeId,
                                        nice,
-                                       false,
-                                       *autotossDoSeen,
-                                       *autotossNoFile,
-                                       *autotossNoFreq,
-                                       *autotossNoExec,
-                                       *autotossNoTrns,
+                                       *autoTossDoSeen,
+                                       *autoTossNoFile,
+                                       *autoTossNoFreq,
+                                       *autoTossNoExec,
+                                       *autoTossNoTrns,
                                )
                        }
+                       <-nodeIdC // call completion
+                       if *autoToss {
+                               close(autoTossFinish)
+                               <-autoTossBadCode
+                       }
+                       conn.Close() // #nosec G104
                }(conn)
        }
 }
index b351b25390fd2b1d526940de53d933eb730154ec..f8915d9b5bf31bc5ba37f79568c29c8095531b6e 100644 (file)
@@ -38,7 +38,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 )
 
 var (
-       Version string = "5.5.1"
+       Version string = "5.6.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )
index f70ffd3dd7674051af5cc74c5a7d5b0a8061ce3e..75e01c4d93633bb27572dca3b0d6e088814f6d31 100644 (file)
@@ -33,6 +33,7 @@ import (
        "path/filepath"
        "strconv"
        "strings"
+       "time"
 
        xdr "github.com/davecgh/go-xdr/xdr2"
        "github.com/dustin/go-humanize"
@@ -99,11 +100,9 @@ func (ctx *Ctx) Toss(
                        )
                        job.Fd.Close() // #nosec G104
                        if err != nil {
-                               ctx.LogE("rx", sds, err, "decryption")
                                return pipeW.CloseWithError(err)
                        }
                        if err = pipeWB.Flush(); err != nil {
-                               ctx.LogE("rx", sds, err, "decryption flush")
                                return pipeW.CloseWithError(err)
                        }
                        return pipeW.Close()
@@ -156,7 +155,7 @@ func (ctx *Ctx) Toss(
                        if !dryRun {
                                cmd := exec.Command(
                                        cmdline[0],
-                                       append(cmdline[1:len(cmdline)], args...)...,
+                                       append(cmdline[1:], args...)...,
                                )
                                cmd.Env = append(
                                        cmd.Env,
@@ -183,7 +182,7 @@ func (ctx *Ctx) Toss(
                                        if exists {
                                                cmd := exec.Command(
                                                        sendmail[0],
-                                                       append(sendmail[1:len(sendmail)], notify.To)...,
+                                                       append(sendmail[1:], notify.To)...,
                                                )
                                                cmd.Stdin = newNotification(notify, fmt.Sprintf(
                                                        "Exec from %s: %s", sender.Name, argsStr,
@@ -304,7 +303,7 @@ func (ctx *Ctx) Toss(
                                if len(sendmail) > 0 && ctx.NotifyFile != nil {
                                        cmd := exec.Command(
                                                sendmail[0],
-                                               append(sendmail[1:len(sendmail)], ctx.NotifyFile.To)...,
+                                               append(sendmail[1:], ctx.NotifyFile.To)...,
                                        )
                                        cmd.Stdin = newNotification(ctx.NotifyFile, fmt.Sprintf(
                                                "File from %s: %s (%s)",
@@ -373,7 +372,7 @@ func (ctx *Ctx) Toss(
                                if len(sendmail) > 0 && ctx.NotifyFreq != nil {
                                        cmd := exec.Command(
                                                sendmail[0],
-                                               append(sendmail[1:len(sendmail)], ctx.NotifyFreq.To)...,
+                                               append(sendmail[1:], ctx.NotifyFreq.To)...,
                                        )
                                        cmd.Stdin = newNotification(ctx.NotifyFreq, fmt.Sprintf(
                                                "Freq from %s: %s", sender.Name, src,
@@ -426,3 +425,26 @@ func (ctx *Ctx) Toss(
        }
        return isBad
 }
+
+func (ctx *Ctx) AutoToss(
+       nodeId *NodeId,
+       nice uint8,
+       doSeen, noFile, noFreq, noExec, noTrns bool,
+) (chan struct{}, chan bool) {
+       finish := make(chan struct{})
+       badCode := make(chan bool)
+       go func() {
+               bad := false
+               for {
+                       select {
+                       case <-finish:
+                               badCode <- bad
+                               break
+                       default:
+                       }
+                       time.Sleep(time.Second)
+                       bad = !ctx.Toss(nodeId, nice, false, doSeen, noFile, noFreq, noExec, noTrns)
+               }
+       }()
+       return finish, badCode
+}
diff --git a/test.do b/test.do
index feb7b5fa8760b7bd2272f21f446715f2168923e1..13b228a8cbdf4e382c3445e06f37697727a08dcc 100644 (file)
--- a/test.do
+++ b/test.do
@@ -1,7 +1,6 @@
-redo-ifchange config gopath module-name
+redo-ifchange config
 exec >&2
 . ./config
-. ./gopath
-mod=`cat module-name`
 cd src
-GOPATH=$GOPATH ${GO:-go} test -failfast $mod/...
+GO=${GO:-go}
+$GO test -failfast ./...