From 9809a97ce4ac8f5b374c7b1d91b5d4571dbf6392 Mon Sep 17 00:00:00 2001 From: Katze Miau Date: Sun, 11 Dec 2011 15:42:01 +0000 Subject: split /www into subdirs for several services; adapt uhttpd config This patch splits the single uhttpd instance into two uhttpd instances with www root /www/ for the following purposes: - service :: self-service / debugging / status.xml - redirection :: use for splash/robinson redirection The uhttpd uci config is adapted: by default all instances declared there are disabled; They shall be enabled by the FSM inetable. To this end a listen_http directive will be added and the config type will be changed from 'disabled' to 'uhttpd' by state transition scripts. diff --git a/files/common/etc/config/uhttpd b/files/common/etc/config/uhttpd index 8320d42..857a7c1 100644 --- a/files/common/etc/config/uhttpd +++ b/files/common/etc/config/uhttpd @@ -1,12 +1,11 @@ -# Server configuration -config uhttpd main - - # HTTP listen addresses, multiple allowed - list listen_http 0.0.0.0:80 - # Server document root - option home /www - option error_page /cgi-bin/redirect - option index_page cgi-bin/redirect +# By default all instances declared here are disabled; They are +# enabled by the FSM inetable. To this end a listen_http directive +# will be added and the config type will be changed from 'disabled' to +# 'uhttpd'; The rest of the config section is left as-is. + +# service instance +config disabled service + option home /www/service # Reject requests from RFC1918 IP addresses # directed to the servers public IP(s). # This is a DNS rebinding countermeasure. @@ -20,7 +19,7 @@ config uhttpd main # write data within the given amount of seconds, # the server will terminate the request with # 504 Gateway Timeout response. - option script_timeout 60 + option script_timeout 10 # Network timeout, if the current connection is # blocked for the specified amount of seconds, @@ -33,7 +32,17 @@ config uhttpd main # The value is given in seconds to specify the # interval between subsequent probes. # Setting this to 0 will disable TCP keep-alive. - option tcp_keepalive 1 - + option tcp_keepalive 10 +# redirection instance +config disabled redirection + option home /www/redirection + option error_page /cgi-bin/redirect + option index_page cgi-bin/redirect + # default options + option rfc1918_filter 1 + option cgi_prefix /cgi-bin + option script_timeout 10 + option network_timeout 30 + option tcp_keepalive 10 diff --git a/files/common/www/cgi-bin/debug b/files/common/www/cgi-bin/debug deleted file mode 100755 index 14d8447..0000000 --- a/files/common/www/cgi-bin/debug +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -echo -en "Status: 200 OK\r\n" -echo -en "Content-Type: text/html\r\n" -echo -en "\r\n" - -echo "" -echo "

Router Status

" -echo "

Batman-ADV

" -echo "
"
-batctl tg | cat
-batctl tl |cat
-echo "
" -echo "

Netzwerk

" -echo "
"
-ifconfig | cat
-echo "
" -echo "

Prozesse

" -echo "
"         
-ps aux | cat       
-echo "
" -echo "

UCI

