Upgrade Perl version; remove redundant fat commas; clean up reflection page

This commit is contained in:
swagg boi 2021-05-31 00:57:39 -04:00
parent b4c7d9896b
commit 49635e2b10
4 changed files with 19 additions and 9 deletions

View file

@ -1,4 +1,4 @@
FROM perl:5.32.1
FROM perl:5.34.0
# Move it
WORKDIR /opt
@ -18,7 +18,6 @@ RUN apt-get -y upgrade
RUN apt-get -y install fortune-mod ruby
RUN cpanm --installdeps .
RUN gem install cgi
RUN gem install ipaddress
# Finish setting up the environment
ENV MOJO_REVERSE_PROXY=1

View file

@ -5,7 +5,6 @@
# Oct 2020
require 'cgi'
require 'ipaddress'
# Create CGI object
cgi = CGI.new('html4')
@ -38,7 +37,7 @@ cgi_env = {
'address' => remote_addr,
'port' => remote_port,
'method' => request_method,
'webmaster' => server_admin,
'webmaster' => 'swaggboi@slackware.uk',
'protocol' => server_protocol,
'server' => server_software
}
@ -54,7 +53,7 @@ easter_egg = {
}
# Easter egg for IPv6
footer =
if IPAddress.valid_ipv6?(cgi_env['address'])
if cgi_env['address'] =~ /[a-fA-F:]/
cgi.img(easter_egg) + cgi.br + "\n" + cgi.br + "\n" + footer
else
'<iframe width="560"

12
public/index.html Normal file
View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Redirecting to Homepage</title>
<link rel="stylesheet" type="text/css" href="/css/swagg.css">
</head>
<body>
<h1>Redirecting to Homepage</h1>
<p>Click <a href="/home">here</a> if not redirected automagically.</p>
<script>window.location.replace("/home");</script>
</body>
</html>

View file

@ -37,7 +37,7 @@ under sub {
};
# The main landing page; index.html
get '/' => sub {
get '/', sub {
my ($c) = @_;
my $count = format_number time; # Grab epoch and add commas
my $fortune = `/usr/games/fortune` || `fortune` || "huh??\n";
@ -48,7 +48,7 @@ get '/' => sub {
);
$c->render();
} => 'index';
}, 'index';
# Process mac address to ula6 ala the ol' ula6.cgi script:
# - Current time of day in 64-bit NTP format
@ -56,7 +56,7 @@ get '/' => sub {
# - Cat first with second
# - Compute SHA-1 of third and use least significant 40 bits
# TODO: This ancient code could certainly be cleaned up
get '/ula6' => sub {
get '/ula6', sub {
my ($c) = @_;
my ($mac, $ula6);
@ -102,7 +102,7 @@ get '/ula6' => sub {
};
# Default route
get '/:route' => [route => [qw{die me news portal}]] => sub {
get '/:route', [route => [qw{die me news portal}]], sub {
my ($c) = @_;
$c->render(template => $c->stash('route'));