App-lupapona
view release on metacpan or search on metacpan
script/lupa-pona view on Meta::CPAN
this, replacing C<$hostname> with whatever you need:
openssl req -new -x509 -newkey ec -subj "/CN=$hostname" \
-pkeyopt ec_paramgen_curve:prime256v1 \
-days 1825 -nodes -out cert.pem -keyout key.pem
This creates a certificate and a private key, both of them unencrypted, using
eliptic curves of a particular kind, valid for five years.
Start the server:
lupa-pona
This starts the server in the foreground, for C<gemini://localhost:1965>. If it
aborts, see the L</Troubleshooting> section below. If it runs, open your
favourite Gemini client and test it, or open another terminal and test it:
echo gemini://localhost \
| openssl s_client --quiet --connect localhost:1965 2>/dev/null
You should see a Gemini page starting with the following:
20 text/gemini; charset=UTF-8
Welcome to Lupa Pona!
Success!! ð ðð
=head2 Troubleshooting
No trouble, yet!
=head2 Options
These are the options Lupa Pona knows about:
=over
=item C<--host> is the address to use; the default is 0.0.0.0, i.e. accepting
all connections (use this option if your machine is reachable via multiple
names, e.g. C<alexschroeder.ch> and C<emacswiki.org> and you just want want to
serve one of them)
=item C<--port> is the port to use; the default is 1965
=item C<--text_encoding> is the text encoding to use if you're not going to use
UTF-8 (consider adding support for L<Encode::Guess>)
=item C<--log_level> is the log level to use (error, warn, info, debug, trace);
the default is C<warn>
=item C<--cert_file> is the certificate file to use; the default is C<cert.pem>
=item C<--key_file> is the key file to use; the default is C<key.pem>
=back
=head2 Using systemd
Systemd is going to handle daemonisation for us. There's more documentation
L<available
online|https://www.freedesktop.org/software/systemd/man/systemd.service.html>.
You could create a specific user:
sudo adduser --disabled-login --disabled-password lupa-pona
Copy Lupa Pona to C</home/lupa-pona/lupa-pona>.
Basically, this is the template for our service:
[Unit]
Description=Lupa Pona
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/lupa-pona
ExecStart=/home/lupa-pona/lupa-pona
Restart=always
User=lupa-pona
Group=lupa-pona
[Install]
WantedBy=multi-user.target
Save this as F<lupa-pona.service>, and then link it:
sudo ln -s /home/lupa-pona/lupa-pona.service /etc/systemd/system/
Reload systemd:
sudo systemctl daemon-reload
Start Lupa Pona:
sudo systemctl start lupa-pona
Check the log output:
sudo journalctl --unit lupa-pona
All the files in C</home/lupa-pona> are going to be served, if the C<lupa-pona>
user can read them.
=head2 Privacy
If you increase the log level, the server will produce more output, including
information about the connections happening, like C<2020/06/29-15:35:59 CONNECT
SSL Peer: "[::1]:52730" Local: "[::1]:1965"> and the like (in this case C<::1>
is my local address so that isn't too useful but it could also be your visitor's
IP numbers, in which case you will need to tell them about it using in order to
comply with the
L<GDPR|https://en.wikipedia.org/wiki/General_Data_Protection_Regulation>.
=cut
use Mojo::Log;
use Mojo::IOLoop;
use Getopt::Long;
use File::Slurper qw(read_binary read_dir);
use Encode qw(encode_utf8 decode_utf8);
use Modern::Perl '2018';
use File::MimeInfo qw(globs);
( run in 1.883 second using v1.01-cache-2.11-cpan-22024b96cdf )