chiark / gitweb /
cgi/ip: Be a FastCGI program.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 8 Jul 2017 00:38:50 +0000 (01:38 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 8 Jul 2017 00:38:50 +0000 (01:38 +0100)
Use Ian Jackson's `cgi-fcgi-interp' wrapper to make it happen.

cgi/ip

diff --git a/cgi/ip b/cgi/ip
index 997bcbc..c2c8cc0 100755 (executable)
--- a/cgi/ip
+++ b/cgi/ip
@@ -1,4 +1,5 @@
-#! /usr/bin/perl
+#! /usr/bin/cgi-fcgi-interp /usr/bin/perl
+### -*-perl-*-
 ###
 ### IP-address reporting webservice for Odin
 ###
 
 use lib 'lib';
 use Odin;
+use CGI::Fast;
 
-print <<EOF;
+while (my $cgi = CGI::Fast->new) {
+  my $addr = $cgi->remote_addr;
+  print <<EOF;
 Content-type: text/plain; charset=us-ascii
 X-AGPL-Source: $Odin::SRCURL
 
-$ENV{REMOTE_ADDR}
+$addr
 EOF
-exit 0;
+}