packages/net/miniupnpd:
- rewrite firewall to actually forward - fix bandwidth calculation - swap upload and download rate - make init and hotplug scripts less verbose - bump package revision git-svn-id: svn://svn.openwrt.org/openwrt/packages@14038 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
cf76c50263
commit
2b7175b8ee
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=miniupnpd
|
PKG_NAME:=miniupnpd
|
||||||
PKG_VERSION:=1.1
|
PKG_VERSION:=1.1
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
PKG_MD5SUM:=a0f6651476721db9b554668c8c83b151
|
PKG_MD5SUM:=a0f6651476721db9b554668c8c83b151
|
||||||
|
|
||||||
PKG_SOURCE_URL:=http://miniupnp.free.fr/files
|
PKG_SOURCE_URL:=http://miniupnp.free.fr/files
|
||||||
|
@ -7,69 +7,57 @@ upnp_ipt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
upnp_firewall_addif() {
|
upnp_firewall_addif() {
|
||||||
local intif
|
local extif
|
||||||
local intip
|
local extip
|
||||||
local coldplug="$1"
|
local iface
|
||||||
|
|
||||||
config_load upnpd
|
config_load upnpd
|
||||||
config_get intif config internal_iface
|
config_get iface config external_iface
|
||||||
|
|
||||||
|
[ -n "$INTERFACE" -a "$INTERFACE" != "$iface" ] && return
|
||||||
|
|
||||||
config_load network
|
config_load network
|
||||||
|
config_get extip "${iface:-wan}" ipaddr
|
||||||
|
config_get extif "${iface:-wan}" ifname
|
||||||
|
|
||||||
for iface in ${intif:-lan}; do
|
logger -t "upnp firewall" "adding wan interface $extif($extip)"
|
||||||
if [ -n "$coldplug" -o "$iface" == "$INTERFACE" ]; then
|
|
||||||
config_get intip "$iface" ipaddr
|
|
||||||
config_get intif "$iface" ifname
|
|
||||||
|
|
||||||
[ -n "$intif" -a -n "$intip" ] && {
|
upnp_ipt -t nat -N miniupnpd_${iface:-wan}_rule
|
||||||
logger -t "upnp firewall" "adding interface $iface($intip)"
|
upnp_ipt -t nat -A miniupnpd_${iface:-wan}_rule -i $extif -d $extip -j MINIUPNPD
|
||||||
|
upnp_ipt -t nat -A prerouting_rule -j miniupnpd_${iface:-wan}_rule
|
||||||
|
|
||||||
upnp_ipt -t nat -N MINIUPNPD
|
upnp_ipt -t filter -N miniupnpd_${iface:-wan}_rule
|
||||||
upnp_ipt -t nat -N miniupnpd_${iface}_rule
|
upnp_ipt -t filter -A miniupnpd_${iface:-wan}_rule -i $extif -o ! $extif -j MINIUPNPD
|
||||||
upnp_ipt -t nat -A miniupnpd_${iface}_rule -i $intif -d $intip -j MINIUPNPD
|
upnp_ipt -t filter -A forwarding_rule -j miniupnpd_${iface:-wan}_rule
|
||||||
upnp_ipt -t nat -A prerouting_rule -j miniupnpd_${iface}_rule
|
|
||||||
|
|
||||||
upnp_ipt -t filter -N MINIUPNPD
|
|
||||||
upnp_ipt -t filter -N miniupnpd_${iface}_rule
|
|
||||||
upnp_ipt -t filter -A miniupnpd_${iface}_rule -i $intif -o ! $intif -j MINIUPNPD
|
|
||||||
upnp_ipt -t filter -A forwarding_rule -j miniupnpd_${iface}_rule
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upnp_firewall_delif() {
|
upnp_firewall_delif() {
|
||||||
local iface="${1:-$INTERFACE}"
|
local iface
|
||||||
|
|
||||||
if [ -n "$iface" ]; then
|
config_load upnpd
|
||||||
logger -t "upnp firewall" "removing interface $iface"
|
config_get iface config external_iface
|
||||||
|
|
||||||
upnp_ipt -t nat -D prerouting_rule -j miniupnpd_${iface}_rule
|
[ -n "$INTERFACE" -a "$INTERFACE" != "$iface" ] && return
|
||||||
upnp_ipt -t nat -F miniupnpd_${iface}_rule
|
|
||||||
upnp_ipt -t nat -X miniupnpd_${iface}_rule
|
|
||||||
|
|
||||||
upnp_ipt -t filter -D forwarding_rule -j miniupnpd_${iface}_rule
|
logger -t "upnp firewall" "removing wan interface"
|
||||||
upnp_ipt -t filter -F miniupnpd_${iface}_rule
|
|
||||||
upnp_ipt -t filter -X miniupnpd_${iface}_rule
|
upnp_ipt -t nat -D prerouting_rule -j miniupnpd_${iface:-wan}_rule
|
||||||
fi
|
upnp_ipt -t nat -F miniupnpd_${iface:-wan}_rule
|
||||||
|
upnp_ipt -t nat -X miniupnpd_${iface:-wan}_rule
|
||||||
|
|
||||||
|
upnp_ipt -t filter -D forwarding_rule -j miniupnpd_${iface:-wan}_rule
|
||||||
|
upnp_ipt -t filter -F miniupnpd_${iface:-wan}_rule
|
||||||
|
upnp_ipt -t filter -X miniupnpd_${iface:-wan}_rule
|
||||||
}
|
}
|
||||||
|
|
||||||
upnp_firewall_start() {
|
upnp_firewall_start() {
|
||||||
logger -t "upnp firewall" "starting ..."
|
upnp_ipt -t nat -N MINIUPNPD
|
||||||
upnp_firewall_addif coldplug
|
upnp_ipt -t filter -N MINIUPNPD
|
||||||
|
upnp_firewall_addif
|
||||||
}
|
}
|
||||||
|
|
||||||
upnp_firewall_stop() {
|
upnp_firewall_stop() {
|
||||||
local intif
|
upnp_firewall_delif
|
||||||
config_load upnpd
|
|
||||||
config_get intif config internal_iface
|
|
||||||
|
|
||||||
logger -t "upnp firewall" "stopping ..."
|
|
||||||
|
|
||||||
for iface in ${intif:-lan}; do
|
|
||||||
upnp_firewall_delif "$iface"
|
|
||||||
done
|
|
||||||
|
|
||||||
upnp_ipt -t nat -F MINIUPNPD
|
upnp_ipt -t nat -F MINIUPNPD
|
||||||
upnp_ipt -t nat -X MINIUPNPD
|
upnp_ipt -t nat -X MINIUPNPD
|
||||||
upnp_ipt -t filter -F MINIUPNPD
|
upnp_ipt -t filter -F MINIUPNPD
|
||||||
|
@ -3,9 +3,16 @@ START=95
|
|||||||
|
|
||||||
include /lib/miniupnpd
|
include /lib/miniupnpd
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
# On boot, there's a race condition with hotplug,
|
||||||
|
# therfore do nothing here
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
local extif
|
local extif
|
||||||
local intif
|
local intif
|
||||||
|
local extiface
|
||||||
local upload
|
local upload
|
||||||
local download
|
local download
|
||||||
local logging
|
local logging
|
||||||
@ -17,14 +24,13 @@ start() {
|
|||||||
config_get download config download
|
config_get download config download
|
||||||
config_get_bool logging config log_output 0
|
config_get_bool logging config log_output 0
|
||||||
|
|
||||||
config_get extif ${extif:-wan} ifname
|
config_load "network"
|
||||||
|
config_get extiface ${extif:-wan} ifname
|
||||||
|
|
||||||
if [ -n "$extif" ]; then
|
if [ -n "$extiface" ]; then
|
||||||
logger -t "upnp daemon" "starting ..."
|
|
||||||
|
|
||||||
upnp_firewall_start
|
upnp_firewall_start
|
||||||
|
|
||||||
local args="-i $extif"
|
local args="-i $extiface"
|
||||||
|
|
||||||
for iface in ${intif:-lan}; do
|
for iface in ${intif:-lan}; do
|
||||||
local ipaddr
|
local ipaddr
|
||||||
@ -35,7 +41,7 @@ start() {
|
|||||||
append args "-p 5000 -U"
|
append args "-p 5000 -U"
|
||||||
|
|
||||||
[ -n "$upload" -a -n "$download" ] && \
|
[ -n "$upload" -a -n "$download" ] && \
|
||||||
append args "-B $(($upload * 1024 / 8)) $(($download * 1024 / 8))"
|
append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
|
||||||
|
|
||||||
if [ "$logging" = "1" ]; then
|
if [ "$logging" = "1" ]; then
|
||||||
eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
|
eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
|
||||||
@ -48,7 +54,6 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
logger -t "upnp daemon" "stopping ..."
|
|
||||||
start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
|
start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
|
||||||
upnp_firewall_stop
|
upnp_firewall_stop
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user