summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash/root/usr/bin/luci-splashd
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-splash/root/usr/bin/luci-splashd')
-rwxr-xr-xapplications/luci-splash/root/usr/bin/luci-splashd20
1 files changed, 20 insertions, 0 deletions
diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd
new file mode 100755
index 0000000000..33391cc5bb
--- /dev/null
+++ b/applications/luci-splash/root/usr/bin/luci-splashd
@@ -0,0 +1,20 @@
+#!/usr/bin/lua
+require("socket")
+
+local server = socket.bind("0.0.0.0", arg[1] or 8082)
+server:settimeout(0, "t")
+
+while true do
+ local client = server:accept()
+
+ if client then
+ client:settimeout(1)
+ local srv = client:getsockname()
+ client:receive()
+ client:send("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