1 #!/bin/sh /etc/rc.common
7 config_get net "$cfg" network
8 [ -n "$net" ] || return 0
10 config_get iface "$net" ifname
11 [ -n "$iface" ] || return 0
14 config_get ipaddr "$net" ipaddr
15 [ -n "$ipaddr" ] || return 0
17 config_get netmask "$net" netmask
18 [ -n "$netmask" ] || return 0
20 eval "$(ipcalc.sh $ipaddr $netmask)"
22 iptables -t nat -A luci_splash -i "$iface" -s "$IP/$PREFIX" -j luci_splash_portal
23 iptables -t nat -A luci_splash_portal -i "$iface" -s "$IP/$PREFIX" -d "$ipaddr" -p tcp --dport 80 -j RETURN
29 config_get mac "$cfg" mac
30 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
36 config_get mac "$cfg" mac
37 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
41 ### Read chains from config
44 config_load luci_splash
47 iptables -t nat -N luci_splash
48 iptables -t nat -N luci_splash_portal
49 iptables -t nat -N luci_splash_leases
51 ### Build the main and portal rule
52 config_foreach blacklist_add blacklist
53 config_foreach whitelist_add whitelist
54 config_foreach iface_add iface
56 ### Build the portal rule
57 iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
58 iptables -t nat -A luci_splash_portal -j luci_splash_leases
60 ### Build the leases rule
61 iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
62 iptables -t nat -A luci_splash_leases -j DROP
64 ### Start the splash httpd
65 httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs
68 /usr/lib/luci-splash/sync.lua
71 iptables -t nat -A prerouting_rule -j luci_splash
75 ### Hook out the chain
76 iptables -t nat -D prerouting_rule -j luci_splash
79 iptables -t nat -F luci_splash_leases
80 iptables -t nat -F luci_splash_portal
81 iptables -t nat -F luci_splash
84 iptables -t nat -X luci_splash_leases
85 iptables -t nat -X luci_splash_portal
86 iptables -t nat -X luci_splash