From 51a110592f9bce0d911d71a29a49068feea0d52a Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Feb 2018 08:14:36 +0100 Subject: [PATCH 1/8] Change "Address" to "Subnet" in Docker custom network settings --- .../dynamix.docker.manager/DockerSettings.page | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/dynamix.docker.manager/DockerSettings.page b/plugins/dynamix.docker.manager/DockerSettings.page index 52d55425c..dc00d2ac1 100644 --- a/plugins/dynamix.docker.manager/DockerSettings.page +++ b/plugins/dynamix.docker.manager/DockerSettings.page @@ -95,7 +95,7 @@ input.net6{width:200px;margin:0 4px} input.check{margin-right:1px} span.net{margin-left:4px;margin-right:2px} span.ip4{display:inline-block;width:200px} -span.ip6{display:inline-block;width:380px} +span.ip6{display:inline-block;width:280px} span.gw4{display:inline-block;width:180px} span.gw6{display:inline-block;width:250px} @@ -246,7 +246,7 @@ IPv4 custom network on interface (optional): } ?> : > - **Address:** **Gateway:** > + **Subnet:** **Gateway:** > **DHCP pool:**. (optional): $mask_user = $dhcp6 ? explode('/',$dhcp6)[1] : $mask; ?> : > - **Address:** **Gateway:** > + **Subnet:** **Gateway:** > **DHCP pool:**:/"; echo " class="check"> - **Address:** >/ + **Subnet:** >/ **Gateway:** " title="IPv4 address A.B.C.D"> **DHCP pool:** >/( hosts) @@ -360,7 +360,7 @@ $disabled = $subnet6 ? '':'disabled'; IPv6 custom network on interface (optional): : class="check"> - **Address:**>/ + **Subnet:**>/ **Gateway:**" title="IPv6 address nnnn:xxxx::yyyy"> **DHCP pool:**>/ @@ -408,7 +408,7 @@ $docker_dhcp = "DOCKER_DHCP_$net"; ?> IPv4 custom network on interface : -: **Address:** **Gateway:** **DHCP pool:**   ( hosts) +: **Subnet:** **Gateway:** **DHCP pool:**   ( hosts) @@ -418,7 +418,7 @@ $net = normalize($network); $docker_dhcp6 = "DOCKER_DHCP6_$net"; if ($dockercfg[$docker_dhcp6]):?> IPv6 custom network on interface : -: **Address:** **Gateway:** **DHCP pool:** +: **Subnet:** **Gateway:** **DHCP pool:** @@ -439,7 +439,7 @@ list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]); ?> IPv4 custom network on interface : -: **Address:** /**Gateway:** **DHCP pool:**   ( hosts) +: **Subnet:** /**Gateway:** **DHCP pool:**   ( hosts) @@ -460,7 +460,7 @@ list($range6,$size6) = explode('/',$dockercfg["DOCKER_RANGE6_$port"]); ?> IPv6 custom network on interface : -: **Address:** /**Gateway:** **DHCP pool:** +: **Subnet:** /**Gateway:** **DHCP pool:** From d82296d329ecca91c4021dfee9924dfca0bbd344 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Feb 2018 09:22:11 +0100 Subject: [PATCH 2/8] Revert "Change "Address" to "Subnet" in Docker custom network settings" This reverts commit 51a110592f9bce0d911d71a29a49068feea0d52a. --- .../dynamix.docker.manager/DockerSettings.page | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/dynamix.docker.manager/DockerSettings.page b/plugins/dynamix.docker.manager/DockerSettings.page index dc00d2ac1..52d55425c 100644 --- a/plugins/dynamix.docker.manager/DockerSettings.page +++ b/plugins/dynamix.docker.manager/DockerSettings.page @@ -95,7 +95,7 @@ input.net6{width:200px;margin:0 4px} input.check{margin-right:1px} span.net{margin-left:4px;margin-right:2px} span.ip4{display:inline-block;width:200px} -span.ip6{display:inline-block;width:280px} +span.ip6{display:inline-block;width:380px} span.gw4{display:inline-block;width:180px} span.gw6{display:inline-block;width:250px} @@ -246,7 +246,7 @@ IPv4 custom network on interface (optional): } ?> : > - **Subnet:** **Gateway:** > + **Address:** **Gateway:** > **DHCP pool:**. (optional): $mask_user = $dhcp6 ? explode('/',$dhcp6)[1] : $mask; ?> : > - **Subnet:** **Gateway:** > + **Address:** **Gateway:** > **DHCP pool:**:/"; echo " class="check"> - **Subnet:** >/ + **Address:** >/ **Gateway:** " title="IPv4 address A.B.C.D"> **DHCP pool:** >/( hosts) @@ -360,7 +360,7 @@ $disabled = $subnet6 ? '':'disabled'; IPv6 custom network on interface (optional): : class="check"> - **Subnet:**>/ + **Address:**>/ **Gateway:**" title="IPv6 address nnnn:xxxx::yyyy"> **DHCP pool:**>/ @@ -408,7 +408,7 @@ $docker_dhcp = "DOCKER_DHCP_$net"; ?> IPv4 custom network on interface : -: **Subnet:** **Gateway:** **DHCP pool:**   ( hosts) +: **Address:** **Gateway:** **DHCP pool:**   ( hosts) @@ -418,7 +418,7 @@ $net = normalize($network); $docker_dhcp6 = "DOCKER_DHCP6_$net"; if ($dockercfg[$docker_dhcp6]):?> IPv6 custom network on interface : -: **Subnet:** **Gateway:** **DHCP pool:** +: **Address:** **Gateway:** **DHCP pool:** @@ -439,7 +439,7 @@ list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]); ?> IPv4 custom network on interface : -: **Subnet:** /**Gateway:** **DHCP pool:**   ( hosts) +: **Address:** /**Gateway:** **DHCP pool:**   ( hosts) @@ -460,7 +460,7 @@ list($range6,$size6) = explode('/',$dockercfg["DOCKER_RANGE6_$port"]); ?> IPv6 custom network on interface : -: **Subnet:** /**Gateway:** **DHCP pool:** +: **Address:** /**Gateway:** **DHCP pool:** From 134d536dc551597f0744f5f24af407b896a447d5 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Feb 2018 12:51:51 +0100 Subject: [PATCH 3/8] Enhamcements to Docker custom network settings --- .../DockerSettings.page | 218 +++++++++++------- 1 file changed, 133 insertions(+), 85 deletions(-) diff --git a/plugins/dynamix.docker.manager/DockerSettings.page b/plugins/dynamix.docker.manager/DockerSettings.page index 52d55425c..c91eea24c 100644 --- a/plugins/dynamix.docker.manager/DockerSettings.page +++ b/plugins/dynamix.docker.manager/DockerSettings.page @@ -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} span.disabled{color:#B0B0B0} @@ -232,7 +257,7 @@ IPv4 custom network on interface (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 (optional): } ?> : > - **Address:** **Gateway:** > - **DHCP pool:**._line" class=""> + **Subnet:** + **Gateway:** + > + **DHCP pool:**. + + (optional): for ($n=$net[$b]; $n<=$max[$b]; $n++) echo mk_option($net_user[$b],$n,$n,$n%$step==0?'':'class="hide"'); echo ""; } - echo "/"; + echo "/ "; echo "($size hosts)"; echo ""; - echo ""; ?> @@ -273,6 +302,37 @@ IPv4 custom network on interface (optional): > > Enter the pool range within each allocated subnet which is used for DHCPv4 assignments by Docker. E.g. 192.168.1.128/25 + + + + + +IPv4 custom network on interface (optional): +: > + **Subnet:** >/ + + + **Gateway:** " title="IPv4 address A.B.C.D"> + > + **DHCP pool:** >/ + + ( hosts) + + + + +> 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 + $route):?> (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; ?> : > - **Address:** **Gateway:** > - **DHCP pool:**:/"; + + **Subnet:** + **Gateway:** + > + **DHCP pool:**: +/ "; echo ""; + echo ""; ?> @@ -311,62 +375,27 @@ IPv6 custom network on interface (optional): $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'; -?> - - -IPv4 custom network on interface (optional): -: class="check"> - **Address:** >/ - **Gateway:** " title="IPv4 address A.B.C.D"> - **DHCP pool:** >/( hosts) - - - - -> 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 - - - - $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'; ?> - + IPv6 custom network on interface (optional): -: class="check"> - **Address:**>/ - **Gateway:**" title="IPv6 address nnnn:xxxx::yyyy"> - **DHCP pool:**>/ +: > + **Subnet:**>/ + + **Gateway:**" title="IPv6 address nnnn:xxxx::yyyy"> + > + **DHCP pool:**>/ + - + > 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"; ?> IPv4 custom network on interface : -: **Address:** **Gateway:** **DHCP pool:**   ( hosts) - - - - $route):?> - -IPv6 custom network on interface : -: **Address:** **Gateway:** **DHCP pool:** +: **Subnet:** + **Gateway:** + **DHCP pool:**   ( hosts) @@ -439,7 +460,22 @@ list($range,$size) = explode('/',$dockercfg["DOCKER_RANGE_$port"]); ?> IPv4 custom network on interface : -: **Address:** /**Gateway:** **DHCP pool:**   ( hosts) +: **Subnet:** / + **Gateway:** + **DHCP pool:**   ( hosts) + + + + $route):?> + + +IPv6 custom network on interface : +: **Subnet:** + **Gateway:** + **DHCP pool:** @@ -460,7 +496,9 @@ list($range6,$size6) = explode('/',$dockercfg["DOCKER_RANGE6_$port"]); ?> IPv6 custom network on interface : -: **Address:** /**Gateway:** **DHCP pool:** +: **Subnet:** / + **Gateway:** + **DHCP pool:** @@ -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'; From aefbaba8013234b4d054c51498daac9135c73a15 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Feb 2018 15:52:02 +0100 Subject: [PATCH 4/8] Fixed number display when >=10000 --- plugins/dynamix/include/Helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index db7f3cfee..935a33720 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -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; From d582a65e45113691aab754472235f155507a34b9 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Feb 2018 15:52:25 +0100 Subject: [PATCH 5/8] Fixed port list in routing table --- plugins/dynamix/RoutingTable.page | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/RoutingTable.page b/plugins/dynamix/RoutingTable.page index 829e83486..0b04847c7 100644 --- a/plugins/dynamix/RoutingTable.page +++ b/plugins/dynamix/RoutingTable.page @@ -14,9 +14,20 @@ Tag="share-alt" * all copies or substantial portions of the Software. */ ?> -