summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash/root/usr/bin/luci-splashd
blob: 6152daa524f51810af7e671bd9212a9121c793eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/lua

local nixio = require "nixio"
local server = nixio.bind(nil, arg[1] or 8082)
local stat = server:listen(32)

while stat do
	local client = server:accept()
	
	if client then
		client:setopt("socket", "rcvtimeo", 1)
		client:setopt("socket", "sndtimeo", 1)
		local srv = client:getsockname()

		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() 
	end
end