1 #!/bin/sh /etc/rc.common
6 local extiface intiface upload download logging secure
8 config_get extiface config external_iface
9 config_get intiface config internal_iface
10 config_get upload config upload
11 config_get download config download
12 config_get_bool logging config log_output
0
13 config_get_bool secure config secure_mode
0
19 config_get ifname
${extiface:-wan} ifname
21 if [ -n "$ifname" ]; then
22 local args
="-i $ifname"
25 for iface
in ${intiface:-lan}; do
27 config_get ipaddr
"$iface" ipaddr
28 [ -n "$ipaddr" ] && append args
"-a $ipaddr"
31 append args
"-p 5000 -U"
33 [ -n "$upload" -a -n "$download" ] && \
34 append args
"-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
36 [ "$secure" -gt 0 ] && \
39 if [ "$logging" = "1" ]; then
40 eval start-stop-daemon
-S -x miniupnpd
-- $args -d | logger
-t miniupnpd
&
42 eval start-stop-daemon
-S -x miniupnpd
-- $args 2>/dev
/null
48 config_get zone core
"${extiface:-wan}_zone"
50 ACTION
="add" ZONE
="$zone" INTERFACE
="${extiface:-wan}" DEVICE
="$ifname" \
51 .
/etc
/hotplug.d
/firewall
/50-miniupnpd
53 logger
-t "upnp daemon" "external interface not found, not starting"
61 config_get ifname
"$state" ifname
62 config_get ipaddr
"$state" ipaddr
64 [ -n "$ifname" ] && [ -n "$ipaddr" ] && {
65 iptables
-t nat
-D prerouting_rule
-i $ifname -d $ipaddr -j MINIUPNPD
66 iptables
-t filter
-D forwarding_rule
-i $ifname ! -o $ifname -j MINIUPNPD
67 uci_revert_state upnpd
"$state"
68 unset "CONFIG_${state}_ifname"
69 unset "CONFIG_${state}_ipaddr"
74 start-stop-daemon
-K -q -x miniupnpd
-p /var
/run
/miniupnpd.pid
75 rm -f /var
/run
/miniupnpd.pid
77 logger
-t "upnp" "removing firewall rules"
80 config_foreach clear_rule firewall
82 iptables
-t nat
-F MINIUPNPD
2>/dev
/null
83 iptables
-t nat
-X MINIUPNPD
2>/dev
/null
84 iptables
-t filter
-F MINIUPNPD
2>/dev
/null
85 iptables
-t filter
-X MINIUPNPD
2>/dev
/null