summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash/root
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-29 14:42:53 +0000
committerSteven Barth <steven@midlink.org>2008-06-29 14:42:53 +0000
commitee324cb3a70d39dc9522a1ee63af12137d433533 (patch)
tree564544d3e6bff5e916d77a427bba6b1536ba7c94 /applications/luci-splash/root
parent4c7df626b2a27e9bea4793c96929de17f38e7bd2 (diff)
* applications/luci-splash: Rewrote luci-splash using an own daemon implementation
* Minor tweaks in luci.dispatcher
Diffstat (limited to 'applications/luci-splash/root')
-rwxr-xr-xapplications/luci-splash/root/etc/init.d/luci_splash4
-rw-r--r--applications/luci-splash/root/etc/luci_splash_httpd.conf1
-rwxr-xr-xapplications/luci-splash/root/usr/bin/luci-splashd20
-rwxr-xr-xapplications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi53
-rw-r--r--applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html10
5 files changed, 22 insertions, 66 deletions
diff --git a/applications/luci-splash/root/etc/init.d/luci_splash b/applications/luci-splash/root/etc/init.d/luci_splash
index 20f7865fd..eb006e9b0 100755
--- a/applications/luci-splash/root/etc/init.d/luci_splash
+++ b/applications/luci-splash/root/etc/init.d/luci_splash
@@ -62,8 +62,8 @@ start() {
iptables -t nat -A luci_splash_leases -j DROP
### Start the splash httpd
- httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs
-
+ start-stop-daemon -S -b -q -x /usr/bin/luci-splashd
+
### Hook in the chain
iptables -t nat -A prerouting_rule -j luci_splash
}
diff --git a/applications/luci-splash/root/etc/luci_splash_httpd.conf b/applications/luci-splash/root/etc/luci_splash_httpd.conf
deleted file mode 100644
index 6007e80db..000000000
--- a/applications/luci-splash/root/etc/luci_splash_httpd.conf
+++ /dev/null
@@ -1 +0,0 @@
-E404:index.html \ No newline at end of file
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 000000000..33391cc5b
--- /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
diff --git a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi
deleted file mode 100755
index 29679a21c..000000000
--- a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/lua
-
-require("luci.sys")
-require("luci.model.uci")
-
-luci.model.uci.set_savedir(luci.model.uci.savedir_state)
-
-local srv
-local net
-local ip = os.getenv("REMOTE_ADDR")
-luci.model.uci.foreach("network", "interface",
- function (section)
- if section.ipaddr then
- local p = luci.sys.net.mask4prefix(section.netmask)
- if luci.sys.net.belongs(ip, section.ipaddr, p) then
- net = section[".name"]
- srv = section.ipaddr
- return
- end
- end
- end)
-
-local stat = false
-luci.model.uci.foreach("luci_splash", "iface",
- function (section)
- if section.network == net then
- stat = true
- end
- end)
-
-if not srv then
- print("Content-Type: text/plain\n")
- print("Unable to detect network settings!")
-elseif not stat then
- print("Status: 302 Found")
- print("Location: http://" .. srv)
-else
- local action = "splash"
-
- local mac = luci.sys.net.ip4mac(ip)
- if not mac then
- action = "unknown"
- end
-
- local status = luci.sys.execl("luci-splash status "..mac)[1]
-
- if status == "whitelisted" or status == "lease" then
- action = "allowed"
- end
-
- print("Status: 302 Found")
- print("Location: http://" .. srv .. "/cgi-bin/luci-splash/" .. action)
-end
diff --git a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html
deleted file mode 100644
index 39ba558df..000000000
--- a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
-</head>
-<body style="background-color: black">
-<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">LuCI - Lua Configuration Interface</a>
-</body>
-</html> \ No newline at end of file