summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 16:45:08 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 16:45:08 (GMT)
commit65c39ba8336b9efc1d76350ae27a18da6d51d5f6 (patch)
tree153e9f49fb41e451c75b5a824f119cfab019db6e
parentee91359463ae23b2ebe5cb235c7e11d362be81c8 (diff)
fsm inetable: change httpd instances in queen/ghost/robinson states
- update the redirection uhttpd config and www-root to redirect all incoming request to a url specified by /tmp/redirection_target - use this to implement robinson and splash redirection during robinson and queen/ghost states, respectively - change the service httpd to listen on the public IPv4 address available on the mesh interface in those states. Missing is the - iptable based redirection - already referenced /sbin/urlencode
-rw-r--r--files/common/etc/config/uhttpd6
-rw-r--r--files/common/etc/fsm/inetable/common_queen.sh1
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/queen.enter14
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/queen.leave7
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/robinson.enter6
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/robinson.leave7
-rwxr-xr-xfiles/common/www/redirection/redirect13
-rwxr-xr-xfiles/common/www/service/cgi-bin/redirect8
8 files changed, 47 insertions, 15 deletions
diff --git a/files/common/etc/config/uhttpd b/files/common/etc/config/uhttpd
index 857a7c1..d1e2eb0 100644
--- a/files/common/etc/config/uhttpd
+++ b/files/common/etc/config/uhttpd
@@ -37,12 +37,12 @@ config disabled service
# redirection instance
config disabled redirection
option home /www/redirection
- option error_page /cgi-bin/redirect
- option index_page cgi-bin/redirect
+ option error_page /redirect
+ option index_page redirect
+ option cgi_prefix /
# 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/etc/fsm/inetable/common_queen.sh b/files/common/etc/fsm/inetable/common_queen.sh
index 8107cd2..86b3aba 100644
--- a/files/common/etc/fsm/inetable/common_queen.sh
+++ b/files/common/etc/fsm/inetable/common_queen.sh
@@ -7,6 +7,7 @@ DHCPLeaseTime=$((12 * 3600))
NodeId="$(cat /etc/nodeid)"
oct3=$(ifconfig br-mesh | egrep -o 'inet addr:[0-9.]*'|cut -f3 -d.)
[ -n "$oct3" ]
+gwip=10.17.$oct3.1
we_own_our_ip () {
[ "$(p2ptbl get $gwiptbl $oct3 | cut -sf2)" == "$NodeId" ]
diff --git a/files/common/etc/fsm/inetable/trans/queen.enter b/files/common/etc/fsm/inetable/trans/queen.enter
index fe0799e..c8ec801 100755
--- a/files/common/etc/fsm/inetable/trans/queen.enter
+++ b/files/common/etc/fsm/inetable/trans/queen.enter
@@ -25,13 +25,14 @@ if [ -z "$oct3" ]; then
# TODO: log warning about IPv4 addr space exhaustion
fi
[ -n "$oct3" ]
+gwip=10.17.$oct3.1
p2ptbl update $gwiptbl $oct3 "queen\t$NodeId" br-mesh
# activate gw mode
batctl gw server
# set up gw IP
-mesh_add_ipv4 10.17.$oct3.1 255.255.0.0
+mesh_add_ipv4 $gwip 255.255.0.0
# TODO: load splash status
@@ -42,7 +43,12 @@ set dhcp.mesh.start=2
set dhcp.mesh.limit=254
set dhcp.mesh.leasetime=$DHCPLeaseTime
set dhcp.mesh.interface=mesh
-set dhcp.mesh.start_ip=10.17.$oct3.2
-set dhcp.mesh.end_ip=10.17.$oct3.254
" | uci batch
-/etc/init.d/dnsmasq restart \ No newline at end of file
+/etc/init.d/dnsmasq restart
+
+# start redirection httpd (for splash), add GW IP to the addrs service
+# httpd listens on
+echo "http://$gwip/cgi-bin/splash? /sbin/urlencode" > /tmp/redirection_target
+enable_httpd redirection $randnet.1:81
+change_service_httpd_listen $gwip:80
+/etc/init.d/uhttpd restart
diff --git a/files/common/etc/fsm/inetable/trans/queen.leave b/files/common/etc/fsm/inetable/trans/queen.leave
index 502e972..306c2f8 100755
--- a/files/common/etc/fsm/inetable/trans/queen.leave
+++ b/files/common/etc/fsm/inetable/trans/queen.leave
@@ -18,3 +18,10 @@ uci delete dhcp.mesh
/etc/init.d/dnsmasq restart
# TODO remove splash iptable
+
+# stop redirection httpd, remove GW IP from the addrs service httpd
+# listens on
+disable_httpd redirection
+rm /tmp/redirection_target
+change_service_httpd_listen
+/etc/init.d/uhttpd restart
diff --git a/files/common/etc/fsm/inetable/trans/robinson.enter b/files/common/etc/fsm/inetable/trans/robinson.enter
index 163f155..e54c6ba 100755
--- a/files/common/etc/fsm/inetable/trans/robinson.enter
+++ b/files/common/etc/fsm/inetable/trans/robinson.enter
@@ -28,4 +28,10 @@ batctl gw off
# TODO: start fake dns
+# start redirection httpd, add robinson IP to service httpd
+echo "http://$randnet.1/robinson.html" > /tmp/redirection_target
+enable_httpd redirection $randnet.1:81
+change_service_httpd_listen $randnet.1:80
+/etc/init.d/uhttpd restart
+
# TODO: redirect all inet traffic to local httpd
diff --git a/files/common/etc/fsm/inetable/trans/robinson.leave b/files/common/etc/fsm/inetable/trans/robinson.leave
index cdc5461..1797e2f 100755
--- a/files/common/etc/fsm/inetable/trans/robinson.leave
+++ b/files/common/etc/fsm/inetable/trans/robinson.leave
@@ -9,4 +9,11 @@ uci delete dhcp.mesh
# TODO: stop fake dns
+# stop redirection httpd, remove robinson IP from service httpd
+disable_httpd redirection
+rm /tmp/redirection_target
+change_service_httpd_listen
+/etc/init.d/uhttpd restart
+
+
# TODO: stop redirecting all inet traffic to local httpd
diff --git a/files/common/www/redirection/redirect b/files/common/www/redirection/redirect
new file mode 100755
index 0000000..41b4eef
--- /dev/null
+++ b/files/common/www/redirection/redirect
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+read url reftrans < /tmp/redirection_target
+if [ -x "$reftrans" ]; then
+ url="$url$($reftrans "$HTTP_HOST$REQUEST_URI")"
+fi
+echo -e \
+"Cache-Control: no-cache, max-age=0, no-store, must-revalidate\r
+Pragma: no-cache\r
+Expires: -1\r
+Status: 302 Temporary Redirect\r
+Location: $url\r
+\r"
diff --git a/files/common/www/service/cgi-bin/redirect b/files/common/www/service/cgi-bin/redirect
deleted file mode 100755
index 9b417db..0000000
--- a/files/common/www/service/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
contact: Jan Huwald // Impressum