summaryrefslogtreecommitdiff
path: root/files/common/etc/splash.sh
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2012-04-23 16:33:37 (GMT)
committerJan Huwald <jh@sotun.de>2012-04-23 16:33:37 (GMT)
commit4176db98cb9a9437c939ac6b9f85fb176614b2cc (patch)
treeb7bd9497beed44948c1bcadca34246ad0c29e55d /files/common/etc/splash.sh
parent312d7c1eb3b92e11b192c0717b1480d096db20d3 (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/etc/splash.sh')
-rw-r--r--files/common/etc/splash.sh38
1 files changed, 32 insertions, 6 deletions
diff --git a/files/common/etc/splash.sh b/files/common/etc/splash.sh
index b56ddb5..75eb620 100644
--- a/files/common/etc/splash.sh
+++ b/files/common/etc/splash.sh
@@ -1,12 +1,7 @@
timeout=6000
chain_prefix=splash_db_
chain_id_file=/tmp/splash_chain_id
-
-chain_id=$(cat $chain_id_file 2>/dev/null || true)
-if ! [ "$chain_id" -gt 0 ] &>/dev/null; then
- chain_id=1
- echo $chain_id > $chain_id_file
-fi
+tbl=/tmp/p2ptbl/splash
lockSplash () {
exec 666<$chain_id_file
@@ -16,3 +11,34 @@ lockSplash () {
unlockSplash () {
exec 666<&-
}
+
+have_splash_iptable () {
+ state=${1:-$(fsm get inetable)}
+ [ "$state" == "queen" ]
+}
+
+# $mac
+add_splash_iptable () {
+ iptables -t nat -I $chain_prefix$chain_id \
+ -m mac --mac-source "$1" -j ACCEPT
+}
+
+# $mac $time
+add_splash_p2ptbl () {
+ p2ptbl update $tbl "$1" "${2:-$(($(date +%s) + $timeout))}" br-mesh
+}
+
+# determine current splash iptable iteration
+chain_id=$(cat $chain_id_file 2>/dev/null || true)
+if ! [ "$chain_id" -gt 0 ] &>/dev/null; then
+ # first -> create id file
+ chain_id=1
+ echo $chain_id > $chain_id_file
+
+ # create splash p2ptbl and add own MAC addr to it with an at least
+ # year 2033 timeout
+ p2ptbl init $tbl
+ add_splash_p2ptbl \
+ $(ifconfig br-mesh | egrep -o '([0-9A-F]{2}:){5}[0-9A-F]{2}') \
+ 2000000000
+fi
contact: Jan Huwald // Impressum