diff options
author | Jan Huwald <jh@sotun.de> | 2012-04-23 16:33:37 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-04-23 16:33:37 (GMT) |
commit | 4176db98cb9a9437c939ac6b9f85fb176614b2cc (patch) | |
tree | b7bd9497beed44948c1bcadca34246ad0c29e55d /files/common/www | |
parent | 312d7c1eb3b92e11b192c0717b1480d096db20d3 (diff) |
rewrite splash to use a p2ptbl
- add p2ptbl splash (see doc/splash.org)
- replace all uci queries with p2ptbl queries
- centralize splash db modification in /etc/splash.sh
- add node to the list of splashed devices upon first use of
/etc/splash.sh (shortly after booting)
- remove locks in cgi-bin/splash_click
Diffstat (limited to 'files/common/www')
-rwxr-xr-x | files/common/www/service/cgi-bin/splash_click.html | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/files/common/www/service/cgi-bin/splash_click.html b/files/common/www/service/cgi-bin/splash_click.html index 59926d0..8affc71 100755 --- a/files/common/www/service/cgi-bin/splash_click.html +++ b/files/common/www/service/cgi-bin/splash_click.html @@ -1,39 +1,21 @@ #!/bin/sh -e - -. $IPKG_INSTROOT/etc/functions.sh . /etc/splash.sh . /www/service/cgi-bin/common.sh # decode request params -#URL="http://$(sed 's/target_url=//g' | urldecode || true)" -URL="http://sotun.de/" +URL="http://$(sed 's/target_url=//g' | urldecode || true)" USER_MAC=$(grep ^$REMOTE_HOST </proc/net/arp \ | awk 'BEGIN { FS = " " } ; { print $4 }') [ -n "$USER_MAC" ] -# check if user is already splashed; splash otherwise -lockSplash -ISSPLASHED=0 -config_load splash_users -is_mac() { - config_get mac "$1" mac - if [ "$mac" == "$USER_MAC" ]; then - ISSPLASHED=1 - fi -} -config_foreach is_mac user -if [ $ISSPLASHED -eq 0 ]; then - # user is now free to go - chain=$chain_prefix$chain_id - if have_internet; then - iptables -t nat -I $chain 1 -m mac --mac-source $USER_MAC -j ACCEPT +# check if user is already splashed; splash otherwise; refresh the +# p2ptbl entry in any case (renews the timer) +if [ -z "$(p2ptbl get $tbl "$USER_MAC")" ]; then + if have_splash_iptable; then + add_splash_iptable "$USER_MAC" fi - - uci -q add splash_users user >/dev/null - uci -q set splash_users.@user[-1].mac=$USER_MAC - uci -q set splash_users.@user[-1].time=`date +%s` fi -unlockSplash +add_splash_p2ptbl "$USER_MAC" # send response (encode / to not confuse sed) |