Gemini: background

This page is a repeat of the info you can find on my gemini capsule and on the club website (in french).

A bit of history

Internet became popular/affordable mostly at the beginning of the 90ies. However, let's not forget it exists since the end of the 60ies and if today's most used protocole is http (https), the internet is built on a basic layer (tcp/ip) on which were built several protocols:

  • FTP: File Transfer Protocol
  • GOPHER: text linking and sharing protocol
  • HTTP: HyperText Transfer protocol
Little by little, http then https ate all the traffic, to the point that ftp is not supported anymore in some browsers.
At the same time, html was extented more and more, at the expenses of security and private life.

Gemini

It is in this context that the gemini protocol is born.
Gemini is "in between" gopher and http in terms of functionalities. That's where the name comes from since the Gemini project (less known by the public) was in between Mercury (first rocket in space) and the Apollo project.
Gemini tries to come back to the origin by eliminating the problems brougth about by the uncontrolled growth of http. By not offering some functionalities, it suppress the associated security and loss of private life problems.

Simple as that :-)

A gemini server is referenced by gemini://, like a http:// ou ftp:// URL.
Gemini sites are called "capsules".
The language used for pages is a simplified markdown (therefore very poor); pages are page.gmi.
By definition, servers are not ressource-hungry at all and can easily be installed on a Raspberry Pi.
My capsule is here (ou via un proxy http) and the Club de TeleMatique's here (ou via un proxy http).

How to get there: I use amfora under linux and deedum on android. Phaedra is quite basic but will run under android 1.0. Kristall and Lagrange are very good cross-platform browsers.


The server

Considering the above and the fact that I have used markdown for a while, creating my capsule was a no-brainer.
Creating my own CGI was a bit more fun.
First of all, it is not very well documented.
I read all the specs I could find, but to no avail. I looked at the source code of various pages, but there again, no big illumination. I installed a server (gemini) on a raspberry3 on my local network to be able to fiddle, but it didn't help. Then I discovered a page:
wikdict
and I contacted the author (Karl), asking for help. Karl was very nice and helpful and triggered my first "aha!" moment. I realized (and so did he) that the reason my setup wasn't working was probably very simply because my server did not support CGIs. I read the documentation he wrote on his setup () and decided to use the same server: gmnisrv. Compiling was straightforward - I just needed to install libssl-dev which wasn't on the raspberry. My research also led me to another page, also very useful.

Thanks to Karl's page and the one quoted above, install was quite simple.
I just had to modify the starting scripts of the raspberry to point to the new server, tested with amfora - good to go.

My config file:
# Space-separated list of hosts
listen=0.0.0.0:1965 [::]:1965
[:tls]
# Path to store certificates on disk
store=/usr/local/gem/certs
# Optional details for new certificates
organization=gmnisrv user
[localhost]
root=/usr/local/gem/files
[localhost:/cgi]
root=/usr/local/gem/files
cgi=on
[raspi31]
root=/usr/local/gem/files
[raspi31:/cgi]
root=/usr/local/gem/files
cgi=on

It is of course this last section with "cgi" which is the key. CGI script must be in /usr/local/gem/files/cgi.

CGI

From the pages and doc read (and Karl's python script used for wikdict, available in his git repository), I knew I would have 4 system variables, of which the most used was $QUERY_STRING.
The 4 variables are:
  • $QUERY_STRING
  • $PATH_INFO
  • $SERVER_NAME
  • $REMOTE_USER

The calling page

>>>----
# Page Test du script

=> cgi/test.sh  Test here
>>>----
page

The script itself


>>>----
if [ $QUERY_STRING"X" = "X" ] ; then
  echo "10 Enter something \r"
else
  echo "20 text/gemini\r"
  echo " "
  echo "l'argument passé est $QUERY_STRING"
  echo "PATH_INFO    = " $PATH_INFO
  echo "QUERY_STRING = " $QUERY_STRING
  echo "SERVER_NAME  = " $SERVER_NAME
  echo "REMOTE_USER  = " $REMOTE_USER
  echo " "
  echo " "
  echo " "
  echo " "
  echo "=> ../test.gmi Back"
  echo " "
  echo " "
  echo " "
  echo " "
fi
>>>----
And yes, there is no first line calling the bash shell. For some reason when I put it, it doesn't work, whereas Karl's scripts in python do call it. Go figure.

Results and remarks


The dialog box on Lagrange and on amfora:
dialog dialog

The resulting page:
result
We can see that $QUERY_STRING contains what was entered in the dialog box.
$SERVER_NAME contains the name of the server.
However the two other variables remain empty, so either I misunderstood the specs, or this server doesn't do it properly.
It is not very important, since with that result, we can already write whatever script we want.