💾 Archived View for tomasino.org captured on 2022-04-29 at 12:21:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-26)

-=-=-=-=-=-=-

Ad-hoc served gemini file

This file is being served by a bit of nonsense /bin/sh. It uses ncat(1), part of the nmap package, to listen on the right port and wrap the connection using my letsencrypt key. xq came up with the idea and the core server code for an experiment he's running for Kristall. I stole it to make this silly thing.

I've got a simple text document being served as the content. The "server" places a 20 response code with text/gemini in the header and serves the all important CRLF. Then I just cat this file. I've added a little loop so that the server continues to run after each connection is made.

The code

#!/bin/sh

port="1965"
cert="cert.pem"
key="key.pem"

printf "Starting gemini server on port %s...\n" "$port"
while true; do
  {
    printf "20 text/gemini; charset=utf-8\r\n"
    printf "Page generated: %s\n\n" "$(date)"
    cat "$1"
  } | ncat --ssl --ssl-cert "$cert" --ssl-key "$key" --listen "$port"
done

Contact

email: james@tomasino.org

fingerprint: 368CD75F5CD5F1E9A72F639F4E0FEB0E09DDD7DF