applications/luci-splash: Always allow clients to connect to the community homepage...
authorManuel Munz <freifunk@somakoma.de>
Sun, 18 Aug 2013 20:37:35 +0000 (20:37 +0000)
committerManuel Munz <freifunk@somakoma.de>
Sun, 18 Aug 2013 20:37:35 +0000 (20:37 +0000)
applications/luci-splash/luasrc/model/cbi/splash/splash.lua
applications/luci-splash/root/etc/init.d/luci_splash
applications/luci-splash/root/usr/sbin/luci-splash

index 47d7695..206ef70 100644 (file)
@@ -16,6 +16,8 @@ s = m:section(NamedSection, "general", "core", translate("General"))
 s.addremove = false
 
 s:option(Value, "leasetime", translate("Clearance time"), translate("Clients that have accepted the splash are allowed to use the network for that many hours."))
 s.addremove = false
 
 s:option(Value, "leasetime", translate("Clearance time"), translate("Clients that have accepted the splash are allowed to use the network for that many hours."))
+local redir = s:option(Value, "redirect_url", translate("Redirect target"), translate("Clients are redirected to this page after they have accepted the splash. If this is left empty they are redirected to the page they had requested."))
+redir.rmempty = true
 
 s:option(Value, "limit_up", translate("Upload limit"), translate("Clients upload speed is limited to this value (kbyte/s)"))
 s:option(Value, "limit_down", translate("Download limit"), translate("Clients download speed is limited to this value (kbyte/s)"))
 
 s:option(Value, "limit_up", translate("Upload limit"), translate("Clients upload speed is limited to this value (kbyte/s)"))
 s:option(Value, "limit_down", translate("Download limit"), translate("Clients download speed is limited to this value (kbyte/s)"))
@@ -74,7 +76,7 @@ s.anonymous = true
 s:option(Value, "mac", translate ("MAC Address"))
 
 s = m:section(TypedSection, "subnet", translate("Allowed hosts/subnets"),
 s:option(Value, "mac", translate ("MAC Address"))
 
 s = m:section(TypedSection, "subnet", translate("Allowed hosts/subnets"),
-       translate("Hosts and Networks that are listed here are excluded from splashing, i.e. they are always allowed."))
+       translate("Destination hosts and networks that are excluded from splashing, i.e. they are always allowed."))
 
 s.template = "cbi/tblsection"
 s.addremove = true
 
 s.template = "cbi/tblsection"
 s.addremove = true
index 3607732..4f36252 100755 (executable)
@@ -270,6 +270,14 @@ start() {
        config_foreach iface_add iface
        config_foreach subnet_add subnet
 
        config_foreach iface_add iface
        config_foreach subnet_add subnet
 
+       ### Add the community homepage to the list of allowed destination subnets
+       hp=$(uci -q get freifunk.community.homepage) && {
+               chp=${hp#http*://}
+               chp=${chp%%/*}
+               $IPT -t nat    -I luci_splash_prerouting -d "${chp}/32" -j RETURN
+               $IPT -t filter -I luci_splash_forwarding -d "${chp}/32" -j RETURN
+       }
+
        ### Find active mac addresses
        MACS=""
 
        ### Find active mac addresses
        MACS=""
 
index e1f8d41..a34eeca 100755 (executable)
@@ -66,14 +66,14 @@ end
 
 
 
 
 
 
-function get_filter_handle(parent, direction, device)
+function get_filter_handle(parent, direction, device, mac)
        local input = utl.split(sys.exec('/usr/sbin/tc filter show dev ' .. device .. ' parent ' .. parent) or {})
        local tbl = {}
        local handle
        for k, v in pairs(input) do
                handle = v:match('filter protocol ip pref %d+ u32 fh (%d*:%d*:%d*) order')
                if handle then
        local input = utl.split(sys.exec('/usr/sbin/tc filter show dev ' .. device .. ' parent ' .. parent) or {})
        local tbl = {}
        local handle
        for k, v in pairs(input) do
                handle = v:match('filter protocol ip pref %d+ u32 fh (%d*:%d*:%d*) order')
                if handle then
-                       local mac1, mac2, mac3, mac4, mac5, mac6
+                       local mac, mac1, mac2, mac3, mac4, mac5, mac6
                        if direction == 'src' then
                                mac1, mac2, mac3, mac4 = input[k+1]:match('match ([%a%d][%a%d])([%a%d][%a%d])([%a%d][%a%d])([%a%d][%a%d])/ffffffff')
                                mac5, mac6 = input[k+2]:match('match ([%a%d][%a%d])([%a%d][%a%d])0000/ffff0000')
                        if direction == 'src' then
                                mac1, mac2, mac3, mac4 = input[k+1]:match('match ([%a%d][%a%d])([%a%d][%a%d])([%a%d][%a%d])([%a%d][%a%d])/ffffffff')
                                mac5, mac6 = input[k+2]:match('match ([%a%d][%a%d])([%a%d][%a%d])0000/ffff0000')
@@ -87,8 +87,8 @@ function get_filter_handle(parent, direction, device)
                        end
                end
        end
                        end
                end
        end
-       if tbl[mac:lower()] then
-               handle = tbl[mac:lower()]
+       if tbl[mac] then
+               handle = tbl[mac]
        end
        return handle
 end
        end
        return handle
 end