summaryrefslogtreecommitdiffstats
path: root/src/usr/local
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-02-08 21:23:44 +0545
committerPhil Davis <phil.davis@inf.org>2016-02-08 21:23:44 +0545
commitcde97f1c624d519324b702d12dce667c3b59455f (patch)
tree167441e6bb9d0521e502fa31507576c6bd8c0d7b /src/usr/local
parent3057984d4c52c7ee7893022f0d84b2094828b5bf (diff)
downloadpfsense-cde97f1c624d519324b702d12dce667c3b59455f.zip
pfsense-cde97f1c624d519324b702d12dce667c3b59455f.tar.gz
Redmine #4647 default DHCP server tab to a interface with DHCP enabled
This has also annoyed me, where WAN has a static IP. Every time I go to Services->DHCP I then have to click the LAN tab. With this change it will look for a "reasonable" tab to go to: 1) The first interface that has DHCP enabled and functional. 2) Otherwise, if LAN is a candidate then choose it (this helps if setting up something when WAN and LAN both have a static IPv4 and there is no DHCP server enabled yet - it will take the user to the LAN tab. That seems sensible, avoiding someone who is not watching accidentally enabling DHCP on WAN) 3) In the unusual case that neither (1) or (2) finds something, then use the original code.
Diffstat (limited to 'src/usr/local')
-rw-r--r--src/usr/local/www/services_dhcp.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php
index f77e780..0c03469 100644
--- a/src/usr/local/www/services_dhcp.php
+++ b/src/usr/local/www/services_dhcp.php
@@ -92,15 +92,35 @@ $iflist = get_configured_interface_with_descr();
/* set the starting interface */
if (!$if || !isset($iflist[$if])) {
+ $found_starting_if = false;
+ // First look for an interface with DHCP already enabled.
foreach ($iflist as $ifent => $ifname) {
$oc = $config['interfaces'][$ifent];
- if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
- (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
- continue;
+ if (is_array($config['dhcpd'][$ifent]) && isset($config['dhcpd'][$ifent]['enable']) && (is_ipaddrv4($oc['ipaddr']))) {
+ $if = $ifent;
+ $found_starting_if = true;
+ break;
}
+ }
+
+ // If there is no DHCP-enabled interface and LAN is a candidate, then choose LAN.
+ if (!$found_starting_if && isset($iflist['lan']) && is_ipaddrv4($config['interfaces']['lan']['ipaddr'])) {
+ $if = 'lan';
+ $found_starting_if = true;
+ }
- $if = $ifent;
- break;
+ // At the last select whatever can be found.
+ if (!$found_starting_if) {
+ foreach ($iflist as $ifent => $ifname) {
+ $oc = $config['interfaces'][$ifent];
+ if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddrv4($oc['ipaddr']))) ||
+ (!is_array($config['dhcpd'][$ifent]) && (!is_ipaddrv4($oc['ipaddr'])))) {
+ continue;
+ }
+
+ $if = $ifent;
+ break;
+ }
}
}
OpenPOWER on IntegriCloud