-- Leo's gemini proxy

-- Connecting to ainent.xyz:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8; lang=en

smolver development log, part 5


Intro


This is the fifth in a planned series of posts (well, sixth if you count the announcement) where I'll share my experience writing smolver, my Gemini server software, written in Swift.


You can find the previous iterations below. This series has become long enough that I've added a dedicated page for it:


smolver Devlog


Alphas 7 & 8, plus 2 more smaller patch releases


So really, alphas 7, 8, 9 & 10. This post is long overdue, as those alpha builds were released on February 8th, 12th and 13th, respectively.


What's changed?


Removed the note from the README declaring that the README is aspirational. It now supports everything as written.

Optionally support robots.txt, configurable

Move a configurable property to the top level of the required json config file

Rename a property in the required json config file

Add support for configuration of redirects

Minor refactoring for code reuse of configuration file validation

Reorganize source files into folders; one for the spec implementation, and another for administrative features

Finally fix the bug where requesting a directory with a trailing slash wouldn't auto-redirect you to one with the trailing slash (with one known exception, that I didn't find out about until almost 2 weeks later, more details below)

Add a `smolver` command that current lets you run the server, print the version number, or print some basic help information

Added a backlog item to allow configuration of the written language in the content of responses

Added a (quirky and awkward...) `install.sh` script to simplify smolver installation. This does not address what is still the hardest part of running smolver from scratch: installing the Swift language on your system. I blame Apple.

Tweak systemd service file to account for oddity where you have to call `/path/to/install/of/smolver/smolver run` instead of just `/path/to/install/of/smolver run`. It makes sense why this is needed, because creating a production build of the app puts the compiled binary and its other generated files into a single directory, instead of spitting out a single raw binary. At least, that was what I thought was going on at the time. While writing this, I tried copying just the final `smolver` binary itself and running it directly via `./smolver`, without any of the other stuff, and it ran fine. I'll have to cleanup the install script and systemd service file accordingly.


This concludes all planned features for v1.0.0, meaning that, barring any major defects, this will be the final alpha build and the next ones will be promoted to beta. As I write that, it sounds inconsequential, but it made me happy to get this far ... it's a nice milestone.


What I've discovered since then


The current redirect implementation is a bit awkward; you have to configure every single file that you want redirected, and if you delete an entire directory of content (for example, because you renamed it), you need to keep that directory in place just so the redirect config file can live there. As I write that, that actually doesn't sound unreasonable? Maybe I'll leave that as is?

When trying to mirror my backup of gemini.circumlunar.space, I discovered that content directories with periods in them will not redirect to the root if requested without a trailing slash. As a workaround, I just called that directory gemini-circumlunar-space.

A glance at the logs looks like sometimes things appear to be logged out of order? I haven't delved too deep into here, so maybe my scanning eyes were just misinterpreting something.

Another glance at the logs and I noticed that rate limiting code I wrote only appears to work if the subsequent request comes in on a new second. i.e., hh:mm:11.22 hh:mm:11.50 won't get rate limited, but hh:mm:11.22 hh:mm:12.10 will. That is for my current configuration, which is supposed to only allow 1 request per IP per second. I'm not sure how it'll behave with larger intervals. Sounds like a great place for some unit tests! I'll need to research the logs some more to confirm.

Noticed that at least one file has the wrong creation and copyright year, so I'll need to go through every file and double check them.


I've added these items to my planned fixes for a second beta build. There are some more pressing stability issues to fix before I'd feel comfortable slapping a 'beta' label on this, so I'll do those first then look at these observations.


Thoughts


Overall, the total lines of code grew only a little bit this time. Running cloc on v0.0.15 returns:


cloc Sources
       9 text files.
       9 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.08 s (118.7 files/s, 17454.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                            9            163            240            921
-------------------------------------------------------------------------------
SUM:                             9            163            240            921
-------------------------------------------------------------------------------

Running cloc on the current HEAD of the master branch (5a4c4a8b7d8e1709bee42b8f1a6e6f6fcedae29a - I am referencing a hash here instead of a tag because the latest changes include a few commits of simple backlog changes, no source changes), which contains all the fixes and backlog enhancements discussed above, returns:


cloc Sources
      12 text files.
      12 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.08 s (147.9 files/s, 19551.7 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                           12            201            310           1075
-------------------------------------------------------------------------------
SUM:                            12            201            310           1075
-------------------------------------------------------------------------------

These numbers do not include dependencies.


That is a growth of 154 lines.

-- Response ended

-- Page fetched on Tue May 21 17:01:40 2024