mirror of
https://github.com/unraid/webgui.git
synced 2026-01-25 02:58:58 -06:00
Major network enhancements
This commit is contained in:
@@ -37,8 +37,8 @@ if (file_exists($realfile)) {
|
||||
}
|
||||
}
|
||||
unset($custom,$other);
|
||||
exec("ls --indicator-style=none /sys/class/net|grep -P '^br[0-9]'",$custom);
|
||||
exec("ls --indicator-style=none /sys/class/net|grep -P '^(bond|eth)[0-9]'",$other);
|
||||
exec("ls /sys/class/net|grep -P '^br[0-9]'",$custom);
|
||||
exec("ls /sys/class/net|grep -P '^(bond|eth)[0-9]'",$other);
|
||||
foreach ($other as $network) {
|
||||
if (substr($network,0,4)=='bond') {
|
||||
$br = str_replace('bond','br',$network);
|
||||
|
||||
@@ -90,25 +90,27 @@ Array.prototype.same = function(){return this.sort().filter(function(v,i,o){retu
|
||||
|
||||
function prepareSettings(form) {
|
||||
var metrics = [];
|
||||
var metrics6 = [];
|
||||
$(form).find('input[name^="METRIC:"]').each(function(){metrics.push($(this).val());});
|
||||
if (metrics.same()) {
|
||||
$(form).find('input[name^="METRIC6:"]').each(function(){metrics6.push($(this).val());});
|
||||
if (metrics.same() || metrics6.same()) {
|
||||
swal('Duplicate metrics','List of default gateways contains duplicate metric values','error');
|
||||
return false;
|
||||
}
|
||||
if (form.TYPE.value == 'access') {
|
||||
$(form).find('input[name^="VLANID:"]').prop('disabled',true);
|
||||
$(form).find('input[name^="DESCRIPTION:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="PROTOCOL:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="USE_DHCP:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="USE_DHCP6:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="IPADDR:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="IPADDR6:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="NETMASK:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="NETMASK6:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="GATEWAY:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="GATEWAY6:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="METRIC:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="PRIVACY6:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="VLANID:"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="DESCRIPTION:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="PROTOCOL:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="USE_DHCP:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="USE_DHCP6:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="IPADDR:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="IPADDR6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="NETMASK:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="NETMASK6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="GATEWAY:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="GATEWAY6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name^="METRIC:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name^="PRIVACY6:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
||||
} else {
|
||||
var vlans = [];
|
||||
$(form).find('input[name^="VLANID:"]').each(function(){vlans.push($(this).val());});
|
||||
@@ -146,45 +148,47 @@ function prepareSettings(form) {
|
||||
var protocol = $(this).val() || 'ipv4';
|
||||
var i = $(this).attr('name').split(':')[1];
|
||||
if (protocol == 'ipv6') {
|
||||
$(form).find('input[name="IPADDR:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('select[name="NETMASK:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('input[name="GATEWAY:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('input[name="METRIC:'+i+'"]').prop('disabled',true);
|
||||
if (i==0) $(form).find('input[name^="DNS_SERVER"]').prop('disabled',true);
|
||||
$(form).find('input[name="IPADDR:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name="NETMASK:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="GATEWAY:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="METRIC:'+i+'"]').prop('disabled',false).val('');
|
||||
if (i==0) $(form).find('input[name^="DNS_SERVER"]').prop('disabled',false).val('');
|
||||
}
|
||||
if (protocol == 'ipv4') {
|
||||
$(form).find('input[name="IPADDR6:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('input[name="NETMASK6:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('input[name="GATEWAY6:'+i+'"]').prop('disabled',true);
|
||||
$(form).find('select[name="PRIVACY6:'+i+'"]').prop('disabled',true);
|
||||
if (i==0) $(form).find('input[name^="DNS6_SERVER"]').prop('disabled',true);
|
||||
}
|
||||
if (protocol != 'ipv6') {
|
||||
var metric = $(form).find('input[name="METRIC:'+i+'"]').val();
|
||||
var gateway = $(form).find('input[name="GATEWAY:'+i+'"]');
|
||||
if (metric) gateway.val(gateway.val()+'#'+metric);
|
||||
$(form).find('input[name="IPADDR6:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="NETMASK6:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="GATEWAY6:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="METRIC6:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('select[name="PRIVACY6:'+i+'"]').prop('disabled',false).val('');
|
||||
if (i==0) $(form).find('input[name^="DNS6_SERVER"]').prop('disabled',false).val('');
|
||||
}
|
||||
});
|
||||
$(form).find('select[name^="USE_DHCP:"]').each(function() {
|
||||
var i = $(this).attr('name').split(':')[1];
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
||||
if ($(this).prop('disabled')==false && $(this).val()=='yes') {
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
||||
if (protocol != 'ipv6') {
|
||||
$(form).find('input[name="IPADDR:'+i+'"]').val('Obtaining IPv4 address...');
|
||||
$(form).find('input[name="GATEWAY:'+i+'"]').val('Obtaining IPv4 gateway...');
|
||||
}
|
||||
} else if (protocol != 'ipv6' && $(this).val()=='yes') {
|
||||
$(form).find('input[name="IPADDR:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="GATEWAY:'+i+'"]').prop('disabled',false).val('');
|
||||
}
|
||||
});
|
||||
$(form).find('select[name^="USE_DHCP6:"]').each(function() {
|
||||
var i = $(this).attr('name').split(':')[1];
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
||||
if ($(this).prop('disabled')==false && $(this).val()=='yes') {
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
||||
if (protocol != 'ipv4') {
|
||||
$(form).find('input[name="IPADDR6:'+i+'"]').val('Obtaining IPv6 address...');
|
||||
$(form).find('input[name="GATEWAY6:'+i+'"]').val('Obtaining IPv6 gateway...');
|
||||
}
|
||||
} else if (protocol != 'ipv4' && $(this).val()=='yes') {
|
||||
$(form).find('input[name="IPADDR6:'+i+'"]').prop('disabled',false).val('');
|
||||
$(form).find('input[name="GATEWAY6:'+i+'"]').prop('disabled',false).val('');
|
||||
}
|
||||
if ($(this).val()!='yes') $(form).find('input[name="PRIVACY6:'+i+'"]').prop('disabled',true);
|
||||
if ($(this).val()!='yes') $(form).find('input[name="PRIVACY6:'+i+'"]').prop('disabled',false).val('');
|
||||
});
|
||||
if (form.DHCP_KEEPRESOLV !== undefined && form.DHCP_KEEPRESOLV.value=='no') {
|
||||
form.DHCP_KEEPRESOLV.disabled = false;
|
||||
@@ -214,7 +218,7 @@ function selectProtocol(form,port,index) {
|
||||
}
|
||||
if ($(form).find('select[name="USE_DHCP:'+i+'"]').val()) more4.show(); else more4.hide();
|
||||
if ($(form).find('select[name="USE_DHCP6:'+i+'"]').val()) more6.show(); else more6.hide();
|
||||
checkNetworkSettings(form,i);
|
||||
checkNetworkSettings(form,i,true);
|
||||
});
|
||||
} else {
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4';
|
||||
@@ -236,7 +240,7 @@ function selectProtocol(form,port,index) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkNetworkSettings(form,index) {
|
||||
function checkNetworkSettings(form,index,start) {
|
||||
var disabled4 = $(form).find('select[name="USE_DHCP:'+index+'"]').val()!='no';
|
||||
var disabled6 = $(form).find('select[name="USE_DHCP6:'+index+'"]').val()!='no';
|
||||
var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4';
|
||||
@@ -254,12 +258,12 @@ function checkNetworkSettings(form,index) {
|
||||
}
|
||||
if (index==0) {
|
||||
if (form.DHCP_KEEPRESOLV !== undefined) {
|
||||
form.DHCP_KEEPRESOLV.value = disabled4 ? 'no' : 'yes';
|
||||
if (!start) form.DHCP_KEEPRESOLV.value = disabled4 ? 'no' : 'yes';
|
||||
form.DHCP_KEEPRESOLV.disabled = !disabled4;
|
||||
checkDNSSettings(form);
|
||||
}
|
||||
if (form.DHCP6_KEEPRESOLV !== undefined) {
|
||||
form.DHCP6_KEEPRESOLV.value = disabled6 ? 'no' : 'yes';
|
||||
if (!start) form.DHCP6_KEEPRESOLV.value = disabled6 ? 'no' : 'yes';
|
||||
form.DHCP6_KEEPRESOLV.disabled = !disabled6;
|
||||
checkDNSSettings6(form);
|
||||
}
|
||||
@@ -328,7 +332,7 @@ function addVLAN(port) {
|
||||
var template = $($('<div/>').loadTemplate($('#network-template-'+port)).html().replace(/INDEX/g,index));
|
||||
var element = $('[id^="index-'+port+'-"]').last();
|
||||
$(element).after(template);
|
||||
selectProtocol($('form[name="'+$(element).parent().attr('name')+'"]'),port);
|
||||
selectProtocol($('form[name="'+$(element).parent().attr('name')+'"]'),port,index);
|
||||
$(element).find('input').first().trigger('change');
|
||||
}
|
||||
function removeVLAN(element) {
|
||||
@@ -361,6 +365,17 @@ function portcheck_eth0() {
|
||||
function portToggle(port,cmd) {
|
||||
$.post('/webGui/include/PortToggle.php',{port:port,cmd:cmd},function(){refresh();});
|
||||
}
|
||||
var watchDHCP = new NchanSubscriber('/sub/dhcp');
|
||||
watchDHCP.on('message', function(data) {
|
||||
data = data.split(' ');
|
||||
for (var i=0,row; row=data[i]; i++) {
|
||||
var id = row.split('_');
|
||||
var form = $('form[name="'+id[0]+'_settings"]');
|
||||
var key = id[2].split('=');
|
||||
if (id[1]=='I') form.find('input[name="'+key[0]+'"]').val(key[1]);
|
||||
else if (id[1]=='S') form.find('select[name="'+key[0]+'"]').val(key[1]);
|
||||
}
|
||||
});
|
||||
$(function() {
|
||||
var ctrl = "<span id='wait_eth0' class='status red' style='display:none;font-size:small;font-style:italic'>Please wait... configuring interfaces</span>";
|
||||
var form = document.eth0_settings;
|
||||
@@ -392,6 +407,7 @@ $(function() {
|
||||
$('div[id=title]').append(ctrl);
|
||||
<?endif;?>
|
||||
portcheck_eth0();
|
||||
watchDHCP.start();
|
||||
});
|
||||
</script>
|
||||
<form markdown="1" name="eth0_settings" method="POST" action="/update.php" target="progressFrame" onchange="exitCode(this,false)" onsubmit="return prepareSettings(this)">
|
||||
@@ -614,6 +630,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:<?=$i?>" maxlength="39" value="<?=$eth0["GATEWAY6:$i"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:<?=$i?>" min="1" max="9999" value="<?=$eth0["METRIC6:$i"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
@@ -756,6 +773,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:<?=$i?>" maxlength="39" value="<?=$eth0["GATEWAY6:$i"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:<?=$i?>" min="1" max="9999" value="<?=$eth0["METRIC6:$i"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
@@ -860,6 +878,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:INDEX" maxlength="39" value="<?=$eth0["GATEWAY6:INDEX"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:INDEX" min="1" max="9999" value="<?=$eth0["METRIC6:INDEX"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:<?=$i?>" maxlength="39" value="<?=$ethX["GATEWAY6:$i"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:<?=$i?>" min="1" max="9999" value="<?=$ethX["METRIC6:$i"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
@@ -380,6 +381,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:<?=$i?>" maxlength="39" value="<?=$ethX["GATEWAY6:$i"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:<?=$i?>" min="1" max="9999" value="<?=$ethX["METRIC6:$i"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
@@ -484,6 +486,7 @@ IPv6 address:
|
||||
|
||||
IPv6 default gateway:
|
||||
: <input type="text" name="GATEWAY6:INDEX" maxlength="39" value="<?=$ethX["GATEWAY6:INDEX"]?>" pattern="<?=$validIP6?>" title="IPv6 address nnnn:xxxx::yyyy">
|
||||
<input type="text" name="METRIC6:INDEX" min="1" max="9999" value="<?=$ethX["METRIC6:INDEX"]?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> <em>optional metric (lowest is preferred)</em>
|
||||
|
||||
> Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router.
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ foreach ($other as $port) {
|
||||
input.fixed{width:200px;}
|
||||
</style>
|
||||
<script>
|
||||
function deleteRoute(button,gateway,route) {
|
||||
swal({title:"Are you sure?",text:"This will delete route "+route+" on gateway "+gateway,type:"warning",showCancelButton:true},function(){
|
||||
$.post('/webGui/include/RoutingTable.php',{gateway:gateway,route:route,task:'delete'},function(){resetTable();});
|
||||
function deleteRoute(gateway,route,metric) {
|
||||
swal({title:"Delete route?",text:route+" by gateway "+gateway,type:"warning",showCancelButton:true},function(){
|
||||
$.post('/webGui/include/RoutingTable.php',{gateway:gateway,route:route,metric:metric,task:'delete'},function(){resetTable();});
|
||||
});
|
||||
}
|
||||
function routeTable() {
|
||||
|
||||
@@ -14,14 +14,15 @@
|
||||
$task = $_POST['task'];
|
||||
switch ($task) {
|
||||
case 'delete':
|
||||
$gateway = str_replace(' ','-',trim($_POST['gateway']));
|
||||
$gateway = str_replace(['via ',' '],['','-'],trim($_POST['gateway']));
|
||||
$route = trim($_POST['route']);
|
||||
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_del"));
|
||||
$metric = trim($_POST['metric'] ?: "1");
|
||||
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_{$metric}_del"));
|
||||
break;
|
||||
case 'Add Route':
|
||||
$gateway = str_replace(' ','-',trim($_POST['gateway']));
|
||||
$gateway = str_replace(['via ',' '],['','-'],trim($_POST['gateway']));
|
||||
$route = trim($_POST['route']);
|
||||
$metric = strlen($_POST['metric']) ? trim($_POST['metric']) : 1;
|
||||
$metric = trim($_POST['metric'] ?: "1");
|
||||
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_{$metric}_add"));
|
||||
break;
|
||||
default:
|
||||
@@ -31,20 +32,20 @@ default:
|
||||
$cell = explode(' ',$info);
|
||||
$route = $cell[0];
|
||||
$gateway = $cell[2];
|
||||
$button = 'bt-'.preg_replace('/[\.:\/]/','',$gateway.$route);
|
||||
if ($route=='default') $gateway .= " via {$cell[4]}";
|
||||
$metric = '1';
|
||||
for ($i=3; $i<count($cell); $i++) if ($cell[$i] == 'metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv4</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a id='$button' href='#' onclick='deleteRoute(\"#$button\",\"$gateway\",\"$route\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv4</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
}
|
||||
if ($ipv6) echo "<tr class='tr_last'><td colspan='5'> </td></tr>";
|
||||
foreach ($ipv6 as $info) {
|
||||
$cell = explode(' ',$info);
|
||||
$route = $cell[0];
|
||||
$gateway = $route=='anycast' ? $cell[3] : $cell[2];
|
||||
$button = 'bt-'.preg_replace('/[\.:\/]/','',$gateway.$route);
|
||||
if ($route=='default') $gateway .= " via {$cell[4]}";
|
||||
$metric = '1';
|
||||
for ($i=3; $i<count($cell); $i++) if ($cell[$i] == 'metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv6</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a id='$button' href='#' onclick='deleteRoute(\"#$button\",\"$gateway\",\"$route\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv6</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
}
|
||||
echo "<tr class='tr_last'><td colspan='5'> </td></tr>";
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ foreach ($ini as $name => $port) {
|
||||
$new[] = "IFNAME[$i]=\"$iface\"";
|
||||
if ($set==$name) $ifname = $iface;
|
||||
foreach ($port as $key => $val) {
|
||||
if (!strlen($val)) continue;
|
||||
if (preg_match('/^(TYPE|BONDING$|BRIDGING)/',$key)) continue;
|
||||
if (!$bonding && preg_match('/^(BONDING_MODE|BONDING_MIIMON|BONDNICS|BONDNAME)/',$key)) continue;
|
||||
if (!$bridging && preg_match('/^(BRSTP|BRFD|BRNICS|BRNAME)/',$key)) continue;
|
||||
@@ -87,6 +88,17 @@ foreach ($ini as $name => $port) {
|
||||
$vlan = ",$j]";
|
||||
} else $vlan = '';
|
||||
if (!$vlan && preg_match('/^VLANID/',$key)) continue;
|
||||
if ($item=='DHCP_KEEPRESOLV') $DHCP_KEEPRESOLV = $val;
|
||||
if ($item=='DHCP6_KEEPRESOLV') $DHCP6_KEEPRESOLV = $val;
|
||||
if ($item=='PROTOCOL') $PROTOCOL = $val;
|
||||
if ($item=='USE_DHCP') $USE_DHCP = $val;
|
||||
if ($item=='USE_DHCP6') $USE_DHCP6 = $val;
|
||||
if (in_array($item,['IPADDR','NETMASK','GATEWAY']) && $USE_DHCP!='no') continue;
|
||||
if (in_array($item,['IPADDR6','NETMASK6','GATEWAY6','PRIVACY6']) && $USE_DHCP6!='no') continue;
|
||||
if (preg_match('/^DNS_SERVER/',$key) && $DHCP_KEEPRESOLV=='no') continue;
|
||||
if (preg_match('/^DNS6_SERVER/',$key) && $DHCP6_KEEPRESOLV=='no') continue;
|
||||
if ($item=='METRIC' && $PROTOCOL == 'ipv6') continue;
|
||||
if ($item=='METRIC6' && $PROTOCOL == 'ipv4') continue;
|
||||
$new[] = $item.(preg_match('/^(DNS6?_SERVER|DHCP6?_KEEPRESOLV)/',$key)?'':'['.$i.($vlan?'':']')).$vlan."=\"$val\"";
|
||||
}
|
||||
if ($trunk) $new[] = "VLANS[$i]=\"".($j+1)."\"";
|
||||
@@ -99,7 +111,6 @@ file_put_contents($cfg,implode("\r\n",$new)."\r\n");
|
||||
// don't execute when only interface description has changed
|
||||
if ($run) {
|
||||
exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$ifname}_start")." >/dev/null");
|
||||
sleep(1);
|
||||
exec("/usr/local/sbin/create_network_ini >/dev/null");
|
||||
}
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user