diff --git a/net/upnp/Makefile b/net/upnp/Makefile index fdff0f124..ea12da552 100644 --- a/net/upnp/Makefile +++ b/net/upnp/Makefile @@ -1,6 +1,5 @@ PLUGIN_NAME= upnp -PLUGIN_VERSION= 1.6 -PLUGIN_REVISION= 1 +PLUGIN_VERSION= 1.7 PLUGIN_DEPENDS= miniupnpd PLUGIN_COMMENT= Universal Plug and Play (UPnP IGD & PCP/NAT-PMP) Service PLUGIN_MAINTAINER= franco@opnsense.org diff --git a/net/upnp/pkg-descr b/net/upnp/pkg-descr index 2382b7529..e97062379 100644 --- a/net/upnp/pkg-descr +++ b/net/upnp/pkg-descr @@ -7,6 +7,10 @@ WWW: https://miniupnp.tuxfamily.org/ Plugin Changelog ================ +1.7 + +* Add option to allow arbitrary number of UPnP/NAT-PMP rules (contributed by Kreeblah) + 1.6 * Fix port maps not listed without description (contributed by Self-Hosting-Group) diff --git a/net/upnp/src/etc/inc/plugins.inc.d/miniupnpd.inc b/net/upnp/src/etc/inc/plugins.inc.d/miniupnpd.inc index 3fdf21214..6214f4ce0 100644 --- a/net/upnp/src/etc/inc/plugins.inc.d/miniupnpd.inc +++ b/net/upnp/src/etc/inc/plugins.inc.d/miniupnpd.inc @@ -104,10 +104,17 @@ function miniupnpd_uuid() function miniupnpd_permuser_list() { - $ret = []; - $count = 8; + global $config; - for ($i = 1; $i <= $count; $i++) { + $num_permuser = 8; + + if (!empty($config['installedpackages']['miniupnpd']['config'][0]['num_permuser'])) { + $num_permuser = $config['installedpackages']['miniupnpd']['config'][0]['num_permuser']; + } + + $ret = []; + + for ($i = 1; $i <= $num_permuser; $i++) { $ret[$i] = "permuser{$i}"; } diff --git a/net/upnp/src/www/services_upnp.php b/net/upnp/src/www/services_upnp.php index e56e08a43..696882676 100644 --- a/net/upnp/src/www/services_upnp.php +++ b/net/upnp/src/www/services_upnp.php @@ -81,6 +81,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { 'permdefault', 'stun_host', 'stun_port', + 'num_permuser', 'sysuptime', 'upload', ]; @@ -133,12 +134,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ((!empty($pconfig['download']) && empty($pconfig['upload'])) || (!empty($pconfig['upload']) && empty($pconfig['download']))) { $input_errors[] = gettext('You must fill in both \'Maximum Download Speed\' and \'Maximum Upload Speed\' fields'); } - if (!empty($pconfig['download']) && ($pconfig['download'] <= 0 || !is_numeric($pconfig['download']))) { + if (!empty($pconfig['download']) && (!is_numeric($pconfig['download']) || $pconfig['download'] <= 0)) { $input_errors[] = gettext('You must specify a value greater than 0 in the \'Maximum Download Speed\' field'); } - if (!empty($pconfig['upload']) && ($pconfig['upload'] <= 0 || !is_numeric($pconfig['upload']))) { + if (!empty($pconfig['upload']) && (!is_numeric($pconfig['upload']) || $pconfig['upload'] <= 0)) { $input_errors[] = gettext('You must specify a value greater than 0 in the \'Maximum Upload Speed\' field'); } + if (!empty($pconfig['num_permuser'] && (!is_numeric($pconfig['num_permuser']) || $pconfig['num_permuser'] < 1))) { + $input_errors[] = gettext('Number of permissions must be an integer greater than 0'); + } /* user permissions validation */ foreach (miniupnpd_permuser_list() as $i => $permuser) { @@ -171,6 +175,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { foreach (['enable', 'enable_upnp', 'enable_natpmp', 'logpackets', 'sysuptime', 'permdefault'] as $fieldname) { $upnp[$fieldname] = !empty($pconfig[$fieldname]); } + // numeric types + if (!empty($upnp['num_permuser'])) { + $upnp['num_permuser'] = $pconfig['num_permuser']; + } // text field types foreach (['ext_iface', 'download', 'upload', 'overridewanip', 'overridesubnet', 'stun_host', 'stun_port'] as $fieldname) { $upnp[$fieldname] = $pconfig[$fieldname]; @@ -382,6 +390,15 @@ include("head.inc");
+