applications/luci-splash: implement alias interface support in luci-splashd

This commit is contained in:
Jo-Philipp Wich 2009-02-19 23:09:28 +00:00
parent b6406c3980
commit 593bc2df7b

View file

@ -16,17 +16,21 @@ while true do
if client then if client then
client:settimeout(1) client:settimeout(1)
local srv local srv
local ip = luci.ip.IPv4((client:getpeername())) print (client:getpeername())
uci:foreach("network", "interface", local ip = luci.ip.IPv4((client:getpeername()))
function (section)
if section.ipaddr then local function find_srv(section)
local net = luci.ip.IPv4(section.ipaddr, section.netmask) if section.ipaddr then
if ip and net and net:contains(ip) then local net = luci.ip.IPv4(section.ipaddr, section.netmask)
srv = section.ipaddr if ip and net and net:contains(ip) then
return srv = section.ipaddr
end return
end end
end) end
end
uci:foreach("network", "interface", find_srv)
uci:foreach("network", "alias", find_srv)
client:receive() client:receive()
client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv .. client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv ..