Revision f8466c36
Added by Jim Pingle almost 12 years ago
etc/inc/pkg-utils.inc | ||
---|---|---|
1381 | 1381 |
/* Do not skip package list */ |
1382 | 1382 |
return false; |
1383 | 1383 |
} |
1384 |
|
|
1385 |
function get_pkg_interfaces_select_source($include_localhost=false) { |
|
1386 |
$interfaces = get_configured_interface_with_descr(); |
|
1387 |
$ssifs = array(); |
|
1388 |
foreach ($interfaces as $iface => $ifacename) { |
|
1389 |
$tmp["name"] = $ifacename; |
|
1390 |
$tmp["value"] = $iface; |
|
1391 |
$ssifs[] = $tmp; |
|
1392 |
} |
|
1393 |
if ($include_localhost) { |
|
1394 |
$tmp["name"] = "Localhost"; |
|
1395 |
$tmp["value"] = "lo0"; |
|
1396 |
$ssifs[] = $tmp; |
|
1397 |
} |
|
1398 |
return $ssifs; |
|
1399 |
} |
|
1384 | 1400 |
?> |
usr/local/pkg/miniupnpd.inc | ||
---|---|---|
80 | 80 |
if($post['enable'] && (!$post['enable_upnp'] && !$post['enable_natpmp'])) |
81 | 81 |
$input_errors[] = 'At least one of \'UPnP\' or \'NAT-PMP\' must be allowed'; |
82 | 82 |
if($post['iface_array']) |
83 |
foreach($post['iface_array'] as $iface) |
|
83 |
foreach($post['iface_array'] as $iface) {
|
|
84 | 84 |
if($iface == 'wan') |
85 | 85 |
$input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field'; |
86 |
elseif ($iface == $post['ext_iface']) |
|
87 |
$input_errors[] = 'You cannot select the external interface as an internal interface.'; |
|
88 |
} |
|
86 | 89 |
if($post['overridewanip'] && !upnp_validate_ip($post['overridewanip'],false)) |
87 | 90 |
$input_errors[] = 'You must specify a valid ip address in the \'Override WAN address\' field'; |
88 | 91 |
if(($post['download'] && !$post['upload']) || ($post['upload'] && !$post['download'])) |
... | ... | |
124 | 127 |
$upnp_config = $config['installedpackages']['miniupnpd']['config'][0]; |
125 | 128 |
$config_file = '/var/etc/miniupnpd.conf'; |
126 | 129 |
|
127 |
$config_text = "ext_ifname=".get_real_interface()."\n"; |
|
130 |
if (!isset($upnp_config['ext_iface']) || empty($upnp_config['ext_iface'])) |
|
131 |
$ext_ifname = get_real_interface(); |
|
132 |
else { |
|
133 |
$if = convert_friendly_interface_to_real_interface_name($upnp_config['ext_iface']); |
|
134 |
if ($if != $upnp_config['ext_iface']) |
|
135 |
$ext_ifname = $if; |
|
136 |
else { |
|
137 |
$ext_ifname = get_real_interface(); |
|
138 |
upnp_warn("Could not resolve real interface for {$upnp_config['ext_iface']}, defaulting to WAN"); |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
$config_text = "ext_ifname={$ext_ifname}\n"; |
|
128 | 143 |
$config_text .= "port=2189\n"; |
129 | 144 |
|
130 | 145 |
$ifaces_active = ''; |
... | ... | |
134 | 149 |
$iface_array = explode(',', $upnp_config['iface_array']); |
135 | 150 |
|
136 | 151 |
foreach($iface_array as $iface) { |
152 |
/* Setting the same internal and external interface is not allowed. */ |
|
153 |
if ($iface == $upnp_config['ext_iface']) |
|
154 |
continue; |
|
137 | 155 |
$if = convert_friendly_interface_to_real_interface_name($iface); |
138 | 156 |
/* above function returns iface if fail */ |
139 | 157 |
if($if!=$iface) { |
usr/local/pkg/miniupnpd.xml | ||
---|---|---|
55 | 55 |
<type>checkbox</type> |
56 | 56 |
<description>This protocol is often used by Apple-compatible systems.</description> |
57 | 57 |
</field> |
58 |
<field> |
|
59 |
<fielddescr>External Interface (generally WAN)</fielddescr> |
|
60 |
<fieldname>ext_iface</fieldname> |
|
61 |
<default_value>wan</default_value> |
|
62 |
<size>3</size> |
|
63 |
<type>select_source</type> |
|
64 |
<source><![CDATA[get_pkg_interfaces_select_source(false)]]></source> |
|
65 |
<source_name>name</source_name> |
|
66 |
<source_value>value</source_value> |
|
67 |
<description>Select only your primary WAN interface (interface with your default route). Only one interface is allowed here, not multiple.</description> |
|
68 |
<required/> |
|
69 |
</field> |
|
58 | 70 |
<field> |
59 | 71 |
<fielddescr>Interfaces (generally LAN)</fielddescr> |
60 | 72 |
<fieldname>iface_array</fieldname> |
61 |
<value>lan</value>
|
|
73 |
<default_value>lan</default_value>
|
|
62 | 74 |
<multiple>true</multiple> |
63 | 75 |
<size>3</size> |
64 |
<type>interfaces_selection</type> |
|
76 |
<type>select_source</type> |
|
77 |
<source><![CDATA[get_pkg_interfaces_select_source(true)]]></source> |
|
78 |
<source_name>name</source_name> |
|
79 |
<source_value>value</source_value> |
|
65 | 80 |
<description>You can use the CTRL or COMMAND key to select multiple interfaces.</description> |
66 | 81 |
<required/> |
67 | 82 |
</field> |
Also available in: Unified diff
Fix interface selections on UPnP to show the customized descriptions entered by the user. While here, add an external interface selection knob. Fixes #3141
Conflicts: