mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
net/upnp - Allow for setting arbitrary number of UPnP permissions (#4305)
This commit is contained in:
parent
6eb2c50d22
commit
6fdf3aad25
4 changed files with 34 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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}";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a id="help_for_num_permuser" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Number of permissions");?></td>
|
||||
<td>
|
||||
<input name="num_permuser" type="number" value="<?=$pconfig['num_permuser'];?>" />
|
||||
<div class="hidden" data-for="help_for_num_permuser">
|
||||
<?=gettext("Number of permissions to configure.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach (miniupnpd_permuser_list() as $i => $permuser): ?>
|
||||
<tr>
|
||||
<?php if ($i == 1): ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue