1 #!/bin/sh /etc/rc.common
6 local extiface intiface upload download logging secure enabled
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
14 config_get_bool enabled config enabled
0
20 config_get ifname
${extiface:-wan} ifname
22 if [ -n "$ifname" ]; then
23 local args
="-i $ifname"
26 for iface
in ${intiface:-lan}; do
28 config_get ipaddr
"$iface" ipaddr
29 [ -n "$ipaddr" ] && append args
"-a $ipaddr"
32 append args
"-p 5000 -U"
34 [ -n "$upload" -a -n "$download" ] && \
35 append args
"-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
37 [ "$secure" -gt 0 ] && \
40 if [ "$logging" = "1" ]; then
41 [ "$enabled" -gt 0 ] && eval start-stop-daemon
-S -x miniupnpd
-- $args -d | logger
-t miniupnpd
&
43 [ "$enabled" -gt 0 ] && eval start-stop-daemon
-S -x miniupnpd
-- $args 2>/dev
/null
49 config_get zone core
"${extiface:-wan}_zone"
51 ACTION
="add" ZONE
="$zone" INTERFACE
="${extiface:-wan}" DEVICE
="$ifname" \
52 .
/etc
/hotplug.d
/firewall
/50-miniupnpd
54 logger
-t "upnp daemon" "external interface not found, not starting"
62 config_get ifname
"$state" ifname
63 config_get ipaddr
"$state" ipaddr
65 [ -n "$ifname" ] && [ -n "$ipaddr" ] && {
66 iptables
-t nat
-D prerouting_rule
-i $ifname -d $ipaddr -j MINIUPNPD
67 iptables
-t filter
-D forwarding_rule
-i $ifname ! -o $ifname -j MINIUPNPD
68 uci_revert_state upnpd
"$state"
69 unset "CONFIG_${state}_ifname"
70 unset "CONFIG_${state}_ipaddr"
75 start-stop-daemon
-K -q -x miniupnpd
-p /var
/run
/miniupnpd.pid
76 rm -f /var
/run
/miniupnpd.pid
78 logger
-t "upnp" "removing firewall rules"
81 config_foreach clear_rule firewall
83 iptables
-t nat
-F MINIUPNPD
2>/dev
/null
84 iptables
-t nat
-X MINIUPNPD
2>/dev
/null
85 iptables
-t filter
-F MINIUPNPD
2>/dev
/null
86 iptables
-t filter
-X MINIUPNPD
2>/dev
/null