-- 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 11 - More Configurability


Intro


This is the eleventh in a planned series of posts (well, twelfth 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.


smolver Devlog


I skipped a writeup like this one for v1.2.1, instead opting for just a Public Service Announcement


2023-05-28 Public Service Announcement - smolver Security Hole Mitigated


v1.3.0


What's changed?


Configurable support for the 30 REDIRECT - TEMPORARY response code -- only permanent redirects were configurable previously

Configurable support for the 41 SERVER UNAVAILABLE response code

Configurable support for the 52 GONE response code

Added note to documentation / README on which status codes smolver does not directly support - only 10 INPUT, 11 SENSITIVE INPUT, and 43 PROXY ERROR. If you need to return any of these, return it from a CGI script as needed.

Configuration for default response language for text/gemini files, with ability to override as needed

Minor performance enhancement - .smol.json configuration files will now only be read from disk once per request. Request processing happens almost instantaneously and so re-reading from disk multiple times per request to check for any configured overrides seemed wasteful. smolver still supports modifying / adding / deleting this file while running, just no inter-request caching.

Removed non-utf-8 support from backlog, including references to future plans for such from code and documentation

Reprioritize bug fixes and refactorings in backlog to come after the rest of the planned features

Added backlog item to investigate slow compile times, especially when including unit tests

Expand backlog with plans to verify and fix suspected defect in CGI support

Rewrite mime type data structures, enabling the rest of the below items in this list

Determine mime type for returned files based on system /etc/mime.types file

Added a few new unit tests

Configurable support for overriding the mime type in the response header

Expanded CGI response support to any text/* mime type -- only text/gemini, text/markdown, text/plain, and text/x-python were supported previously


Known issues


.smol.json configuration of language and mime type overrides do not apply to subdirectories unless you duplicate the configuration in every subdirectory. Need to detect this scenario automatically so you won't have to duplicate your configuration(s).


Code metrics


Overall, these features required only minor code changes.


Running cloc on smolver production code v1.2.1 returns:


$ cloc Sources
      25 text files.
      25 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.16 s (156.4 files/s, 18847.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                           25            381            668           1964
-------------------------------------------------------------------------------
SUM:                            25            381            668           1964
-------------------------------------------------------------------------------

Running cloc on smolver production code v1.3.0 returns:


$ cloc Sources
      25 text files.
      25 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.18 s (139.2 files/s, 18057.9 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                           25            439            668           2135
-------------------------------------------------------------------------------
SUM:                            25            439            668           2135
-------------------------------------------------------------------------------

Running cloc on smolver test code v1.2.1 returns:


$ cloc Tests
      17 text files.
      17 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.21 s (80.0 files/s, 23139.7 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                           12            732            466           3645
Bourne Shell                     4              9              0             34
Python                           1              7              0             23
-------------------------------------------------------------------------------
SUM:                            17            748            466           3702
-------------------------------------------------------------------------------

Running cloc on smolver test code v1.3.0 returns:


$ cloc Tests
      18 text files.
      18 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.86  T=0.24 s (76.3 files/s, 21454.5 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift                           13            759            491           3741
Bourne Shell                     4              9              0             34
Python                           1              7              0             23
-------------------------------------------------------------------------------
SUM:                            18            775            491           3798
-------------------------------------------------------------------------------

That is a net change of 171 lines to smolver production code, 96 lines to smolver unit tests, for a total increase of 267 lines.


I have also found a new feature in the cloc CLI program, which generated the above data: you can point it to two git references and it'll show you data from the changeset! Naturally, I have included that below:


cloc --git --diff v1.2.1 v1.3.0
      31 text files.
      32 text files.
       4 files ignored.

github.com/AlDanial/cloc v 1.86  T=2.57 s (18.3 files/s, 2457.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Swift
 same                            0              0            357           1763
 modified                       11              0              9             93
 added                           6            284            167           1463
 removed                         5            199            142           1196
Markdown
 same                            0              0              0            244
 modified                        3              0              0             23
 added                           6             29              0            157
 removed                         6              3              0             39
Bourne Shell
 same                            0              0              0              0
 modified                        0              0              0              0
 added                           4              9              0             34
 removed                         4              9              0             34
Python
 same                            0              0              0              0
 modified                        0              0              0              0
 added                           1              7              0             23
 removed                         1              7              0             23
-------------------------------------------------------------------------------
SUM:
 same                            0              0            357           2007
 modified                       14              0              9            116
 added                          17            329            167           1677
 removed                        16            218            142           1292
-------------------------------------------------------------------------------

None of these numbers includes smolver's dependencies, including but not limited to SocketServer & BlueSSLService.

-- Response ended

-- Page fetched on Tue May 21 20:54:46 2024