include $(TOPDIR)/rules.mk
PKG_NAME:=simple-captive-portal
-PKG_VERSION:=2025.06.22
-PKG_RELEASE:=2
+PKG_VERSION:=2026.08.06
+PKG_RELEASE:=1
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
PKG_LICENSE:=GPL-2.0-or-later
EXTRA_COMMANDS='firewall'
firewall() {
- local INTF PORT_REDIRECT TIMEOUT
+ local INTF PORT_REDIRECT PORT_PORTAL TIMEOUT
config_load "simple-captive-portal"
config_get INTF main interface
[ -z "${INTF}" ] && exit 0
config_get PORT_REDIRECT main port_redirect 8888
+ config_get PORT_PORTAL main port_portal 8889
config_get TIMEOUT main timeout 86400
/usr/sbin/nft -f- <<EOF
type nat hook prerouting priority mangle - 5; policy drop;
iif != ${INTF} accept
ether saddr @guest_macs accept
+ tcp dport 80 fib daddr . iif type local redirect to ${PORT_PORTAL}
tcp dport 80 redirect to ${PORT_REDIRECT}
fib daddr . iif type { local, broadcast, multicast } accept
reject
procd_open_instance redirect
procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -k0 -h /etc/simple-captive-portal/ -l / -L /usr/share/simple-captive-portal/redirect.lua -p "${PORT_REDIRECT}"
- procd_set_param env PORT_PORTAL=${PORT_PORTAL}
procd_add_jail simple-captive-portal-redirect log procfs sysfs ronly
procd_add_jail_mount /etc/simple-captive-portal/
procd_add_jail_mount /usr/share/simple-captive-portal/redirect.lua
-port_portal = os.getenv("PORT_PORTAL")
-
function handle_request(env)
uhttpd.send("Status: 302 Found\r\n")
uhttpd.send("Server: simple-captive-portal\r\n")
if string.find(env.SERVER_ADDR, ":") == nil then
- uhttpd.send("Location: http://" .. env.SERVER_ADDR .. ":" .. port_portal .. "/\r\n")
+ uhttpd.send("Location: http://" .. env.SERVER_ADDR .. "/\r\n")
else
- uhttpd.send("Location: http://[" .. env.SERVER_ADDR .. "]:" .. port_portal .. "/\r\n")
+ uhttpd.send("Location: http://[" .. env.SERVER_ADDR .. "]/\r\n")
end
uhttpd.send("Cache-Control: no-cache\r\n")
uhttpd.send("Content-Length: 0\r\n\r\n")