💾 Archived View for ew.srht.site › en › 2024 › 20240525-bws-nex.gmi captured on 2024-05-26 at 14:27:39. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2024-06-16)

-=-=-=-=-=-=-

2024-05-25

Adding nex and kinex to bubble wrapped services (bws)

tags: software

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.

gemini://tobykurien.com/articles/2022-10-08-simpler-linux-selfhosting.gmi

local copy

The source of bws (bubblewrapped services) is available at

https://cloud.tobykurien.com/cgi-bin/repo/bws/

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

nex://nightfall.city

https://nightfall.city

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:

https://hg.sr.ht/~m15o/nexd

https://hg.sr.ht/~m15o/nex-pfm

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:

--ro-bind $HOME/public/nex $HOME/app/public/nex
#!/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.

https://hg.sr.ht/~m15o/kinex

https://hg.sr.ht/~m15o/nex-pfm

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:

--ro-bind $HOME/public/nex $HOME/app/public/kinex
#!/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!

Home