-gopath
-module-name
VERSION
-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
redo bin/clean
-rm -f gopath module-name VERSION
+rm -f VERSION
cron: "*/1 * * * MON-FRI"
onlinedeadline: 3600
nice: PRIORITY+10
+
+ autotoss: true
+ autotoss-doseen: true
},
{
cron: "30 * * * SAT,SUN"
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
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|}
@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
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}
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
@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
@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
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
@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:
(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}
@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}:
@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:
@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
@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}
@}
@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,
@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
@item
@command{nncp-bundle} команда может создавать потоки зашифрованных
-пакетов или потреблять их. Это полезно когда речь идёт о stdin/stdout
-методах передачи (например запись на CD-ROM без создания промежуточного
-подготовленного ISO образа или работа с ленточными накопителями).
+пакетов или потреблять их. Это полезно когда речь идёт о
+@code{stdin}/@code{stdout} методах передачи (например запись на CD-ROM
+без создания промежуточного подготовленного ISO образа или работа с
+ленточными накопителями).
@item
@command{nncp-toss} команда может создавать @file{.seen} файлы,
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
@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
@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
+++ /dev/null
-echo GOPATH=${GOPATH:-`pwd`}
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
########################################################################
-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"
+++ /dev/null
-redo-ifchange src/go.mod
-sed -n 's/^module //p' < src/go.mod
# $FreeBSD: $
PORTNAME= nncp
-DISTVERSION= 5.4.0
+DISTVERSION= 5.5.1
CATEGORIES= net
MASTER_SITES= http://www.nncpgo.org/download/
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
Addr *string
OnlineDeadline time.Duration
MaxOnlineTime time.Duration
+
+ AutoToss bool
+ AutoTossDoSeen bool
+ AutoTossNoFile bool
+ AutoTossNoFreq bool
+ AutoTossNoExec bool
+ AutoTossNoTrns bool
}
func (ctx *Ctx) CallNode(
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 {
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,
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{
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()
}
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,
*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)
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()
} 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,
false,
nil,
)
- if *autotoss {
- ctx.Toss(
- node.Id,
- call.Nice,
- false,
- *autotossDoSeen,
- *autotossNoFile,
- *autotossNoFreq,
- *autotossNoExec,
- *autotossNoTrns,
- )
+
+ if call.AutoToss {
+ close(autoTossFinish)
+ <-autoTossBadCode
}
node.Lock()
# # txrate: 20
# # xx: rx
# # addr: lan
+ # #
+ # # autotoss: false
+ # # autotoss-doseen: true
+ # # autotoss-nofile: true
+ # # autotoss-nofreq: true
+ # # autotoss-noexec: true
+ # # autotoss-notrns: true
# # },
# # ]
# }
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,
}, "")
} 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() {
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()
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
}
}
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)
}
}
)
var (
- Version string = "5.5.1"
+ Version string = "5.6.0"
Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
)
"path/filepath"
"strconv"
"strings"
+ "time"
xdr "github.com/davecgh/go-xdr/xdr2"
"github.com/dustin/go-humanize"
)
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()
if !dryRun {
cmd := exec.Command(
cmdline[0],
- append(cmdline[1:len(cmdline)], args...)...,
+ append(cmdline[1:], args...)...,
)
cmd.Env = append(
cmd.Env,
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,
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)",
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,
}
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
+}
-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 ./...