Remove Luasocket - obsoleted by nixio
[project/luci.git] / applications / luci-splash / root / usr / bin / luci-splashd
1 #!/usr/bin/lua
2
3 local nixio = require "nixio"
4 local server = nixio.bind(nil, arg[1] or 8082)
5 local stat = server:listen(32)
6
7 while stat do
8         local client = server:accept()
9         
10         if client then
11                 client:setopt("socket", "rcvtimeo", 1)
12                 client:setopt("socket", "sndtimeo", 1)
13                 local srv = client:getsockname()
14
15                 client:read(1024)
16                 client:writeall("HTTP/1.0 302 Found\r\nLocation: http://" .. srv ..
17                  (arg[2] or "/luci/splash") .. "\r\n\r\n")
18                 client:close() 
19         end
20 end