Revision 88cbd62a
Added by Ermal LUÇI over 14 years ago
usr/local/pkg/miniupnpd.inc | ||
---|---|---|
130 | 130 |
$ifaces_active = ''; |
131 | 131 |
|
132 | 132 |
/* since config is written before this file invoked we don't need to read post data */ |
133 |
if($upnp_config['enable'] && $upnp_config['iface_array'])
|
|
133 |
if($upnp_config['enable'] && !empty($upnp_config['iface_array'])) {
|
|
134 | 134 |
$iface_array = explode(',', $upnp_config['iface_array']); |
135 | 135 |
|
136 |
if($iface_array) { |
|
137 | 136 |
foreach($iface_array as $iface) { |
138 | 137 |
$if = convert_friendly_interface_to_real_interface_name($iface); |
139 | 138 |
/* above function returns iface if fail */ |
140 | 139 |
if($if!=$iface) { |
141 | 140 |
$addr = find_interface_ip($if); |
142 |
/* non enabled interfaces are displayed in list on miniupnpd settings page */ |
|
143 | 141 |
/* check that the interface has an ip address before adding parameters */ |
144 |
if($addr) {
|
|
142 |
if (is_ipaddr($addr)) {
|
|
145 | 143 |
$config_text .= "listening_ip={$addr}\n"; |
146 | 144 |
if(!$ifaces_active) { |
147 | 145 |
$webgui_ip = $addr; |
148 | 146 |
$ifaces_active = $iface; |
149 |
} else {
|
|
147 |
} else |
|
150 | 148 |
$ifaces_active .= ", {$iface}"; |
151 |
} |
|
152 |
} else { |
|
149 |
} else |
|
153 | 150 |
upnp_warn("Interface {$iface} has no ip address, ignoring"); |
154 |
} |
|
155 |
} else { |
|
151 |
} else |
|
156 | 152 |
upnp_warn("Could not resolve real interface for {$iface}"); |
157 |
} |
|
158 | 153 |
} |
159 | 154 |
|
160 |
if($ifaces_active) {
|
|
155 |
if (!empty($ifaces_active)) {
|
|
161 | 156 |
/* override wan ip address, common for carp, etc */ |
162 | 157 |
if($upnp_config['overridewanip']) |
163 | 158 |
$config_text .= "ext_ip={$upnp_config['overridewanip']}\n"; |
... | ... | |
224 | 219 |
upnp_action('start'); |
225 | 220 |
} |
226 | 221 |
/* or restart miniupnpd if settings were changed */ |
227 |
elseif($_POST['iface_array']) {
|
|
222 |
else { |
|
228 | 223 |
upnp_notice("Restarting service on interface: {$ifaces_active}"); |
229 | 224 |
upnp_action('restart'); |
230 | 225 |
} |
231 | 226 |
} |
232 |
} |
|
233 |
|
|
234 |
if(!$iface_array || !$ifaces_active) { |
|
235 |
/* no parameters user does not want miniupnpd running */ |
|
227 |
} else { |
|
228 |
/* user does not want miniupnpd running */ |
|
236 | 229 |
/* lets stop the service and remove the rc file */ |
237 | 230 |
|
238 |
if(file_exists($config_file)) { |
|
231 |
if (file_exists($config_file)) {
|
|
239 | 232 |
if(!$upnp_config['enable']) |
240 | 233 |
upnp_notice('Stopping service: miniupnpd disabled'); |
241 | 234 |
else |
242 | 235 |
upnp_notice('Stopping service: no interfaces selected'); |
243 | 236 |
|
244 | 237 |
upnp_action('stop'); |
245 |
unlink($config_file); |
|
238 |
@unlink($config_file);
|
|
246 | 239 |
} |
247 | 240 |
} |
248 | 241 |
} |
Also available in: Unified diff
More fixes to comments and code for upnpd. Also bring up to speed the stop/start logic.