This commit is contained in:
parent
706da44cf2
commit
ace012a032
34 changed files with 0 additions and 5185 deletions
|
@ -1,43 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=ffluci-splash
|
|
||||||
PKG_VERSION:=0.1
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
PKG_BUILD_DEPENDS:=lua-luci
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/ffluci-splash
|
|
||||||
SECTION:=admin
|
|
||||||
CATEGORY:=Administration
|
|
||||||
SUBMENU:=FFLuCI
|
|
||||||
DEPENDS:=+ffluci +iptables-mod-nat +lua-luci
|
|
||||||
TITLE:=FFLuCI DHCP-Splash
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/ffluci-splash/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/luci-splash/htdocs/cgi-bin
|
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
|
||||||
$(INSTALL_DIR) $(1)/etc/cron.minutely
|
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
|
||||||
|
|
||||||
$(CP) -a ./src/luci-splash/* $(1)/usr/lib/luci-splash/ -R
|
|
||||||
$(INSTALL_BIN) ./src/luci-splash/htdocs/cgi-bin/index.cgi $(1)/usr/lib/luci-splash/htdocs/cgi-bin
|
|
||||||
$(INSTALL_BIN) ./src/luci_splash.init $(1)/etc/init.d/luci_splash
|
|
||||||
$(INSTALL_BIN) ./src/luci-splash.lua $(1)/usr/sbin/luci-splash
|
|
||||||
|
|
||||||
$(INSTALL_BIN) -a ./src/luci_splash.cron $(1)/etc/cron.minutely/luci_splash
|
|
||||||
$(CP) -a ./src/luci_splash.uci $(1)/etc/config/luci_splash
|
|
||||||
$(CP) -a ./src/luci_splash_httpd.conf $(1)/etc/
|
|
||||||
|
|
||||||
$(CP) -a ./ipkg/conffiles $(1)/CONTROL/conffiles
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,ffluci-splash))
|
|
|
@ -1 +0,0 @@
|
||||||
/etc/config/luci_splash
|
|
|
@ -1,173 +0,0 @@
|
||||||
#!/usr/bin/lua
|
|
||||||
package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
|
|
||||||
package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
|
|
||||||
|
|
||||||
require("ffluci.http")
|
|
||||||
require("ffluci.sys")
|
|
||||||
require("ffluci.model.uci")
|
|
||||||
|
|
||||||
-- Init state session
|
|
||||||
uci = ffluci.model.uci.Session("/var/state")
|
|
||||||
|
|
||||||
|
|
||||||
-- Parse stdin and do something
|
|
||||||
function main(argv)
|
|
||||||
local cmd = argv[1]
|
|
||||||
local arg = argv[2]
|
|
||||||
|
|
||||||
if not cmd then
|
|
||||||
print("Usage: " .. argv[0] .. " <status|add|remove|sync> [MAC]")
|
|
||||||
os.exit(1)
|
|
||||||
elseif cmd == "status" then
|
|
||||||
if not arg then
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if iswhitelisted(arg) then
|
|
||||||
print("whitelisted")
|
|
||||||
os.exit(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
if haslease(arg) then
|
|
||||||
print("lease")
|
|
||||||
os.exit(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
print("unknown")
|
|
||||||
os.exit(0)
|
|
||||||
elseif cmd == "add" then
|
|
||||||
if not arg then
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not haslease(arg) then
|
|
||||||
add_lease(arg)
|
|
||||||
else
|
|
||||||
print("already leased!")
|
|
||||||
os.exit(2)
|
|
||||||
end
|
|
||||||
os.exit(0)
|
|
||||||
elseif cmd == "remove" then
|
|
||||||
if not cmd[2] then
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
remove_lease(arg)
|
|
||||||
os.exit(0)
|
|
||||||
elseif cmd == "sync" then
|
|
||||||
sync()
|
|
||||||
os.exit(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Add a lease to state and invoke add_rule
|
|
||||||
function add_lease(mac)
|
|
||||||
local key = uci:add("luci_splash", "lease")
|
|
||||||
uci:set("luci_splash", key, "mac", mac)
|
|
||||||
uci:set("luci_splash", key, "start", os.time())
|
|
||||||
add_rule(mac)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Remove a lease from state and invoke remove_rule
|
|
||||||
function remove_lease(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v.mac:lower() == mac then
|
|
||||||
remove_rule(mac)
|
|
||||||
uci:del("luci_splash", k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Add an iptables rule
|
|
||||||
function add_rule(mac)
|
|
||||||
return os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Remove an iptables rule
|
|
||||||
function remove_rule(mac)
|
|
||||||
return os.execute("iptables -t nat -D luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Check whether a MAC-Address is listed in the lease state list
|
|
||||||
function haslease(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v[".type"] == "lease" and v.mac and v.mac:lower() == mac then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Check whether a MAC-Address is whitelisted
|
|
||||||
function iswhitelisted(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v[".type"] == "whitelist" and v.mac and v.mac:lower() == mac then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Returns a list of MAC-Addresses for which a rule is existing
|
|
||||||
function listrules()
|
|
||||||
local cmd = "iptables -t nat -L luci_splash_leases | grep RETURN |"
|
|
||||||
cmd = cmd .. "egrep -io [0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+"
|
|
||||||
return ffluci.util.split(ffluci.sys.exec(cmd))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Synchronise leases, remove abandoned rules
|
|
||||||
function sync()
|
|
||||||
local written = {}
|
|
||||||
local time = os.time()
|
|
||||||
|
|
||||||
-- Current leases in state files
|
|
||||||
local leases = uci:show("luci_splash").luci_splash
|
|
||||||
|
|
||||||
-- Convert leasetime to seconds
|
|
||||||
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600
|
|
||||||
|
|
||||||
-- Clean state file
|
|
||||||
uci:revert("luci_splash")
|
|
||||||
|
|
||||||
|
|
||||||
-- For all leases
|
|
||||||
for k, v in pairs(uci:show("luci_splash")) do
|
|
||||||
if v[".type"] == "lease" then
|
|
||||||
if os.difftime(time, tonumber(v.start)) > leasetime then
|
|
||||||
-- Remove expired
|
|
||||||
remove_rule(v.mac)
|
|
||||||
else
|
|
||||||
-- Rewrite state
|
|
||||||
local n = uci:add("luci_splash", "lease")
|
|
||||||
uci:set("luci_splash", n, "mac", v.mac)
|
|
||||||
uci:set("luci_splash", n, "start", v.start)
|
|
||||||
written[v.mac] = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Delete rules without state
|
|
||||||
for i, r in ipairs(listrules()) do
|
|
||||||
if #r > 0 and not written[r] then
|
|
||||||
remove_rule(r)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
main(arg)
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/haserl --shell=luac
|
|
||||||
package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
|
|
||||||
package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
|
|
||||||
|
|
||||||
require("ffluci.http")
|
|
||||||
require("ffluci.sys")
|
|
||||||
require("ffluci.model.uci")
|
|
||||||
|
|
||||||
local srv
|
|
||||||
local ip = ffluci.http.remote_addr()
|
|
||||||
for k, v in pairs(ffluci.model.uci.show("network").network) do
|
|
||||||
if v[".type"] == "interface" and v.ipaddr then
|
|
||||||
local p = ffluci.sys.net.mask4prefix(v.netmask)
|
|
||||||
if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
|
|
||||||
srv = v.ipaddr
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not srv then
|
|
||||||
ffluci.http.textheader()
|
|
||||||
return print("Unable to detect network settings!")
|
|
||||||
end
|
|
||||||
|
|
||||||
local action = "splash"
|
|
||||||
|
|
||||||
local mac = ffluci.sys.net.ip4mac(ip)
|
|
||||||
if not mac then
|
|
||||||
action = "unknown"
|
|
||||||
end
|
|
||||||
|
|
||||||
local status = ffluci.sys.exec("luci-splash status "..mac)
|
|
||||||
|
|
||||||
if status == "whitelisted" or status == "lease" then
|
|
||||||
action = "allowed"
|
|
||||||
end
|
|
||||||
|
|
||||||
ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)
|
|
|
@ -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">FFLuCI - Freifunk Lua Configuration Interface</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
[ "$(date +%M | cut -c2)" == "5" ] && luci-splash sync
|
|
|
@ -1,88 +0,0 @@
|
||||||
#!/bin/sh /etc/rc.common
|
|
||||||
START=70
|
|
||||||
|
|
||||||
iface_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get net "$cfg" network
|
|
||||||
[ -n "$net" ] || return 0
|
|
||||||
|
|
||||||
config_get iface "$net" ifname
|
|
||||||
[ -n "$iface" ] || return 0
|
|
||||||
iface="${iface%%:*}"
|
|
||||||
|
|
||||||
config_get ipaddr "$net" ipaddr
|
|
||||||
[ -n "$ipaddr" ] || return 0
|
|
||||||
|
|
||||||
config_get netmask "$net" netmask
|
|
||||||
[ -n "$netmask" ] || return 0
|
|
||||||
|
|
||||||
eval "$(ipcalc.sh $ipaddr $netmask)"
|
|
||||||
|
|
||||||
iptables -t nat -A luci_splash -i "$iface" -s "$IP/$PREFIX" -j luci_splash_portal
|
|
||||||
iptables -t nat -A luci_splash_portal -i "$iface" -s "$IP/$PREFIX" -d "$ipaddr" -p tcp --dport 80 -j RETURN
|
|
||||||
}
|
|
||||||
|
|
||||||
blacklist_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get mac "$cfg" mac
|
|
||||||
[ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
|
|
||||||
}
|
|
||||||
|
|
||||||
whitelist_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get mac "$cfg" mac
|
|
||||||
[ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
### Read chains from config
|
|
||||||
include /lib/network
|
|
||||||
scan_interfaces
|
|
||||||
config_load luci_splash
|
|
||||||
|
|
||||||
### Create subchains
|
|
||||||
iptables -t nat -N luci_splash
|
|
||||||
iptables -t nat -N luci_splash_portal
|
|
||||||
iptables -t nat -N luci_splash_leases
|
|
||||||
|
|
||||||
### Build the main and portal rule
|
|
||||||
config_foreach blacklist_add blacklist
|
|
||||||
config_foreach whitelist_add whitelist
|
|
||||||
config_foreach iface_add iface
|
|
||||||
|
|
||||||
### Build the portal rule
|
|
||||||
iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
|
|
||||||
iptables -t nat -A luci_splash_portal -j luci_splash_leases
|
|
||||||
|
|
||||||
### Build the leases rule
|
|
||||||
iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
|
|
||||||
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
|
|
||||||
|
|
||||||
### Sync leases
|
|
||||||
/usr/lib/luci-splash/sync.lua
|
|
||||||
|
|
||||||
### Hook in the chain
|
|
||||||
iptables -t nat -A prerouting_rule -j luci_splash
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
### Hook out the chain
|
|
||||||
iptables -t nat -D prerouting_rule -j luci_splash
|
|
||||||
|
|
||||||
### Clear subchains
|
|
||||||
iptables -t nat -F luci_splash_leases
|
|
||||||
iptables -t nat -F luci_splash_portal
|
|
||||||
iptables -t nat -F luci_splash
|
|
||||||
|
|
||||||
### Delete subchains
|
|
||||||
iptables -t nat -X luci_splash_leases
|
|
||||||
iptables -t nat -X luci_splash_portal
|
|
||||||
iptables -t nat -X luci_splash
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
config core general
|
|
||||||
option leasetime 1
|
|
|
@ -1 +0,0 @@
|
||||||
E404:index.html
|
|
|
@ -1,32 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=ffluci-system-addons
|
|
||||||
PKG_VERSION:=0.1
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/ffluci-splash
|
|
||||||
SECTION:=admin
|
|
||||||
CATEGORY:=Administration
|
|
||||||
SUBMENU:=FFLuCI
|
|
||||||
TITLE:=FFLuCI System Addons for Kamikaze
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/ffluci-system-addons/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
|
||||||
$(INSTALL_DIR) $(1)/etc/crontabs
|
|
||||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
|
||||||
|
|
||||||
$(INSTALL_BIN) ./src/run-parts $(1)/usr/bin
|
|
||||||
$(CP) ./src/root.crontab $(1)/etc/crontabs/root
|
|
||||||
$(CP) ./src/hotplug.d-20-aliases $(1)/etc/hotplug.d/iface/20-aliases
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,ffluci-system-addons))
|
|
|
@ -1,24 +0,0 @@
|
||||||
add_aliases() {
|
|
||||||
local config="$1"
|
|
||||||
|
|
||||||
config_get base "$INTERFACE" ifname
|
|
||||||
config_get iface "$config" ifname
|
|
||||||
config_get ipaddr "$config" ipaddr
|
|
||||||
config_get auto "$config" auto
|
|
||||||
|
|
||||||
[ "${iface%%:*}" == "$base" -a "$iface" != "$base" ] && {
|
|
||||||
case "$auto" in
|
|
||||||
1|on|enabled) setup_interface "$iface" "$config";;
|
|
||||||
*) return 1;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case "$ACTION" in
|
|
||||||
ifup)
|
|
||||||
include /lib/network
|
|
||||||
scan_interfaces
|
|
||||||
config_foreach "add_aliases" interface
|
|
||||||
;;
|
|
||||||
esac
|
|
|
@ -1,3 +0,0 @@
|
||||||
0-59/1 * * * * /usr/bin/run-parts /etc/cron.minutely
|
|
||||||
0 * * * * /usr/bin/run-parts /etc/cron.hourly
|
|
||||||
0 0 * * * /usr/bin/run-parts /etc/cron.daily
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set +e
|
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
|
||||||
echo "Usage: run-parts <dir>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d $1 ]; then
|
|
||||||
echo "Not a directory: $1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $1/*; do
|
|
||||||
[ -x $i ] && $i
|
|
||||||
done
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,74 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=ffluci
|
|
||||||
PKG_REV:=HEAD
|
|
||||||
PKG_VERSION:=0.3+svn$(PKG_REV)
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
PKG_BRANCH:=trunk
|
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=svn
|
|
||||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
|
||||||
PKG_SOURCE_URL:=https://dev.leipzig.freifunk.net/svn/ff-luci/$(PKG_BRANCH)
|
|
||||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
|
|
||||||
PKG_BUILD_DEPENDS:=lua-luci
|
|
||||||
|
|
||||||
MAKE_ACTION:=compile LUAC=$(BUILD_DIR_HOST)/lua-luci/luac
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/ffluci
|
|
||||||
SECTION:=admin
|
|
||||||
CATEGORY:=Administration
|
|
||||||
TITLE:=FFLuCI
|
|
||||||
SUBMENU:=FFLuCI
|
|
||||||
DEPENDS:=+luaposix +haserl-lua +ffluci-system-addons
|
|
||||||
MAINTAINER:=Steven Barth <steven-at-midlink-dot-org>
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR)/core $(MAKE_ACTION)
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR)/module/admin-core $(MAKE_ACTION)
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR)/module/public-core $(MAKE_ACTION)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/ffluci/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/ffluci
|
|
||||||
$(INSTALL_DIR) $(1)/www/cgi-bin
|
|
||||||
$(INSTALL_DIR) $(1)/www/ffluci
|
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
|
||||||
$(INSTALL_DIR) $(1)/sbin
|
|
||||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
|
||||||
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/core/dist/* $(1)/usr/lib/lua/ -R
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/core/contrib/uci/* $(1)/etc/config/
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/ffluci $(1)/www/cgi-bin
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/ffluci-upload $(1)/www/cgi-bin
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/index.cgi $(1)/www/cgi-bin
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/index.html $(1)/www
|
|
||||||
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/themes/fledermaus/contrib/media $(1)/www/ffluci/ -R
|
|
||||||
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/module/admin-core/dist/* $(1)/usr/lib/lua/ffluci/ -R
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/module/admin-core/contrib/uci/luci_fw $(1)/etc/config/luci_fw
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/init.d/luci_fw $(1)/etc/init.d/luci_fw
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/ffluci-flash $(1)/sbin
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/luci-splash $(1)/www/cgi-bin
|
|
||||||
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/module/public-core/dist/* $(1)/usr/lib/lua/ffluci/ -R
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/module/public-core/contrib/media $(1)/www/ffluci/ -R
|
|
||||||
|
|
||||||
$(CP) -a ./ipkg/ffluci.postinst $(1)/CONTROL/postinst
|
|
||||||
$(CP) -a ./ipkg/conffiles $(1)/CONTROL/conffiles
|
|
||||||
rm $(DL_DIR)/$(PKG_SOURCE)
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,ffluci))
|
|
|
@ -1,2 +0,0 @@
|
||||||
/etc/config/luci
|
|
||||||
/etc/config/luci_fw
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
PATTERNS='/cgi-bin/ffluci/admin:root:$p$root /cgi-bin/ffluci-upload:root:$p$root'
|
|
||||||
|
|
||||||
for i in $PATTERNS
|
|
||||||
do
|
|
||||||
grep "$i" ${IPKG_INSTROOT}/etc/httpd.conf >/dev/null 2>/dev/null || echo "$i" >> ${IPKG_INSTROOT}/etc/httpd.conf
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -n ${IPKG_INSTROOT} ] || /etc/init.d/httpd restart
|
|
|
@ -1,40 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (C) 2006 OpenWrt.org
|
|
||||||
#
|
|
||||||
# This is free software, licensed under the GNU General Public License v2.
|
|
||||||
# See /LICENSE for more information.
|
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=haserl-lua
|
|
||||||
PKG_VERSION:=0.9.24
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
|
||||||
PKG_SOURCE_URL:=http://dev.leipzig.freifunk.net/svn/ff-luci/trunk/contrib/package-source/ \
|
|
||||||
http://firmware.freifunk-halle.net/ffluci/package-source/
|
|
||||||
PKG_MD5SUM:=b004005594b84e35839b1d5c330f8e03
|
|
||||||
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/haserl-lua
|
|
||||||
SECTION:=utils
|
|
||||||
CATEGORY:=Utilities
|
|
||||||
TITLE:=A CGI wrapper to embed shell scripts in HTML documents
|
|
||||||
URL:=http://haserl.sourceforge.net/
|
|
||||||
DEPENDS:=+liblua-luci
|
|
||||||
endef
|
|
||||||
|
|
||||||
CONFIGURE_ARGS += \
|
|
||||||
--with-lua
|
|
||||||
|
|
||||||
define Package/haserl-lua/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
|
||||||
$(STRIP) $(PKG_BUILD_DIR)/src/haserl
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/haserl $(1)/usr/bin/
|
|
||||||
echo "Replaces: haserl" >> $(1)/CONTROL/control
|
|
||||||
echo "Conflicts: haserl" >> $(1)/CONTROL/control
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,haserl-lua))
|
|
|
@ -1,12 +0,0 @@
|
||||||
diff -ur haserl-0.9.23.orig/src/haserl_lualib.inc haserl-0.9.23/src/haserl_lualib.inc
|
|
||||||
--- haserl-0.9.23.orig/src/haserl_lualib.inc 2008-04-05 16:40:35.000000000 +0200
|
|
||||||
+++ haserl-0.9.23/src/haserl_lualib.inc 2008-04-05 16:41:37.000000000 +0200
|
|
||||||
@@ -1,7 +1,7 @@
|
|
||||||
/* This file was automatically generated from haserl_lualib.lua. DO NOT EDIT */
|
|
||||||
|
|
||||||
static const unsigned char haserl_lualib[] = {
|
|
||||||
- 27, 76,117, 97, 81, 0, 1, 4, 4, 4, 8, 0, 19, 0, 0, 0,
|
|
||||||
+ 27, 76,117, 97, 81, 0, 1, 4, 4, 4, 8, 4, 19, 0, 0, 0,
|
|
||||||
64,104, 97,115,101,114,108, 95,108,117, 97,108,105, 98, 46,108,
|
|
||||||
117, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 16,
|
|
||||||
0, 0, 0, 10, 0, 0, 0, 74, 0, 0, 0,138, 0, 0, 0,135,
|
|
|
@ -1,151 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (C) 2006 OpenWrt.org
|
|
||||||
#
|
|
||||||
# This is free software, licensed under the GNU General Public License v2.
|
|
||||||
# See /LICENSE for more information.
|
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=lua-luci
|
|
||||||
PKG_VERSION:=5.1.3
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
|
||||||
PKG_SOURCE_URL:=http://dev.leipzig.freifunk.net/svn/ff-luci/trunk/contrib/package-source/ \
|
|
||||||
http://firmware.freifunk-halle.net/ffluci/package-source/
|
|
||||||
PKG_MD5SUM:=98b12c767a5eed92169b01537e988c7f
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
|
|
||||||
X_HOST_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/lua-luci/Default
|
|
||||||
SUBMENU:=LUA
|
|
||||||
SECTION:=lang
|
|
||||||
CATEGORY:=Languages
|
|
||||||
TITLE:=LUA programming language
|
|
||||||
URL:=http://www.lua.org/
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci/Default/description
|
|
||||||
Lua is a powerful light-weight programming language designed for extending
|
|
||||||
applications. Lua is also frequently used as a general-purpose, stand-alone
|
|
||||||
language. Lua is free software.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/liblua-luci
|
|
||||||
$(call Package/lua-luci/Default)
|
|
||||||
SUBMENU:=
|
|
||||||
SECTION:=libs
|
|
||||||
CATEGORY:=Libraries
|
|
||||||
TITLE+= (libraries)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/liblua-luci/description
|
|
||||||
$(call Package/lua-luci/Default/description)
|
|
||||||
This package contains the LUA shared libraries, needed by other programs.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci
|
|
||||||
$(call Package/lua-luci/Default)
|
|
||||||
DEPENDS:=+liblua-luci
|
|
||||||
TITLE+= (interpreter)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci/description
|
|
||||||
$(call Package/lua-luci/Default/description)
|
|
||||||
This package contains the LUA language interpreter.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/luac-luci
|
|
||||||
$(call Package/lua-luci/Default)
|
|
||||||
DEPENDS:=+liblua-luci
|
|
||||||
TITLE+= (compiler)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/luac/description
|
|
||||||
$(call Package/lua-luci/Default/description)
|
|
||||||
This package contains the LUA language compiler.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci-examples
|
|
||||||
$(call Package/lua-luci/Default)
|
|
||||||
DEPENDS:=lua-luci
|
|
||||||
TITLE+= (examples)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci-examples/description
|
|
||||||
$(call Package/lua-luci/Default/description)
|
|
||||||
This package contains LUA language examples.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
cp $(PKG_BUILD_DIR)/src $(PKG_BUILD_DIR)/src-host -R
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
|
||||||
CC="$(TARGET_CROSS)gcc" \
|
|
||||||
LD="$(TARGET_CROSS)ld" \
|
|
||||||
AR="$(TARGET_CROSS)ar rcu" \
|
|
||||||
RANLIB="$(TARGET_CROSS)ranlib" \
|
|
||||||
INSTALL_ROOT=/usr \
|
|
||||||
MYCFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
|
|
||||||
MYLDFLAGS="$(TARGET_LDFLAGS)" \
|
|
||||||
PKG_VERSION=$(PKG_VERSION) \
|
|
||||||
all linux
|
|
||||||
rm -rf $(PKG_INSTALL_DIR)
|
|
||||||
mkdir -p $(PKG_INSTALL_DIR)
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
|
||||||
INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
|
|
||||||
install
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR)/src-host luac-host
|
|
||||||
mkdir -p $(X_HOST_DIR)
|
|
||||||
cp $(PKG_BUILD_DIR)/src-host/luac-host $(X_HOST_DIR)/luac
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/InstallDev
|
|
||||||
mkdir -p $(1)/usr/include
|
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
|
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
|
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
|
|
||||||
mkdir -p $(1)/usr/lib
|
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so.*} $(1)/usr/lib/
|
|
||||||
ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblua.so
|
|
||||||
ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/liblua-luci/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/lib
|
|
||||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
|
|
||||||
echo "Replaces: liblua" >> $(1)/CONTROL/control
|
|
||||||
echo "Conflicts: liblua" >> $(1)/CONTROL/control
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
|
||||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
|
|
||||||
echo "Replaces: lua" >> $(1)/CONTROL/control
|
|
||||||
echo "Conflicts: lua" >> $(1)/CONTROL/control
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/luac-luci/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
|
||||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
|
|
||||||
echo "Replaces: luac" >> $(1)/CONTROL/control
|
|
||||||
echo "Conflicts: luac" >> $(1)/CONTROL/control
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/lua-luci-examples/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/share/lua/examples
|
|
||||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
|
|
||||||
$(1)/usr/share/lua/examples/
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,liblua-luci))
|
|
||||||
$(eval $(call BuildPackage,lua-luci))
|
|
||||||
$(eval $(call BuildPackage,luac-luci))
|
|
||||||
$(eval $(call BuildPackage,lua-luci-examples))
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,139 +0,0 @@
|
||||||
diff -ur lua-5.1.3-pt1/Makefile lua-5.1.3-pt2/Makefile
|
|
||||||
--- lua-5.1.3-pt1/Makefile 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/Makefile 2008-04-05 15:13:38.000000000 +0200
|
|
||||||
@@ -37,8 +37,8 @@
|
|
||||||
|
|
||||||
# What to install.
|
|
||||||
TO_BIN= lua luac
|
|
||||||
-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
|
|
||||||
-TO_LIB= liblua.a
|
|
||||||
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
|
|
||||||
+TO_LIB= liblua.a liblua.so liblua.so.$R
|
|
||||||
TO_MAN= lua.1 luac.1
|
|
||||||
|
|
||||||
# Lua version and release.
|
|
||||||
diff -ur lua-5.1.3-pt1/src/ldo.h lua-5.1.3-pt2/src/ldo.h
|
|
||||||
--- lua-5.1.3-pt1/src/ldo.h 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/ldo.h 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -46,7 +46,7 @@
|
|
||||||
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
|
|
||||||
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
|
|
||||||
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
|
|
||||||
-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
|
|
||||||
+LUA_API void luaD_growstack (lua_State *L, int n);
|
|
||||||
|
|
||||||
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
|
|
||||||
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
|
|
||||||
diff -ur lua-5.1.3-pt1/src/lfunc.h lua-5.1.3-pt2/src/lfunc.h
|
|
||||||
--- lua-5.1.3-pt1/src/lfunc.h 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/lfunc.h 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -18,7 +18,7 @@
|
|
||||||
cast(int, sizeof(TValue *)*((n)-1)))
|
|
||||||
|
|
||||||
|
|
||||||
-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
|
|
||||||
+LUA_API Proto *luaF_newproto (lua_State *L);
|
|
||||||
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
|
|
||||||
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
|
|
||||||
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
|
|
||||||
diff -ur lua-5.1.3-pt1/src/lmem.h lua-5.1.3-pt2/src/lmem.h
|
|
||||||
--- lua-5.1.3-pt1/src/lmem.h 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/lmem.h 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -38,9 +38,9 @@
|
|
||||||
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
|
|
||||||
|
|
||||||
|
|
||||||
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
|
|
||||||
+LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
|
|
||||||
size_t size);
|
|
||||||
-LUAI_FUNC void *luaM_toobig (lua_State *L);
|
|
||||||
+LUA_API void *luaM_toobig (lua_State *L);
|
|
||||||
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
|
|
||||||
size_t size_elem, int limit,
|
|
||||||
const char *errormsg);
|
|
||||||
diff -ur lua-5.1.3-pt1/src/lstring.h lua-5.1.3-pt2/src/lstring.h
|
|
||||||
--- lua-5.1.3-pt1/src/lstring.h 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/lstring.h 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -25,7 +25,7 @@
|
|
||||||
|
|
||||||
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
|
|
||||||
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
|
|
||||||
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
|
|
||||||
+LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
diff -ur lua-5.1.3-pt1/src/lundump.h lua-5.1.3-pt2/src/lundump.h
|
|
||||||
--- lua-5.1.3-pt1/src/lundump.h 2008-04-05 14:23:14.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/lundump.h 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -17,7 +17,7 @@
|
|
||||||
LUAI_FUNC void luaU_header (char* h);
|
|
||||||
|
|
||||||
/* dump one chunk; from ldump.c */
|
|
||||||
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
|
||||||
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
|
||||||
|
|
||||||
#ifdef luac_c
|
|
||||||
/* print one chunk; from print.c */
|
|
||||||
diff -ur lua-5.1.3-pt1/src/Makefile lua-5.1.3-pt2/src/Makefile
|
|
||||||
--- lua-5.1.3-pt1/src/Makefile 2008-04-05 14:23:31.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt2/src/Makefile 2008-04-05 14:25:40.000000000 +0200
|
|
||||||
@@ -23,6 +23,7 @@
|
|
||||||
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
|
||||||
|
|
||||||
LUA_A= liblua.a
|
|
||||||
+LUA_SO= liblua.so
|
|
||||||
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
|
|
||||||
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
|
|
||||||
lundump.o lvm.o lzio.o lnum.o
|
|
||||||
@@ -33,11 +34,12 @@
|
|
||||||
LUA_O= lua.o
|
|
||||||
|
|
||||||
LUAC_T= luac
|
|
||||||
-LUAC_O= luac.o print.o
|
|
||||||
+LUAC_O= luac.o print.o lopcodes.o
|
|
||||||
|
|
||||||
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
|
|
||||||
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
|
|
||||||
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
|
|
||||||
ALL_A= $(LUA_A)
|
|
||||||
+ALL_SO= $(LUA_SO)
|
|
||||||
|
|
||||||
default: $(PLAT)
|
|
||||||
|
|
||||||
@@ -47,14 +49,23 @@
|
|
||||||
|
|
||||||
a: $(ALL_A)
|
|
||||||
|
|
||||||
+so: $(ALL_SO)
|
|
||||||
+
|
|
||||||
$(LUA_A): $(CORE_O) $(LIB_O)
|
|
||||||
$(AR) $@ $?
|
|
||||||
$(RANLIB) $@
|
|
||||||
|
|
||||||
-$(LUA_T): $(LUA_O) $(LUA_A)
|
|
||||||
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
|
||||||
+$(LUA_SO): $(CORE_O) $(LIB_O)
|
|
||||||
+ $(LD) -o $@.$(PKG_VERSION) -shared -soname="$@.$(PKG_VERSION)" $?
|
|
||||||
+ ln -fs $@.$(PKG_VERSION) $@
|
|
||||||
+
|
|
||||||
+$(LUA_T): $(LUA_O) $(LUA_SO)
|
|
||||||
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
|
|
||||||
+
|
|
||||||
+$(LUAC_T): $(LUAC_O) $(LUA_SO)
|
|
||||||
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
|
|
||||||
|
|
||||||
-$(LUAC_T): $(LUAC_O) $(LUA_A)
|
|
||||||
+$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
|
|
||||||
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@@ -96,7 +107,7 @@
|
|
||||||
$(MAKE) all MYCFLAGS=
|
|
||||||
|
|
||||||
linux:
|
|
||||||
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
|
||||||
+ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
|
||||||
|
|
||||||
macosx:
|
|
||||||
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
|
|
|
@ -1,113 +0,0 @@
|
||||||
diff -ur lua-5.1.3-pt2/src/ldump.c lua-5.1.3-pt3/src/ldump.c
|
|
||||||
--- lua-5.1.3-pt2/src/ldump.c 2008-04-05 14:25:13.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt3/src/ldump.c 2008-04-05 14:28:27.000000000 +0200
|
|
||||||
@@ -67,12 +67,12 @@
|
|
||||||
{
|
|
||||||
if (s==NULL || getstr(s)==NULL)
|
|
||||||
{
|
|
||||||
- size_t size=0;
|
|
||||||
+ unsigned int size=0;
|
|
||||||
DumpVar(size,D);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
- size_t size=s->tsv.len+1; /* include trailing '\0' */
|
|
||||||
+ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
|
|
||||||
DumpVar(size,D);
|
|
||||||
DumpBlock(getstr(s),size,D);
|
|
||||||
}
|
|
||||||
diff -ur lua-5.1.3-pt2/src/lundump.c lua-5.1.3-pt3/src/lundump.c
|
|
||||||
--- lua-5.1.3-pt2/src/lundump.c 2008-04-05 14:25:13.000000000 +0200
|
|
||||||
+++ lua-5.1.3-pt3/src/lundump.c 2008-04-05 14:28:27.000000000 +0200
|
|
||||||
@@ -25,6 +25,7 @@
|
|
||||||
ZIO* Z;
|
|
||||||
Mbuffer* b;
|
|
||||||
const char* name;
|
|
||||||
+ int swap;
|
|
||||||
} LoadState;
|
|
||||||
|
|
||||||
#ifdef LUAC_TRUST_BINARIES
|
|
||||||
@@ -40,7 +41,6 @@
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
|
|
||||||
#define LoadByte(S) (lu_byte)LoadChar(S)
|
|
||||||
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
|
||||||
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
|
||||||
@@ -52,6 +52,49 @@
|
|
||||||
IF (r!=0, "unexpected end");
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void LoadMem (LoadState* S, void* b, int n, size_t size)
|
|
||||||
+{
|
|
||||||
+ LoadBlock(S,b,n*size);
|
|
||||||
+ if (S->swap)
|
|
||||||
+ {
|
|
||||||
+ char* p=(char*) b;
|
|
||||||
+ char c;
|
|
||||||
+ switch (size)
|
|
||||||
+ {
|
|
||||||
+ case 1:
|
|
||||||
+ break;
|
|
||||||
+ case 2:
|
|
||||||
+ while (n--)
|
|
||||||
+ {
|
|
||||||
+ c=p[0]; p[0]=p[1]; p[1]=c;
|
|
||||||
+ p+=2;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case 4:
|
|
||||||
+ while (n--)
|
|
||||||
+ {
|
|
||||||
+ c=p[0]; p[0]=p[3]; p[3]=c;
|
|
||||||
+ c=p[1]; p[1]=p[2]; p[2]=c;
|
|
||||||
+ p+=4;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case 8:
|
|
||||||
+ while (n--)
|
|
||||||
+ {
|
|
||||||
+ c=p[0]; p[0]=p[7]; p[7]=c;
|
|
||||||
+ c=p[1]; p[1]=p[6]; p[6]=c;
|
|
||||||
+ c=p[2]; p[2]=p[5]; p[5]=c;
|
|
||||||
+ c=p[3]; p[3]=p[4]; p[4]=c;
|
|
||||||
+ p+=8;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ IF(1, "bad size");
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int LoadChar(LoadState* S)
|
|
||||||
{
|
|
||||||
char x;
|
|
||||||
@@ -83,7 +126,7 @@
|
|
||||||
|
|
||||||
static TString* LoadString(LoadState* S)
|
|
||||||
{
|
|
||||||
- size_t size;
|
|
||||||
+ unsigned int size;
|
|
||||||
LoadVar(S,size);
|
|
||||||
if (size==0)
|
|
||||||
return NULL;
|
|
||||||
@@ -194,6 +237,7 @@
|
|
||||||
char s[LUAC_HEADERSIZE];
|
|
||||||
luaU_header(h);
|
|
||||||
LoadBlock(S,s,LUAC_HEADERSIZE);
|
|
||||||
+ S->swap=(s[6]!=h[6]); s[6]=h[6];
|
|
||||||
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -228,7 +272,7 @@
|
|
||||||
*h++=(char)LUAC_FORMAT;
|
|
||||||
*h++=(char)*(char*)&x; /* endianness */
|
|
||||||
*h++=(char)sizeof(int);
|
|
||||||
- *h++=(char)sizeof(size_t);
|
|
||||||
+ *h++=(char)sizeof(unsigned int);
|
|
||||||
*h++=(char)sizeof(Instruction);
|
|
||||||
*h++=(char)sizeof(lua_Number);
|
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
diff -ur lua-luci-5.1.3/src/luaconf.h lua-luci-5.1.3-new/src/luaconf.h
|
|
||||||
--- lua-luci-5.1.3/src/luaconf.h 2008-04-14 13:19:54.000000000 +0200
|
|
||||||
+++ lua-luci-5.1.3-new/src/luaconf.h 2008-04-14 13:19:17.000000000 +0200
|
|
||||||
@@ -38,7 +38,6 @@
|
|
||||||
#if defined(LUA_USE_LINUX)
|
|
||||||
#define LUA_USE_POSIX
|
|
||||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
|
||||||
-#define LUA_USE_READLINE /* needs some extra libraries */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(LUA_USE_MACOSX)
|
|
||||||
Nur in lua-luci-5.1.3-new/src: luaconf.h.orig.
|
|
||||||
diff -ur lua-luci-5.1.3/src/Makefile lua-luci-5.1.3-new/src/Makefile
|
|
||||||
--- lua-luci-5.1.3/src/Makefile 2008-04-14 13:19:57.000000000 +0200
|
|
||||||
+++ lua-luci-5.1.3-new/src/Makefile 2008-04-14 13:19:17.000000000 +0200
|
|
||||||
@@ -17,6 +17,7 @@
|
|
||||||
MYCFLAGS=
|
|
||||||
MYLDFLAGS=
|
|
||||||
MYLIBS=
|
|
||||||
+# USE_READLINE=1
|
|
||||||
|
|
||||||
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
|
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@
|
|
||||||
@echo "MYLIBS = $(MYLIBS)"
|
|
||||||
|
|
||||||
# convenience targets for popular platforms
|
|
||||||
-
|
|
||||||
+RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
|
|
||||||
none:
|
|
||||||
@echo "Please choose a platform:"
|
|
||||||
@echo " $(PLATS)"
|
|
||||||
@@ -101,16 +102,16 @@
|
|
||||||
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
|
|
||||||
|
|
||||||
freebsd:
|
|
||||||
- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
|
|
||||||
+ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
|
|
||||||
|
|
||||||
generic:
|
|
||||||
$(MAKE) all MYCFLAGS=
|
|
||||||
|
|
||||||
linux:
|
|
||||||
- $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
|
||||||
+ $(MAKE) all MYCFLAGS+="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
|
|
||||||
|
|
||||||
macosx:
|
|
||||||
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
|
|
||||||
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
|
|
||||||
# use this on Mac OS X 10.3-
|
|
||||||
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
|
|
||||||
|
|
||||||
Nur in lua-luci-5.1.3-new/src: Makefile.orig.
|
|
|
@ -1,44 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=luaposix
|
|
||||||
PKG_VERSION:=5.1.2
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
|
||||||
PKG_SOURCE_URL:=http://luaforge.net/frs/download.php/3063
|
|
||||||
PKG_MD5SUM:=31deeb4add91f76b3c2d36aae2888d81
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/luaposix
|
|
||||||
SECTION:=lib
|
|
||||||
CATEGORY:=Libraries
|
|
||||||
TITLE:=Lua Posix library
|
|
||||||
URL:=http://luaforge.net/projects/luaposix/
|
|
||||||
DEPENDS:=+liblua-luci
|
|
||||||
MAINTAINER:=Steven Barth <steven-at-midlink-dot-org>
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
|
||||||
CC="$(TARGET_CROSS)gcc" \
|
|
||||||
LD="$(TARGET_CROSS)ld" \
|
|
||||||
AR="$(TARGET_CROSS)ar rcu" \
|
|
||||||
RANLIB="$(TARGET_CROSS)ranlib" \
|
|
||||||
INSTALL_ROOT=/usr \
|
|
||||||
LUAINC=$(STAGING_DIR)/usr/include
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/luaposix/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua
|
|
||||||
$(STRIP) $(PKG_BUILD_DIR)/posix.so
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/posix.so $(1)/usr/lib/lua
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,luaposix))
|
|
|
@ -1,41 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=luci-splash
|
|
||||||
PKG_VERSION:=0.1
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/luci-splash
|
|
||||||
SECTION:=admin
|
|
||||||
CATEGORY:=Administration
|
|
||||||
SUBMENU:=FFLuCI
|
|
||||||
DEPENDS:=+ffluci +iptables-mod-nat
|
|
||||||
TITLE:=FFLuCI DHCP-Splash
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/luci-splash/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/luci-splash/htdocs
|
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
|
||||||
$(INSTALL_DIR) $(1)/etc/crontabs
|
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
|
||||||
|
|
||||||
$(CP) -a ./src/luci-splash/* $(1)/usr/lib/luci-splash/ -R
|
|
||||||
$(INSTALL_BIN) ./src/luci-splash/sync.lua $(1)/usr/lib/luci-splash
|
|
||||||
$(INSTALL_BIN) ./src/luci-splash/htdocs/cgi-bin/index.cgi $(1)/usr/lib/luci-splash/htdocs/cgi-bin
|
|
||||||
$(INSTALL_BIN) ./src/luci_splash.init $(1)/etc/init.d/luci_splash
|
|
||||||
|
|
||||||
$(CP) -a ./src/luci_splash.cron $(1)/etc/crontabs/luci_splash
|
|
||||||
$(CP) -a ./src/luci_splash.uci $(1)/etc/config/luci_splash
|
|
||||||
$(CP) -a ./src/luci_splash_httpd.conf $(1)/etc/
|
|
||||||
|
|
||||||
$(CP) -a ./ipkg/conffiles $(1)/CONTROL/conffiles
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,luci-splash))
|
|
|
@ -1 +0,0 @@
|
||||||
/etc/config/luci_splash
|
|
|
@ -1,31 +0,0 @@
|
||||||
#!/usr/bin/haserl --shell=luac
|
|
||||||
dofile("/usr/lib/luci-splash/splash.lua")
|
|
||||||
|
|
||||||
local srv
|
|
||||||
local ip = ffluci.http.remote_addr()
|
|
||||||
for k, v in pairs(uci:show("network").network) do
|
|
||||||
if v[".type"] == "interface" then
|
|
||||||
local p = ffluci.sys.net.mask4prefix(v.netmask)
|
|
||||||
if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
|
|
||||||
srv = v.ipaddr
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not srv then
|
|
||||||
ffluci.http.textheader()
|
|
||||||
return print("Unable to detect network settings!")
|
|
||||||
end
|
|
||||||
|
|
||||||
local action = "splash"
|
|
||||||
|
|
||||||
local mac = ip4mac(ip)
|
|
||||||
if not mac then
|
|
||||||
action = "unknown"
|
|
||||||
end
|
|
||||||
|
|
||||||
if iswhitelisted(mac) or haslease(mac) then
|
|
||||||
action = "allowed"
|
|
||||||
end
|
|
||||||
|
|
||||||
ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)
|
|
|
@ -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">FFLuCI - Freifunk Lua Configuration Interface</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,93 +0,0 @@
|
||||||
package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
|
|
||||||
package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
|
|
||||||
|
|
||||||
require("ffluci.http")
|
|
||||||
require("ffluci.sys")
|
|
||||||
require("ffluci.model.uci")
|
|
||||||
|
|
||||||
-- Init state session
|
|
||||||
uci = ffluci.model.uci.Session("/var/state")
|
|
||||||
|
|
||||||
|
|
||||||
-- Add a lease to state and invoke add_rule
|
|
||||||
function add_lease(mac)
|
|
||||||
local key = uci:add("luci_splash", "lease")
|
|
||||||
uci:set("luci_splash", key, "mac", mac)
|
|
||||||
uci:set("luci_splash", key, "start", os.time())
|
|
||||||
add_rule(mac)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Remove a lease from state and invoke remove_rule
|
|
||||||
function remove_lease(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v.mac:lower() == mac then
|
|
||||||
remove_rule(mac)
|
|
||||||
uci:del("luci_splash", k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Add an iptables rule
|
|
||||||
function add_rule(mac)
|
|
||||||
return os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Remove an iptables rule
|
|
||||||
function remove_rule(mac)
|
|
||||||
return os.execute("iptables -t nat -D luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Get the MAC-Address of current user
|
|
||||||
function ip4mac(ip)
|
|
||||||
local mac = nil
|
|
||||||
|
|
||||||
for i, l in ipairs(ffluci.sys.net.arptable()) do
|
|
||||||
if l["IP address"] == ip then
|
|
||||||
mac = l["HW address"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return mac
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Check whether a MAC-Address is listed in the lease state list
|
|
||||||
function haslease(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v[".type"] == "lease" and v.mac and v.mac:lower() == mac then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Check whether a MAC-Address is whitelisted
|
|
||||||
function iswhitelisted(mac)
|
|
||||||
mac = mac:lower()
|
|
||||||
|
|
||||||
for k, v in pairs(uci:show("luci_splash").luci_splash) do
|
|
||||||
if v[".type"] == "whitelist" and v.mac and v.mac:lower() == mac then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Returns a list of MAC-Addresses for which a rule is existing
|
|
||||||
function listrules()
|
|
||||||
local cmd = "iptables -t nat -L luci_splash_leases | grep RETURN |"
|
|
||||||
cmd = cmd .. "egrep -io [0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+"
|
|
||||||
return ffluci.util.split(ffluci.sys.exec(cmd))
|
|
||||||
end
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/haserl --shell=luac --accept-none
|
|
||||||
dofile("/usr/lib/luci-splash/splash.lua")
|
|
||||||
|
|
||||||
local written = {}
|
|
||||||
local time = os.time()
|
|
||||||
|
|
||||||
-- Current leases in state files
|
|
||||||
local leases = uci:show("luci_splash").luci_splash
|
|
||||||
|
|
||||||
-- Convert leasetime to seconds
|
|
||||||
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600
|
|
||||||
|
|
||||||
-- Clean state file
|
|
||||||
uci:revert("luci_splash")
|
|
||||||
|
|
||||||
|
|
||||||
-- For all leases
|
|
||||||
for k, v in pairs(uci:show("luci_splash")) do
|
|
||||||
if v[".type"] == "lease" then
|
|
||||||
if os.difftime(time, tonumber(v.start)) > leasetime then
|
|
||||||
-- Remove expired
|
|
||||||
remove_rule(v.mac)
|
|
||||||
else
|
|
||||||
-- Rewrite state
|
|
||||||
local n = uci:add("luci_splash", "lease")
|
|
||||||
uci:set("luci_splash", n, "mac", v.mac)
|
|
||||||
uci:set("luci_splash", n, "start", v.start)
|
|
||||||
written[v.mac] = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Delete rules without state
|
|
||||||
for i, r in ipairs(listrules()) do
|
|
||||||
if not written[r] then
|
|
||||||
remove_rule(r)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
*/15 * * * * /usr/lib/luci-splash/sync.lua
|
|
|
@ -1,87 +0,0 @@
|
||||||
#!/bin/sh /etc/rc.common
|
|
||||||
START=70
|
|
||||||
|
|
||||||
iface_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get net "$cfg" network
|
|
||||||
[ -n "$net" ] || return 0
|
|
||||||
|
|
||||||
config_get iface "$net" ifname
|
|
||||||
[ -n "$iface" ] || return 0
|
|
||||||
iface="${iface%%:*}"
|
|
||||||
|
|
||||||
config_get ipaddr "$net" ipaddr
|
|
||||||
[ -n "$ipaddr" ] || return 0
|
|
||||||
|
|
||||||
config_get netmask "$net" netmask
|
|
||||||
[ -n "$netmask" ] || return 0
|
|
||||||
|
|
||||||
eval "$(ipcalc.sh $ipaddr $netmask)"
|
|
||||||
|
|
||||||
iptables -t nat -A luci_splash -i "$iface" -s "$IP/$PREFIX" -j luci_splash_portal
|
|
||||||
iptables -t nat -A luci_splash_portal -i "$iface" -s "$IP/$PREFIX" -d "$ipaddr" -p tcp --dport 80 -j RETURN
|
|
||||||
}
|
|
||||||
|
|
||||||
blacklist_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get mac "$cfg" mac
|
|
||||||
[ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
|
|
||||||
}
|
|
||||||
|
|
||||||
whitelist_add() {
|
|
||||||
local cfg="$1"
|
|
||||||
|
|
||||||
config_get mac "$cfg" mac
|
|
||||||
[ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
### Read chains from config
|
|
||||||
include /lib/network
|
|
||||||
scan_interfaces
|
|
||||||
config_load luci_splash
|
|
||||||
|
|
||||||
### Create subchains
|
|
||||||
iptables -t nat -N luci_splash
|
|
||||||
iptables -t nat -N luci_splash_portal
|
|
||||||
iptables -t nat -N luci_splash_leases
|
|
||||||
|
|
||||||
### Build the main rule
|
|
||||||
config_foreach iface_add iface
|
|
||||||
|
|
||||||
### Build the portal rule
|
|
||||||
config_foreach blacklist_add blacklist
|
|
||||||
config_foreach whitelist_add whitelist
|
|
||||||
iptables -t nat -A luci_splash_portal -j luci_splash_leases
|
|
||||||
|
|
||||||
### Build the leases rule
|
|
||||||
iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
|
|
||||||
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
|
|
||||||
|
|
||||||
### Sync leases
|
|
||||||
/usr/lib/luci-splash/sync.lua
|
|
||||||
|
|
||||||
### Hook in the chain
|
|
||||||
iptables -t nat -A prerouting_rule -j luci_splash
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
### Hook out the chain
|
|
||||||
iptables -t nat -D prerouting_rule -j luci_splash
|
|
||||||
|
|
||||||
### Clear subchains
|
|
||||||
iptables -t nat -F luci_splash_leases
|
|
||||||
iptables -t nat -F luci_splash_portal
|
|
||||||
iptables -t nat -F luci_splash
|
|
||||||
|
|
||||||
### Delete subchains
|
|
||||||
iptables -t nat -X luci_splash_leases
|
|
||||||
iptables -t nat -X luci_splash_portal
|
|
||||||
iptables -t nat -X luci_splash
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
config core general
|
|
||||||
option leasetime 1
|
|
|
@ -1 +0,0 @@
|
||||||
E404:index.html
|
|
Loading…
Reference in a new issue