" -echo "
"         
-uci show | cat       
-echo "
" -echo "" - diff --git a/files/common/www/cgi-bin/redirect b/files/common/www/cgi-bin/redirect deleted file mode 100755 index 9b417db..0000000 --- a/files/common/www/cgi-bin/redirect +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -echo -en "Cache-Control: no-cache, max-age=0, no-store, must-revalidate\r\n" -echo -en "Pragma: no-cache\r\n" -echo -en "Expires: -1\r\n" -echo -en "Status: 302 Temporary Redirect\r\n" -echo -en "Location: http://"`uci get network.mesh.ipaddr`"/cgi-bin/splash?"`/bin/urlencode "$HTTP_HOST$REQUEST_URI"`"\r\n" -echo -en "\r\n" -exit 0 diff --git a/files/common/www/cgi-bin/splash b/files/common/www/cgi-bin/splash deleted file mode 100755 index ee907d6..0000000 --- a/files/common/www/cgi-bin/splash +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -echo -en "Status: 200 OK\r\n" -echo -en "Content-Type: text/html\r\n" -echo -en "\r\n" -#targeturl=$(echo $QUERY_STRING) -#targeturl=$(echo $QUERY_STRING | sed -f /etc/urlencode.sed) -targeturl=`echo $QUERY_STRING` -sed "s/targeturl/"$targeturl"/g" /www/splash.html diff --git a/files/common/www/cgi-bin/splash_click b/files/common/www/cgi-bin/splash_click deleted file mode 100755 index d08af6a..0000000 --- a/files/common/www/cgi-bin/splash_click +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -echo -en "Status: 200 OK\r\n" -echo -en "Content-Type: text/html\r\n" -echo -en "\r\n" -TEST=`cat ` -TEST=`echo $TEST | sed 's/'target_url='/''/g'` -TEST=`/bin/urldecode "$TEST"` -TEST=`echo $TEST | sed 's/%2F/\//g'` -USER_MAC=`cat /proc/net/arp | grep $REMOTE_HOST | awk 'BEGIN { FS = " " } ; { print $4 }'` - -. $IPKG_INSTROOT/etc/functions.sh -ISSPLASHED=0 -config_load splash_users -is_mac() { - config_get mac "$1" mac - if [ "$mac" == "$USER_MAC" ]; then - ISSPLASHED=1 - fi -} -#check if user is alredy splashed -config_foreach is_mac user -sed 's/targeturl/'"$(echo $TEST| sed 's#/#\\/#g')"'/g' /www/iframe.html - -if [ $ISSPLASHED -eq 1 ]; then - exit -fi -#User is now free to go -iptables -t nat -I ffj_splash 1 -m --mac-source $USER_MAC -j ACCEPT - -uci -q add splash_users user -uci -q set splash_users.@user[-1].mac=$USER_MAC -uci -q set splash_users.@user[-1].time=`date +%s` - -exit 0 - - - - diff --git a/files/common/www/cgi-bin/status.xml b/files/common/www/cgi-bin/status.xml deleted file mode 100755 index 8d45a90..0000000 --- a/files/common/www/cgi-bin/status.xml +++ /dev/null @@ -1,3 +0,0 @@ -#/bin/bash! -hostname=`hostname` -eval "echo \"$(cat template.status.xml)\"" diff --git a/files/common/www/cgi-bin/template.status.xml b/files/common/www/cgi-bin/template.status.xml deleted file mode 100644 index 7df4e9f..0000000 --- a/files/common/www/cgi-bin/template.status.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - $hostname - 0 - - - - - Max Mustermann - Susi Mustermann - - - - - - - - - - - - - - - - - - - - - diff --git a/files/common/www/ff-jena_signet.png b/files/common/www/ff-jena_signet.png deleted file mode 100644 index 15d216c..0000000 Binary files a/files/common/www/ff-jena_signet.png and /dev/null differ diff --git a/files/common/www/ffj.css b/files/common/www/ffj.css deleted file mode 100644 index 3542611..0000000 --- a/files/common/www/ffj.css +++ /dev/null @@ -1,61 +0,0 @@ -div#body { -width: 100%; -text-align: center; -} -div#maincontent{ -margin-left: auto; -margin-right: auto; -max-width: 600px; -font-family: Arial, Verdana, sans-serif; -font-size: 12pt; -text-align: left; -} -div#maincontent a, a:link, a:visited { -color: #464646; -text-decoration: none; -} - -div#button_area{ -padding-left:150px; -padding-right:150px; -text-align:center; -} - -div#button_left{ -float:left; -width: 50%; -text-align:center; -} - -div#button_right{ -float:right; -width: 50%; -text-align:center; -} - -input.button{ -border-color:white black black white; -border-style:solid; -border-width:1px; -background-color: #E5E5E5; -padding: 5px; -color: black; -font-weight: bold; -border-radius: 5px; --moz-border-radius: 5px; --webkit-border-radius: 5px; -} -input.button:hover { -background-color: grey; -border-color:white black black white; -border-style:solid; -border-width:1px; -} -div#logo { -height: 125px; -font-size: 24px; -} -img.logo { -float: left; -padding: 5px; -} diff --git a/files/common/www/iframe.html b/files/common/www/iframe.html deleted file mode 100644 index cdee514..0000000 --- a/files/common/www/iframe.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - Freifunk Jena - - - - - - - - - - diff --git a/files/common/www/service/cgi-bin/debug b/files/common/www/service/cgi-bin/debug new file mode 100755 index 0000000..14d8447 --- /dev/null +++ b/files/common/www/service/cgi-bin/debug @@ -0,0 +1,26 @@ +#!/bin/sh +echo -en "Status: 200 OK\r\n" +echo -en "Content-Type: text/html\r\n" +echo -en "\r\n" + +echo "" +echo "

