.gitignore | 1 - Makefile | 19 ------------------- PUBKEY-SSH.pub | 1 + PUBKEY-SSH.pub.asc | 11 +++++++++++ VERSION.do | 2 -- all.do | 1 - bin/.gitignore | 2 -- bin/all.do | 2 -- bin/build | 15 +++++++++++++++ bin/clean.do | 1 - bin/default.do | 10 ---------- bin/hjson-cli.do | 3 --- clean.do | 2 -- doc.do | 1 - doc/ack.texi | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/building.texi | 37 +++++++++++-------------------------- doc/call.texi | 6 ++++-- doc/cfg/neigh.texi | 19 +++++++++++++++++++ doc/cmd/nncp-ack.texi | 66 ++++------------------------------------------------- doc/cmd/nncp-rm.texi | 3 ++- doc/cmd/nncp-toss.texi | 11 ++++++++--- doc/download.texi | 223 +++++++++++++++++++++++++++++++++++------------------ doc/index.texi | 5 +++-- doc/integration/bittorrent.texi | 6 +++--- doc/integration/download.texi | 2 +- doc/integrity.texi | 36 +++++++++++++++++++----------------- doc/makeinfo.rc | 3 +-- doc/mirrors.texi | 7 ++----- doc/news.ru.texi | 28 ++++++++++++++++++++++++++++ doc/news.texi | 28 ++++++++++++++++++++++++++++ doc/nncp.html.do | 3 ++- doc/spool.texi | 10 ++++++++++ doc/style.css | 5 ----- doc/www.do | 16 ++++++++++++++++ install | 18 ++++++++++++++++++ install-strip | 9 +++++++++ install-strip.do | 5 ----- install.do | 16 ---------------- makedist | 50 ++++++++++++++++++++++++-------------------------- src/call.go | 1 + src/cfg.go | 26 ++++++++++++++++++++++++++ src/cfgdir.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/cmd/nncp-ack/main.go | 23 ++++++++++++++++++----- src/cmd/nncp-bundle/main.go | 1 - src/cmd/nncp-call/main.go | 52 +++++++++++++++++++++++++++++++++------------------- src/cmd/nncp-caller/main.go | 46 +++++++++++++++++++++++++++++----------------- src/cmd/nncp-cfgdir/main.go | 1 - src/cmd/nncp-cfgenc/main.go | 1 - src/cmd/nncp-cfgmin/main.go | 1 - src/cmd/nncp-cfgnew/main.go | 1 - src/cmd/nncp-check/main.go | 1 - src/cmd/nncp-cronexpr/main.go | 1 - src/cmd/nncp-daemon/main.go | 68 +++++++++++++++++++++++++++++++++-------------------- src/cmd/nncp-exec/main.go | 33 +++++++++++++++++---------------- src/cmd/nncp-file/main.go | 6 +++--- src/cmd/nncp-freq/main.go | 29 +++++++++++++++-------------- src/cmd/nncp-hash/main.go | 1 - src/cmd/nncp-log/main.go | 1 - src/cmd/nncp-pkt/main.go | 1 - src/cmd/nncp-reass/main.go | 9 ++++----- src/cmd/nncp-rm/main.go | 58 +++++++++++++++++++++++++++++++++++++++++++++++------ src/cmd/nncp-stat/main.go | 1 - src/cmd/nncp-toss/main.go | 51 ++++++++++++++++++++++++++++++++++++++++++--------- src/cmd/nncp-trns/main.go | 6 +++--- src/cmd/nncp-xfer/main.go | 17 ++++++++--------- src/go.mod | 14 +++++++------- src/go.sum | 31 +++++++++++++++---------------- src/mcd.go | 4 +--- src/nncp.go | 19 +++++-------------- src/node.go | 2 ++ src/toss.go | 114 +++++++++++++++++++++++++++++++++-------------------- src/toss_test.go | 30 ++++++++++-------------------- src/tx_test.go | 4 ++-- test.do | 6 ------ uninstall | 8 ++++++++ uninstall.do | 5 ----- version | 3 +++ diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f9f200acf8555413faf8b109d423137c6f06e21d793dcdba49aa504298c50622..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -VERSION diff --git a/Makefile b/Makefile deleted file mode 100644 index feb7a2399a3473046e61ad6ed3f8821a8dfa393b2ab35faaa47070d79b9f5521..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -REDO ?= contrib/do -c - -warning: - @echo WARNING: this is not real Makefile. Just proxying commands to redo command - -all: warning - $(REDO) $@ - -clean: warning - $(REDO) $@ - -install: warning - $(REDO) $@ - -install-strip: warning - $(REDO) $@ - -uninstall: warning - $(REDO) $@ diff --git a/PUBKEY-SSH.pub b/PUBKEY-SSH.pub new file mode 100644 index 0000000000000000000000000000000000000000..13327d5b1ea7c6d90f4816584074bbabc5284bcf3559b364f252cffe88010201 --- /dev/null +++ b/PUBKEY-SSH.pub @@ -0,0 +1 @@ +releases@nncpgo.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAN9JzbXHVPouT+atdxhcVgVmCWLm9Dx/mhPWfU4Sceb diff --git a/PUBKEY-SSH.pub.asc b/PUBKEY-SSH.pub.asc new file mode 100644 index 0000000000000000000000000000000000000000..8815b6708335b60798c8862f096b7f72325ee5c95e7bae595cf261950432f8d6 --- /dev/null +++ b/PUBKEY-SSH.pub.asc @@ -0,0 +1,11 @@ +-----BEGIN PGP SIGNATURE----- + +iQFIBAABCgAyFiEEksLwrv5zII5Gv/PeKyWGjnWhqVMFAmTSnBMUHHJlbGVhc2Vz +QG5uY3Bnby5vcmcACgkQKyWGjnWhqVOiHQgAzMartvzE1En6hMo9kg31/1QKFbgc ++tHOF5L62hpp3BOvbAyHG1IbFRRCUCi/m3i1KJ0BexaNLItDFba2L/w1P554rDqh +DslQsI3aU91eVLv/x2CTzkK4Sfx1KCH+sq6BfDnwgwR8LOshspvxcLstcao9dzjh +IVFdVwQT4t3iHy7DUTR8AsMzO4El28Q8BNbU4Vb3SAyp6XWS08woyB2kNztH83h4 +FJrq17OFmxwRjQg3FXHuQDQs89XI7RE5pcw7RmOAcoKZbU+267NgHwW0BeFkPxwF +NjKv4rmq6mnHUljCaVTR2DWSvvq+uhSy+Z9Ve05TxFPnwL+NdXkbTy8WNg== +=59zV +-----END PGP SIGNATURE----- diff --git a/VERSION.do b/VERSION.do deleted file mode 100644 index 66a97a70bde2f941417ac5c1e74f4c51ad9711f55dab756053711b7575eed262..0000000000000000000000000000000000000000 --- a/VERSION.do +++ /dev/null @@ -1,2 +0,0 @@ -redo-ifchange src/nncp.go -perl -ne 'print "$1\n" if /Version.* = "(.*)"$/' < src/nncp.go diff --git a/all.do b/all.do deleted file mode 100644 index 3820e43dab50af214c261f55269a2fae28d6b3dcdc0e6c06a4a998610c8ac636..0000000000000000000000000000000000000000 --- a/all.do +++ /dev/null @@ -1 +0,0 @@ -redo-ifchange bin/all diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 3326391b8d7d263ffc93d432cec70bf6e34ba57c4a631daac83286f4059e3c31..0000000000000000000000000000000000000000 --- a/bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -hjson-cli -nncp-* diff --git a/bin/all.do b/bin/all.do deleted file mode 100644 index 36ac5d4c530a7c63bcd0006f1815aa20427f516b5200ceffbf181d4f7518c4c2..0000000000000000000000000000000000000000 --- a/bin/all.do +++ /dev/null @@ -1,2 +0,0 @@ -redo-ifchange cmd.list hjson-cli -redo-ifchange `cat cmd.list` diff --git a/bin/build b/bin/build new file mode 100755 index 0000000000000000000000000000000000000000..95b37d86b2b51b9c1477943327159e91129956a251b8df108d777aebcb86f8c5 --- /dev/null +++ b/bin/build @@ -0,0 +1,15 @@ +#!/bin/sh -e + +cd "$(realpath -- $(dirname "$0"))"/../src +GO=${GO:-go} +. ../config +[ -d vendor ] && vendor="-mod=vendor" || : +mod=`$GO list $vendor -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" +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/hjson-cli $GO_CFLAGS github.com/hjson/hjson-go/hjson-cli diff --git a/bin/clean.do b/bin/clean.do deleted file mode 100644 index 3dfcfa366b6ca6e89ad5071b2ae059a64a372d226c1a49085f69e3366c18f106..0000000000000000000000000000000000000000 --- a/bin/clean.do +++ /dev/null @@ -1 +0,0 @@ -rm -f `cat cmd.list` hjson-cli diff --git a/bin/default.do b/bin/default.do deleted file mode 100644 index c7c34f54c1bf7bed615fee0f567aceccbddf3f20b10983a5f83bce4b8712bf66..0000000000000000000000000000000000000000 --- a/bin/default.do +++ /dev/null @@ -1,10 +0,0 @@ -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" -$GO build -o ../bin/$3 $GO_CFLAGS -ldflags "$GO_LDFLAGS" ./cmd/${1##*/} diff --git a/bin/hjson-cli.do b/bin/hjson-cli.do deleted file mode 100644 index 6273d4e83b90a2c4da9fa4762c09f7eb9bf974dc0a89b7aca7871383d9d95d0a..0000000000000000000000000000000000000000 --- a/bin/hjson-cli.do +++ /dev/null @@ -1,3 +0,0 @@ -cd ../src -GO=${GO:-go} -$GO build -o ../bin/$3 github.com/hjson/hjson-go/hjson-cli diff --git a/clean.do b/clean.do deleted file mode 100644 index 0ba028ac187626d4e5c5ca31142bae023ee0f4fc400b541b3543fd887a92a291..0000000000000000000000000000000000000000 --- a/clean.do +++ /dev/null @@ -1,2 +0,0 @@ -redo bin/clean -rm -f VERSION diff --git a/doc.do b/doc.do deleted file mode 100644 index 3aea49c4191956e4e42ea35f7a4e5b4f424e969f32b2a972aefce6a79ba5879a..0000000000000000000000000000000000000000 --- a/doc.do +++ /dev/null @@ -1 +0,0 @@ -redo-ifchange doc/all diff --git a/doc/ack.texi b/doc/ack.texi new file mode 100644 index 0000000000000000000000000000000000000000..a132a47f60400d3d18debad76d5e9c2f9a84dedd65edd9dfc383d57c56de6855 --- /dev/null +++ b/doc/ack.texi @@ -0,0 +1,72 @@ +@node ACK +@cindex ACKnowledgements +@cindex packet acknowledgement +@unnumbered ACKnowledgements + +There is possibility to explicitly acknowledge the receipt of the +encrypted packet, by generating the reply of @code{ACK}-type which +contains the packet identifier. + +ACK packets can be generated explicitly by @command{@ref{nncp-ack}} +command, or during the tossing procedure if @option{-gen-ack} option +is specified. + +General workflow with acknowledgement is following, assuming that +Alice has some outbound packets for Bob: + +@itemize + +@item Transfer encrypted packets, without deleting them locally: + +@example +alice$ nncp-xfer -keep -tx -node bob /mnt/shared +@end example + +@item On Bob's side retrieve those packets: + +@example +bob$ nncp-xfer -rx /mnt/shared +@end example + +That will also check if copied packets checksum is not mismatched. + +@item Create ACK packets of received ones, saving the list of encrypted + ACK packets: + +@example +bob$ nncp-ack -node alice 4>acks +@end example + +@item Send those newly created packets back to Alice: + +@example +bob$ nncp-xfer [-keep] -tx /mnt/shared +@end example + +@item Remove them from outbound spool, because we expect no + acknowledgement for them: + +@example +bob$ nncp-rm -node alice -pkt &1 >&2 | nncp-rm [@dots{}] -pkt @end example -Send acknowledgement of successful @option{PKT} (Base32-encoded hash) -packet receipt from @option{NODE} node. If no @option{-pkt} is -specified, then acknowledge all packet in node's @code{rx} outbound -spool. If @option{-all} is specified, then do that for all nodes. +Send @ref{ACK, acknowledgement} of successful @option{PKT} +(Base32-encoded hash) packet receipt from @option{NODE} node. If no +@option{-pkt} is specified, then acknowledge all packet in node's +@code{rx} spool. If @option{-all} is specified, then do that for all +nodes. That commands outputs list of created encrypted ACK packets (@code{NODE/PKT}) to @strong{4}th file descriptor. That output can be passed for example to @command{@ref{nncp-rm}} to remove them after transmission to not wait for acknowledgement and retransmission. - -General workflow with acknowledgement is following, assuming that -Alice has some outbound packets for Bob: - -@itemize - -@item Transfer encrypted packets, without deleting them locally: - -@example -alice$ nncp-xfer -keep -tx -node bob /mnt/shared -@end example - -@item On Bob's side retrieve those packets: - -@example -bob$ nncp-xfer -rx /mnt/shared -@end example - -That will also check if copied packets checksum is not mismatched. - -@item Create ACK packets of received ones, saving the list of encrypted - ACK packets: - -@example -bob$ nncp-ack -node alice 4>acks -@end example - -@item Send those newly created packets back to Alice: - -@example -bob$ nncp-xfer [-keep] -tx /mnt/shared -@end example - -@item Remove them from outbound spool, because we expect no - acknowledgement for them: - -@example -bob$ nncp-rm -node alice -pkt @end verbatim -@itemize - -@item @example $ gpg --auto-key-locate dane --locate-keys releases at nncpgo dot org $ gpg --auto-key-locate wkd --locate-keys releases at nncpgo dot org @end example -@item -@verbatiminclude .well-known/openpgpkey/nncpgo.org/hu/i4cdqgcarfjdjnba6y4jnf498asg8c6p.asc - -@end itemize - -Then you could verify tarballs signature: +@item @url{https://www.openssh.com/, OpenSSH} @file{.sig} signature + @url{PUBKEY-SSH.pub, Public key} and its OpenPGP + @url{PUBKEY-SSH.pub.asc, signature} made with the key above. + Its fingerprint: @code{SHA256:FRiWawVNBkyS3jFn8uZ/JlT+PWKSFbhWe5XSixp1+SY}. @example -$ gpg --verify nncp-@value{VERSION}.tar.xz.sig nncp-@value{VERSION}.tar.xz +$ ssh-keygen -Y verify -f PUBKEY-SSH.pub -I releases@@nncpgo.org -n file \ + -s nncp-@value{VERSION}.tar.zst.sig < nncp-@value{VERSION}.tar.zst @end example + +@end table diff --git a/doc/makeinfo.rc b/doc/makeinfo.rc index 36a8c51242376bc7af6a66a54aec1d784759fbe1b0b2644555a3599e5f043fcd..12a06b2edb59d42babd43476d81654a15805334e8e45a8fabe6f732257859f13 100644 --- a/doc/makeinfo.rc +++ b/doc/makeinfo.rc @@ -1,6 +1,5 @@ redo-ifchange \ ../config \ - ../VERSION \ *.texi \ cfg/*.texi \ cmd/*.texi \ @@ -12,7 +11,7 @@ usecases.ru/*.texi \ usecases/*.texi . ../config ${MAKEINFO:-makeinfo} \ - -D "VERSION `cat ../VERSION`" \ + -D "VERSION `../version`" \ $MAKEINFO_OPTS \ --set-customization-variable SECTION_NAME_IN_TITLE=1 \ --set-customization-variable TREE_TRANSFORMATIONS=complete_tree_nodes_menus \ diff --git a/doc/mirrors.texi b/doc/mirrors.texi index 445a0c203d4e1a3f07e50b140ecc8a133f908e9d1314bc37e765488f8dba1b24..ab3a2091b3a3b0dcaafb03d1e47ab08cd35e52e7e237614b2b665524bbacbcfe 100644 --- a/doc/mirrors.texi +++ b/doc/mirrors.texi @@ -3,9 +3,7 @@ @cindex mirror @unnumbered Mirrors Main NNCP website is hosted on two geographically distant servers -located in Moscow region, Russian Federation. Only one of those servers -supports TLS and another just proxies the traffic to it. So TLS-capable -version has less availability. +located in Moscow and Saint-Petersburg regions, Russian Federation. @cindex DANE @cindex DNSCurve @@ -18,8 +16,7 @@ @url{https://dnscurve.org/, DNSCurve}-secured @url{http://www.stargrave.org/Trust-anchor.html, trust anchors}. Both @code{ca.cypherpunks.ru} and DNSCurve trust anchors are signed with @code{12AD 3268 9C66 0D42 6967 FD75 CB82 0563 2107 AD8A} -@url{https://en.wikipedia.org/wiki/OpenPGP, OpenPGP} -@url{http://www.stargrave.org/Contacts.html, public key}. +@url{https://en.wikipedia.org/wiki/OpenPGP, OpenPGP} public key. Also there is @url{https://yggdrasil-network.github.io/, Yggdrasil} accessible address: @url{http://y.www.nncpgo.org/}. diff --git a/doc/news.ru.texi b/doc/news.ru.texi index af3b621dd97e07a3e08b29865ec789c58ca1a34cfc726b0c5a50e830fd0736bd..e966dbe9364654e5704555960bcdac48314459313f380c857e36fa8239aa6557 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,34 @@ @node Новости @section Новости +@node Релиз 8.9.0 +@subsection Релиз 8.9.0 +@itemize + +@item +@command{nncp-toss} команда имеет @option{-gen-ack} опцию. +@command{nncp-daemon}, @command{nncp-caller}, @command{nncp-call} +команды имеют @option{-autotoss-gen-ack} опцию. Они автоматически +генерируют ACK пакеты и сохраняют соответствующие @file{spoo/tx/ack/} +ссылки на них, чтобы их можно было удалить после передачи. + +@item +@code{autotoss-gen-ack} появился в конфигурации call. +@code{ack} секция появилась в конфигурации ноды. + +@item +@command{nncp-rm} команда имеет @option{-ack} опцию для удаления пакетов +на которые ссылаются @file{spool/tx/ack/} файлы созданные во время toss. + +@item +@command{redo} система сборки более не требуется при установке, так как +по сути нет зависимостей, только компиляция Go кода. + +@item +Обновлены некоторые зависимости. + +@end itemize + @node Релиз 8.8.3 @subsection Релиз 8.8.3 @itemize diff --git a/doc/news.texi b/doc/news.texi index 7200930ce1d8f99e4796f19748488c31b4835a09a235a6be99dc869cefb4e4b0..75c9faf7f4dd7efd39b6075c796c73b7e8100df8e4b19b4749505d82e760b20d 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -4,6 +4,34 @@ @unnumbered News See also this page @ref{Новости, on russian}. +@node Release 8_9_0 +@section Release 8.9.0 +@itemize + +@item +@command{nncp-toss} command has @option{-gen-ack} option. +@command{nncp-daemon}, @command{nncp-caller}, @command{nncp-call} +commands have @option{-autotoss-gen-ack} option. They automatically +generate ACK packets and store corresponding @file{spool/tx/ack/} +references to them, to be able to remove them after the transfer. + +@item +@code{autotoss-gen-ack} appeared in call configuration. +@code{ack} section appeared in neighbour configuration. + +@item +@command{nncp-rm} command has @option{-ack} option to remove packets +referenced by stored @file{spool/tx/ack/} files generated during tossing. + +@item +Get rid of @command{redo} build system during installation, as there are +virtually none dependencies, just only compilation of the Go code. + +@item +Updated some dependencies. + +@end itemize + @node Release 8_8_3 @section Release 8.8.3 @itemize diff --git a/doc/nncp.html.do b/doc/nncp.html.do index cef94d36731b709cfa4d2fec7372e9981982de655503b7131e5d6f453f81c791..864fc0d49da36bda3aeb9e0f9a3e793673842a4589c2ad1cf331f561520d35a0 100644 --- a/doc/nncp.html.do +++ b/doc/nncp.html.do @@ -1,6 +1,7 @@ redo-ifchange makeinfo.rc rm -fr nncp.html -MAKEINFO_OPTS="$MAKEINFO_OPTS --html --css-include style.css" +MAKEINFO_OPTS="$MAKEINFO_OPTS --html" +MAKEINFO_OPTS="$MAKEINFO_OPTS --set-customization-variable NO_CSS=1" MAKEINFO_OPTS="$MAKEINFO_OPTS --set-customization-variable FORMAT_MENU=menu" MAKEINFO_OPTS="$MAKEINFO_OPTS --set-customization-variable DATE_IN_HEADER=1" MAKEINFO_OPTS="$MAKEINFO_OPTS" . makeinfo.rc diff --git a/doc/spool.texi b/doc/spool.texi index 3847c71f8bca156abef5274e9f3f658a8a1ddd7c722e01c43618f3791691601c..c8c08fed0647bb877c5c0c0bada5564312b4eff951ae0c873d02c3dca1380976 100644 --- a/doc/spool.texi +++ b/doc/spool.texi @@ -86,4 +86,14 @@ that will recreate them. In many cases many @file{hdr/} files will be allocated more or less linearly on the disk, decreasing listing time even more. +@cindex ack files +@anchor{ACKFile} +@item tx/ack/LYT64MWSNDK34CVYOO7TA6ZCJ3NWI2OUDBBMX2A4QWF34FIRY4DQ +If tossing was performed with @option{-gen-ack} option, then for each +generated @ref{ACK} packet there will be corresponding empty @file{ack/} +file. ACK outbound packets needs to be deleted after the transmission, +but since they are stored encrypted in the spool, there needs to be some +kind of knowledge what packets are ACK ones. Both ACK and corresponding +@file{ack/} files are removed by @command{@ref{nncp-rm} -ack} command. + @end table diff --git a/doc/style.css b/doc/style.css deleted file mode 100644 index 7b29463e7dab00907f74b58401bc74e06d55bd05fff3d7aed283a1b793c08f4c..0000000000000000000000000000000000000000 --- a/doc/style.css +++ /dev/null @@ -1,5 +0,0 @@ -body { background-color: #AEBECE } -h1, h2, h3, h4 { text-align: center } -h1, h2, h3, h4, strong { color: #900090 } -pre { background-color: #CCCCCC } -table, th, td { border: 1px solid black ; border-collapse: collapse } diff --git a/doc/www.do b/doc/www.do new file mode 100644 index 0000000000000000000000000000000000000000..38a0fd94b9e3d13555155b7ae9e978476e4736e3620a2a136a50b089a5cc82a4 --- /dev/null +++ b/doc/www.do @@ -0,0 +1,16 @@ +html=nncp.html +redo $html +cp -a .well-known $html/ +cp -a download $html/ +cp ../PUBKEY-* $html/ +( + cd $html/download + export ATOM_ID="e33cb83e-bf33-46f8-b9b1-6115f46e1218" + export NAME=NNCP + export BASE_URL=http://www.nncpgo.org/download + export AUTHOR_EMAIL=releases@nncpgo.org + ~/work/releases-feed/releases.atom.zsh +) +perl -i -npe 'print "\n" if /^<\/head>/' $html/Tarballs.html +find nncp.html -type d -exec chmod 755 {} + +find nncp.html -type f -exec chmod 644 {} + diff --git a/install b/install new file mode 100755 index 0000000000000000000000000000000000000000..653f26a7b2c56bf890e33439b9fb7b4716c19947c69627df38bf8a44f7e4bc4e --- /dev/null +++ b/install @@ -0,0 +1,18 @@ +#!/bin/sh -e + +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 +done + +mkdir -p "$INFODIR" +cp -f doc/nncp.info "$INFODIR" +chmod 644 "$INFODIR"/nncp.info + +mkdir -p "$DOCDIR" +cp -f -L AUTHORS NEWS NEWS.RU README README.RU THANKS $DOCDIR +chmod 644 "$DOCDIR"/* diff --git a/install-strip b/install-strip new file mode 100755 index 0000000000000000000000000000000000000000..cf158686af8d1497301968fd31a1158b7d2fffec73be5755f8687e71266cc19e --- /dev/null +++ b/install-strip @@ -0,0 +1,9 @@ +#!/bin/sh -e + +root="$(realpath -- $(dirname "$0"))" +cd "$root" +./install +. ./config +for cmd in `cat bin/cmd.list` ; do + strip "$BINDIR"/$cmd +done diff --git a/install-strip.do b/install-strip.do deleted file mode 100644 index 616a0b3c4a814f9a5d712c2f0bef600a7bb330ae1cdc86a73d0f80801c2255cc..0000000000000000000000000000000000000000 --- a/install-strip.do +++ /dev/null @@ -1,5 +0,0 @@ -redo-ifchange config install -. ./config -for cmd in `cat bin/cmd.list` ; do - strip $BINDIR/$cmd -done diff --git a/install.do b/install.do deleted file mode 100644 index 209e5abdcc9cf689e8010fd48087fd909efc418c433e66c829586c447192d669..0000000000000000000000000000000000000000 --- a/install.do +++ /dev/null @@ -1,16 +0,0 @@ -redo-ifchange config bin/all doc/nncp.info -. ./config - -mkdir -p $BINDIR -for cmd in `cat bin/cmd.list` ; do - cp -f bin/$cmd $BINDIR - chmod 755 $BINDIR/$cmd -done - -mkdir -p $INFODIR -cp -f doc/nncp.info $INFODIR -chmod 644 $INFODIR/nncp.info - -mkdir -p $DOCDIR -cp -f -L AUTHORS NEWS NEWS.RU README README.RU THANKS $DOCDIR -chmod 644 $DOCDIR/* diff --git a/makedist b/makedist index 76fbdd8a636fba7377f82870497a4288edb42a6a35295c52d309ea17a7e972fa..79c82f393b8194cdbac51a1808b496194e6336a5b19d927ee6837db7a33428d0 100755 --- a/makedist +++ b/makedist @@ -1,5 +1,6 @@ #!/bin/sh -ex +PATH=$HOME/work/meta4ra/contrib:$PATH cur=$(pwd) tmp=$(mktemp -d) release=$1 @@ -8,7 +9,7 @@ git clone . $tmp/nncp-$release cd $tmp/nncp-$release git checkout v$release -redo VERSION +./version > VERSION cd src go mod vendor modvendor -v -copy="**/*_test.go **/words.go **/README.md **/main.go" @@ -35,9 +36,6 @@ -name .travis.yml -o \ -name .goreleaser.yml -o \ -name .gitattributes \) -delete -mkdir contrib -cp ~/work/redo/apenwarr/minimal/do contrib/do - cat > doc/download.texi < "$tarball".asc -meta4-create -fn "$tarball" -mtime "$tarball" -sig "$tarball".asc \ +ssh-keygen -Y sign -f ~/.ssh/sign/releases@nncpgo.org -n file $tarball +gpg --armor --detach-sign --sign --local-user releases@nncpgo.org "$tarball" +meta4-create -fn "$tarball" -mtime "$tarball" \ + -sig-pgp "$tarball".asc -sig-ssh "$tarball".sig \ http://www.nncpgo.org/download/"$tarball" \ http://y.www.nncpgo.org/download/"$tarball" \ https://nncp.mirrors.quux.org/download/"$tarball" < "$tarball" > "$tarball".meta4 @@ -133,15 +128,16 @@ size=$(( $(stat -f %z $tarball) / 1024 )) release_date=$(date "+%Y-%m-%d") -mv -v $tmp/"$tarball" $tmp/"$tarball".sig $tmp/"$tarball".meta4 $cur/doc/download +mv -v $tmp/"$tarball" $tmp/"$tarball".asc $tmp/"$tarball".sig $tmp/"$tarball".meta4 $cur/doc/download release_underscored=`echo $release | tr . _` cat < -Fingerprint: 92C2 F0AE FE73 208E 46BF F3DE 2B25 868E 75A1 A953 +OpenPGP key: 92C2 F0AE FE73 208E 46BF F3DE 2B25 868E 75A1 A953 + NNCP releases +OpenSSH key: SHA256:FRiWawVNBkyS3jFn8uZ/JlT+PWKSFbhWe5XSixp1+SY There are mirrors where you can also get the source code tarballs: http://www.nncpgo.org/Mirrors.html @@ -234,10 +231,11 @@ Исходный код и его подпись для этой версии находятся здесь: http://www.nncpgo.org/download/nncp-${release}.tar.xz ($size KiB) - http://www.nncpgo.org/download/nncp-${release}.tar.xz.sig + http://www.nncpgo.org/download/nncp-${release}.tar.xz.asc -Идентификатор GPG ключа: 0x2B25868E75A1A953 NNCP releases -Отпечаток: 92C2 F0AE FE73 208E 46BF F3DE 2B25 868E 75A1 A953 +OpenPGP ключ: 92C2 F0AE FE73 208E 46BF F3DE 2B25 868E 75A1 A953 + NNCP releases +OpenSSH ключ: SHA256:FRiWawVNBkyS3jFn8uZ/JlT+PWKSFbhWe5XSixp1+SY Есть и зеркала где вы также можете получить архивы с исходным кодом: http://www.nncpgo.org/Mirrors.html diff --git a/src/call.go b/src/call.go index 6c0c651048b3adcd998d7215d76f0702a8b384c2407665a9c0d9e61493e42def..ccbbe42ce4bc3fe12000ddde862bfce93cbba0f5459cd99d40552a27d33d4862 100644 --- a/src/call.go +++ b/src/call.go @@ -51,6 +51,7 @@ AutoTossNoExec bool AutoTossNoTrns bool AutoTossNoArea bool AutoTossNoACK bool + AutoTossGenACK bool } func (ctx *Ctx) CallNode( diff --git a/src/cfg.go b/src/cfg.go index 62074d2be8773dcf6a88924b7291fafc11ca48d1c3109cd0ff07fd1d09898b5f..e7cb0d9dee910db95d72a2639fe2ab968e1ca9be4d28528cc99dd6d9bd2b6676 100644 --- a/src/cfg.go +++ b/src/cfg.go @@ -56,6 +56,7 @@ NoisePub *string `json:"noisepub,omitempty"` Incoming *string `json:"incoming,omitempty"` Exec map[string][]string `json:"exec,omitempty"` Freq *NodeFreqJSON `json:"freq,omitempty"` + ACK *NodeACKJSON `json:"ack,omitempty"` Via []string `json:"via,omitempty"` Calls []CallJSON `json:"calls,omitempty"` @@ -74,6 +75,11 @@ MinSize *uint64 `json:"minsize,omitempty"` MaxSize *uint64 `json:"maxsize,omitempty"` } +type NodeACKJSON struct { + MinSize *uint64 `json:"minsize,omitempty"` + Nice *string `json:"nice,omitempty"` +} + type CallJSON struct { Cron string `json:"cron"` Nice *string `json:"nice,omitempty"` @@ -94,6 +100,8 @@ AutoTossNoFreq bool `json:"autotoss-nofreq,omitempty"` AutoTossNoExec bool `json:"autotoss-noexec,omitempty"` AutoTossNoTrns bool `json:"autotoss-notrns,omitempty"` AutoTossNoArea bool `json:"autotoss-noarea,omitempty"` + AutoTossNoACK bool `json:"autotoss-noack,omitempty"` + AutoTossGenACK bool `json:"autotoss-gen-ack,omitempty"` } type NodeOurJSON struct { @@ -220,6 +228,20 @@ freqMaxSize = int64(*f.MaxSize) * 1024 } } + ackNice := uint8(255) + var ackMinSize int64 + if cfg.ACK != nil { + if cfg.ACK.Nice != nil { + ackNice, err = NicenessParse(*cfg.ACK.Nice) + if err != nil { + return nil, err + } + } + if cfg.ACK.MinSize != nil { + ackMinSize = int64(*cfg.ACK.MinSize) * 1024 + } + } + defRxRate := 0 if cfg.RxRate != nil && *cfg.RxRate > 0 { defRxRate = *cfg.RxRate @@ -317,6 +339,8 @@ call.AutoTossNoFreq = callCfg.AutoTossNoFreq call.AutoTossNoExec = callCfg.AutoTossNoExec call.AutoTossNoTrns = callCfg.AutoTossNoTrns call.AutoTossNoArea = callCfg.AutoTossNoArea + call.AutoTossNoACK = callCfg.AutoTossNoACK + call.AutoTossGenACK = callCfg.AutoTossGenACK calls = append(calls, &call) } @@ -332,6 +356,8 @@ FreqPath: freqPath, FreqChunked: freqChunked, FreqMinSize: freqMinSize, FreqMaxSize: freqMaxSize, + ACKNice: ackNice, + ACKMinSize: ackMinSize, Calls: calls, Addrs: cfg.Addrs, RxRate: defRxRate, diff --git a/src/cfgdir.go b/src/cfgdir.go index a254b53bc68b3a6af9d07bef5ed3ec6b31e051f7b58de407fe78a47f1774a7d3..f46902d2f06cddfeb36645005dd6a1286f6ce0c9f0e9409691477ad88a876dca 100644 --- a/src/cfgdir.go +++ b/src/cfgdir.go @@ -260,6 +260,24 @@ return } } + if n.ACK != nil { + if err = cfgDirMkdir(dst, "neigh", name, "ack"); err != nil { + return + } + if err = cfgDirSave( + n.ACK.MinSize, + dst, "neigh", name, "ack", "minsize", + ); err != nil { + return + } + if err = cfgDirSave( + n.ACK.Nice, + dst, "neigh", name, "ack", "nice", + ); err != nil { + return + } + } + if len(n.Via) > 0 { if err = cfgDirSave( strings.Join(n.Via, "\n"), @@ -372,6 +390,16 @@ if err = cfgDirTouch(dst, "neigh", name, "calls", is, "autotoss-noarea"); err != nil { return } } + if call.AutoTossNoACK { + if err = cfgDirTouch(dst, "neigh", name, "calls", is, "autotoss-noack"); err != nil { + return + } + } + if call.AutoTossGenACK { + if err = cfgDirTouch(dst, "neigh", name, "calls", is, "autotoss-gen-ack"); err != nil { + return + } + } } } @@ -689,6 +717,23 @@ node.Freq.MaxSize = &i } } + if cfgDirExists(src, "neigh", n, "ack") { + node.ACK = &NodeACKJSON{} + i64, err := cfgDirLoadIntOpt(src, "neigh", n, "ack", "minsize") + if err != nil { + return nil, err + } + if i64 != nil { + i := uint64(*i64) + node.ACK.MinSize = &i + } + if node.ACK.Nice, err = cfgDirLoadOpt( + src, "neigh", n, "ack", "nice", + ); err != nil { + return nil, err + } + } + via, err := cfgDirLoadOpt(src, "neigh", n, "via") if err != nil { return nil, err @@ -855,6 +900,12 @@ call.AutoTossNoTrns = true } if cfgDirExists(src, "neigh", n, "calls", is, "autotoss-noarea") { call.AutoTossNoArea = true + } + if cfgDirExists(src, "neigh", n, "calls", is, "autotoss-noack") { + call.AutoTossNoACK = true + } + if cfgDirExists(src, "neigh", n, "calls", is, "autotoss-gen-ack") { + call.AutoTossGenACK = true } node.Calls = append(node.Calls, call) } diff --git a/src/cmd/nncp-ack/main.go b/src/cmd/nncp-ack/main.go index 4d4aa3af893968bba27ff4eeed869bb6d360b57133c31da8138c8f75788b1e29..31a4ba301d0d2ba9b463fe400cb0df81a4c946ecc174124561526f5f809453ad 100644 --- a/src/cmd/nncp-ack/main.go +++ b/src/cmd/nncp-ack/main.go @@ -34,7 +34,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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]) @@ -45,9 +44,10 @@ } func main() { var ( - cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") - niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq), "Outbound packet niceness") - minSizeRaw = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB") + cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") + niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq), + "Outbound packet niceness") + minSizeRaw = flag.Int64("minsize", -1, "Minimal required resulting packet size, in KiB") viaOverride = flag.String("via", "", "Override Via path to destination node (ignored with -all)") spoolPath = flag.String("spool", "", "Override path to spool") logPath = flag.String("log", "", "Override path to logfile") @@ -94,7 +94,6 @@ log.Fatalln("Config lacks private keys") } ctx.Umask() - minSize := int64(*minSizeRaw) * 1024 var nodes []*nncp.Node if *nodesRaw != "" { @@ -130,6 +129,14 @@ usage() os.Exit(1) } nncp.ViaOverride(*viaOverride, ctx, nodes[0]) + + var minSize int64 + if *minSizeRaw < 0 { + minSize = nodes[0].ACKMinSize + } else if *minSizeRaw > 0 { + minSize = *minSizeRaw * 1024 + } + pktName, err := ctx.TxACK(nodes[0], nice, *pktRaw, minSize) if err != nil { log.Fatalln(err) @@ -140,6 +147,12 @@ } isBad := false for _, node := range nodes { + var minSize int64 + if *minSizeRaw < 0 { + minSize = node.ACKMinSize + } else if *minSizeRaw > 0 { + minSize = *minSizeRaw * 1024 + } for job := range ctx.Jobs(node.Id, nncp.TRx) { pktName := filepath.Base(job.Path) sender := ctx.Neigh[*job.PktEnc.Sender] diff --git a/src/cmd/nncp-bundle/main.go b/src/cmd/nncp-bundle/main.go index 64ab36f3d60cb6240c87f9ff0bbb2ef3624f2e5177313f1914a9fdbae926dc59..d36a2ef8e76fa3f77e81bcf62b662c431255fa5e0d0ce67f32dcc9f7c08d5aa7 100644 --- a/src/cmd/nncp-bundle/main.go +++ b/src/cmd/nncp-bundle/main.go @@ -38,7 +38,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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]) diff --git a/src/cmd/nncp-call/main.go b/src/cmd/nncp-call/main.go index 8e4e7ad20ff25781479a980c90cb0f0985c3cabfebf895ce6b67639412f58b04..90d5b5c0a24d3c9dcb16981426203470acafb443b5af6572a40c040d861d78f5 100644 --- a/src/cmd/nncp-call/main.go +++ b/src/cmd/nncp-call/main.go @@ -32,7 +32,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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:") @@ -61,17 +60,29 @@ debug = flag.Bool("debug", false, "Print debug messages") version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") - onlineDeadlineSec = flag.Uint("onlinedeadline", 0, "Override onlinedeadline option") - maxOnlineTimeSec = flag.Uint("maxonlinetime", 0, "Override maxonlinetime option") + 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") - autoTossNoArea = flag.Bool("autotoss-noarea", false, "Do not process \"area\" packets during tossing") - autoTossNoACK = flag.Bool("autotoss-noack", false, "Do not process \"ack\" 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") + autoTossNoArea = flag.Bool("autotoss-noarea", false, + "Do not process \"area\" packets during tossing") + autoTossNoACK = flag.Bool("autotoss-noack", false, + "Do not process \"ack\" packets during tossing") + autoTossGenACK = flag.Bool("autotoss-gen-ack", false, + "Generate ACK packets") ) log.SetFlags(log.Lshortfile) flag.Usage = usage @@ -211,14 +222,17 @@ var autoTossBadCode chan bool if *autoToss { autoTossFinish, autoTossBadCode = ctx.AutoToss( node.Id, - nice, - *autoTossDoSeen, - *autoTossNoFile, - *autoTossNoFreq, - *autoTossNoExec, - *autoTossNoTrns, - *autoTossNoArea, - *autoTossNoACK, + &nncp.TossOpts{ + Nice: nice, + DoSeen: *autoTossDoSeen, + NoFile: *autoTossNoFile, + NoFreq: *autoTossNoFreq, + NoExec: *autoTossNoExec, + NoTrns: *autoTossNoTrns, + NoArea: *autoTossNoArea, + NoACK: *autoTossNoACK, + GenACK: *autoTossGenACK, + }, ) } diff --git a/src/cmd/nncp-caller/main.go b/src/cmd/nncp-caller/main.go index 9d029642ac959f608c1e5a986c390995ff3815cfc6a7393b1b4eace9b86a2af3..68b2e1efe6da3c9f7e8c97bf7067da52c49dd76dd70fd53c105d895c777183f3 100644 --- a/src/cmd/nncp-caller/main.go +++ b/src/cmd/nncp-caller/main.go @@ -33,7 +33,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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:") @@ -52,14 +51,24 @@ 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") - autoTossNoArea = flag.Bool("autotoss-noarea", false, "Do not process \"area\" packets during tossing") - autoTossNoACK = flag.Bool("autotoss-noack", false, "Do not process \"ack\" 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") + autoTossNoArea = flag.Bool("autotoss-noarea", false, + "Do not process \"area\" packets during tossing") + autoTossNoACK = flag.Bool("autotoss-noack", false, + "Do not process \"ack\" packets during tossing") + autoTossGenACK = flag.Bool("autotoss-gen-ack", false, + "Generate ACK packets") ) log.SetFlags(log.Lshortfile) flag.Usage = usage @@ -213,14 +222,17 @@ var autoTossBadCode chan bool if call.AutoToss || *autoToss { autoTossFinish, autoTossBadCode = ctx.AutoToss( node.Id, - call.Nice, - call.AutoTossDoSeen || *autoTossDoSeen, - call.AutoTossNoFile || *autoTossNoFile, - call.AutoTossNoFreq || *autoTossNoFreq, - call.AutoTossNoExec || *autoTossNoExec, - call.AutoTossNoTrns || *autoTossNoTrns, - call.AutoTossNoArea || *autoTossNoArea, - call.AutoTossNoACK || *autoTossNoACK, + &nncp.TossOpts{ + Nice: call.Nice, + DoSeen: call.AutoTossDoSeen || *autoTossDoSeen, + NoFile: call.AutoTossNoFile || *autoTossNoFile, + NoFreq: call.AutoTossNoFreq || *autoTossNoFreq, + NoExec: call.AutoTossNoExec || *autoTossNoExec, + NoTrns: call.AutoTossNoTrns || *autoTossNoTrns, + NoArea: call.AutoTossNoArea || *autoTossNoArea, + NoACK: call.AutoTossNoACK || *autoTossNoACK, + GenACK: call.AutoTossGenACK || *autoTossGenACK, + }, ) } diff --git a/src/cmd/nncp-cfgdir/main.go b/src/cmd/nncp-cfgdir/main.go index 7a59f473eb02ab99fe461d09af4edf76f9ec498e0c19fd09040cb9425f134cb4..895b08ddee3784c92a1c4aceac81040c4fab7482292b6a9515086c98ce3fba96 100644 --- a/src/cmd/nncp-cfgdir/main.go +++ b/src/cmd/nncp-cfgdir/main.go @@ -29,7 +29,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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]) diff --git a/src/cmd/nncp-cfgenc/main.go b/src/cmd/nncp-cfgenc/main.go index ebfedc62a9b2c18fbec07733de5a93a81c08c8a84cd1dc4ffca157f6fabcacf7..d8af83ddfe90a9692e4adb73876f28570f7f8fa07ea0f465607cb9232851ea36 100644 --- a/src/cmd/nncp-cfgenc/main.go +++ b/src/cmd/nncp-cfgenc/main.go @@ -33,7 +33,6 @@ "golang.org/x/term" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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]) diff --git a/src/cmd/nncp-cfgmin/main.go b/src/cmd/nncp-cfgmin/main.go index dd334ee0bc2c2ef313f210b9b408b6172d2ea87ab9e9107bc92f711ba4b9906c..94daf3e3bd7e3d671a60de9f849ab09310d1c1f7caa2931d81bf16257c4bd79e 100644 --- a/src/cmd/nncp-cfgmin/main.go +++ b/src/cmd/nncp-cfgmin/main.go @@ -29,7 +29,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-cfgnew/main.go b/src/cmd/nncp-cfgnew/main.go index e17da8ba2136ad827219fe24b8125844b1e1284fc84a7e7b3b48df114f0c69c3..99e324c230ecd7f41948a22d36ab957eef19523913cd7f53e99f18196326a5d7 100644 --- a/src/cmd/nncp-cfgnew/main.go +++ b/src/cmd/nncp-cfgnew/main.go @@ -36,7 +36,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:") flag.PrintDefaults() } diff --git a/src/cmd/nncp-check/main.go b/src/cmd/nncp-check/main.go index e9c5e195fedd5725c3cddefa53f77125025ac4971828b66a846b91a82d936a89..fde623730e76d1bce74b46e15772f42748642f01ceff3fffd70f12060d6ccbc7 100644 --- a/src/cmd/nncp-check/main.go +++ b/src/cmd/nncp-check/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-cronexpr/main.go b/src/cmd/nncp-cronexpr/main.go index 705f37dde02abca09b67dc0897b3dcb52c61c4f88292eb81dc8d662287ba60bd..7d8f6c3a13fc7981197d1de2fc09a9fe8cfaa2426046d8e0540c9e71b5a4913d 100644 --- a/src/cmd/nncp-cronexpr/main.go +++ b/src/cmd/nncp-cronexpr/main.go @@ -31,7 +31,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-daemon/main.go b/src/cmd/nncp-daemon/main.go index 3eacb1588333058ad1a7a824b9d06f37c15178340c729027064d781027ce72b9..7c037077652221d92cf6af195a32a8ec472d3e831ac017e4459c0c0359aef203 100644 --- a/src/cmd/nncp-daemon/main.go +++ b/src/cmd/nncp-daemon/main.go @@ -36,7 +36,6 @@ "golang.org/x/net/netutil" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) fmt.Fprint(os.Stderr, "nncp-daemon -- TCP daemon\n\n") fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0]) flag.PrintDefaults() @@ -138,7 +137,8 @@ niceRaw = flag.String("nice", nncp.NicenessFmt(255), "Minimal required niceness") bind = flag.String("bind", "[::]:5400", "Address to bind to") ucspi = flag.Bool("ucspi", false, "Is it started as UCSPI-TCP server") inetd = flag.Bool("inetd", false, "Obsolete, use -ucspi") - yggdrasil = flag.String("yggdrasil", "", "Start Yggdrasil listener: yggdrasils://PRV[:PORT]?[bind=BIND][&pub=PUB][&peer=PEER][&mcast=REGEX[:PORT]]") + yggdrasil = flag.String("yggdrasil", "", + "Start Yggdrasil listener: yggdrasils://PRV[:PORT]?[bind=BIND][&pub=PUB][&peer=PEER][&mcast=REGEX[:PORT]]") maxConn = flag.Int("maxconn", 128, "Maximal number of simultaneous connections") noCK = flag.Bool("nock", false, "Do no checksum checking") mcdOnce = flag.Bool("mcd-once", false, "Send MCDs once and quit") @@ -151,14 +151,24 @@ 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") - autoTossNoArea = flag.Bool("autotoss-noarea", false, "Do not process \"area\" packets during tossing") - autoTossNoACK = flag.Bool("autotoss-noack", false, "Do not process \"ack\" 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") + autoTossNoArea = flag.Bool("autotoss-noarea", false, + "Do not process \"area\" packets during tossing") + autoTossNoACK = flag.Bool("autotoss-noack", false, + "Do not process \"ack\" packets during tossing") + autoTossGenACK = flag.Bool("autotoss-gen-ack", false, + "Generate ACK packets") ) log.SetFlags(log.Lshortfile) flag.Usage = usage @@ -211,14 +221,17 @@ var autoTossBadCode chan bool if *autoToss && nodeId != nil { autoTossFinish, autoTossBadCode = ctx.AutoToss( nodeId, - nice, - *autoTossDoSeen, - *autoTossNoFile, - *autoTossNoFreq, - *autoTossNoExec, - *autoTossNoTrns, - *autoTossNoArea, - *autoTossNoACK, + &nncp.TossOpts{ + Nice: nice, + DoSeen: *autoTossDoSeen, + NoFile: *autoTossNoFile, + NoFreq: *autoTossNoFreq, + NoExec: *autoTossNoExec, + NoTrns: *autoTossNoTrns, + NoArea: *autoTossNoArea, + NoACK: *autoTossNoACK, + GenACK: *autoTossGenACK, + }, ) } <-nodeIdC // call completion @@ -298,14 +311,17 @@ var autoTossBadCode chan bool if *autoToss && nodeId != nil { autoTossFinish, autoTossBadCode = ctx.AutoToss( nodeId, - nice, - *autoTossDoSeen, - *autoTossNoFile, - *autoTossNoFreq, - *autoTossNoExec, - *autoTossNoTrns, - *autoTossNoArea, - *autoTossNoACK, + &nncp.TossOpts{ + Nice: nice, + DoSeen: *autoTossDoSeen, + NoFile: *autoTossNoFile, + NoFreq: *autoTossNoFreq, + NoExec: *autoTossNoExec, + NoTrns: *autoTossNoTrns, + NoArea: *autoTossNoArea, + NoACK: *autoTossNoACK, + GenACK: *autoTossGenACK, + }, ) } <-nodeIdC // call completion diff --git a/src/cmd/nncp-exec/main.go b/src/cmd/nncp-exec/main.go index 201b0c8f06f4ca0271baf657fd2aad94d47c8f04b9d458f88d73dd5e0e5fd96b..41f5d0deec5da83c53931e447016f4fb259bbe311aba0204bb932cafaf767e36 100644 --- a/src/cmd/nncp-exec/main.go +++ b/src/cmd/nncp-exec/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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", @@ -40,21 +39,23 @@ } func main() { var ( - noCompress = flag.Bool("nocompress", false, "Do not compress input data") - cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") - niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceExec), "Outbound packet niceness") - replyNiceRaw = flag.String("replynice", nncp.NicenessFmt(nncp.DefaultNiceFile), "Possible reply packet niceness") - minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB") - argMaxSize = flag.Uint64("maxsize", 0, "Maximal allowable resulting packet size, in KiB") - viaOverride = flag.String("via", "", "Override Via path to destination node") - spoolPath = flag.String("spool", "", "Override path to spool") - logPath = flag.String("log", "", "Override path to logfile") - quiet = flag.Bool("quiet", false, "Print only errors") - showPrgrs = flag.Bool("progress", false, "Force progress showing") - omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing") - debug = flag.Bool("debug", false, "Print debug messages") - version = flag.Bool("version", false, "Print version information") - warranty = flag.Bool("warranty", false, "Print warranty information") + noCompress = flag.Bool("nocompress", false, "Do not compress input data") + cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") + niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceExec), + "Outbound packet niceness") + replyNiceRaw = flag.String("replynice", nncp.NicenessFmt(nncp.DefaultNiceFile), + "Possible reply packet niceness") + minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB") + argMaxSize = flag.Uint64("maxsize", 0, "Maximal allowable resulting packet size, in KiB") + viaOverride = flag.String("via", "", "Override Via path to destination node") + spoolPath = flag.String("spool", "", "Override path to spool") + logPath = flag.String("log", "", "Override path to logfile") + quiet = flag.Bool("quiet", false, "Print only errors") + showPrgrs = flag.Bool("progress", false, "Force progress showing") + omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing") + debug = flag.Bool("debug", false, "Print debug messages") + version = flag.Bool("version", false, "Print version information") + warranty = flag.Bool("warranty", false, "Print warranty information") ) log.SetFlags(log.Lshortfile) flag.Usage = usage diff --git a/src/cmd/nncp-file/main.go b/src/cmd/nncp-file/main.go index a14919e0d4cd551773c32abe6216f34b9373858879523eca9ffaf27a7197c3be..4422588ac3d60c09ad53fb962d5d5e9bac0d29ef84fe6019aab444bbbdbdd1d3 100644 --- a/src/cmd/nncp-file/main.go +++ b/src/cmd/nncp-file/main.go @@ -29,7 +29,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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", @@ -46,8 +45,9 @@ } func main() { var ( - cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") - niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile), "Outbound packet niceness") + cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") + niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile), + "Outbound packet niceness") argMinSize = flag.Int64("minsize", -1, "Minimal required resulting packet size, in KiB") argMaxSize = flag.Uint64("maxsize", 0, "Maximal allowable resulting packets size, in KiB") argChunkSize = flag.Int64("chunked", -1, "Split file on specified size chunks, in KiB") diff --git a/src/cmd/nncp-freq/main.go b/src/cmd/nncp-freq/main.go index e2aaf128deb0c456b0e6ce8c13a4f4afbf50a621d36c9ee727aa956786ef883b..82dee7ca17c67482d7a7260c59e03be120ee4361e6ca2f6e41596ca9dbb1386e 100644 --- a/src/cmd/nncp-freq/main.go +++ b/src/cmd/nncp-freq/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() @@ -38,19 +37,21 @@ } func main() { var ( - cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") - niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq), "Outbound packet niceness") - replyNiceRaw = flag.String("replynice", nncp.NicenessFmt(nncp.DefaultNiceFile), "Reply file packet niceness") - minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB") - viaOverride = flag.String("via", "", "Override Via path to destination node") - spoolPath = flag.String("spool", "", "Override path to spool") - logPath = flag.String("log", "", "Override path to logfile") - quiet = flag.Bool("quiet", false, "Print only errors") - showPrgrs = flag.Bool("progress", false, "Force progress showing") - omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing") - debug = flag.Bool("debug", false, "Print debug messages") - version = flag.Bool("version", false, "Print version information") - warranty = flag.Bool("warranty", false, "Print warranty information") + cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") + niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFreq), + "Outbound packet niceness") + replyNiceRaw = flag.String("replynice", nncp.NicenessFmt(nncp.DefaultNiceFile), + "Reply file packet niceness") + minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB") + viaOverride = flag.String("via", "", "Override Via path to destination node") + spoolPath = flag.String("spool", "", "Override path to spool") + logPath = flag.String("log", "", "Override path to logfile") + quiet = flag.Bool("quiet", false, "Print only errors") + showPrgrs = flag.Bool("progress", false, "Force progress showing") + omitPrgrs = flag.Bool("noprogress", false, "Omit progress showing") + debug = flag.Bool("debug", false, "Print debug messages") + version = flag.Bool("version", false, "Print version information") + warranty = flag.Bool("warranty", false, "Print warranty information") ) log.SetFlags(log.Lshortfile) flag.Usage = usage diff --git a/src/cmd/nncp-hash/main.go b/src/cmd/nncp-hash/main.go index fad8841957b12fcaf9289889f8d072ce7a8585f3ae1c5cf6b9b8afcf1d9bcfbe..4649f12c45c4052a96142408f6f80f084871af98a137c17796a3875c7a8f9add 100644 --- a/src/cmd/nncp-hash/main.go +++ b/src/cmd/nncp-hash/main.go @@ -32,7 +32,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-log/main.go b/src/cmd/nncp-log/main.go index 60992cc5a3749e83e75a653b0826409de80ddc3849dafac4b845c268a9c7483d..6a380ec356e1c449556746604e92459cf0ddaf960e87b04ca93da0c7ba28d93f 100644 --- a/src/cmd/nncp-log/main.go +++ b/src/cmd/nncp-log/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/recfile" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) fmt.Fprint(os.Stderr, "nncp-log -- read logs\n\n") fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0]) flag.PrintDefaults() diff --git a/src/cmd/nncp-pkt/main.go b/src/cmd/nncp-pkt/main.go index 92f8aee97282a964fb15192ee0dd145bc83476b96e5cc197b982ecc0ebddbb85..cc9f436a33a23bd50ad8159bf9d9b2fb6b82050fd0c296587c3f79910f39f751 100644 --- a/src/cmd/nncp-pkt/main.go +++ b/src/cmd/nncp-pkt/main.go @@ -33,7 +33,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-reass/main.go b/src/cmd/nncp-reass/main.go index 2942560cacf3b074b480c42d5d573f97f1e2c632b89732eb449ec7de925a6245..06bc805e8181ebc37d64bc33e6456eb018d2a072e817642e6bd2975b62985b4d 100644 --- a/src/cmd/nncp-reass/main.go +++ b/src/cmd/nncp-reass/main.go @@ -40,7 +40,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() @@ -301,16 +300,16 @@ ctx.LogE("reass", nncp.LEs{{K: "Path", V: dirPath}}, err, logMsg) return nil } defer dir.Close() - fis, err := dir.Readdir(0) + entries, err := dir.ReadDir(0) dir.Close() if err != nil { ctx.LogE("reass", nncp.LEs{{K: "Path", V: dirPath}}, err, logMsg) return nil } metaPaths := make([]string, 0) - for _, fi := range fis { - if strings.HasSuffix(fi.Name(), nncp.ChunkedSuffixMeta) { - metaPaths = append(metaPaths, filepath.Join(dirPath, fi.Name())) + for _, entry := range entries { + if strings.HasSuffix(entry.Name(), nncp.ChunkedSuffixMeta) { + metaPaths = append(metaPaths, filepath.Join(dirPath, entry.Name())) } } return metaPaths diff --git a/src/cmd/nncp-rm/main.go b/src/cmd/nncp-rm/main.go index 99e59171df9c1dac56d8cb081fa4bd9f8fb1e42e23766abe25883723096e0836..ba2c976c98be9b014f837b483dd52bc10b5ac84706229383ac0a37abcad98706 100644 --- a/src/cmd/nncp-rm/main.go +++ b/src/cmd/nncp-rm/main.go @@ -36,7 +36,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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]) @@ -45,7 +44,8 @@ fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} -seen\n", os.Args[0]) fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} -nock\n", os.Args[0]) fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} -area\n", os.Args[0]) fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} {-rx|-tx} [-hdr]\n", os.Args[0]) - fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} -pkt < ...\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s [options] {-all|-node NODE} -pkt < ...\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s [options] {-all|-node NODE} -ack\n", os.Args[0]) fmt.Fprintln(os.Stderr, "-older option's time units are: (s)econds, (m)inutes, (h)ours, (d)ays") fmt.Fprintln(os.Stderr, "Options:") flag.PrintDefaults() @@ -68,6 +68,7 @@ doArea = flag.Bool("area", false, "Remove only area/* seen files") older = flag.String("older", "", "XXX{smhd}: only older than XXX number of time units") dryRun = flag.Bool("dryrun", false, "Do not actually remove files") doPkt = flag.Bool("pkt", false, "Remove only that packets") + doACK = flag.Bool("ack", false, "Remove ACK packets from outbound") spoolPath = flag.String("spool", "", "Override path to spool") quiet = flag.Bool("quiet", false, "Print only errors") debug = flag.Bool("debug", false, "Print debug messages") @@ -251,9 +252,11 @@ if err != nil { return err } if now.Sub(info.ModTime()) < oldBoundary { - ctx.LogD("rm-skip", nncp.LEs{{K: "File", V: pth}}, func(les nncp.LEs) string { - return fmt.Sprintf("File %s: too fresh, skipping", pth) - }) + ctx.LogD("rm-skip", nncp.LEs{{K: "File", V: pth}}, + func(les nncp.LEs) string { + return fmt.Sprintf("File %s: too fresh, skipping", pth) + }, + ) continue } if (*doNoCK && strings.HasSuffix(entry.Name(), nncp.NoCKSuffix)) || @@ -293,7 +296,9 @@ log.Fatalln("Can not remove:", err) } } removeSub := func(p string) error { - return filepath.Walk(p, func(path string, info os.FileInfo, err error) error { + return filepath.Walk(p, func( + path string, info os.FileInfo, err error, + ) error { if err != nil { if errors.Is(err, fs.ErrNotExist) { return nil @@ -389,6 +394,47 @@ return os.Remove(path) }); err != nil { log.Fatalln("Can not remove:", err) } + } + if *doACK { + dirPath := filepath.Join( + ctx.Spool, node.Id.String(), string(nncp.TTx), nncp.ACKDir) + dir, err := os.Open(dirPath) + if err != nil { + continue + } + for { + fis, err := dir.ReadDir(1 << 10) + if err != nil { + if err == io.EOF { + break + } + log.Fatalln("Can not read directory:", err) + } + for _, fi := range fis { + for _, pth := range []string{ + filepath.Join( + ctx.Spool, + node.Id.String(), + string(nncp.TTx), + fi.Name(), + ), + filepath.Join(dirPath, fi.Name()), + } { + if err = os.Remove(pth); err == nil { + ctx.LogI( + "rm", + nncp.LEs{{K: "File", V: pth}}, + func(les nncp.LEs) string { + return fmt.Sprintf("File %s: removed", pth) + }, + ) + } else if !errors.Is(err, fs.ErrNotExist) { + log.Fatalln("Can not remove:", pth, ":", err) + } + } + } + } + dir.Close() } } } diff --git a/src/cmd/nncp-stat/main.go b/src/cmd/nncp-stat/main.go index fde377dfe8cbe9f21da67dca4bc492e1734f88a8372f0a1a480ffbe729f2f172..df892ced62f49c1c18eaa3697a34e68c90c8a3bdedf32f84eb4bbb249ede361b 100644 --- a/src/cmd/nncp-stat/main.go +++ b/src/cmd/nncp-stat/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() diff --git a/src/cmd/nncp-toss/main.go b/src/cmd/nncp-toss/main.go index 4cc705f6be12d328a1581ae55dfd524874a7e4e2b28703df2cc96221d83c7ab6..0ce9d1ff005dc3af3efd73a1a1d9b64f8de096c6c69283b71aff1ed3c387cfb2 100644 --- a/src/cmd/nncp-toss/main.go +++ b/src/cmd/nncp-toss/main.go @@ -30,7 +30,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() @@ -50,6 +49,7 @@ noExec = flag.Bool("noexec", false, "Do not process \"exec\" packets") noTrns = flag.Bool("notrns", false, "Do not process \"transitional\" packets") noArea = flag.Bool("noarea", false, "Do not process \"area\" packets") noACK = flag.Bool("noack", false, "Do not process \"ack\" packets") + genACK = flag.Bool("gen-ack", false, "Generate ACK packets") spoolPath = flag.String("spool", "", "Override path to spool") logPath = flag.String("log", "", "Override path to logfile") quiet = flag.Bool("quiet", false, "Print only errors") @@ -110,15 +110,31 @@ } isBad = ctx.Toss( node.Id, nncp.TRx, - nice, - *dryRun, *doSeen, *noFile, *noFreq, *noExec, *noTrns, *noArea, *noACK, + &nncp.TossOpts{ + Nice: nice, + DoSeen: *doSeen, + NoFile: *noFile, + NoFreq: *noFreq, + NoExec: *noExec, + NoTrns: *noTrns, + NoArea: *noArea, + NoACK: *noACK, + GenACK: *genACK, + }, ) || isBad if nodeId == *ctx.SelfId { isBad = ctx.Toss( node.Id, nncp.TTx, - nice, - *dryRun, false, true, true, true, true, *noArea, *noACK, + &nncp.TossOpts{ + Nice: nice, + NoFile: true, + NoFreq: true, + NoExec: true, + NoTrns: true, + NoArea: *noArea, + NoACK: *noACK, + }, ) || isBad } } @@ -150,15 +166,32 @@ for nodeId := range nodeIds { ctx.Toss( nodeId, nncp.TRx, - nice, - *dryRun, *doSeen, *noFile, *noFreq, *noExec, *noTrns, *noArea, *noACK, + &nncp.TossOpts{ + Nice: nice, + DryRun: *dryRun, + DoSeen: *doSeen, + NoFile: *noFile, + NoFreq: *noFreq, + NoExec: *noExec, + NoTrns: *noTrns, + NoArea: *noArea, + NoACK: *noACK, + GenACK: *genACK, + }, ) if *nodeId == *ctx.SelfId { ctx.Toss( nodeId, nncp.TTx, - nice, - *dryRun, false, true, true, true, true, *noArea, *noACK, + &nncp.TossOpts{ + Nice: nice, + NoFile: true, + NoFreq: true, + NoExec: true, + NoTrns: true, + NoArea: *noArea, + NoACK: *noACK, + }, ) } } diff --git a/src/cmd/nncp-trns/main.go b/src/cmd/nncp-trns/main.go index b1433f1cd59d1f5734273f3e6074e1515e3e7e7ec7867ce63da346abdc427e7f..215892f3f2cb0ddac5ca824fddf16121f357d77cfc411fecfaf152cdeda895f1 100644 --- a/src/cmd/nncp-trns/main.go +++ b/src/cmd/nncp-trns/main.go @@ -31,7 +31,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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") @@ -42,8 +41,9 @@ } func main() { var ( - cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") - niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile), "Outbound packet niceness") + cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") + niceRaw = flag.String("nice", nncp.NicenessFmt(nncp.DefaultNiceFile), + "Outbound packet niceness") viaOverride = flag.String("via", "", "Override Via path to destination node") spoolPath = flag.String("spool", "", "Override path to spool") logPath = flag.String("log", "", "Override path to logfile") diff --git a/src/cmd/nncp-xfer/main.go b/src/cmd/nncp-xfer/main.go index df778e8d7e228ef346f7e320a5a7ede811b7c9cd0ff041eb617e79d8a48c84d9..246a5dbaaf0201d5d7e4db58f4ef46fbdd5d8fffc63417fc9313e147be1cb2a9 100644 --- a/src/cmd/nncp-xfer/main.go +++ b/src/cmd/nncp-xfer/main.go @@ -34,7 +34,6 @@ "go.cypherpunks.ru/nncp/v8" ) func usage() { - fmt.Fprint(os.Stderr, nncp.UsageHeader()) 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() @@ -106,7 +105,7 @@ ctx.Umask() selfPath := filepath.Join(flag.Arg(0), ctx.SelfId.String()) isBad := false var dir *os.File - var fis []os.FileInfo + var entries []os.DirEntry var les nncp.LEs var logMsg func(les nncp.LEs) string if *txOnly { @@ -141,7 +140,7 @@ }) isBad = true goto Tx } - fis, err = dir.Readdir(0) + entries, err = dir.ReadDir(0) dir.Close() if err != nil { ctx.LogE("xfer-self-read", les, err, func(les nncp.LEs) string { @@ -150,12 +149,12 @@ }) isBad = true goto Tx } - for _, fi := range fis { - if !fi.IsDir() { + for _, entry := range entries { + if !entry.IsDir() { continue } - nodeId, err := nncp.NodeIdFromString(fi.Name()) - les := append(les, nncp.LE{K: "Node", V: fi.Name()}) + nodeId, err := nncp.NodeIdFromString(entry.Name()) + les := append(les, nncp.LE{K: "Node", V: entry.Name()}) logMsg := func(les nncp.LEs) string { return "Packet transfer, received from " + ctx.NodeName(nodeId) } @@ -177,7 +176,7 @@ return logMsg(les) + ": unknown" }) continue } - dir, err = os.Open(filepath.Join(selfPath, fi.Name())) + dir, err = os.Open(filepath.Join(selfPath, entry.Name())) if err != nil { ctx.LogE("xfer-rx-open", les, err, func(les nncp.LEs) string { return logMsg(les) + ": opening" @@ -195,7 +194,7 @@ isBad = true continue } for _, fiInt := range fisInt { - if !fi.IsDir() { + if fiInt.IsDir() { continue } // Check that it is valid Base32 encoding diff --git a/src/go.mod b/src/go.mod index 86908f029784aaa0e91698a4a7c02a9eaa7941a0d47f28e635153273099e6c04..4aa728b69f3a2ff5e904144b8f75b8a7fb2a5bb6ec69f235326fa53cf617858b 100644 --- a/src/go.mod +++ b/src/go.mod @@ -9,22 +9,22 @@ github.com/fsnotify/fsnotify v1.6.0 github.com/gologme/log v1.3.0 github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 github.com/hjson/hjson-go v3.3.0+incompatible - github.com/klauspost/compress v1.16.5 + github.com/klauspost/compress v1.16.7 github.com/yggdrasil-network/yggdrasil-go v0.4.7 go.cypherpunks.ru/balloon v1.1.1 go.cypherpunks.ru/recfile v0.7.0 - golang.org/x/crypto v0.8.0 - golang.org/x/net v0.9.0 - golang.org/x/sys v0.7.0 - golang.org/x/term v0.7.0 + golang.org/x/crypto v0.12.0 + golang.org/x/net v0.10.0 + golang.org/x/sys v0.11.0 + golang.org/x/term v0.11.0 gvisor.dev/gvisor v0.0.0-20230428223346-f33f75cda699 - lukechampine.com/blake3 v1.1.7 + lukechampine.com/blake3 v1.2.1 ) require ( github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 // indirect github.com/google/btree v1.0.1 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect ) diff --git a/src/go.sum b/src/go.sum index 932f694257fbafc220c7caa60f030267ce115512c3ae063bc53e72f57654306d..6f34f906fc4f135e825e3bd9662b2490ce4048b8cbb2273a158a49e2ac55b401 100644 --- a/src/go.sum +++ b/src/go.sum @@ -18,11 +18,10 @@ github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY= github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/hjson/hjson-go v3.3.0+incompatible h1:Rqr+Ya+0aCJMjaE4s8E9YKvuJLuLVpEvz4ONum52vnI= github.com/hjson/hjson-go v3.3.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -36,19 +35,19 @@ go.cypherpunks.ru/recfile v0.7.0 h1:0R1UnDGKccp7JnC66msslJMlSY02jHx/XkW+ISl0GuY= go.cypherpunks.ru/recfile v0.7.0/go.mod h1:sR+KajB+vzofL3SFVFwKt3Fke0FaCcN1g3YPNAhU3qI= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -57,5 +56,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gvisor.dev/gvisor v0.0.0-20230428223346-f33f75cda699 h1:Ns93L6u6C3xgQY2eodedE2ZgIW8JaQYExfHdACX1BJc= gvisor.dev/gvisor v0.0.0-20230428223346-f33f75cda699/go.mod h1:pzr6sy8gDLfVmDAg8OYrlKvGEHw5C3PGTiBXBTCx76Q= -lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= -lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= diff --git a/src/mcd.go b/src/mcd.go index 5d3924842786633a951500de0e31efabf9b46d2b7fca6ef3a467740656c3ddcf..4c4024b4ad305108ad68bd0352f2be0a5b4876041a10d6776423c3e3e646092e 100644 --- a/src/mcd.go +++ b/src/mcd.go @@ -28,9 +28,7 @@ xdr "github.com/davecgh/go-xdr/xdr2" ) -const ( - MCDPort = 5400 -) +const MCDPort = 5400 type MCD struct { Magic [8]byte diff --git a/src/nncp.go b/src/nncp.go index 60105538c550a58d0980c481b86bf4dfb642aa7ddefe347d7097e53755fc7e91..720f2664fec6d83d7a23be2762df19c1e5441515fe1ad09831c540cb316bc641 100644 --- a/src/nncp.go +++ b/src/nncp.go @@ -24,7 +24,9 @@ "runtime" ) const ( - Warranty = `This program is free software: you can redistribute it and/or modify + Warranty = `Copyright (C) 2016-2023 Sergey Matveev + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. @@ -35,12 +37,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .` + Base32Encoded32Len = 52 ) -const Base32Encoded32Len = 52 - var ( - Version string = "8.8.3" + Version string = "8.9.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) ) @@ -48,13 +49,3 @@ func VersionGet() string { return "NNCP version " + Version + " built with " + runtime.Version() } - -func UsageHeader() string { - return VersionGet() + ` -Copyright (C) 2016-2023 Sergey Matveev -License GPLv3: GNU GPL version 3 -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. - -` -} diff --git a/src/node.go b/src/node.go index 8145d2a197425534fabb5ec638a1826fe72d1e2c748cbe11d2b6ff179c00617c..8f54e33e8844d1479bd8ae24150594c300dcd7ed588e6951b7a0f89702e80906 100644 --- a/src/node.go +++ b/src/node.go @@ -50,6 +50,8 @@ FreqPath *string FreqChunked int64 FreqMinSize int64 FreqMaxSize int64 + ACKNice uint8 + ACKMinSize int64 Via []*NodeId Addrs map[string]string RxRate int diff --git a/src/toss.go b/src/toss.go index cd86f487e14cf90da23f6200102037d6d928897d50205775adcbe25016e22b08..9525ca84ecf2c53c51f9f381cf82b0927005e2fc383ae135dec28e9d79843951 100644 --- a/src/toss.go +++ b/src/toss.go @@ -44,7 +44,21 @@ ) const ( SeenDir = "seen" + ACKDir = "ack" ) + +type TossOpts struct { + Nice uint8 + DryRun bool + DoSeen bool + NoFile bool + NoFreq bool + NoExec bool + NoTrns bool + NoArea bool + NoACK bool + GenACK bool +} func jobPath2Seen(jobPath string) string { return filepath.Join(filepath.Dir(jobPath), SeenDir, filepath.Base(jobPath)) @@ -91,7 +105,7 @@ nice uint8, pktSize uint64, jobPath string, decompressor *zstd.Decoder, - dryRun, doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK bool, + opts *TossOpts, ) error { defer pipeR.Close() sendmail := ctx.Neigh[*ctx.SelfId].Exec["sendmail"] @@ -111,9 +125,36 @@ sender.Name, pktName, humanize.IBytes(pktSize), ) }) + if opts.GenACK && pkt.Type != PktTypeACK { + newPktName, err := ctx.TxACK( + sender, sender.ACKNice, pktName, sender.ACKMinSize, + ) + if err != nil { + ctx.LogE("rx-unmarshal", les, err, func(les LEs) string { + return fmt.Sprintf("Tossing %s/%s: generating ACK", sender.Name, pktName) + }) + return err + } + ackDir := filepath.Join(ctx.Spool, sender.Id.String(), string(TTx), ACKDir) + os.MkdirAll(ackDir, os.FileMode(0777)) + if fd, err := os.Create(filepath.Join(ackDir, newPktName)); err == nil { + fd.Close() + if err = DirSync(ackDir); err != nil { + ctx.LogE("rx-genack", les, err, func(les LEs) string { + return fmt.Sprintf("Tossing %s/%s: genACK", sender.Name, pktName) + }) + return err + } + } else { + ctx.LogE("rx-genack", les, err, func(les LEs) string { + return fmt.Sprintf("Tossing %s/%s: genACK", sender.Name, pktName) + }) + return err + } + } switch pkt.Type { case PktTypeExec, PktTypeExecFat: - if noExec { + if opts.NoExec { return nil } path := bytes.Split(pkt.Path[:int(pkt.PathLen)], []byte{0}) @@ -144,7 +185,7 @@ if err = decompressor.Reset(pipeR); err != nil { log.Fatalln(err) } } - if !dryRun { + if !opts.DryRun { cmd := exec.Command(cmdline[0], append(cmdline[1:], args...)...) cmd.Env = append( cmd.Env, @@ -203,8 +244,8 @@ sender.Name, argsStr, humanize.IBytes(pktSize), ) }) - if !dryRun && jobPath != "" { - if doSeen { + if !opts.DryRun && jobPath != "" { + if opts.DoSeen { if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil { return err } @@ -238,7 +279,7 @@ } } case PktTypeFile: - if noFile { + if opts.NoFile { return nil } dst := string(pkt.Path[:int(pkt.PathLen)]) @@ -283,7 +324,7 @@ ) }) return err } - if !dryRun { + if !opts.DryRun { tmp, err := TempFile(dir, "file") if err != nil { ctx.LogE("rx-mktemp", les, err, func(les LEs) string { @@ -400,9 +441,9 @@ "Got file %s (%s) from %s", dst, humanize.IBytes(pktSize), sender.Name, ) }) - if !dryRun { + if !opts.DryRun { if jobPath != "" { - if doSeen { + if opts.DoSeen { if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil { return err } @@ -456,7 +497,7 @@ } } case PktTypeFreq: - if noFreq { + if opts.NoFreq { return nil } src := string(pkt.Path[:int(pkt.PathLen)]) @@ -503,7 +544,7 @@ }, ) return err } - if !dryRun { + if !opts.DryRun { err = ctx.TxFile( sender, pkt.Nice, @@ -528,9 +569,9 @@ } ctx.LogI("rx", les, func(les LEs) string { return fmt.Sprintf("Got file request %s to %s", src, sender.Name) }) - if !dryRun { + if !opts.DryRun { if jobPath != "" { - if doSeen { + if opts.DoSeen { if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil { return err } @@ -583,7 +624,7 @@ } } case PktTypeTrns: - if noTrns { + if opts.NoTrns { return nil } dst := new([MTHSize]byte) @@ -605,7 +646,7 @@ ctx.LogE("rx-unknown", les, err, logMsg) return err } ctx.LogD("rx-tx", les, logMsg) - if !dryRun { + if !opts.DryRun { if len(node.Via) == 0 { if err = ctx.TxTrns(node, nice, int64(pktSize), pipeR); err != nil { ctx.LogE("rx", les, err, func(les LEs) string { @@ -645,8 +686,8 @@ ctx.NodeName(&nodeId), humanize.IBytes(pktSize), ) }) - if !dryRun && jobPath != "" { - if doSeen { + if !opts.DryRun && jobPath != "" { + if opts.DoSeen { if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil { return err } @@ -681,7 +722,7 @@ } } case PktTypeArea: - if noArea { + if opts.NoArea { return nil } areaId := new(AreaId) @@ -712,7 +753,7 @@ msgHash := Base32Codec.EncodeToString(msgHashRaw[:]) les = append(les, LE{"AreaMsg", msgHash}) ctx.LogD("rx-area", les, logMsg) - if dryRun { + if opts.DryRun { for _, nodeId := range area.Subs { node := ctx.Neigh[*nodeId] lesEcho := append(les, LE{"Echo", nodeId}) @@ -791,7 +832,7 @@ if _, err := os.Stat(seenPath); err == nil { ctx.LogD("rx-area-seen", les, func(les LEs) string { return logMsg(les) + ": already seen" }) - if !dryRun && jobPath != "" { + if !opts.DryRun && jobPath != "" { if err = os.Remove(jobPath); err != nil { ctx.LogE("rx-area-remove", les, err, func(les LEs) string { return fmt.Sprintf( @@ -858,7 +899,7 @@ nice, uint64(pktSizeWithoutEnc(int64(pktSize))), "", decompressor, - dryRun, doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK, + opts, ) }() _, _, _, err = PktEncRead( @@ -881,7 +922,7 @@ return err } } - if !dryRun && jobPath != "" { + if !opts.DryRun && jobPath != "" { if err = os.MkdirAll(seenDir, os.FileMode(0777)); err != nil { ctx.LogE("rx-area-mkdir", les, err, logMsg) return err @@ -909,7 +950,7 @@ } } case PktTypeACK: - if noACK { + if opts.NoACK { return nil } hsh := Base32Codec.EncodeToString(pkt.Path[:MTHSize]) @@ -920,7 +961,7 @@ } ctx.LogD("rx-ack", les, logMsg) pktPath := filepath.Join(ctx.Spool, sender.Id.String(), string(TTx), hsh) if _, err := os.Stat(pktPath); err == nil { - if !dryRun { + if !opts.DryRun { if err = os.Remove(pktPath); err != nil { ctx.LogE("rx-ack", les, err, func(les LEs) string { return logMsg(les) + ": removing packet" @@ -935,7 +976,7 @@ ctx.LogD("rx-ack", les, func(les LEs) string { return logMsg(les) + ": already disappeared" }) } - if !dryRun && doSeen { + if !opts.DryRun && opts.DoSeen { if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil { return err } @@ -954,7 +995,7 @@ return err } } } - if !dryRun { + if !opts.DryRun { if err = os.Remove(jobPath); err != nil { ctx.LogE("rx", les, err, func(les LEs) string { return logMsg(les) + ": removing job" @@ -984,12 +1025,7 @@ } return nil } -func (ctx *Ctx) Toss( - nodeId *NodeId, - xx TRxTx, - nice uint8, - dryRun, doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK bool, -) bool { +func (ctx *Ctx) Toss(nodeId *NodeId, xx TRxTx, opts *TossOpts) bool { dirLock, err := ctx.LockDir(nodeId, "toss") if err != nil { return false @@ -1008,7 +1044,7 @@ {"Node", job.PktEnc.Sender}, {"Pkt", pktName}, {"Nice", int(job.PktEnc.Nice)}, } - if job.PktEnc.Nice > nice { + if job.PktEnc.Nice > opts.Nice { ctx.LogD("rx-too-nice", les, func(les LEs) string { return fmt.Sprintf( "Tossing %s/%s: too nice: %s", @@ -1056,7 +1092,7 @@ job.PktEnc.Nice, uint64(pktSizeWithoutEnc(job.Size)), job.Path, decompressor, - dryRun, doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK, + opts, ) }() pipeWB := bufio.NewWriter(pipeW) @@ -1103,11 +1139,7 @@ } return isBad } -func (ctx *Ctx) AutoToss( - nodeId *NodeId, - nice uint8, - doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK bool, -) (chan struct{}, chan bool) { +func (ctx *Ctx) AutoToss(nodeId *NodeId, opts *TossOpts) (chan struct{}, chan bool) { dw, err := ctx.NewDirWatcher( filepath.Join(ctx.Spool, nodeId.String(), string(TRx)), time.Second, @@ -1126,9 +1158,7 @@ dw.Close() badCode <- bad return case <-dw.C: - bad = !ctx.Toss( - nodeId, TRx, nice, false, - doSeen, noFile, noFreq, noExec, noTrns, noArea, noACK) || bad + bad = !ctx.Toss(nodeId, TRx, opts) || bad } } }() diff --git a/src/toss_test.go b/src/toss_test.go index 647ad63904946412f1cf00fbccdfe48dd5578fbd72906c22c29fbd6c1440c12c..9c61fb2ad97b884e982735dfd0b9cf72f4574346481c88a062d599bdbef3f654 100644 --- a/src/toss_test.go +++ b/src/toss_test.go @@ -111,15 +111,13 @@ os.Rename(filepath.Join(spool, ctx.Self.Id.String(), string(TTx)), rxPath) if len(dirFiles(rxPath)) == 0 { continue } - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceExec-1, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceExec - 1}) if len(dirFiles(rxPath)) == 0 { return false } ctx.Neigh[*nodeOur.Id].Exec = make(map[string][]string) ctx.Neigh[*nodeOur.Id].Exec[handle] = []string{"/bin/sh", "-c", "false"} - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceExec, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceExec}) if len(dirFiles(rxPath)) == 0 { return false } @@ -131,8 +129,7 @@ filepath.Join(spool, "mbox"), filepath.Join(spool, "mbox"), ), } - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceExec, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceExec}) if len(dirFiles(rxPath)) != 0 { return false } @@ -218,14 +215,12 @@ } } rxPath := filepath.Join(spool, ctx.Self.Id.String(), string(TRx)) os.Rename(filepath.Join(spool, ctx.Self.Id.String(), string(TTx)), rxPath) - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFile, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFile}) if len(dirFiles(rxPath)) == 0 { return false } ctx.Neigh[*nodeOur.Id].Incoming = &incomingPath - if ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFile, - false, false, false, false, false, false, false, false) { + if ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFile}) { return false } if len(dirFiles(rxPath)) != 0 { @@ -301,8 +296,7 @@ } rxPath := filepath.Join(spool, ctx.Self.Id.String(), string(TRx)) os.Rename(filepath.Join(spool, ctx.Self.Id.String(), string(TTx)), rxPath) ctx.Neigh[*nodeOur.Id].Incoming = &incomingPath - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFile, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFile}) expected := make(map[string]struct{}) expected["samefile"] = struct{}{} for i := 0; i < files-1; i++ { @@ -374,14 +368,12 @@ rxPath := filepath.Join(spool, ctx.Self.Id.String(), string(TRx)) txPath := filepath.Join(spool, ctx.Self.Id.String(), string(TTx)) os.Rename(txPath, rxPath) os.MkdirAll(txPath, os.FileMode(0700)) - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFreq, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFreq}) if len(dirFiles(txPath)) != 0 || len(dirFiles(rxPath)) == 0 { return false } ctx.Neigh[*nodeOur.Id].FreqPath = &spool - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFreq, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFreq}) if len(dirFiles(txPath)) != 0 || len(dirFiles(rxPath)) == 0 { return false } @@ -394,8 +386,7 @@ ); err != nil { panic(err) } } - ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFreq, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: DefaultNiceFreq}) if len(dirFiles(txPath)) == 0 || len(dirFiles(rxPath)) != 0 { return false } @@ -498,8 +489,7 @@ ); err != nil { panic(err) } } - ctx.Toss(ctx.Self.Id, TRx, 123, - false, false, false, false, false, false, false, false) + ctx.Toss(ctx.Self.Id, TRx, &TossOpts{Nice: 123}) if len(dirFiles(rxPath)) != 0 { return false } diff --git a/src/tx_test.go b/src/tx_test.go index 4d68276de6d8c217807b07bc20103a145531fe4fcfd4e41273a3b7d8a3675e99..404fb2e8a4f3d37c6cf1b52b4c20003c963c8e4e0a44479aa7fe76c27388da79 100644 --- a/src/tx_test.go +++ b/src/tx_test.go @@ -22,7 +22,7 @@ "bytes" "crypto/rand" "io" "os" - "path" + "path/filepath" "testing" "testing/quick" @@ -63,7 +63,7 @@ } nodeTgt := nodeTgtOur.Their() ctx := Ctx{ Spool: spool, - LogPath: path.Join(spool, "log.log"), + LogPath: filepath.Join(spool, "log.log"), Debug: true, Self: nodeOur, SelfId: nodeOur.Id, diff --git a/test.do b/test.do deleted file mode 100644 index 4d139ba23f12fbd9dd7dddedb78d1c24e41fac629f92b729dc7bc4284b1c79ae..0000000000000000000000000000000000000000 --- a/test.do +++ /dev/null @@ -1,6 +0,0 @@ -redo-ifchange config -exec >&2 -. ./config -cd src -GO=${GO:-go} -$GO test -failfast ./... diff --git a/uninstall b/uninstall new file mode 100755 index 0000000000000000000000000000000000000000..c0e2fc7779477364b7054cdbfe8968f69479d2b64a8eab57848b28b3f99dd8e8 --- /dev/null +++ b/uninstall @@ -0,0 +1,8 @@ +#!/bin/sh -e + +root="$(realpath -- $(dirname "$0"))" +. "$root"/config +cd "$BINDIR" +rm -f `cat "$root"/bin/cmd.list` +rm -f "$INFODIR"/nncp.info +rm -fr "$DOCDIR" diff --git a/uninstall.do b/uninstall.do deleted file mode 100644 index 1888b8c28f8437cb00d895e5aa02363462d62dae74ae07d356d1de4b80adaad2..0000000000000000000000000000000000000000 --- a/uninstall.do +++ /dev/null @@ -1,5 +0,0 @@ -redo-ifchange config -. ./config -for cmd in `cat bin/cmd.list` ; do rm -f $BINDIR/$cmd ; done -rm -f $INFODIR/nncp.info -rm -fr $DOCDIR diff --git a/version b/version new file mode 100755 index 0000000000000000000000000000000000000000..d6ac5abcc749ea82acca879d0beb7734b0a0b2a21fda76ce2a63de22e41d7814 --- /dev/null +++ b/version @@ -0,0 +1,3 @@ +#!/bin/sh -e + +exec perl -ne 'print "$1\n" if /Version.* = "(.*)"$/' < "$(realpath -- $(dirname "$0"))"/src/nncp.go