Date: 2025-02-23
Last update: 2025-02-24

How NPS - The board of heroes works
-----------------------------------

I use Perl script to do this. It may already looks a bit complex.
However what it really does is "cat >> /var/nex/board".
Networking is handled by inetd. So when user starts his connection
with netcat "nc morena.rip 1915" inetd calls the Perl script, which
runs practically equivalent of the command above and wait for user
input. When user hits enter, his text is written to the board file.
It's very simple way how to get data over network.

/bin/nps.pl

Perl script nps.pl does just few extra things, to make it nicer and
bit more secure. Practically the whole script contains mostly extra
things and not the main function - append text to the file "board".

One function is that if user type '.' - dot on its own line, it
terminates transaction, so it ends doing things.

What it also does, it limits maximum length of a line and maximum
number of lines appended to the file. So random Muhammad will not send
1 gigabyte of data. Additionally it also prints some text into
the board file to separate different user inputs.

At the core, if the script is just bare bones like bellow, it will
work.

#!/bin/sh
cat >> /var/nex/board

Everything will be appended to the board file and NPS will work.
The dot will have no effect, so user has to close netcat connection to
finish it. Also nothing will be printed when user send text or
something goes wrong. No limit for number or length of lines.

It's pretty interesting how a simple command, simple function needs
usually so many "helpers" that it becomes a bit safer and maybe more
friendly. Like 10 workers dancing around the boss.

To implement NPS, one would start with that simple command or
equivalent in different programming language and then add those
cosmetic, security and other extras. Sometimes it's pretty hard to
know where to stop as those things can grow rapidly fast. Some check,
some limit, or some informational text to user adds few lines here and
there. Then the whole program can grow from one line to tens or
hundreds lines of code.

Obviously more extras it gets, more prone to fail it is. It is also
harder to understand and change.

Current nps.pl used here is still small, but functional. There is
still a lot of space for improvenments, however it will add another
complexity. It could lock a file while one user is typing into his
session so it does not break when more users will try to send data at
the same time. It could do many things. Like don't write to the board
file line by line, but as a whole and ask user for a confirmation at
the end before it is posted online. If one start to think about all
this, there are many other things which would be helpful to add. Then
the program will be one hundred of lines or maybe more and one can
start to think, if something different, more robust would not fit
better. Then you will find some similar already made "board software"
full of features.

It's important to keep it tiny and really implement just what is
needed to survive. It has to be "human limited". Otherwise "adding"
will never end or one will find himself later in some Discord or X.

----------------------------------------------------------------------

Ever lured by convenience. We see only promises. Not that, which is
taken in lieu. No critical thought. Giving ground every day.
Slavery sure to ensue. -- IanJ's mom