.gitignore | 2 -- bin/default.do | 14 ++++++-------- clean.do | 2 +- doc/call.texi | 8 ++++++++ doc/cfg.texi | 8 ++++---- doc/cmds.texi | 58 ++++++++++++++++++++++++++++++----------------------- doc/comparison.texi | 2 +- doc/download.texi | 4 ++++ doc/integration.texi | 2 +- doc/news.ru.texi | 29 ++++++++++++++++++++++++++--- doc/news.texi | 33 ++++++++++++++++++++++++++++----- gopath.do | 1 - makedist.sh | 128 +++++++++++------------------------------------------ module-name.do | 2 -- ports/nncp/Makefile | 3 ++- src/call.go | 7 +++++++ src/cfg.go | 41 +++++++++++++++++++++++++++++++++-------- src/cmd/nncp-call/main.go | 42 +++++++++++++++++++++++++----------------- src/cmd/nncp-caller/main.go | 37 +++++++++++++++++++------------------ src/cmd/nncp-cfgnew/main.go | 7 +++++++ src/cmd/nncp-daemon/main.go | 62 +++++++++++++++++++++++++++++++++++------------------ src/nncp.go | 2 +- src/toss.go | 34 ++++++++++++++++++++++++++++------ test.do | 7 +++---- diff --git a/.gitignore b/.gitignore index 98819b53e8a61212445993ab92bb519f61e46901e26f47da0df330481b2f28f5..f9f200acf8555413faf8b109d423137c6f06e21d793dcdba49aa504298c50622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -gopath -module-name VERSION diff --git a/bin/default.do b/bin/default.do index b102ab9d73190bca986f7cb45973b7370a54c428b933f1d7033c810225c5a758..345e0470e3d278ea67d7bb6c29122ef9403ee9c19731fd247a01a4d74d8c9840 100644 --- a/bin/default.do +++ b/bin/default.do @@ -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 diff --git a/clean.do b/clean.do index 05802db3e26ca9eadf0436ff6751fa0cff60edd35ea7facbe5d18a9b773ff4b5..0ba028ac187626d4e5c5ca31142bae023ee0f4fc400b541b3543fd887a92a291 100644 --- a/clean.do +++ b/clean.do @@ -1,2 +1,2 @@ redo bin/clean -rm -f gopath module-name VERSION +rm -f VERSION diff --git a/doc/call.texi b/doc/call.texi index f4ecb593519d70e60e48c66a1e37afd5a94dd7e31e71f6943f5d62b57cf720cf..3808de9726d30eca9a4afc1a6cecb61fa63c1c05466fdc102b9f8bdbb7c91460 100644 --- a/doc/call.texi +++ b/doc/call.texi @@ -11,6 +11,9 @@ { cron: "*/1 * * * MON-FRI" onlinedeadline: 3600 nice: PRIORITY+10 + + autotoss: true + autotoss-doseen: true }, { cron: "30 * * * SAT,SUN" @@ -184,5 +187,10 @@ @item maxonlinetime 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 diff --git a/doc/cfg.texi b/doc/cfg.texi index 72b15edb2b4a8658e8e1f5622a9f5c1e52bff05376c2c0878f6cc94325ef2744..f6de9b51d10c42209fae2734234c87a6d2ad8998c23f55cd270975b5089be53e 100644 --- a/doc/cfg.texi +++ b/doc/cfg.texi @@ -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 diff --git a/doc/cmds.texi b/doc/cmds.texi index fc3adcfd423fce4cac34c887caae6099fb62eadcd7054bfa2c1d560a2a7b9e53..84a3b5d6c52ca93c901701449621adaf8e02505df22e57ad7927946c0da8029b 100644 --- a/doc/cmds.texi +++ b/doc/cmds.texi @@ -53,10 +53,10 @@ @end example 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: diff --git a/doc/comparison.texi b/doc/comparison.texi index 5aa2e980fa06434bdd1d04dc361fb51fd3db82e14aaf21a6bb2248684fcdf944..510ed9f85b5824c12f4e29c416149197d2e83c1e85e292b22c53e3b6ac5aeda6 100644 --- a/doc/comparison.texi +++ b/doc/comparison.texi @@ -120,7 +120,7 @@ @tab @command{nncp-call}, @command{nncp-caller} @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 diff --git a/doc/download.texi b/doc/download.texi index 375ce6125cff67cc02d597fbbe3e717cf26e947e290da2eeb31530ac9284e461..8865550446e62595de68ae6dfaaad9e5a76b618e2902a4e12da40109d9a6f65b 100644 --- a/doc/download.texi +++ b/doc/download.texi @@ -25,6 +25,10 @@ @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} diff --git a/doc/integration.texi b/doc/integration.texi index ab0b01f28e7ae7a2486d81b9e9272f1a79107b440087f98540b17efe074a5ff8..a16ee2fd7c3c90da0892eefac5a3224a4925ce6cc6f86d269dd4434b4d5ad5fe 100644 --- a/doc/integration.texi +++ b/doc/integration.texi @@ -243,7 +243,7 @@ rsmtp: ["/usr/sbin/sendmail", "-bS"] @} @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, diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 0b7cb87b36ec397f811008200dab196c4c5f8e89855268b897dabde18fd8f2d1..e813b10b0a43858564a09de2a84822dac3e18f6693db78939d64acb4b3427b23 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -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 @@ со старыми версиями не поддерживается. @item @command{nncp-bundle} команда может создавать потоки зашифрованных -пакетов или потреблять их. Это полезно когда речь идёт о stdin/stdout -методах передачи (например запись на CD-ROM без создания промежуточного -подготовленного ISO образа или работа с ленточными накопителями). +пакетов или потреблять их. Это полезно когда речь идёт о +@code{stdin}/@code{stdout} методах передачи (например запись на CD-ROM +без создания промежуточного подготовленного ISO образа или работа с +ленточными накопителями). @item @command{nncp-toss} команда может создавать @file{.seen} файлы, diff --git a/doc/news.texi b/doc/news.texi index d3e5f6967c78ff53c58627770884725d8a451ba53289776e2bc0afc21110ea96..85b4217169fcf0b7b07f81970e043f6a7a5343cf720d8d5ce66d70ba3c02394c 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,28 @@ @unnumbered News 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 @@ @section Release 0.7 @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 index a6f3700b87a7ec25f53c187b49c9bcbbca831a6fbe41ee2b0f7d2c6c570220e7..0000000000000000000000000000000000000000 --- a/gopath.do +++ /dev/null @@ -1 +0,0 @@ -echo GOPATH=${GOPATH:-`pwd`} diff --git a/makedist.sh b/makedist.sh index 032723c4b67ce46f8d27ec0e63961f33db117b01fd2ebe6bf8858f69b6c8a8d4..3603fa3bed1c9f269706d6af7caea26b2fc564e317b025f1c4d6d3a247be4038 100755 --- a/makedist.sh +++ b/makedist.sh @@ -8,109 +8,26 @@ 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 < $tmp/includes < $tmp/excludes < gopath.do - -perl -p -i -e "s#src/#src/$mod_name/#g" bin/default.do cat > doc/download.texi <.` ) var ( - Version string = "5.5.1" + Version string = "5.6.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) ) diff --git a/src/toss.go b/src/toss.go index c82505d754956fe02113f034c7fc1f2b1fc2ea133ac8091714939d9e3a2754ec..74f6168e0fff75b46ee9c9e1a98341444981f8a78119902f69f1863777ee0ec3 100644 --- a/src/toss.go +++ b/src/toss.go @@ -33,6 +33,7 @@ "path" "path/filepath" "strconv" "strings" + "time" xdr "github.com/davecgh/go-xdr/xdr2" "github.com/dustin/go-humanize" @@ -99,11 +100,9 @@ pipeWB, ) 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 @@ } 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 @@ } 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 @@ } 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 @@ } 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 @@ pipeR.Close() // #nosec G104 } 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 1ea28ab8fe5c6ee00a48ec92ebe6f291927eaba7f5cbb4c33e8a7e873746763e..4d139ba23f12fbd9dd7dddedb78d1c24e41fac629f92b729dc7bc4284b1c79ae 100644 --- 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 ./...