diff --git a/plugins/dynamix.docker.manager/DockerSettings.page b/plugins/dynamix.docker.manager/DockerSettings.page index 52d55425c..da5d83011 100644 --- a/plugins/dynamix.docker.manager/DockerSettings.page +++ b/plugins/dynamix.docker.manager/DockerSettings.page @@ -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} 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'; diff --git a/plugins/dynamix.docker.manager/include/CreateDocker.php b/plugins/dynamix.docker.manager/include/CreateDocker.php index 7f9570f70..d4e44dac0 100644 --- a/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -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 element # check for and use the V1 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 - + Donation Text: diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index 2332f5567..eabd0c263 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -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 = $($('
').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 = ""; var form = document.eth0_settings; @@ -392,6 +407,7 @@ $(function() { $('div[id=title]').append(ctrl); portcheck_eth0(); + watchDHCP.start(); });
@@ -614,6 +630,7 @@ IPv6 address: IPv6 default gateway: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > 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: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > 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: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router. diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index eb50a0427..142e982d0 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -270,6 +270,7 @@ IPv6 address: IPv6 default gateway: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > 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: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > 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: : " pattern="" title="IPv6 address nnnn:xxxx::yyyy"> + " class="slim"> optional metric (lowest is preferred) > Greyed out when using automatic IP assignment. Otherwise specify here the IPv6 address of your router. diff --git a/plugins/dynamix/RoutingTable.page b/plugins/dynamix/RoutingTable.page index 829e83486..87e62a233 100644 --- a/plugins/dynamix/RoutingTable.page +++ b/plugins/dynamix/RoutingTable.page @@ -14,17 +14,28 @@ Tag="share-alt" * all copies or substantial portions of the Software. */ ?> -