mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Fix interface selections on UPnP to show the customized descriptions entered by the user. While here, add an external interface selection knob. Fixes #3141
This commit is contained in:
parent
a2dc7392fc
commit
afa76eff3d
@ -1348,4 +1348,19 @@ function stop_packages() {
|
||||
}
|
||||
}
|
||||
|
||||
function get_pkg_interfaces_select_source($include_localhost=false) {
|
||||
$interfaces = get_configured_interface_with_descr();
|
||||
$ssifs = array();
|
||||
foreach ($interfaces as $iface => $ifacename) {
|
||||
$tmp["name"] = $ifacename;
|
||||
$tmp["value"] = $iface;
|
||||
$ssifs[] = $tmp;
|
||||
}
|
||||
if ($include_localhost) {
|
||||
$tmp["name"] = "Localhost";
|
||||
$tmp["value"] = "lo0";
|
||||
$ssifs[] = $tmp;
|
||||
}
|
||||
return $ssifs;
|
||||
}
|
||||
?>
|
||||
@ -80,9 +80,12 @@
|
||||
if($post['enable'] && (!$post['enable_upnp'] && !$post['enable_natpmp']))
|
||||
$input_errors[] = 'At least one of \'UPnP\' or \'NAT-PMP\' must be allowed';
|
||||
if($post['iface_array'])
|
||||
foreach($post['iface_array'] as $iface)
|
||||
foreach($post['iface_array'] as $iface) {
|
||||
if($iface == 'wan')
|
||||
$input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field';
|
||||
elseif ($iface == $post['ext_iface'])
|
||||
$input_errors[] = 'You cannot select the external interface as an internal interface.';
|
||||
}
|
||||
if($post['overridewanip'] && !upnp_validate_ip($post['overridewanip'],false))
|
||||
$input_errors[] = 'You must specify a valid ip address in the \'Override WAN address\' field';
|
||||
if(($post['download'] && !$post['upload']) || ($post['upload'] && !$post['download']))
|
||||
@ -124,7 +127,19 @@
|
||||
$upnp_config = $config['installedpackages']['miniupnpd']['config'][0];
|
||||
$config_file = '/var/etc/miniupnpd.conf';
|
||||
|
||||
$config_text = "ext_ifname=".get_real_interface()."\n";
|
||||
if (!isset($upnp_config['ext_iface']) || empty($upnp_config['ext_iface']))
|
||||
$ext_ifname = get_real_interface();
|
||||
else {
|
||||
$if = convert_friendly_interface_to_real_interface_name($upnp_config['ext_iface']);
|
||||
if ($if != $upnp_config['ext_iface'])
|
||||
$ext_ifname = $if;
|
||||
else {
|
||||
$ext_ifname = get_real_interface();
|
||||
upnp_warn("Could not resolve real interface for {$upnp_config['ext_iface']}, defaulting to WAN");
|
||||
}
|
||||
}
|
||||
|
||||
$config_text = "ext_ifname={$ext_ifname}\n";
|
||||
$config_text .= "port=2189\n";
|
||||
|
||||
$ifaces_active = '';
|
||||
@ -134,6 +149,9 @@
|
||||
$iface_array = explode(',', $upnp_config['iface_array']);
|
||||
|
||||
foreach($iface_array as $iface) {
|
||||
/* Setting the same internal and external interface is not allowed. */
|
||||
if ($iface == $upnp_config['ext_iface'])
|
||||
continue;
|
||||
$if = convert_friendly_interface_to_real_interface_name($iface);
|
||||
/* above function returns iface if fail */
|
||||
if($if!=$iface) {
|
||||
|
||||
@ -55,13 +55,28 @@
|
||||
<type>checkbox</type>
|
||||
<description>This protocol is often used by Apple-compatible systems.</description>
|
||||
</field>
|
||||
<field>
|
||||
<fielddescr>External Interface (generally WAN)</fielddescr>
|
||||
<fieldname>ext_iface</fieldname>
|
||||
<default_value>wan</default_value>
|
||||
<size>3</size>
|
||||
<type>select_source</type>
|
||||
<source><![CDATA[get_pkg_interfaces_select_source(false)]]></source>
|
||||
<source_name>name</source_name>
|
||||
<source_value>value</source_value>
|
||||
<description>Select only your primary WAN interface (interface with your default route). Only one interface is allowed here, not multiple.</description>
|
||||
<required/>
|
||||
</field>
|
||||
<field>
|
||||
<fielddescr>Interfaces (generally LAN)</fielddescr>
|
||||
<fieldname>iface_array</fieldname>
|
||||
<value>lan</value>
|
||||
<default_value>lan</default_value>
|
||||
<multiple>true</multiple>
|
||||
<size>3</size>
|
||||
<type>interfaces_selection</type>
|
||||
<type>select_source</type>
|
||||
<source><![CDATA[get_pkg_interfaces_select_source(true)]]></source>
|
||||
<source_name>name</source_name>
|
||||
<source_value>value</source_value>
|
||||
<description>You can use the CTRL or COMMAND key to select multiple interfaces.</description>
|
||||
<required/>
|
||||
</field>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user