X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-splash%2Froot%2Fusr%2Fbin%2Fluci-splashd;h=e8c275209e4ce54011769c59d3c57c32bb049d57;hp=33391cc5bb4950ba4279803b1580048bfd2726c8;hb=e080fcebd2396c138d8c916d1cf385a88e0db246;hpb=ee324cb3a70d39dc9522a1ee63af12137d433533 diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd index 33391cc5b..e8c275209 100755 --- a/applications/luci-splash/root/usr/bin/luci-splashd +++ b/applications/luci-splash/root/usr/bin/luci-splashd @@ -1,5 +1,10 @@ #!/usr/bin/lua + require("socket") +require("luci.ip") +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 +14,19 @@ while true do if client then client:settimeout(1) - local srv = client:getsockname() + 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) + client:receive() client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv .. (arg[2] or "/luci/splash") .. "\r\n\r\n")