2022-02-04 Wondering about NNCP

My wife is in the city looking for stuff and I have a few hours to myself… Sitting on the sofa, as I often do.

I am interested in a Usenet feed.

Since NNCP is quite similar to UUCP – in fact, you can map UUCP commands to NNCP ones – it is quite possible, and not all that hard, to run Usenet over NNCP. In fact, in a number of ways, it works better than Usenet over UUCP! – Usenet over NNCP

Usenet over NNCP

All of this nncp/nntp stuff makes me think that I should try to set it up on my laptop. And I mean: on the laptop, and not on the server, so that I can confirm it all works with only partial uptime. I didn’t find the nncp package on my laptop, though.

@jgoerzen said:

@jgoerzen

I only uploaded #NNCP to #Debian after Bullseye was released, so if they derive from stable, that’s why. But, you can get it from Debian’s backports, most likely.

OK, downloading:

nncp (8.0.2-1~bpo11+1) … NNCP is a package facilitating secure store-and-forward file and mail exchange. It can be thought of as a modern UUCP with Internet smarts. – nncp in Bullseye backports

nncp in Bullseye backports

Installing seems to work:

sudo dpkg --install nncp_8.0.2-1\~bpo11+1_amd64.deb

I’m surprised that it didn’t fail because of dependencies. I’m using PureOS, which is some mix of Debian testing, I think. And this file is from is from the Debian repos. Is this the benefit of Go? 😁

Let’s see… which of these commands looks harmless enough? How about nncp-log:

main.go:61: Error during initialization: stat /etc/nncp.hjson: no such file or directory

OK, not bad! In the “Setting up NNCP” section it mentions nncp.hjson, so I hope I’m on the right path.

I think I found the page I need, with a simple test case:

After packets are exchanged and tossed after a few minutes, you should have a copy of README.txt in the directory you labeled as incoming in your configuration. – quux.org NNCP public relay

quux.org NNCP public relay

Excellent, let’s try that.

I think the info I needed to get me started in addition to the above was the note that the /etc/nncp.hjson file needs to be created using the following:

nncp-cfgnew > new.hjson – Configuration

Configuration

So I’ve done that, and sent an email to John Goerzen, requesting to join the quux NNCP relay, providing my preferred node name, which isn’t published, via no path in particular, with the public keys the command above had generated.

Let’s hope this works. Waiting… got John’s reply. OK, let’s try to get that README file. Remember to switch to the nncp user because the /var/spool/nncp/ directory belongs to the nncp user.

sudo -u nncp nncp-freq quux:README.txt

I tried adding my own user to the nncp group, but that doesn’t help. It still cannot create the necessary directories. I guess this needs to be a script

Let’s try to call the NNCP relay:

sudo -u nncp nncp-call quux

That gets me a packet! 😃

But where is the file?

It seems it should be here because there’s nothing queued?

sudo -u nncp nncp-stat -node quux

When I examine the directories and files in /var/spool/nncp, I can’t find any actual data file. The /etc/nncp.hjson file I have says that quux uses /tmp for incoming, but /tmp also contains nothing. And yet the log file says I received something.

Hm. Let’s check that again. The output for the nncp-call:

2022-02-05T07:13:02Z We have got for quux: 1 packets, 490 B
2022-02-05T07:13:02Z Connection to quux (nncp.quux.org:5400)
2022-02-05T07:13:02Z Tx SRCN365O7N5NQA52..NEVM2762STF7HUOA 490 B/490 B 100% (0 B/sec)
2022-02-05T07:13:02Z Packet SRCN365O7N5NQA526F7WRSRWD5BT5Y5YGWCDNEVM2762STF7HUOA is sent
2022-02-05T07:13:13Z Finished call with quux (0:0:11): 32 KiB received (32 KiB/sec), 33 KiB transferred (33 KiB/sec)

I think this might just be the request being sent out! OK, let’s call it again.

2022-02-05T07:26:19Z Packet YCPXPBTDOL32JPIO2OK262HTB45LD3TPM2KVMCRNHQHCZFV4BDZQ (1.3 KiB) (nice B): 0%
2022-02-05T07:26:19Z quux has got for us: 1 packets, 1.3 KiB
2022-02-05T07:26:19Z Connection to quux (nncp.quux.org:5400)
2022-02-05T07:26:19Z Rx YCPXPBTDOL32JPIO..MCRNHQHCZFV4BDZQ 1.3 KiB/1.3 KiB 100% (0 B/sec)
2022-02-05T07:26:19Z Got packet YCPXPBTDOL32JPIO2OK262HTB45LD3TPM2KVMCRNHQHCZFV4BDZQ 100% (1.3 KiB / 1.3 KiB): done
2022-02-05T07:26:30Z Finished call with quux (0:0:11): 33 KiB received (33 KiB/sec), 32 KiB transferred (32 KiB/sec)

Aah! I guess this is the reply I’ve been waiting for. And now nncp-stat shows something:

quux
	nice:   B | Rx:    1.3 KiB,   1 pkts | Tx:        0 B,   0 pkts

And tossing also works!

sudo -u nncp nncp-toss

The file was finally received:

2022-02-05T07:29:26Z Rx file YCPXPBTDOL32JPIO..MCRNHQHCZFV4BDZQ 810 B/810 B 100% (0 B/sec)
2022-02-05T07:29:26Z Got file README.txt (810 B) from quux

All right. Time to read it!

less /tmp/README.txt

​#NNCP ​#Administration

First you need to get their keys. Use GPG encrypted mail, or magic-wormhole if you’re online at the same time:

This package provides a library and a command-line tool named wormhole, which makes it possible to get arbitrary-sized files and directories (or short pieces of text) from one computer to another. – Magic-Wormhole

Magic-Wormhole

Then you add a section to your nncp.hjson file, inside “neigh” and add add a “via” section, like in the neighbour config example from the docs:

  bob: {
    id: 2IZNP...UYGYA
    exchpub: WFLMZ...B7NHA
    signpub: GTGXG...IE3OA
    incoming: "/tmp"
    via: ["quux"]
  }

To queue a file for bob, via quux:

sudo -u nncp nncp-file FILE bob

To post it to quux, and to receive back packets from anybody else who is sending you stuff via quux:

sudo -u nncp nncp-call quux

Packets you receive end up in your spool, not in the incoming directory, since they could be for all sorts of things, not just files to be saved. To distribute the packets you received and thus to get the file reassembled in the “incoming” directory in our simple case:

sudo -u nncp nncp-toss

Use nncp-stat to look at the spool. Here’s how to show individual packets:

sudo -u nncp nncp-stat -pkt

And here’s how to remove the ones that are stuck because you didn’t provide the correct -via argument (and didn’t add the info to your nncp.hjson file):

sudo -u nncp nncp-rm -node bob -pkt HASH

Remember:

Don’t forget the “via” line in your config file, or use -via when posting stuff to neighbours if they use the quux relay.

Don’t forget the “incoming” line in your config file if you expect to be receiving files from your neighbours.

As for daemons: When I installed the packages, I got some nice files in /usr/share/doc/nncp/examples! The location of nncp-toss had to be fixed, though. I also needed to add a “call” line for quux, in the /etc/nncp.hjson file:

      calls: [
        {
          cron: "*/2 * * * *"
        }
      ]

If none of the entries is going to get called automatically, you also don’t need to install nncp-caller! Also, if you don’t want to call quux every two minutes, replace */2 with something else. For my own use, I think once an hour is more than enough so I’m using 12 instead of */2. 😃

cd /usr/share/doc/nncp/examples
sudo sed -i -e 's/local\///' nncp-toss.service
sudo cp -i cron-daily-nncp /etc/cron.daily/nncp
sudo cp -i logrotate-nncp /etc/logrotate.d/nncp
sudo cp -i *.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable nncp-caller
sudo systemctl enable nncp-daemon
sudo systemctl enable nncp-toss
sudo systemctl start nncp-daemon

(The use of /usr/local/bin/nncp-toss has been fixed upstream.)

I've been working on connecting the laptop and the server using NNCP.

connecting the laptop and the server using NNCP