From 32114c009f762980f7aa6ce03a2d82fed459114c Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 27 Jan 2025 21:39:22 +0800 Subject: [PATCH] miniupnpd: compatible with js luci --- net/miniupnpd/files/miniupnpd.init | 37 +++++++++++++----------------- net/miniupnpd/files/upnpd.config | 22 +++++++++--------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/net/miniupnpd/files/miniupnpd.init b/net/miniupnpd/files/miniupnpd.init index c2b57e81..0c815e01 100644 --- a/net/miniupnpd/files/miniupnpd.init +++ b/net/miniupnpd/files/miniupnpd.init @@ -69,7 +69,7 @@ upnpd() { local extip port usesysuptime conffile serial_number model_number local uuid notify_interval presentation_url enable_upnp local upnp_lease_file clean_ruleset_threshold clean_ruleset_interval - local ipv6_listening_ip enabled + local args ifname ipv6_listening_ip enabled config_get_bool enabled config enabled 1 @@ -94,22 +94,18 @@ upnpd() { config_get clean_ruleset_interval config clean_ruleset_interval config_get ipv6_listening_ip config ipv6_listening_ip - local args - . /lib/functions/network.sh - local ifname - - # manual external interface overrides everything - if [ -z "$extiface" ] ; then - # manual external zone (if dynamically find interfaces - # belonging to it) overrides network_find_wan* - if [ -n "$extzone" ] ; then - ifname=$(fw3 -q zone $extzone | head -1) - fi - [ -n "$extiface" ] || network_find_wan extiface - [ -n "$extiface" ] || network_find_wan6 extiface - fi + # manual external interface overrides everything + if [ -z "$extiface" ] ; then + # manual external zone (if dynamically find interfaces + # belonging to it) overrides network_find_wan* + if [ -n "$extzone" ] ; then + ifname=$(fw3 -q zone $extzone | head -1) + fi + [ -n "$extiface" ] || network_find_wan extiface + [ -n "$extiface" ] || network_find_wan6 extiface + fi [ -n "$ifname" ] || network_get_device ifname ${extiface} @@ -181,17 +177,16 @@ upnpd() { [ -n "${model_number}" ] && \ echo "model_number=${model_number}" >>$tmpconf - config_foreach conf_rule_add perm_rule "$tmpconf" + config_foreach conf_rule_add perm_rule "$tmpconf" fi - if [ -n "$ifname" ]; then # start firewall iptables -L MINIUPNPD >/dev/null 2>/dev/null || fw3 reload else logger -t "upnp daemon" "external interface not found, not starting" fi - + procd_open_instance procd_set_param command "$PROG" procd_set_param respawn @@ -204,9 +199,9 @@ stop_service() { iptables -t nat -F MINIUPNPD 2>/dev/null iptables -t filter -F MINIUPNPD 2>/dev/null - [ -x /usr/sbin/ip6tables ] && { - ip6tables -t filter -F MINIUPNPD 2>/dev/null - } + [ -x /usr/sbin/ip6tables ] && { + ip6tables -t filter -F MINIUPNPD 2>/dev/null + } } start_service() { diff --git a/net/miniupnpd/files/upnpd.config b/net/miniupnpd/files/upnpd.config index 9a65bfa6..a3481c9a 100644 --- a/net/miniupnpd/files/upnpd.config +++ b/net/miniupnpd/files/upnpd.config @@ -4,14 +4,14 @@ config upnpd config option enable_upnp 1 option secure_mode 1 option log_output 0 - option download 1024 - option upload 512 - #by default, looked up dynamically from ubus - #option external_iface wan + option download 1024 + option upload 512 +#by default, looked up dynamically from ubus +# option external_iface wan option internal_iface lan option port 5000 - option upnp_lease_file /var/upnp.leases - + option upnp_lease_file /var/run/miniupnpd.leases + config perm_rule option action allow option ext_ports 1024-65535 @@ -20,8 +20,8 @@ config perm_rule option comment "Allow high ports" config perm_rule - option action deny - option ext_ports 0-65535 - option int_addr 0.0.0.0/0 - option int_ports 0-65535 - option comment "Default deny" + option action deny + option ext_ports 0-65535 + option int_addr 0.0.0.0/0 + option int_ports 0-65535 + option comment "Default deny"