diff options
author | Darkeye <postfach@martinmichel.info> | 2011-01-24 16:23:56 (GMT) |
---|---|---|
committer | Darkeye <postfach@martinmichel.info> | 2011-01-24 16:23:56 (GMT) |
commit | b24ca8d14eb8244f18288c429a0f6a69222c78d0 (patch) | |
tree | 0bd5b4993a414b892ea4f2ed500b3ca2bf49843c /files | |
parent | b6f2f51aef5938d585a4ad7aeb7666116c420c24 (diff) |
Splash Screen first implementation. Only wifi-ap is splashed. After click user can use the ap 6000 seconds. Splashed users stored in uci file
Diffstat (limited to 'files')
-rw-r--r-- | files/etc/config/splash_users | 1 | ||||
-rw-r--r-- | files/etc/config/uhttpd | 39 | ||||
-rw-r--r-- | files/etc/crontabs/root | 1 | ||||
-rwxr-xr-x | files/sbin/splash_sync | 43 | ||||
-rwxr-xr-x | files/www/cgi-bin/splash_click | 31 | ||||
-rw-r--r-- | files/www/splash.html | 3 |
6 files changed, 118 insertions, 0 deletions
diff --git a/files/etc/config/splash_users b/files/etc/config/splash_users new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/files/etc/config/splash_users @@ -0,0 +1 @@ + diff --git a/files/etc/config/uhttpd b/files/etc/config/uhttpd new file mode 100644 index 0000000..a424463 --- /dev/null +++ b/files/etc/config/uhttpd @@ -0,0 +1,39 @@ +# 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 /splash.html + option index_page splash.html + # Reject requests from RFC1918 IP addresses + # directed to the servers public IP(s). + # This is a DNS rebinding countermeasure. + option rfc1918_filter 1 + + # CGI url prefix, will be searched in docroot. + # Default is /cgi-bin + option cgi_prefix /cgi-bin + + # CGI/Lua timeout, if the called script does not + # write data within the given amount of seconds, + # the server will terminate the request with + # 504 Gateway Timeout response. + option script_timeout 60 + + # Network timeout, if the current connection is + # blocked for the specified amount of seconds, + # the server will terminate the associated + # request process. + option network_timeout 30 + + # TCP Keep-Alive, send periodic keep-alive probes + # over established connections to detect dead peers. + # 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 + + + diff --git a/files/etc/crontabs/root b/files/etc/crontabs/root index cfac6b1..bf3cb9e 100644 --- a/files/etc/crontabs/root +++ b/files/etc/crontabs/root @@ -1 +1,2 @@ * * * * * /sbin/test_gateway > /dev/null +* * * * * /sbin/splash_sync > /dev/null diff --git a/files/sbin/splash_sync b/files/sbin/splash_sync new file mode 100755 index 0000000..8299f97 --- /dev/null +++ b/files/sbin/splash_sync @@ -0,0 +1,43 @@ +#!/bin/sh +. $IPKG_INSTROOT/etc/functions.sh +x=0 +config_load splash_users +test=1 +splash_check() { + timeout=6000 + current_time=`date +%s` + config_get ip "$1" ip + config_get time "$1" time + local config="$1" + echo Vergleich Jetzt `date +%s` gespeichert $time + let time_check=$time+$timeout + if [ $time_check -gt $current_time ]; then + # User ist noch gesplashed + echo User ist noch gesplashed + iptables -t nat -D ffj_splash -s $ip -j ACCEPT + iptables -t nat -I ffj_splash 1 -s $ip -j ACCEPT + else + # User is not longer splashed / the user must click again + iptables -t nat -D ffj_splash -s $ip -j ACCPET + uci delete splash_users.@user[$x].ip + uci delete splash_users.@user[$x].time + uci delete splash_users.@user[$x] + uci commit + fi + let x=$x+1 +} +#chain refresh +iptables -t nat -D zone_mesh_prerouting -p tcp -j ffj_splash +iptables -t nat -F ffj_splash +iptables -t nat -X ffj_splash +#recreation +iptables -t nat -N ffj_splash +iptables -t nat -I zone_mesh_prerouting 1 -p tcp -j ffj_splash +config_foreach splash_check user +#iptables -t nat -D ffj_splash -p tcp -j DNAT --to 10.17.200.1:80 +iptables -t nat -A ffj_splash -p tcp -j DNAT --to 10.17.200.1:80 +#iptables -t nat -D ffj_splash -j DROP +#iptables -t nat -A ffj_splash -j DROP + + + diff --git a/files/www/cgi-bin/splash_click b/files/www/cgi-bin/splash_click new file mode 100755 index 0000000..32fce2e --- /dev/null +++ b/files/www/cgi-bin/splash_click @@ -0,0 +1,31 @@ +#!/bin/sh +echo -en "Status: 302 Temporary Redirect\r\n" +echo -en "Location: http://www.freifunk-jena.de\r\n" +echo -en "\r\n" + +. $IPKG_INSTROOT/etc/functions.sh +ISSPLASHED=0 +config_load splash_users +is_ip() { + config_get ip "$1" ip + if [ "$ip" == "$REMOTE_HOST" ]; then + ISSPLASHED=1 + fi +} +#check if user is alredy splashed +config_foreach is_ip user + +if [ $ISSPLASHED -eq 1 ]; then + exit +fi +#User is now free to go +iptables -t nat -I ffj_splash 1 -s $REMOTE_HOST -j ACCEPT +uci add splash_users user +uci set splash_users.@user[-1].ip=$REMOTE_HOST +uci set splash_users.@user[-1].time=`date +%s` +uci -q commit > /dev/null +exit 0 + + + + diff --git a/files/www/splash.html b/files/www/splash.html new file mode 100644 index 0000000..89e0736 --- /dev/null +++ b/files/www/splash.html @@ -0,0 +1,3 @@ +<h1>Splashpage</h1> + +<a href="/cgi-bin/splash_click?accept">Aktzeptieren</a> <a href="#">Ablehnen</a> |