Router Status

" +echo "

Batman-ADV

" +echo "
"
+batctl tg | cat
+batctl tl |cat
+echo "
" +echo "

Netzwerk

" +echo "
"
+ifconfig | cat
+echo "
" +echo "

Prozesse

" +echo "
"         
+ps aux | cat       
+echo "
" +echo "

UCI

" +echo "
"         
+uci show | cat       
+echo "
" +echo "" + diff --git a/files/common/www/service/cgi-bin/redirect b/files/common/www/service/cgi-bin/redirect new file mode 100755 index 0000000..9b417db --- /dev/null +++ b/files/common/www/service/cgi-bin/redirect @@ -0,0 +1,8 @@ +#!/bin/sh +echo -en "Cache-Control: no-cache, max-age=0, no-store, must-revalidate\r\n" +echo -en "Pragma: no-cache\r\n" +echo -en "Expires: -1\r\n" +echo -en "Status: 302 Temporary Redirect\r\n" +echo -en "Location: http://"`uci get network.mesh.ipaddr`"/cgi-bin/splash?"`/bin/urlencode "$HTTP_HOST$REQUEST_URI"`"\r\n" +echo -en "\r\n" +exit 0 diff --git a/files/common/www/service/cgi-bin/splash b/files/common/www/service/cgi-bin/splash new file mode 100755 index 0000000..ee907d6 --- /dev/null +++ b/files/common/www/service/cgi-bin/splash @@ -0,0 +1,8 @@ +#!/bin/sh +echo -en "Status: 200 OK\r\n" +echo -en "Content-Type: text/html\r\n" +echo -en "\r\n" +#targeturl=$(echo $QUERY_STRING) +#targeturl=$(echo $QUERY_STRING | sed -f /etc/urlencode.sed) +targeturl=`echo $QUERY_STRING` +sed "s/targeturl/"$targeturl"/g" /www/splash.html diff --git a/files/common/www/service/cgi-bin/splash_click b/files/common/www/service/cgi-bin/splash_click new file mode 100755 index 0000000..d08af6a --- /dev/null +++ b/files/common/www/service/cgi-bin/splash_click @@ -0,0 +1,38 @@ +#!/bin/sh +echo -en "Status: 200 OK\r\n" +echo -en "Content-Type: text/html\r\n" +echo -en "\r\n" +TEST=`cat ` +TEST=`echo $TEST | sed 's/'target_url='/''/g'` +TEST=`/bin/urldecode "$TEST"` +TEST=`echo $TEST | sed 's/%2F/\//g'` +USER_MAC=`cat /proc/net/arp | grep $REMOTE_HOST | awk 'BEGIN { FS = " " } ; { print $4 }'` + +. $IPKG_INSTROOT/etc/functions.sh +ISSPLASHED=0 +config_load splash_users +is_mac() { + config_get mac "$1" mac + if [ "$mac" == "$USER_MAC" ]; then + ISSPLASHED=1 + fi +} +#check if user is alredy splashed +config_foreach is_mac user +sed 's/targeturl/'"$(echo $TEST| sed 's#/#\\/#g')"'/g' /www/iframe.html + +if [ $ISSPLASHED -eq 1 ]; then + exit +fi +#User is now free to go +iptables -t nat -I ffj_splash 1 -m --mac-source $USER_MAC -j ACCEPT + +uci -q add splash_users user +uci -q set splash_users.@user[-1].mac=$USER_MAC +uci -q set splash_users.@user[-1].time=`date +%s` + +exit 0 + + + + diff --git a/files/common/www/service/cgi-bin/status.xml b/files/common/www/service/cgi-bin/status.xml new file mode 100755 index 0000000..8d45a90 --- /dev/null +++ b/files/common/www/service/cgi-bin/status.xml @@ -0,0 +1,3 @@ +#/bin/bash! +hostname=`hostname` +eval "echo \"$(cat template.status.xml)\"" diff --git a/files/common/www/service/cgi-bin/template.status.xml b/files/common/www/service/cgi-bin/template.status.xml new file mode 100644 index 0000000..7df4e9f --- /dev/null +++ b/files/common/www/service/cgi-bin/template.status.xml @@ -0,0 +1,31 @@ + + + $hostname + 0 + + + + + Max Mustermann + Susi Mustermann + + + + + + + + + + + + + + + + + + + + + diff --git a/files/common/www/service/ff-jena_signet.png b/files/common/www/service/ff-jena_signet.png new file mode 100644 index 0000000..15d216c Binary files /dev/null and b/files/common/www/service/ff-jena_signet.png differ diff --git a/files/common/www/service/ffj.css b/files/common/www/service/ffj.css new file mode 100644 index 0000000..3542611 --- /dev/null +++ b/files/common/www/service/ffj.css @@ -0,0 +1,61 @@ +div#body { +width: 100%; +text-align: center; +} +div#maincontent{ +margin-left: auto; +margin-right: auto; +max-width: 600px; +font-family: Arial, Verdana, sans-serif; +font-size: 12pt; +text-align: left; +} +div#maincontent a, a:link, a:visited { +color: #464646; +text-decoration: none; +} + +div#button_area{ +padding-left:150px; +padding-right:150px; +text-align:center; +} + +div#button_left{ +float:left; +width: 50%; +text-align:center; +} + +div#button_right{ +float:right; +width: 50%; +text-align:center; +} + +input.button{ +border-color:white black black white; +border-style:solid; +border-width:1px; +background-color: #E5E5E5; +padding: 5px; +color: black; +font-weight: bold; +border-radius: 5px; +-moz-border-radius: 5px; +-webkit-border-radius: 5px; +} +input.button:hover { +background-color: grey; +border-color:white black black white; +border-style:solid; +border-width:1px; +} +div#logo { +height: 125px; +font-size: 24px; +} +img.logo { +float: left; +padding: 5px; +} diff --git a/files/common/www/service/iframe.html b/files/common/www/service/iframe.html new file mode 100644 index 0000000..cdee514 --- /dev/null +++ b/files/common/www/service/iframe.html @@ -0,0 +1,20 @@ + + + + + + + Freifunk Jena + + + + + + + + + + diff --git a/files/common/www/service/splash.html b/files/common/www/service/splash.html new file mode 100644 index 0000000..7b85b5e --- /dev/null +++ b/files/common/www/service/splash.html @@ -0,0 +1,88 @@ + + + + + + + + + + + Freifunk Jena + + + + + +
+
+ + + +

Willkommen!

+

+ Du bist jetzt mit dem freien Funknetz Freifunk Jena verbunden.
+ + Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. +

+ +

+ Ein Zugang ins Internet ist trotzdem möglich, + da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. + Diese Zugänge müssen sich hier alle teilen. + Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: +

+ +
    +
  • bitte keine Filesharing-Programme betreiben!
  • +
  • bitte keine unnötigen Downloads oder Streams starten!
  • +
  • bitte keine illegalen Aktivitäten!
  • +
+ +

+ Wenn Du unsere Idee gut findest und das Netz regelmässig benutzt, dann bitten wir Dich um Unterstützung: +

+ + + +

+ Mit einem Klick auf Akzeptieren kannst du für + 1 Stunde(n) unser Netz verwenden. Dann wirst du + erneut aufgefordet, diese Bedingungen zu akzeptieren. +

+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+ + diff --git a/files/common/www/splash.html b/files/common/www/splash.html deleted file mode 100644 index 7b85b5e..0000000 --- a/files/common/www/splash.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - Freifunk Jena - - - - - -
-
- - - -

Willkommen!

-

- Du bist jetzt mit dem freien Funknetz Freifunk Jena verbunden.
- - Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. -

- -

- Ein Zugang ins Internet ist trotzdem möglich, - da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. - Diese Zugänge müssen sich hier alle teilen. - Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: -

- -
    -
  • bitte keine Filesharing-Programme betreiben!
  • -
  • bitte keine unnötigen Downloads oder Streams starten!
  • -
  • bitte keine illegalen Aktivitäten!
  • -
- -

- Wenn Du unsere Idee gut findest und das Netz regelmässig benutzt, dann bitten wir Dich um Unterstützung: -

- - - -

- Mit einem Klick auf Akzeptieren kannst du für - 1 Stunde(n) unser Netz verwenden. Dann wirst du - erneut aufgefordet, diese Bedingungen zu akzeptieren. -

- - -
-
-
-
- - -
-
-
-
-
-
- -
-
-
-
-
-
- - -- cgit v0.10.1