applications/luci-splash: remove debugging code from splashd
[project/luci.git] / applications / luci-splash / root / usr / bin / luci-splashd
index 3e0c938ebda9b58b7f74e4a68c17f23e32989521..b6b877ad0481ecaaacc14e46bde4ced50b7de185 100755 (executable)
@@ -4,7 +4,8 @@ require("socket")
 require("luci.ip")
 require("luci.model.uci")
 
-luci.model.uci.load_state("network")
+local uci = luci.model.uci.cursor_state()
+uci:load("network")
 
 local server = socket.bind("0.0.0.0", arg[1] or 8082)
 server:settimeout(0, "t")
@@ -15,17 +16,20 @@ while true do
        if client then
                client:settimeout(1)
                local srv
-               local ip = luci.ip.IPv4(client:getpeername())
-               luci.model.uci.foreach("network", "interface",
-                       function (section)
-                           if section.ipaddr then
-                               local net = luci.ip.IPv4(section.ipaddr, section.netmask)
-                               if ip and net and net:contains(ip) then
-                                   srv = section.ipaddr
-                                   return
-                               end
-                           end
-                       end)
+               local ip  = luci.ip.IPv4((client:getpeername()))
+
+               local function find_srv(section)
+                       if section.ipaddr then
+                               local net = luci.ip.IPv4(section.ipaddr, section.netmask)
+                               if ip and net and net:contains(ip) then
+                                       srv = section.ipaddr
+                                       return
+                               end
+                       end
+               end
+               
+               uci:foreach("network", "interface", find_srv)
+               uci:foreach("network", "alias", find_srv)
 
                client:receive()
                client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv ..