* applications/luci-splash: Rewrote luci-splash using an own daemon implementation
[project/luci.git] / applications / luci-splash / root / usr / bin / luci-splashd
1 #!/usr/bin/lua
2 require("socket")
3
4 local server = socket.bind("0.0.0.0", arg[1] or 8082)
5 server:settimeout(0, "t")
6
7 while true do
8         local client = server:accept()
9         
10         if client then
11                 client:settimeout(1)
12                 local srv = client:getsockname()
13                 client:receive()
14                 client:send("HTTP/1.0 302 Found\r\nLocation: http://" .. srv ..
15                  (arg[2] or "/luci/splash") .. "\r\n\r\n")
16                 client:close() 
17         else
18                 socket.sleep(0.1)
19         end
20 end