diff options
author | Steven Barth <steven@midlink.org> | 2009-05-01 11:28:34 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-05-01 11:28:34 +0000 |
commit | 67fbe1b33c2195cc763309ba7467100f56676467 (patch) | |
tree | 9d2f649d045e0da1e2df38d4ec896251861bb3a8 /applications | |
parent | 78d8ad784bdc06d07e2fcac409f2052b1d13d5f3 (diff) |
Remove Luasocket - obsoleted by nixio
Remove old luasocket based LuCI Httpd - obsoleted by lucittpd
Remove lpeg - not in use
Rewrite luci-splashd using nixio
Diffstat (limited to 'applications')
-rwxr-xr-x | applications/luci-splash/root/usr/bin/luci-splashd | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd index b6b877ad0..6152daa52 100755 --- a/applications/luci-splash/root/usr/bin/luci-splashd +++ b/applications/luci-splash/root/usr/bin/luci-splashd @@ -1,41 +1,20 @@ #!/usr/bin/lua -require("socket") -require("luci.ip") -require("luci.model.uci") +local nixio = require "nixio" +local server = nixio.bind(nil, arg[1] or 8082) +local stat = server:listen(32) -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") - -while true do +while stat do local client = server:accept() if client then - client:settimeout(1) - local srv - 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:setopt("socket", "rcvtimeo", 1) + client:setopt("socket", "sndtimeo", 1) + local srv = client:getsockname() - client:receive() - client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv .. + client:read(1024) + client:writeall("HTTP/1.0 302 Found\r\nLocation: http://" .. srv .. (arg[2] or "/luci/splash") .. "\r\n\r\n") client:close() - else - socket.sleep(0.1) end end |