Merge pull request #259 from bergware/6.4-wip

Enhancements to Docker custom network settings
This commit is contained in:
tom mortensen
2018-02-19 16:53:51 -08:00
committed by GitHub
10 changed files with 246 additions and 156 deletions

View File

@@ -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);
@@ -49,7 +49,7 @@ foreach ($other as $network) {
if (!in_array($br,$custom) && !in_array($bond,$custom)) $custom[] = $network;
}
}
$include = $include6 = $address = $address6 = $gateway = $gateway6 = $unset = [];
$include = $include6 = $address = $address6 = $gateway = $gateway6 = $unset = $protocol = [];
foreach ($custom as $network) {
$ip4 = exec("ip -4 addr show $network|awk '/inet /{print $2}'");
$ip6 = exec("ip -6 addr show $network noprefixroute|awk '/inet6 /{print $2}'");
@@ -58,9 +58,32 @@ foreach ($custom as $network) {
$gw6 = exec("ip -6 route show dev $network default|awk '{print $3}'");
$route4 = exec("ip -4 route show dev $network $ip4|awk '{print $1}'");
$route6 = exec("ip -6 route show dev $network $ip6|awk '{print $1}'");
if ($ip4 && $route4) {$include[$network] = $route4; $address[$network] = $ip4; $gateway[$network] = $gw4;} elseif (!array_key_exists($network,$gateway6)) $unset[] = $network;
if ($ip6 && $route6) {$include6[$network] = $route6; $address6[$network] = $ip6; $gateway6[$network] = $gw6;} elseif (!array_key_exists($network,$gateway)) $unset[] = $network;
list($eth,$vlan) = explode('.',$network);
$eth = str_replace(['bond','br'],'eth',$eth);
if (!$vlan) {
$protocol[$network] = $$eth['PROTOCOL:0'] ?? 'ipv4';
} else {
foreach ($$eth as $key => $value) if (strpos($key,'VLANID')!==false && $value==$vlan) {$protocol[$network] = $$eth[str_replace('VLANID','PROTOCOL',$key)] ?? 'ipv4'; break;}
}
if ($ip4 && $route4) {
$include[$network] = $route4;
$address[$network] = $ip4;
$gateway[$network] = $gw4;
} elseif (!array_key_exists($network,$gateway6)) {
$unset[] = $network;
}
if ($ip6 && $route6) {
$include6[$network] = $route6;
$address6[$network] = $ip6;
$gateway6[$network] = $gw6;
} elseif (!array_key_exists($network,$gateway)) {
$unset[] = $network;
}
if ($protocol[$network] != 'ipv4') $wide = true;
}
$ip4class = $wide ? 'ip6' : 'ip4';
$gw4class = $wide ? 'gw6' : 'gw4';
$unset = array_unique($unset);
function normalize($network) {
@@ -88,16 +111,18 @@ function base_net($route) {
.basic{display:block}
.advanced{display:none;white-space:nowrap}
select.mask{min-width:0;margin:0 10px 0 4px}
select.net{min-width:0;margin:0 4px 0 0}
select.net{min-width:0;margin:0 4px 0 2px}
select option.hide{display:none}
input.net{width:100px;margin:0 4px 0 2px}
input.net6{width:200px;margin:0 4px}
input.check{margin-right:1px}
input.ip4{width:100px;margin:0 4px 0 1px}
input.ip6{width:140px;margin:0 4px}
input.gw4{width:100px;margin:0 4px 0 1px}
input.gw6{width:160px;margin:0 4px}
input.pool6{width:40px;margin:0 4px 0 1px}
span.net{margin-left:4px;margin-right:2px}
span.ip4{display:inline-block;width:200px}
span.ip6{display:inline-block;width:380px}
span.gw4{display:inline-block;width:180px}
span.gw6{display:inline-block;width:250px}
span.ip4{display:inline-block;width:260px}
span.ip6{display:inline-block;width:310px}
span.gw4{display:inline-block;width:200px}
span.gw6{display:inline-block;width:270px}
<?if (strstr('white,azure',$display['theme'])):?>
span.disabled{color:#B0B0B0}
<?else:?>
@@ -232,7 +257,7 @@ IPv4 custom network on interface <?=$network?> (optional):
$auto = $dockercfg[$docker_auto]!='no';
$autoDisabled = $auto ? '':'disabled';
$dhcp = $dockercfg[$docker_dhcp] ?? false;
$dhcpDisabled = $dhcp||$auto ? '':'disabled';
$dhcpDisabled = ($auto && $dhcp) ? '':'disabled';
$net = base_min($route);
$max = base_max($route);
$mask = explode('/',$route)[1];
@@ -246,8 +271,13 @@ IPv4 custom network on interface <?=$network?> (optional):
}
?>
: <input type="checkbox" id="<?=$docker_dhcp?>_edit" onchange="changeEdit(this.id,4)"<?=$auto?'checked':''?>>
<span id="<?=$docker_dhcp?>_line" class="<?=$autoDisabled?>"><span class="ip4">**Address:** <?=$address[$network]?></span><span class="gw4">**Gateway:** <?=$gateway[$network]?></span><input type="checkbox" id="<?=$docker_dhcp?>_dhcp" onchange="changeDHCP(this.id,4)"<?=$dhcp?'checked':''?><?=$dhcpDisabled?>>
**DHCP pool:**<span id="<?=$docker_dhcp?>_net" class="net <?=$dhcpDisabled?>"><?=$prefix?>.</span></span><?
<span id="<?=$docker_dhcp?>_line" class="<?=$autoDisabled?>">
<span class="<?=$ip4class?>">**Subnet:** <?=$route?></span>
<span class="<?=$gw4class?>">**Gateway:** <?=$gateway[$network]?></span>
<input type="checkbox" id="<?=$docker_dhcp?>_dhcp" onchange="changeDHCP(this.id,4)"<?=$dhcp?'checked':''?><?=$autoDisabled?>>
**DHCP pool:**<span id="<?=$docker_dhcp?>_net" class="net <?=$dhcpDisabled?>"><?=$prefix?>.</span>
</span>
<?
for ($b=$box; $b<=3; $b++) {
switch ($b) {
case 1: $step = $size/65536%256; break;
@@ -259,12 +289,11 @@ IPv4 custom network on interface <?=$network?> (optional):
for ($n=$net[$b]; $n<=$max[$b]; $n++) echo mk_option($net_user[$b],$n,$n,$n%$step==0?'':'class="hide"');
echo "</select>";
}
echo "/";
echo "/ ";
echo "<select id=\"{$docker_dhcp}_mask\" class=\"mask\" onchange=\"changeMask(this.id,this.value)\" $dhcpDisabled>";
for ($m=$mask+1; $m<=30; $m++) echo mk_option($mask_user,$m,$m);
echo "</select><span id=\"{$docker_dhcp}_size\" style=\"".($dhcp?'':'display:none')."\">($size hosts)</span>";
echo "<input type=\"hidden\" name=\"$docker_dhcp\" value=\"\">";
echo "";
?>
<?endforeach;?>
@@ -273,6 +302,37 @@ IPv4 custom network on interface <?=$network?> (optional):
>
> Enter the pool range within each allocated subnet which is used for DHCPv4 assignments by Docker. E.g. 192.168.1.128/25
<?endif;?>
<?foreach ($unset as $network):?>
<?
$port = normalize($network);
list($subnet,$mask) = explode('/',$dockercfg["DOCKER_SUBNET_$port"]);
list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]);
$disabled = $subnet ? '':'disabled';
$dhcpDisabled = $range ? '':'disabled';
?>
<?if ($protocol[$network] != 'ipv6'):?>
IPv4 custom network on interface <?=$network?> (optional):
: <input type="checkbox" id="DOCKER_CUSTOM_<?=$port?>_edit" onchange="changeCustom(this.id,4)"<?=$subnet?'checked':''?>>
<span class="<?=$ip4class?>">**Subnet:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_net" name="DOCKER_SUBNET_<?=$port?>" class="ip4" value="<?=$subnet?>" title="IPv4 address A.B.C.D"<?=$disabled?>>/
<select id="DOCKER_CUSTOM_<?=$port?>_mask" name="DOCKER_MASK_<?=$port?>" class="mask"<?=$disabled?>>
<?for ($m=16; $m<=30; $m++) echo mk_option($mask?:24,$m,$m)?></select>
</span>
<span class="<?=$gw4class?>">**Gateway:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_gw" name="DOCKER_GATEWAY_<?=$port?>" class="ip4" value="<?=$dockercfg["DOCKER_GATEWAY_$port"]?>" title="IPv4 address A.B.C.D"<?=$disabled?>></span>
<input type="checkbox" id="DOCKER_CUSTOM_<?=$port?>_dhcp" onchange="customDHCP(this.id,4)"<?=$subnet?'checked':''?><?=$dhcpDisabled?>>
**DHCP pool:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_pool" name="DOCKER_RANGE_<?=$port?>" class="ip4" value="<?=$range?>" title="IPv4 address A.B.C.D"<?=$disabled?>>/
<select id="DOCKER_CUSTOM_<?=$port?>_size" name="DOCKER_SIZE_<?=$port?>" class="mask" onchange="changeHosts(this.id,this.value)"<?=$disabled?>>
<?for ($m=16; $m<=30; $m++) echo mk_option($size?:25,$m,$m)?></select>
<span id="DOCKER_CUSTOM_<?=$port?>_hosts" style="<?=$subnet?'':'display:none'?>">(<?=pow(2,32-($size?:25))?> hosts)</span>
<?endif;?>
<?endforeach;?>
<?if ($unset && $protocol[$network] != 'ipv6'):?>
> Include or exclude (default) the above interfaces or VLANs as custom network for Docker.
>
> Enter the pool range within each allocated subnet which is used for DHCPv4 assignments by Docker. E.g. 192.168.1.128/25
<?endif;?>
<?foreach ($include6 as $network => $route):?>
<?
@@ -286,19 +346,23 @@ IPv6 custom network on interface <?=$network?> (optional):
$auto6 = $dockercfg[$docker_auto]!='no';
$auto6Disabled = $auto6 ? '':'disabled';
$dhcp6 = $dockercfg[$docker_dhcp6] ?? false;
$dhcp6Disabled = $dhcp6||$auto6 ? '':'disabled';
$dhcp6Disabled = ($auto6 && $dhcp6) ? '':'disabled';
$net = base_net($route);
$mask = explode('/',$route)[1];
$net_user = $dhcp6 ? str_replace("$net:","",base_net($dhcp6)) : '';
$mask_user = $dhcp6 ? explode('/',$dhcp6)[1] : $mask;
?>
: <input type="checkbox" id="<?=$docker_dhcp6?>_edit" onchange="changeEdit(this.id,6)"<?=$auto6?'checked':''?>>
<span id="<?=$docker_dhcp6?>_line" class="<?=$auto6Disabled?>"><span class="ip6">**Address:** <?=$address6[$network]?></span><span class="gw6">**Gateway:** <?=$gateway6[$network]?></span><input type="checkbox" id="<?=$docker_dhcp6?>_dhcp" onchange="changeDHCP(this.id,6)"<?=$dhcp6?'checked':''?><?=$dhcp6Disabled?>>
**DHCP pool:**<span id="<?=$docker_dhcp6?>_net" class="net <?=$dhcp6Disabled?>"><?=$net?>:</span></span><?
echo "<input type=\"text\" id=\"{$docker_dhcp6}_text\" value=\"$net_user\" class=\"net\" $dhcp6Disabled>/";
<span id="<?=$docker_dhcp6?>_line" class="<?=$auto6Disabled?>">
<span class="ip6">**Subnet:** <?=$route?></span>
<span class="gw6">**Gateway:** <?=$gateway6[$network]?></span>
<input type="checkbox" id="<?=$docker_dhcp6?>_dhcp" onchange="changeDHCP(this.id,6)"<?=$dhcp6?'checked':''?><?=$auto6Disabled?>>
**DHCP pool:**<span id="<?=$docker_dhcp6?>_net" class="net <?=$dhcp6Disabled?>"><?=$net?>:</span>
<?
echo "<input type=\"text\" id=\"{$docker_dhcp6}_text\" value=\"$net_user\" class=\"pool6\" $dhcp6Disabled>/ ";
echo "<select id=\"{$docker_dhcp6}_mask\" class=\"mask\" $dhcp6Disabled>";
for ($m=$mask+8; $m<=120; $m+=8) echo mk_option($mask_user,$m,$m);
echo "</select><input type=\"hidden\" name=\"$docker_dhcp6\" value=\"\">";
echo "</select><input type=\"hidden\" name=\"$docker_dhcp6\" value=\"\"></span>";
?>
<?endforeach;?>
@@ -311,62 +375,27 @@ IPv6 custom network on interface <?=$network?> (optional):
<?foreach ($unset as $network):?>
<?
$port = normalize($network);
list($eth,$vlan) = explode('.',$network);
$eth = str_replace(['bond','br'],'eth',$eth);
if (!$vlan) {
$protocol = $$eth['PROTOCOL:0'] ?? 'ipv4';
} else {
foreach ($$eth as $key => $value) {
if (strpos($key,'VLANID')!==false && $value==$vlan) {$protocol = $$eth[str_replace('VLANID','PROTOCOL',$key)] ?? 'ipv4'; break;}
}
}
list($subnet,$mask) = explode('/',$dockercfg["DOCKER_SUBNET_$port"]);
list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]);
$disabled = $subnet ? '':'disabled';
?>
<?if ($protocol != 'ipv6'):?>
IPv4 custom network on interface <?=$network?> (optional):
: <input type="checkbox" id="DOCKER_CUSTOM_<?=$port?>_edit" onchange="changeCustom(this.id,4)"<?=$subnet?'checked':''?> class="check">
**Address:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_net" name="DOCKER_SUBNET_<?=$port?>" class="net" value="<?=$subnet?>" title="IPv4 address A.B.C.D"<?=$disabled?>>/<select id="DOCKER_CUSTOM_<?=$port?>_mask" name="DOCKER_MASK_<?=$port?>" class="mask"<?=$disabled?>><?for ($m=16; $m<=30; $m++) echo mk_option($mask?:24,$m,$m)?></select>
**Gateway:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_gw" name="DOCKER_GATEWAY_<?=$port?>" class="net" value="<?=$dockercfg["DOCKER_GATEWAY_$port"]?>" title="IPv4 address A.B.C.D"<?=$disabled?>>
**DHCP pool:** <input type="text" id="DOCKER_CUSTOM_<?=$port?>_pool" name="DOCKER_RANGE_<?=$port?>" class="net" value="<?=$range?>" title="IPv4 address A.B.C.D"<?=$disabled?>>/<select id="DOCKER_CUSTOM_<?=$port?>_size" name="DOCKER_SIZE_<?=$port?>" class="mask" onchange="changeHosts(this.id,this.value)"<?=$disabled?>><?for ($m=16; $m<=30; $m++) echo mk_option($size?:25,$m,$m)?></select><span id="DOCKER_CUSTOM_<?=$port?>_hosts" style="<?=$subnet?'':'display:none'?>">(<?=pow(2,32-($size?:25))?> hosts)</span>
<?endif;?>
<?endforeach;?>
<?if ($unset && $protocol != 'ipv6'):?>
> Include or exclude (default) the above interfaces or VLANs as custom network for Docker.
>
> Enter the pool range within each allocated subnet which is used for DHCPv4 assignments by Docker. E.g. 192.168.1.128/25
<?endif;?>
<?foreach ($unset as $network):?>
<?
$port = normalize($network);
list($eth,$vlan) = explode('.',$network);
$eth = str_replace(['bond','br'],'eth',$eth);
if (!$vlan) {
$protocol = $$eth['PROTOCOL:0'] ?? 'ipv4';
} else {
foreach ($$eth as $key => $value) {
if (strpos($key,'VLANID')!==false && $value==$vlan) {$protocol = $$eth[str_replace('VLANID','PROTOCOL',$key)] ?? 'ipv4'; break;}
}
}
list($subnet6,$mask6) = explode('/',$dockercfg["DOCKER_SUBNET6_$port"]);
list($range6,$size6) = explode('/',$dockercfg["DOCKER_RANGE6_$port"]);
$disabled = $subnet6 ? '':'disabled';
$dhcpDisabled = $range6 ? '':'disabled';
?>
<?if ($protocol != 'ipv4'):?>
<?if ($protocol[$network] != 'ipv4'):?>
IPv6 custom network on interface <?=$network?> (optional):
: <input type="checkbox" id="DOCKER_CUSTOM6_<?=$port?>_edit" onchange="changeCustom(this.id,6)"<?=$subnet6?'checked':''?> class="check">
**Address:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_net" name="DOCKER_SUBNET6_<?=$port?>" class="net6" value="<?=$subnet6?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>>/<select id="DOCKER_CUSTOM6_<?=$port?>_mask" name="DOCKER_MASK6_<?=$port?>" class="mask"<?=$disabled?>><?for ($m=64; $m<=120; $m+=8) echo mk_option($mask6?:64,$m,$m)?></select>
**Gateway:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_gw" name="DOCKER_GATEWAY6_<?=$port?>" class="net6" value="<?=$dockercfg["DOCKER_GATEWAY6_$port"]?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>>
**DHCP pool:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_pool" name="DOCKER_RANGE6_<?=$port?>" class="net6" value="<?=$range6?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>>/<select id="DOCKER_CUSTOM6_<?=$port?>_size" name="DOCKER_SIZE6_<?=$port?>" class="mask"<?=$disabled?>><?for ($m=64; $m<=120; $m+=8) echo mk_option($size6?:72,$m,$m)?></select>
: <input type="checkbox" id="DOCKER_CUSTOM6_<?=$port?>_edit" onchange="changeCustom(this.id,6)"<?=$subnet6?'checked':''?>>
<span class="ip6">**Subnet:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_net" name="DOCKER_SUBNET6_<?=$port?>" class="ip6" value="<?=$subnet6?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>>/
<select id="DOCKER_CUSTOM6_<?=$port?>_mask" name="DOCKER_MASK6_<?=$port?>" class="mask"<?=$disabled?>>
<?for ($m=64; $m<=120; $m+=8) echo mk_option($mask6?:64,$m,$m)?></select></span>
<span class="gw6">**Gateway:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_gw" name="DOCKER_GATEWAY6_<?=$port?>" class="gw6" value="<?=$dockercfg["DOCKER_GATEWAY6_$port"]?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>></span>
<input type="checkbox" id="DOCKER_CUSTOM6_<?=$port?>_dhcp" onchange="customDHCP(this.id,6)"<?=$subnet6?'checked':''?><?=$dhcpDisabled?>>
**DHCP pool:**<input type="text" id="DOCKER_CUSTOM6_<?=$port?>_pool" name="DOCKER_RANGE6_<?=$port?>" class="ip6" value="<?=$range6?>" title="IPv6 address nnnn:xxxx::yyyy"<?=$disabled?>>/
<select id="DOCKER_CUSTOM6_<?=$port?>_size" name="DOCKER_SIZE6_<?=$port?>" class="mask"<?=$disabled?>>
<?for ($m=64; $m<=120; $m+=8) echo mk_option($size6?:72,$m,$m)?></select>
<?endif;?>
<?endforeach;?>
<?if ($unset && $protocol != 'ipv4'):?>
<?if ($unset && $protocol[$network] != 'ipv4'):?>
> Include or exclude (default) the above interfaces or VLANs as custom network for Docker.
>
> Enter the pool range within each allocated subnet which is used for DHCPv6 assignments by Docker. E.g. 2a02:abcd:9ef5:100:1::/72
@@ -408,17 +437,9 @@ $docker_dhcp = "DOCKER_DHCP_$net";
?>
<?if ($dockercfg[$docker_dhcp] || empty($dockercfg["DOCKER_AUTO_$net"])):?>
IPv4 custom network on interface <?=$network?>:
: <span class="ip4">**Address:** <?=$address[$network]?></span><span class="gw4">**Gateway:** <?=$gateway[$network]?></span>**DHCP pool:** <?=$dockercfg[$docker_dhcp] ?? 'not set'?><?if ($dockercfg[$docker_dhcp]):?>&nbsp;&nbsp;(<?=pow(2,32-explode('/',$dockercfg[$docker_dhcp])[1])?> hosts)<?endif;?>
<?endif;?>
<?endforeach;?>
<?foreach ($include6 as $network => $route):?>
<?
$net = normalize($network);
$docker_dhcp6 = "DOCKER_DHCP6_$net";
if ($dockercfg[$docker_dhcp6]):?>
IPv6 custom network on interface <?=$network?>:
: <span class="ip6">**Address:** <?=$address6[$network]?></span><span class="gw6">**Gateway:** <?=$gateway6[$network]?></span>**DHCP pool:** <?=$dockercfg[$docker_dhcp6] ?? 'not set'?>
: <span class="<?=$gw4class?>">**Subnet:** <?=$route?></span>
<span class="<?=$gw4class?>">**Gateway:** <?=$gateway[$network]?></span>
**DHCP pool:** <?=$dockercfg[$docker_dhcp] ?? 'not set'?><?if ($dockercfg[$docker_dhcp]):?>&nbsp;&nbsp;(<?=pow(2,32-explode('/',$dockercfg[$docker_dhcp])[1])?> hosts)<?endif;?>
<?endif;?>
<?endforeach;?>
@@ -439,7 +460,22 @@ list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]);
?>
<?if ($protocol != 'ipv6' && $subnet):?>
IPv4 custom network on interface <?=$network?>:
: <span class="ip4">**Address:** <?=$subnet?>/<?=$mask?></span><span class="gw4">**Gateway:** <?=$dockercfg["DOCKER_GATEWAY_$port"]?></span>**DHCP pool:** <?=$range?"$range/$size":"not set"?><?if ($range):?>&nbsp;&nbsp;(<?=pow(2,32-($size?:25))?> hosts)<?endif;?>
: <span class="<?=$gw4class?>">**Subnet:** <?=$subnet?>/<?=$mask?></span>
<span class="<?=$gw4class?>">**Gateway:** <?=$dockercfg["DOCKER_GATEWAY_$port"]?></span>
**DHCP pool:** <?=$range?"$range/$size":"not set"?><?if ($range):?>&nbsp;&nbsp;(<?=pow(2,32-($size?:25))?> hosts)<?endif;?>
<?endif;?>
<?endforeach;?>
<?foreach ($include6 as $network => $route):?>
<?
$net = normalize($network);
$docker_dhcp6 = "DOCKER_DHCP6_$net";
if ($dockercfg[$docker_dhcp6] || empty($dockercfg["DOCKER_AUTO_$net"])):?>
<?$wide = true;?>
IPv6 custom network on interface <?=$network?>:
: <span class="gw6">**Subnet:** <?=$route?></span>
<span class="gw6">**Gateway:** <?=$gateway6[$network]?></span>
**DHCP pool:** <?=$dockercfg[$docker_dhcp6] ?? 'not set'?>
<?endif;?>
<?endforeach;?>
@@ -460,7 +496,9 @@ list($range6,$size6) = explode('/',$dockercfg["DOCKER_RANGE6_$port"]);
?>
<?if ($protocol != 'ipv4' && $subnet6):?>
IPv6 custom network on interface <?=$network?>:
: <span class="ip6">**Address:** <?=$subnet6?>/<?=$mask6?></span><span class="gw6">**Gateway:** <?=$dockercfg["DOCKER_GATEWAY6_$port"]?></span>**DHCP pool:** <?=$range6?"$range6/$size6":"not set"?>
: <span class="gw6">**Subnet:** <?=$subnet6?>/<?=$mask6?></span>
<span class="gw6">**Gateway:** <?=$dockercfg["DOCKER_GATEWAY6_$port"]?></span>
**DHCP pool:** <?=$range6?"$range6/$size6":"not set"?>
<?endif;?>
<?endforeach;?>
@@ -554,7 +592,8 @@ function prepareDocker(form) {
$(form).find('input[name^="DOCKER_RANGE_"]').each(function(){
var edit = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_edit';
var size = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_size';
if ($(edit).prop('checked')) {
var dhcp = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_dhcp';
if ($(edit).prop('checked') && $(dhcp).prop('checked')) {
if ($(this).val()) $(this).val($(this).val()+'/'+$(size).val());
} else {
$(this).val('').prop('disabled',false);
@@ -578,7 +617,8 @@ function prepareDocker(form) {
$(form).find('input[name^="DOCKER_RANGE6_"]').each(function(){
var edit6 = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_edit';
var size6 = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_size';
if ($(edit6).prop('checked')) {
var dhcp6 = '#'+$(this).attr('name').replace('RANGE','CUSTOM')+'_dhcp';
if ($(edit6).prop('checked') && $(dhcp6).prop('checked')) {
if ($(this).val()) $(this).val($(this).val()+'/'+$(size6).val());
} else {
$(this).val('').prop('disabled',false);
@@ -646,6 +686,13 @@ function changeDHCP(id,ip,sid) {
}
}
}
function customDHCP(id,ip) {
var checked = $('#'+id).prop('checked');
id = '#'+id.substr(0,id.length-4);
$(id+'pool').prop('disabled',!checked);
$(id+'size').prop('disabled',!checked);
if (ip==4) checked ? $(id+'hosts').show() : $(id+'hosts').hide();
}
function changeCustom(id,ip) {
var checked = $('#'+id).prop('checked');
var device = id.substr(0,id.length-5).split('_').splice(2,2).join('.').toLowerCase();
@@ -664,9 +711,10 @@ function changeCustom(id,ip) {
$(id+'net').prop('disabled',!checked);
$(id+'mask').prop('disabled',!checked);
$(id+'gw').prop('disabled',!checked);
$(id+'dhcp').prop('disabled',!checked);
$(id+'pool').prop('disabled',!checked);
$(id+'size').prop('disabled',!checked);
if (checked) $(id+'hosts').show(); else $(id+'hosts').hide();
checked ? $(id+'hosts').show() : $(id+'hosts').hide();
}
function changeMask(id,val) {
var mask = Math.pow(2,32-val);
@@ -725,7 +773,7 @@ function checkDHCP() {
}
function checkIP() {
var validIP4 = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
var validIP6 = /^((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*::((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*|((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4})){7}$/;
var validIP6 = /^((?:[0-9A-F]{1,4}))((?::[0-9A-F]{1,4}))*::((?:[0-9A-F]{1,4}))((?::[0-9A-F]{1,4}))*|((?:[0-9A-F]{1,4}))((?::[0-9A-F]{1,4})){7}$/i;
var error = null;
$('#settingsForm').find('input[name^="DOCKER_SUBNET_"]').each(function(){
if ($(this).val() && !validIP4.test($(this).val())) error = 'IPv4 address';

View File

@@ -198,7 +198,7 @@ function postToXML($post, $setOwnership = false) {
$xml->MyIP = xml_encode($post['contMyIP']);
$xml->Privileged = (strtolower($post["contPrivileged"]) == 'on') ? 'true' : 'false';
$xml->Support = xml_encode($post['contSupport']);
$xml->Project = xml_encode($post['contProject']);
$xml->Project = xml_encode($post['contProject']);
$xml->Overview = xml_encode($post['contOverview']);
$xml->Category = xml_encode($post['contCategory']);
$xml->WebUI = xml_encode(trim($post['contWebUI']));
@@ -257,14 +257,14 @@ function postToXML($post, $setOwnership = false) {
}
function xmlToVar($xml) {
$xml = (is_file($xml)) ? simplexml_load_file($xml) : simplexml_load_string($xml);
global $subnet;
$xml = is_file($xml) ? simplexml_load_file($xml) : simplexml_load_string($xml);
$out = [];
$out['Name'] = preg_replace('/\s+/', '', xml_decode($xml->Name));
$out['Repository'] = xml_decode($xml->Repository);
$out['Registry'] = xml_decode($xml->Registry);
$out['Network'] = isset($xml->Network) ? xml_decode($xml->Network) : xml_decode($xml->Network['Default']);
$out['MyIP'] = isset($xml->MyIP) ? xml_decode($xml->MyIP) : '';
$out['Network'] = xml_decode($xml->Network);
$out['MyIP'] = xml_decode($xml->MyIP ?? '');
$out['Privileged'] = xml_decode($xml->Privileged);
$out['Support'] = xml_decode($xml->Support);
$out['Project'] = xml_decode($xml->Project);
@@ -277,10 +277,9 @@ function xmlToVar($xml) {
$out['PostArgs'] = xml_decode($xml->PostArgs);
$out['DonateText'] = xml_decode($xml->DonateText);
$out['DonateLink'] = xml_decode($xml->DonateLink);
$out['DonateImg'] = (xml_decode($xml->DonateImage)) ? xml_decode($xml->DonateImage) : xml_decode($xml->DonateImg); # Various authors use different tags. DonateImg is the official spec
$out['DonateImg'] = xml_decode($xml->DonateImg ?? $xml->DonateImage); # Various authors use different tags. DonateImg is the official spec
$out['MinVer'] = xml_decode($xml->MinVer);
$out['Config'] = [];
$out['Config'] = [];
if (isset($xml->Config)) {
foreach ($xml->Config as $config) {
$c = [];
@@ -303,12 +302,13 @@ function xmlToVar($xml) {
$out['Config'][] = $c;
}
}
# some xml templates advertise as V2 but omit the new <Network> element
# check for and use the V1 <Networking> element when this occurs
if (empty($out['Network']) && isset($xml->Networking->Mode)) {
$out['Network'] = xml_decode($xml->Networking->Mode);
}
# check if network exists
if (!key_exists($out['Network'],$subnet)) $out['Network'] = 'none';
# V1 compatibility
if ($xml["version"] != "2") {
@@ -335,7 +335,6 @@ function xmlToVar($xml) {
];
}
}
if (isset($xml->Data->Volume)) {
$volNum = 0;
foreach ($xml->Data->Volume as $vol) {
@@ -355,7 +354,6 @@ function xmlToVar($xml) {
];
}
}
if (isset($xml->Environment->Variable)) {
$varNum = 0;
foreach ($xml->Environment->Variable as $varitem) {
@@ -376,7 +374,6 @@ function xmlToVar($xml) {
}
}
}
return $out;
}
@@ -1379,7 +1376,7 @@ optgroup.title{background-color:#625D5D;color:#FFFFFF;text-align:center;margin-t
</blockquote>
</td>
</tr>
<tr class="<?=$authoring;?>">
<tr class="<?=$authoring;?>">
<td>Donation Text:</td>
<td><input type="text" name="contDonateText"></td>
</tr>

View File

@@ -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.

View File

@@ -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.

View File

@@ -14,17 +14,28 @@ Tag="share-alt"
* all copies or substantial portions of the Software.
*/
?>
<?
exec("ls --indicator-style=none /sys/class/net|grep -P '^(eth|br|bond)[0-9]'",$list);
unset($list,$other);
exec("ls /sys/class/net|grep -P '^br[0-9]'",$list);
exec("ls /sys/class/net|grep -P '^(bond|eth)[0-9]'",$other);
foreach ($other as $port) {
if (substr($port,0,4)=='bond') {
$br = str_replace('bond','br',$port);
if (!in_array($br,$list)) $list[] = $port;
} else {
$br = str_replace('eth','br',$port);
$bond = str_replace('eth','bond',$port);
if (!in_array($br,$list) && !in_array($bond,$list)) $list[] = $port;
}
}
?>
<style>
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() {

View File

@@ -34,7 +34,7 @@ function my_scale($value, &$unit, $decimals=NULL, $scale=NULL) {
if ($scale<0 && round($value,-1)==1000) {$value = 1; $base++;}
$unit = $units[$base];
}
return number_format($value, $decimals, $number[0], $value>=10000 ? $number[1] : '');
return number_format($value, $decimals, $number[0], $value>9999 ? $number[1] : '');
}
function my_number($value) {
global $display;

View File

@@ -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'>&nbsp;</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'>&nbsp;</td></tr>";
}

View File

@@ -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);

View File

@@ -90,7 +90,7 @@ input.trim{width:50px}
.usage-disk.sys>span{text-align:right;color:#FFFFFF}
.usage-disk.all{margin-right:2px}
.usage-disk.all>span{text-align:right;color:#FFFFFF;font-size:11px}
.notice{background:#FFF6BF url(../images/notice.png) no-repeat;background-position:15px 50%;text-align:left;padding:15px 15px 15px 100px;display:table-cell;height:30px;width:1270px;vertical-align:middle;border-top:2px solid #FFD324;border-bottom:2px solid #FFD324}
.notice{background:#FFF6BF url(../images/notice.png) no-repeat;background-position:15px 50%;text-align:left;padding:15px 15px 15px 100px;display:table-cell;height:30px;width:100%;vertical-align:middle;border-top:2px solid #FFD324;border-bottom:2px solid #FFD324}
.whitebar{background:-webkit-radial-gradient(#C7C7C7,#EEEEEE);background:linear-gradient(#C7C7C7,#EEEEEE)}
.greenbar{background:-webkit-radial-gradient(#127A05,#17BF0B);background:linear-gradient(#127A05,#17BF0B)}
.orangebar{background:-webkit-radial-gradient(#CE7C10,#F0B400);background:linear-gradient(#CE7C10,#F0B400)}

View File

@@ -90,7 +90,7 @@ input.trim{width:50px}
.usage-disk.sys>span{text-align:right;color:#FFFFFF}
.usage-disk.all{margin-right:2px}
.usage-disk.all>span{text-align:right;color:#FFFFFF;font-size:11px}
.notice{background:#FFF6BF url(../images/notice.png) no-repeat;background-position:15px 50%;text-align:left;padding:15px 15px 15px 100px;display:table-cell;height:30px;width:1270px;vertical-align:middle;border-top:2px solid #FFD324;border-bottom:2px solid #FFD324}
.notice{background:#FFF6BF url(../images/notice.png) no-repeat;background-position:15px 50%;text-align:left;padding:15px 15px 15px 100px;display:table-cell;height:30px;width:100%;vertical-align:middle;border-top:2px solid #FFD324;border-bottom:2px solid #FFD324}
.whitebar{background:-webkit-radial-gradient(#C7C7C7,#EEEEEE);background:linear-gradient(#C7C7C7,#EEEEEE)}
.greenbar{background:-webkit-radial-gradient(#127A05,#17BF0B);background:linear-gradient(#127A05,#17BF0B)}
.orangebar{background:-webkit-radial-gradient(#CE7C10,#F0B400);background:linear-gradient(#CE7C10,#F0B400)}