]> Cypherpunks.ru repositories - nncp.git/blob - doc/cmds.texi
stdin/stdout formatting
[nncp.git] / doc / cmds.texi
1 @node Commands
2 @unnumbered Commands
3
4 Nearly all commands have the following common options:
5
6 @table @option
7 @item -cfg
8     Path to configuration file. May be overridden by @env{NNCPCFG}
9     environment variable. If file file is an encrypted @ref{EBlob,
10     eblob}, then ask for passphrase to decrypt it first.
11 @item -debug
12     Print debug messages. Normally this option should not be used.
13 @item -minsize
14     @anchor{OptMinSize}
15     Minimal required resulting packet size, in KiBs. For example if you
16     send 2 KiB file and set @option{-minsize 4}, then resulting packet
17     will be 4 KiB (containing file itself and some junk).
18 @item -nice
19     Set desired outgoing packet @ref{Niceness, niceness level}.
20 @item -replynice
21     Set desired reply packet @ref{Niceness, niceness level}. Only freq
22     and exec packets look at that niceness level.
23 @item -via
24     Override @ref{CfgVia, via} configuration option for destination node.
25     Specified nodes must be separated with comma: @verb{|NODE1,NODE2|}.
26     With @verb{|-via -|} you can disable relaying at all.
27 @item -spool
28     Override path to spool directory. May be specified by
29     @env{NNCPSPOOL} environment variable.
30 @item -log
31     Override path to logfile. May be specified by @env{NNCPLOG}
32     environment variable.
33 @item -quiet
34     Print only errors, omit simple informational messages. In any case
35     those messages are logged, so you can reread them using
36     @ref{nncp-log} command.
37 @item -progress, -noprogress
38     Either force progress showing, or disable it.
39 @item -version
40     Print version information.
41 @item -warranty
42     Print warranty information (no warranty).
43 @end table
44
45 @node nncp-bundle
46 @section nncp-bundle
47
48 @example
49 $ nncp-bundle [options] -tx [-delete] NODE [NODE ...] > ...
50 $ nncp-bundle [options] -rx -delete [-dryrun] [NODE ...] < ...
51 $ nncp-bundle [options] -rx [-check] [-dryrun] [NODE ...] < ...
52 @end example
53
54 With @option{-tx} option, this command creates @ref{Bundles, bundle} of
55 @ref{Encrypted, encrypted packets} from the spool directory and writes
56 it to @code{stdout}.
57
58 With @option{-rx} option, this command takes bundle from @code{stdin}
59 and copies all found packets for our node to the spool directory. Pay
60 attention that @strong{no} integrity checking is done by default. Modern
61 tape drives could easily provide too much throughput your CPU won't be
62 able to verify on the fly. So if you won't @ref{nncp-toss, toss}
63 received packets at the place, it is advisable either to run
64 @ref{nncp-check} utility for packets integrity verification, or to use
65 @option{-check} option to enable on the fly integrity check.
66
67 You can specify multiple @option{NODE} arguments, telling for what nodes
68 you want to create the stream, or take it from. If no nodes are
69 specified for @option{-rx} mode, then all packets aimed at us will be
70 processed.
71
72 When packets are sent through the stream, they are still kept in the
73 spool directory, because there is no assurance that they are transferred
74 to the media (media (CD-ROM, tape drive, raw hard drive) can end). If
75 you want to forcefully delete them (after they are successfully flushed
76 to @code{stdout}) anyway, use @option{-delete} option.
77
78 But you can verify produced stream after, by digesting it by yourself
79 with @option{-rx} and @option{-delete} options -- in that mode, stream
80 packets integrity will be checked and they will be deleted from the
81 spool if everything is good. So it is advisable to recheck your streams:
82
83 @example
84 $ nncp-bundle -tx ALICE BOB WHATEVER | cdrecord -tao -
85 $ dd if=/dev/cd0 bs=2048 | nncp-bundle -rx -delete
86 @end example
87
88 @option{-dryrun} option prevents any writes to the spool. This is
89 useful when you need to see what packets will pass by and possibly check
90 their integrity.
91
92 @node nncp-call
93 @section nncp-call
94
95 @example
96 $ nncp-call [options]
97     [-onlinedeadline INT]
98     [-maxonlinetime INT]
99     [-rx|-tx]
100     [-list]
101     [-pkts PKT,PKT,...]
102     [-rxrate INT]
103     [-txrate INT]
104     [-autotoss*]
105     NODE[:ADDR] [FORCEADDR]
106 @end example
107
108 Call (connect to) specified @option{NODE} and run @ref{Sync,
109 synchronization} protocol with the @ref{nncp-daemon, daemon} on the
110 remote side. Normally this command could be run any time you wish to
111 either check for incoming packets, or to send out queued ones.
112 Synchronization protocol allows resuming and bidirectional packets
113 transfer.
114
115 If @option{-rx} option is specified then only inbound packets
116 transmission is performed. If @option{-tx} option is specified, then
117 only outbound transmission is performed. @option{-onlinedeadline}
118 overrides @ref{CfgOnlineDeadline, @emph{onlinedeadline}}.
119 @option{-maxonlinetime} overrides @ref{CfgMaxOnlineTime,
120 @emph{maxonlinetime}}. @option{-rxrate}/@option{-txrate} override
121 @ref{CfgXxRate, rxrate/txrate}. @option{-list} option allows you to list
122 packets of remote node, without any transmission.
123
124 You can specify what packets your want to download, by specifying
125 @option{-pkts} option with comma-separated list of packets identifiers.
126
127 Each @option{NODE} can contain several uniquely identified
128 @option{ADDR}esses in @ref{CfgAddrs, configuration} file. If you do
129 not specify the exact one, then all will be tried until the first
130 success. Optionally you can force @option{FORCEADDR} address usage,
131 instead of addresses taken from configuration file. You can specify both
132 @verb{|host:port|} and @verb{#|some command#} formats.
133
134 Pay attention that this command runs integrity check for each completely
135 received packet in the background. This can be time consuming.
136 Connection could be lost during that check and remote node won't be
137 notified that file is done. But after successful integrity check that
138 file is renamed from @file{.part} one and when you rerun
139 @command{nncp-call} again, remote node will receive completion
140 notification.
141
142 @option{-autotoss} options runs tosser on node's spool after call
143 is finished. All @option{-autotoss-*} options is the same as in
144 @ref{nncp-toss} command.
145
146 @node nncp-caller
147 @section nncp-caller
148
149 @example
150 $ nncp-caller [options] [NODE ...]
151 @end example
152
153 Croned daemon that calls remote nodes from time to time, according to
154 their @ref{CfgCalls, @emph{calls}} configuration field.
155
156 Optional number of @option{NODE}s tells to ignore other ones.
157 Otherwise all nodes with specified @emph{calls} configuration
158 field will be called.
159
160 Look at @ref{nncp-call} for more information.
161
162 @node nncp-cfgenc
163 @section nncp-cfgenc
164
165 @example
166 $ nncp-cfgenc [options] [-s INT] [-t INT] [-p INT] cfg.hjson > cfg.hjson.eblob
167 $ nncp-cfgenc [options] -d cfg.hjson.eblob > cfg.hjson
168 @end example
169
170 This command allows you to encrypt provided @file{cfg.hjson} file with
171 the passphrase, producing @ref{EBlob, eblob}, to safely keep your
172 configuration file with private keys. This utility was written for users
173 who do not want (or can not) to use either @url{https://gnupg.org/,
174 GnuPG} or similar tools. That @file{eblob} file can be used directly in
175 @option{-cfg} option of nearly all commands.
176
177 @option{-s}, @option{-t}, @option{-p} are used to tune @file{eblob}'s
178 password strengthening function. Space memory cost (@option{-s}),
179 specified in number of BLAKE2b-256 blocks (32 bytes), tells how many
180 memory must be used for hashing -- bigger values are better, but slower.
181 Time cost (@option{-t}) tells how many rounds/iterations must be
182 performed -- bigger is better, but slower. Number of parallel jobs
183 (@option{-p}) tells how many computation processes will be run: this is
184 the same as running that number of independent hashers and then joining
185 their result together.
186
187 When invoked for encryption, passphrase is entered manually twice. When
188 invoked for decryption (@option{-d} option), it is asked once and exits
189 if passphrase can not decrypt @file{eblob}.
190
191 @option{-dump} options parses @file{eblob} and prints parameters used
192 during its creation. For example:
193 @example
194 $ nncp-cfgenc -dump /usr/local/etc/nncp.hjson.eblob
195 Strengthening function: Balloon with BLAKE2b-256
196 Memory space cost: 1048576 bytes
197 Number of rounds: 16
198 Number of parallel jobs: 2
199 Blob size: 2494
200 @end example
201
202 @node nncp-cfgmin
203 @section nncp-cfgmin
204
205 @example
206 $ nncp-cfgmin [options] > stripped.hjson
207 @end example
208
209 Print out stripped configuration version: only path to @ref{Spool,
210 spool}, path to log file, neighbours public keys are stayed. This is
211 useful mainly for usage with @ref{nncp-xfer} that has to know only
212 neighbours, without private keys involving.
213
214 @node nncp-cfgnew
215 @section nncp-cfgnew
216
217 @example
218 $ nncp-cfgnew [options] [-nocomments] > new.hjson
219 @end example
220
221 Generate new node configuration: private keys, example configuration
222 file and print it to @code{stdout}. You must use this command when you
223 setup the new node. @option{-nocomments} will create configuration file
224 without descriptive huge comments -- useful for advanced users.
225
226 Pay attention that private keys generation consumes an entropy from your
227 operating system.
228
229 @node nncp-check
230 @section nncp-check
231
232 @example
233 $ nncp-check [options]
234 @end example
235
236 Perform @ref{Spool, spool} directory integrity check. Read all files
237 that has Base32-encoded filenames and compare it with recalculated
238 BLAKE2b hash output of their contents. That supplementary command is
239 not used often in practice, if ever.
240
241 @node nncp-daemon
242 @section nncp-daemon
243
244 @example
245 $ nncp-daemon [options] [-maxconn INT] [-bind ADDR] [-inetd] [-autotoss*]
246 @end example
247
248 Start listening TCP daemon, wait for incoming connections and run
249 @ref{Sync, synchronization protocol} with each of them. You can run
250 @ref{nncp-toss} utility in background to process inbound packets from
251 time to time.
252
253 @option{-maxconn} option specifies how many simultaneous clients daemon
254 can handle. @option{-bind} option specifies @option{addr:port} it must
255 bind to and listen.
256
257 It could be run as @command{inetd} service, by specifying
258 @option{-inetd} option. Pay attention that because it uses
259 @code{stdin}/@code{stdout}, it can not effectively work with IO timeouts
260 and connection closing can propagate up to 5 minutes in practice.
261 Example inetd-entry:
262
263 @verbatim
264 uucp    stream  tcp6    nowait  nncpuser        /usr/local/bin/nncp-daemon      nncp-daemon -quiet -inetd
265 @end verbatim
266
267 @option{-autotoss} options runs tosser on node's spool after call
268 is finished. All @option{-autotoss-*} options is the same as in
269 @ref{nncp-toss} command.
270
271 @node nncp-exec
272 @section nncp-exec
273
274 @example
275 $ nncp-exec [options] [-use-tmp] [-nocompress] NODE HANDLE [ARG0 ARG1 ...]
276 @end example
277
278 Send execution command to @option{NODE} for specified @option{HANDLE}.
279 Body is read from stdin (either into memory, or into encrypted temporary
280 file if @option{-use-tmp} is specified) and compressed (unless
281 @option{-nocompress} is specified). After receiving, remote side will
282 execute specified @ref{CfgExec, handle} command with @option{ARG*}
283 appended and decompressed body fed to command's stdin.
284
285 For example, if remote side has following configuration file for your
286 node:
287
288 @verbatim
289 exec: {
290   sendmail: [/usr/sbin/sendmail, "-t"]
291   appender: ["/bin/sh", "-c", "cat >> /append"]
292 }
293 @end verbatim
294
295 then executing @verb{|echo My message | nncp-exec -replynice 123 REMOTE
296 sendmail root@localhost|} will lead to execution of:
297
298 @example
299 echo My message |
300     NNCP_SELF=REMOTE \
301     NNCP_SENDER=OurNodeId \
302     NNCP_NICE=123 \
303     /usr/sbin/sendmail -t root@@localhost
304 @end example
305
306 If @ref{CfgNotify, notification} is enabled on the remote side for exec
307 handles, then it will sent simple letter after successful command
308 execution with its output in message body.
309
310 @strong{Pay attention} that packet generated with this command won't be
311 be chunked.
312
313 @node nncp-file
314 @section nncp-file
315
316 @example
317 $ nncp-file [options] [-chunked INT] SRC NODE:[DST]
318 @end example
319
320 Send @file{SRC} file to remote @option{NODE}. @file{DST} specifies
321 destination file name in remote's @ref{CfgIncoming, incoming}
322 directory. If this file already exists there, then counter will be
323 appended to it.
324
325 This command queues file in @ref{Spool, spool} directory immediately
326 (through the temporary file of course) -- so pay attention that sending
327 2 GiB file will create 2 GiB outbound encrypted packet.
328
329 If @file{SRC} equals to @file{-}, then create an encrypted temporary
330 file and copy everything taken from @code{stdin} to it and use for outbound
331 packet creation. Pay attention that if you want to send 1 GiB of data
332 taken from @code{stdin}, then you have to have more than 2 GiB of disk space
333 for that temporary file and resulting encrypted packet. You can control
334 where temporary file will be stored using @env{TMPDIR} environment
335 variable. Encryption is performed in AEAD mode with
336 @url{https://cr.yp.to/chacha.html, ChaCha20}-@url{https://en.wikipedia.org/wiki/Poly1305, Poly1305}
337 algorithms. Data is splitted on 128 KiB blocks. Each block is encrypted
338 with increasing nonce counter.
339
340 If @file{SRC} points to directory, then
341 @url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01, pax archive}
342 will be created on the fly with directory contents and destination
343 filename @file{.tar} appended. It @strong{won't} contain any entities
344 metainformation, but modification time with the names. UID/GID are set
345 to zero. Directories have 777 permissions, files have 666, for being
346 friendly with @command{umask}. Also each entity will have comment like
347 @verb{|Autogenerated by NNCP version X.Y.Z built with goXXX|}.
348
349 If @option{-chunked} is specified, then source file will be split
350 @ref{Chunked, on chunks}. @option{INT} is the desired chunk size in
351 KiBs. This mode is more CPU hungry. Pay attention that chunk is saved in
352 spool directory immediately and it is not deleted if any error occurs.
353 @option{-minsize} option is applied per each chunk. Do not forget about
354 @ref{ChunkedZFS, possible} ZFS deduplication issues. Zero
355 @option{-chunked} disables chunked transmission.
356
357 If @ref{CfgNotify, notification} is enabled on the remote side for
358 file transmissions, then it will sent simple letter after successful
359 file receiving.
360
361 @node nncp-freq
362 @section nncp-freq
363
364 @example
365 $ nncp-freq [options] NODE:SRC [DST]
366 @end example
367
368 Send file request to @option{NODE}, asking it to send its @file{SRC}
369 file from @ref{CfgFreq, freq.path} directory to our node under @file{DST}
370 filename in our @ref{CfgIncoming, incoming} one. If @file{DST} is not
371 specified, then last element of @file{SRC} will be used.
372
373 If @ref{CfgNotify, notification} is enabled on the remote side for
374 file request, then it will sent simple letter after successful file
375 queuing.
376
377 @node nncp-log
378 @section nncp-log
379
380 @example
381 $ nncp-log [options]
382 @end example
383
384 Parse @ref{Log, log} file and print out its records in human-readable form.
385
386 @node nncp-pkt
387 @section nncp-pkt
388
389 @example
390 $ nncp-pkt [options] < pkt
391 $ nncp-pkt [options] [-decompress] -dump < pkt > payload
392 $ nncp-pkt -overheads
393 @end example
394
395 Low level packet parser. Normally it should not be used, but can help in
396 debugging.
397
398 By default it will print packet's type, for example:
399 @example
400 Packet type: encrypted
401 Niceness: 64
402 Sender: 2WHBV3TPZHDOZGUJEH563ZEK7M33J4UESRFO4PDKWD5KZNPROABQ
403 @end example
404
405 If you specify @option{-dump} option and provide an @ref{Encrypted,
406 encrypted} packet, then it will verify and decrypt it to @code{stdout}.
407 Encrypted packets contain @ref{Plain, plain} ones, that also can be fed
408 to @command{nncp-pkt}:
409
410 @example
411 Packet type: plain
412 Payload type: transitional
413 Path: VHMTRWDOXPLK7BR55ICZ5N32ZJUMRKZEMFNGGCEAXV66GG43PEBQ
414
415 Packet type: plain
416 Payload type: mail
417 Path: stargrave@@stargrave.org
418 @end example
419
420 And with the @option{-dump} option it will give you the actual payload
421 (the whole file, mail message, and so on). @option{-decompress} option
422 tries to zstd-decompress the data from plain packet (useful for mail
423 packets).
424
425 @option{-overheads} options print encrypted, plain and size header overheads.
426
427 @node nncp-reass
428 @section nncp-reass
429
430 @example
431 $ nncp-reass [options] [-dryrun] [-keep] [-dump] [-stdout] FILE.nncp.meta
432 $ nncp-reass [options] [-dryrun] [-keep] @{-all | -node NODE@}
433 @end example
434
435 Reassemble @ref{Chunked, chunked file} after @ref{nncp-toss, tossing}.
436
437 When called with @option{FILE} option, this command will reassemble only
438 it. When called with @option{-node} option, this command will try to
439 reassemble all @file{.nncp.meta} files found in @option{NODE}'s
440 @ref{CfgIncoming, incoming} directory. When called with @option{-all}
441 option, then cycle through all known nodes to do the same.
442
443 Reassembling process does the following:
444
445 @enumerate
446 @item Parses @ref{Chunked, @file{.nncp.meta}} file.
447 @item Checks existence and size of every @file{.nncp.chunkXXX}.
448 @item Verifies integrity of every chunk.
449 @item Concatenates all chunks, simultaneously removing them from filesystem.
450 @end enumerate
451
452 That process reads the whole data twice. Be sure to have free disk
453 space for at least one chunk. Decrypted chunk files as a rule are saved
454 in pseudo-random order, so removing them during reassembly process will
455 likely lead to filesystem fragmentation. Reassembly process on
456 filesystems with deduplication capability should be rather lightweight.
457
458 If @option{-dryrun} option is specified, then only existence and
459 integrity checking are performed.
460
461 If @option{-keep} option is specified, then no
462 @file{.nncp.meta}/@file{.nncp.chunkXXX} files are deleted during
463 reassembly process.
464
465 @option{-stdout} option outputs reassembled file to @code{stdout},
466 instead of saving to temporary file with renaming after. This could be
467 useful for reassembling on separate filesystem to lower fragmentation
468 effect, and/or separate storage device for higher performance.
469
470 @option{-dump} option prints meta-file contents in human-friendly form.
471 It is useful mainly for debugging purposes. For example:
472 @example
473 Original filename: testfile
474 File size: 3.8 MiB (3987795 bytes)
475 Chunk size: 1.0 MiB (1048576 bytes)
476 Number of chunks: 4
477 Checksums:
478     0: eac60d819edf40b8ecdacd0b9a5a8c62de2d15eef3c8ca719eafa0be9b894017
479     1: 013a07e659f2e353d0e4339c3375c96c7fffaa2fa00875635f440bbc4631052a
480     2: f4f883975a663f2252328707a30e71b2678f933b2f3103db8475b03293e4316e
481     3: 0e9e229501bf0ca42d4aa07393d19406d40b179f3922a3986ef12b41019b45a3
482 @end example
483
484  Do not forget about @ref{ChunkedZFS, possible} ZFS deduplication issues.
485
486 @node nncp-rm
487 @section nncp-rm
488
489 @example
490 $ nncp-rm [options] -tmp
491 $ nncp-rm [options] -lock
492 $ nncp-rm [options] -node NODE -part
493 $ nncp-rm [options] -node NODE -seen
494 $ nncp-rm [options] -node NODE [-rx] [-tx]
495 $ nncp-rm [options] -node NODE -pkt PKT
496 @end example
497
498 This command is aimed to delete various files from your spool directory:
499
500 @itemize
501
502 @item If @option{-tmp} option is specified, then it will delete all
503 temporary files in @file{spool/tmp} directory. Files may stay in it when
504 commands like @ref{nncp-file} fail for some reason.
505
506 @item If @option{-lock} option is specified, then all @file{.lock} files
507 will be deleted in your spool directory.
508
509 @item If @option{-pkt} option is specified, then @file{PKT} packet (its
510 Base32 name) will be deleted. This is useful when you see some packet
511 failing to be processed.
512
513 @item When either @option{-rx} or @option{-tx} options are specified
514 (maybe both of them), then delete all packets from that given queues. If
515 @option{-part} is given, then delete only @file{.part}ly downloaded
516 ones. If @option{-seen} option is specified, then delete only
517 @file{.seen} files.
518
519 @item @option{-dryrun} option just prints what will be deleted.
520
521 @item You can also select files that only have modification date older
522 than specified @option{-older} time units (@code{10s} (10 seconds),
523 @code{5m} (5 minutes), @code{12h} (12 hours), @code{2d} (2 days)).
524
525 @end itemize
526
527 @node nncp-stat
528 @section nncp-stat
529
530 @example
531 $ nncp-stat [options] [-pkt] [-node NODE]
532 @end example
533
534 Print current @ref{Spool, spool} statistics about unsent and unprocessed
535 packets. For each node (unless @option{-node} specified) and each
536 niceness level there will be printed how many packets (with the total
537 size) are in inbound (Rx) and outbound (Tx) queues. @option{-pkt} option
538 show information about each packet.
539
540 @node nncp-toss
541 @section nncp-toss
542
543 @example
544 $ nncp-toss [options]
545     [-node NODE]
546     [-dryrun]
547     [-cycle INT]
548     [-seen]
549     [-nofile]
550     [-nofreq]
551     [-noexec]
552     [-notrns]
553 @end example
554
555 Perform "tossing" operation on all inbound packets. This is the tool
556 that decrypts all packets and processes all payload packets in them:
557 copies files, sends mails, sends out file requests and relays transition
558 packets. It should be run after each online/offline exchange.
559
560 @option{-dryrun} option does not perform any writing and sending, just
561 tells what it will do.
562
563 @option{-cycle} option tells not to quit, but to repeat tossing every
564 @option{INT} seconds in an infinite loop. That can be useful when
565 running this command as a daemon.
566
567 @option{-seen} option creates empty @file{XXX.seen} file after
568 successful tossing of @file{XXX} packet. @ref{nncp-xfer},
569 @ref{nncp-bundle}, @ref{nncp-daemon} and @ref{nncp-call} commands skip
570 inbound packets that has been already seen, processed and tossed. This
571 is helpful to prevent duplicates.
572
573 @option{-nofile}, @option{-nofreq}, @option{-noexec}, @option{-notrns}
574 options allow to disable any kind of packet types processing.
575
576 @node nncp-xfer
577 @section nncp-xfer
578
579 @example
580 $ nncp-xfer [options] [-node NODE] [-mkdir] [-keep] [-rx|-tx] DIR
581 @end example
582
583 Search for directory in @file{DIR} containing inbound packets for us and
584 move them to local @ref{Spool, spool} directory. Also search for known
585 neighbours directories and move locally queued outbound packets to them.
586 This command is used for offline packets transmission.
587
588 If @option{-mkdir} option is specified, then outbound neighbour(s)
589 directories will be created. This is useful for the first time usage,
590 when storage device does not have any directories tree.
591
592 If @option{-keep} option is specified, then keep copied files, do not
593 remove them.
594
595 @option{-rx} option tells only to move inbound packets addressed to us.
596 @option{-tx} option tells exactly the opposite: move only outbound packets.
597
598 @ref{nncp-cfgmin} could be useful for creating stripped minimalistic
599 configuration file version without any private keys.
600
601 @file{DIR} directory has the following structure:
602 @file{RECIPIENT/SENDER/PACKET}, where @file{RECIPIENT} is Base32 encoded
603 destination node, @file{SENDER} is Base32 encoded sender node.
604
605 Also look for @ref{nncp-bundle}, especially if you deal with CD-ROM and
606 tape drives.