Diamant Gemini Server

Diamant is a server for the Gemini network protocol, built in Ruby. Diamant has very few features, and can only serve static files.

About the gemini protocol

About the gemini protocol (HTTPS)

Internally, it uses the OpenSSL library to handle the TLS sessions, and the Ruby `Thread' implementation to handle concurrent requests.

It is named « Diamant », as one of the first french attempt to build a rocket. The first Diamant launch happen in 1965, exactly like Gemini. I think it’s cool.

About the Diamant rocket program on Wikipedia (HTTPS)

I’m already aware another Ruby implementation exists, named Gack. However, Diamant differs from it for two reasons:

Gack on github (HTTPS)

Installation and setup

Diamant is a Ruby gem[1]. You need a working Ruby environment to use it. We recommand you to use RVM[2] and a specific gemset. However it will works with a global ruby installation too.

rvm get latest
rvm use ruby-2.7.2@diamant --create
gem install diamant

Then you need to a generate self-signed TLS certificate and private key. In the following example, remember to replace the example hostname `myhostname.com' by the one you would like to use.

Diamant provides a tool to create these certificate and key:

diamant generate_tls_cert myhostname.com

You can also use the OpenSSL command if you prefer:

openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem
    -days 3650 -nodes -subj "/CN=myhostname.com"

Finally, you should create a folder to store your static files to serve:

mkdir public_gmi
echo 'Hello World!' > public_gmi/index.gmi

[1] Ruby gem (HTTPS)

[2] RVM (HTTPS)

Run the server

Basic way

With all the default options, runing the server is as simple as:

diamant

However, you may want to use some other options:

diamant --public-path ~/my_gemini_site -b 0.0.0.0

To see all possible options, just enter the following command:

diamant --help

As a systemd service

You can inspire yourself from the following service example file:

[Unit]
Description=Control Diamant Gemini Server
After=network.target

[Service]
Type=simple
User=gemini
Group=gemini
Environment="PATH=/home/gemini/.rvm/gems/ruby-2.7.2@diamant/bin:/home/gemini/.rvm/gems/ruby-2.7.2@global/bin:/home/gemini/.rvm/rubies/ruby-2.7.2/bin:/home/gemini/.rvm/bin:/usr/local/bin:/usr/bin:/bin"
Environment="GEM_HOME=/home/gemini/.rvm/gems/ruby-2.7.2@diamant"
Environment="GEM_PATH=/home/gemini/.rvm/gems/ruby-2.7.2@diamant:/home/gemini/.rvm/gems/ruby-2.7.2@global"
WorkingDirectory=/home/gemini
ExecStart=/home/gemini/.rvm/gems/ruby-2.7.2@diamant/bin/diamant -b 0.0.0.0
KillMode=control-group

[Install]
WantedBy=multi-user.target

Sources

Development occurs on my own git repositoy:

diamant gemini server git repository (HTTPS)

--

📅 dernière modification le jeudi 3 décembre 2020 à 09:29

📝 Écrit par Étienne Deparis avec GNU/Emacs 27.2 (Org mode 9.4.6) et publié avec Fronde 0.3.2