2024-05-25
Adding nex and kinex to bubble wrapped services (bws)
Some time back Toby Kurien published details and code about his favourite setup regarding self hosting services at home. He did put in quite some effort to make this simple to install and run. This time I have added nexd and kinex by ~m15o to run in this setup.
The source of bws (bubblewrapped services) is available at
including installation instructions.
nex
nex is a very simple setup to retrieve documents from a remote machine. Calling this a protocol seems overkill to me. The default client is the venerable netcat programm. The server side interprets the incoming string as filepath and, if found, returns the content of said file, or a listing, if path is a directory. Really small and simple.
~m15o of "The Midnight Pub" fame has set this up and it can be seen in operation at
To see for yourself call netcat in your favourite shell similar to this:
echo nex/info/specification.txt | nc nightfall.city 1900 | less
nexd
nexd is a server implementation written in Go. It can be found on sourcehut:
The main program file "nexd.go" weighs in at a whopping 46 lines of code! In words: fourty six! Ok, ok, some functions are delegated to nex-pfm.go adding another 103 lines of code. Plus a few imports, of course. But I can't help calling this quite lean. Using the content of Makefile, and adjusting two variables results in a one line command to compile the programm:
GOARCH=$(uname -m) GOOS=linux go build -o nexd nexd.go
Adding this server into a bubble wrapped service is straight forward. In the ~/services directory we add a new directory named nexd. It holds 3 files:
- ./bin/linux-$(uname -m)/nexd -- the freshly compiled executable
- ./sandbox.args -- a configuration snippet to make the plan file available inside the bubblewrap container, for example:
--ro-bind $HOME/public/nex $HOME/app/public/nex
- ./start.sh -- a start script cloned from one of the start scripts coming with the source of bws.
#!/bin/sh OS="$(uname -s)" PLATFORM="$(uname -m)" BIN="unknown" if test "$OS" = "Linux"; then BIN="linux-$PLATFORM" elif test "$OS" = "Darwin"; then BIN="macos-$PLATFORM" fi ./bin/$BIN/nexd ./public/nex
kinex
Of course, no one is going to explore the worlds of nex:// if netcat were the only client. ~m15o has everyone covered by providing a proxy server to https://, aptly named kinex to acknowledge another such proxy for gemini://, namely kineto.
kinex is available at sourcehut as well, and uses nex-pfm, too.
kinex will be compiled like nexd:
GOARCH=$(uname -m) GOOS=linux go build -o kinex kinex.go
The 3 files in ~/services/kinex are similar to the above:
- ./bin/linux-$(uname -m)/kinex -- the freshly compiled executable
- ./sandbox.args -- a configuration snippet to make the plan file available inside the bubblewrap container, for example:
--ro-bind $HOME/public/nex $HOME/app/public/kinex
- ./start.sh -- a start script cloned from one of the start scripts coming with the source of bws.
#!/bin/sh OS="$(uname -s)" PLATFORM="$(uname -m)" BIN="unknown" if test "$OS" = "Linux"; then BIN="linux-$PLATFORM" elif test "$OS" = "Darwin"; then BIN="macos-$PLATFORM" fi # from README # kinex [-s style.css] [-t template.tpl] [-p 8080] /var/nex/ nex.nightfall.city ./bin/$BIN/kinex -p 8080 ./public/kinex localhost
call nexd and kinex
All there is left to do, is to register these services, and add some content, too. In ~/services/start add two corresponding lines:
~/services/bws start nexd ~/services/bws start kinex
---
Thank you ~m15o for this wonderfully simple setup, for another fun way to explore the possibilities of "the net". Of course, all of this is completely insecure, scanning, denial of service, sharp knives, and explosives included. It should be possible to hide this fun behind some sort of ssh tunnel or an onion service. However, that will not make it any simpler! Have the appropriate amount of fun!