Enhamcements to Docker custom network settings

This commit is contained in:
bergware
2018-02-05 12:51:51 +01:00
parent d82296d329
commit 134d536dc5
@@ -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';