Gemini Server in C. From https://github.com/jovoro/geminid

Bob Mottram 6fb8a71b48 File is generated 21 hours ago
docroot b370f8f433 Switch to .gmi ending for gemini files 1 week ago
.gitignore 29c4fdce34 Cleanup 1 week ago
LICENSE 7ce7673a44 Use real name in LICENSE 1 week ago
Makefile 2afe0bc27b Also make library search path configurable 6 days ago
README.md 931398d124 Add some missing bits... 6 days ago
config.c 292ac75f84 Introduce configuration via configuration file, make log date format configurable 6 days ago
config.h 292ac75f84 Introduce configuration via configuration file, make log date format configurable 6 days ago
example.conf 292ac75f84 Introduce configuration via configuration file, make log date format configurable 6 days ago
file.c 8419b0650f Merge 2 days ago
file.h 235783c651 Add support for directory listing 1 week ago
gemini.c 5a0ce26fd7 Adjust response header to current specification 2 days ago
gemini.h 292ac75f84 Introduce configuration via configuration file, make log date format configurable 6 days ago
lexurl.l 1fbdc50bfd Add new URL parser and test program 1 week ago
log.c 559b06a3a6 Fix date in error log 6 days ago
log.h 292ac75f84 Introduce configuration via configuration file, make log date format configurable 6 days ago
main.c 8df180153b Adress zombie problem 6 days ago
mime.c 06f6596a0e Add basic handling of mime types via libmagic. 1 week ago
mime.h 06f6596a0e Add basic handling of mime types via libmagic. 1 week ago
parseurl.c 477eb15361 Fix warnings on FreeBSD 1 week ago
tls.c 29c4fdce34 Cleanup 1 week ago
tls.h 068bc51c38 Initial code commit 1 week ago
url.c 1fbdc50bfd Add new URL parser and test program 1 week ago
url.h 1fbdc50bfd Add new URL parser and test program 1 week ago
util.c 2ad2f48fe6 Get it running on Linux. Do not send charset in header meta (Castor doesn't like it, haven't tried with other clients 1 week ago
util.h 06f6596a0e Add basic handling of mime types via libmagic. 1 week ago

README.md

geminid

A Gemini Server in C. Please note that this is not production-ready code. The current state is a result of a few hours of hacking, barely able to even serve content. But the goal is to have a compliant gemini server written in C.

Configuring

There is no configuration file yet. Some tunable parameters are avaible in gemini.h. For convenience you can use make cert to generate a self-signed certificate.

Prerequisites

A Unix-like or POSIX-compliant OS is required. OpenSSL 1.1.1 is recommended. If you build with an earlier version, I assume it is one which at least supports TLS 1.2. You need to define TLS_USE_V1_2_METHOD if you want to use TLS 1.2. If you want to use even older versions, you need to modify the source code in tls.c to use the appropriate version-specific method.

I've added a more sophisticated URL parser which is based on lex/flex, so you need that, too. As of 2020-05-20 there is a new configuration file introduced which requires libconfig as a dependency.

Building

Edit Makefile and gemini.h to your needs, do make geminid. There is a test program for the URL parser, which can be built with make parseurl. If you have non-standard include or library paths, you can use INCDIRS and LIBDIRS, respectively. You are advised to include local modifications in a separate file Makefile.local, which will be included if it exists.

So, if you are on BSD, you might want to do

cat > Makefile.local <<EOF
INCDIRS=-L/usr/local/include
LIBDIRS=-L/usr/local/lib
EOF

to let the preprocessor and linker know where to look for libraries, i.e. libconfig.

Configuring

There's an example configuration file named example.conf in this repo. The configuration is supposed to define multiple vhosts, but currently only the first is usable, because I haven't implemented SNI yet... The format of log times is described according to strftime(3).

The docroot directive is relative to the serverroot. Log files are relative to logdir. Certificates are absolute or relative to the cwd of the geminid process, since they tend to live anywhere on the filesystem. I don't know if that makes sense to you. If it doesn't, let me know - I'd love to hear your thoughts.

Running

Just run the produced executable geminid. Some options are now configurable via command line parameters:

  • -c <config>: Path to the configuration file
  • -t: Test and print configuration

Complaining

To vent your anger, you may reach me at jr at vrtz dot ch.

You can find a demonstration of it running at gemini://gemini.uxq.ch/ and some more information on how I run it at gemini://gemini.uxq.ch/running.gmi