💾 Archived View for her.st › blog › atlas-my-gemini-server.gmi captured on 2024-02-05 at 09:23:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Atlas is a gemini server without any dependencies. It works on x86, x64 and ARM64. Linux is supported and Windows/MacOS should work fine too - but I don't know since I don't use either. The name refers to the launch rocket used to launch the gemini capsules into space.
After a week of trial and error with the occasional look at the documentation, I've finished the first version of atlas. The gemini protocol is super easy to understand and implement but the other features I wanted were not :D
There's no way to upload anything using gemini. The best you can do is to use the INPUT request to pass query strings to the server.
So there's a companion protocol called Titan which allows you to upload files. The Titan protocol uses the same status codes as gemini and works just fine in-band.
gemini:// and titan:// are pretty much the same, titan just adds a filename and size parameter inside the META section of the request. Very easy to parse.
Spartan was a bit more involved, as it's not compatible with gemini. It uses a different default port and no encryption. Also the status codes are not identical to those of gemini. I've had to open another socket for spartan and write custom handlers for all the different requests. Although the protocol itself is very similar to gemini - simpler really - it is different enough to require a second codepath for parsing requests and sending responses.
Gemini Virtual-Hosts can be easily implemented by looking at the SNI parameter in the TLS handshake, spartan doesn't use TLS, so they put the hostname into the request header - no problems there.
CGI scripting was super easy too, just a bunch of different environment variables that get passed to the script and its output redirected to the user's browser. Authorisation and authentication can be done using the client certificate when the request comes from gemini. If the request comes from spartan however, the script has to do the heavy lifting. Maybe there shouldn't be any authorization or authentication with spartan since its a plaintext protocol and passwords or tokens would be suseptible to MITM attacks.
Directory Listing was implemented directly in the server and creates a nicely spaced list of files. I've not done directory navigation yet though. That shouldn't be too hard though.
For configuring atlas, i've settled on a simple JSON file.
I took some inspiration from nginx there and since gemini, spartan and titan rely heavily on mimetypes, I've added a TSV file of mimetypes that can be easily edited by hand.
To make deployment easy, I've added docker support.
you can pull it from dockerhub
_docker pull herstfortress/atlas:latest_
make sure you mount two volumes, one for /srv and one for /etc
the config belongs in `/etc/atlas/config.json` and the capsules in `/srv/gemini/my.capsule.com/`
The code can be found on github
That's basically it for now.