]> bicyclesonthemoon.info Git - yplom/proxy/commitdiff
First version.
authorb <b@05ce6ebb-7522-4a6e-a768-0026ae12be9f>
Fri, 6 Nov 2015 17:22:57 +0000 (17:22 +0000)
committerb <b@05ce6ebb-7522-4a6e-a768-0026ae12be9f>
Fri, 6 Nov 2015 17:22:57 +0000 (17:22 +0000)
git-svn-id: svn://botcastle1b/yplom/proxy@1 05ce6ebb-7522-4a6e-a768-0026ae12be9f

makefile [new file with mode: 0644]
proxy.pl [new file with mode: 0755]
rewrite [new file with mode: 0755]

diff --git a/makefile b/makefile
new file mode 100644 (file)
index 0000000..5d0c7e3
--- /dev/null
+++ b/makefile
@@ -0,0 +1,27 @@
+CC=gcc
+#CC2=g++
+CF=-g -Wall
+#LF=-lIL
+LF2=-lcgi
+
+OD=/yplom/bin/proxy
+
+all: moveout copyout
+
+moveout: proxy setuid exec
+       mv proxy $(OD)
+
+copyout: rewrite setuid exec
+       cp rewrite $(OD)
+
+setuid: proxy
+       chmod u+s proxy
+
+exec: rewrite proxy
+       chmod +x rewrite proxy
+
+#proxy: proxy.c
+#      $(CC) $(CF) -o proxy proxy.c
+
+proxy: proxy.pl
+       cp proxy.pl proxy
diff --git a/proxy.pl b/proxy.pl
new file mode 100755 (executable)
index 0000000..fd80538
--- /dev/null
+++ b/proxy.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+use constant UNLOCK_PROXY_URL  => '/proxy/unlock';
+use constant UNLOCK_PROXY_HOST => qr/^yplom\.bicyclesonthemoon\.info(:[0-9]*)?$/;
+use constant UNLOCK_PROXY_PATH => qr/^\/proxy\/unlock\/?$/;
+
+if (($ENV{'HTTP_HOST'} =~ UNLOCK_PROXY_HOST) and ($ENV{'PATH_INFO'} =~ UNLOCK_PROXY_PATH)){
+# if (($ENV{'HTTP_HOST'} =~ /^yplom\.bicyclesonthemoon\.info(:(590)?80)?$/) and ($ENV{'PATH_INFO'} =~ /^\/proxy\/unlock\/?$/)){
+       unlockpage();
+}
+else {
+       debag();
+}
+
+sub unlockpage {
+       print "Content-type: text/html\n\n";
+       print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">';
+       print '<html lang="en"><head>';
+       print '<title>Unlock the proxy</title>';
+       print '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">';
+       print '</head><body>';
+       print '<h1>Unlock the proxy</h1>';
+       print '<form method="get" action="'.UNLOCK_PROXY_URL.'">';
+       print '<b>Username: </b><input type="text" name="username"><br>';
+       print '<b>Password: </b><input type="password" name="password"><br>';
+       print '<input type="submit" value="unlock">';
+       print '</form></body></html>';
+       print "\n";
+}
+
+sub debag {
+       print "Content-type: text/plain\n\n";
+       print foreach $envk (keys %ENV) { 
+               print "$envk  =  $ENV{$envk}\n"; 
+       }
+       print "\n";
+       
+       foreach $line ( <STDIN> ) {
+               print $line;
+       }
+       print "\n\n";
+       if ($ENV{'REQUEST_URI'} =~ /^[a-z]*(:[0-9]*)?:\/\//){
+               #if
+               $URL=$ENV{'REQUEST_URI'}
+       }
+       else{
+               $URL='http://'.$ENV{'HTTP_HOST'}.$ENV{'REQUEST_URI'};
+       }       
+       print 'URL: ',$URL,"\n";
+}
+
+
+
+
+
diff --git a/rewrite b/rewrite
new file mode 100755 (executable)
index 0000000..cbef212
--- /dev/null
+++ b/rewrite
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "OK rewrite-url=\"bicyclesonthemoon.info:59443\""