summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash/root
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-12 15:38:11 +0000
committerSteven Barth <steven@midlink.org>2008-07-12 15:38:11 +0000
commitc026b6ed03d78dc408bbe468c2eda0a9fe85a4d5 (patch)
tree3634a23adc1d28e5cad512b2044d609422aea5b3 /applications/luci-splash/root
parent12c01f8ae47d99d6486cd9512547b80ceb9e1ff1 (diff)
applications/luci-splash: Added UCI-state based server address detection
Diffstat (limited to 'applications/luci-splash/root')
-rwxr-xr-xapplications/luci-splash/root/usr/bin/luci-splashd17
1 files changed, 16 insertions, 1 deletions
diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd
index 33391cc5bb..a178ef232e 100755
--- a/applications/luci-splash/root/usr/bin/luci-splashd
+++ b/applications/luci-splash/root/usr/bin/luci-splashd
@@ -1,5 +1,8 @@
#!/usr/bin/lua
require("socket")
+require("luci.model.uci")
+
+luci.model.uci.set_savedir(luci.model.uci.savedir_state)
local server = socket.bind("0.0.0.0", arg[1] or 8082)
server:settimeout(0, "t")
@@ -9,7 +12,19 @@ while true do
if client then
client:settimeout(1)
- local srv = client:getsockname()
+ local ip = client:getpeername()
+ local srv
+ luci.model.uci.foreach("network", "interface",
+ function (section)
+ if section.ipaddr then
+ local p = luci.sys.net.mask4prefix(section.netmask)
+ if luci.sys.net.belongs(ip, section.ipaddr, p) then
+ srv = section.ipaddr
+ return
+ end
+ end
+ end)
+
client:receive()
client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv ..
(arg[2] or "/luci/splash") .. "\r\n\r\n")