diff --git a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page index 0203a7f896..b6072ab567 100644 --- a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page +++ b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page @@ -25,23 +25,23 @@ exec("/etc/rc.d/rc.docker status >/dev/null",$dummy,$DockerStopped); function strposX($s, $c, $n=1) { $p = 0; - while ($n && $p=strpos($s,$c,$p)!==false) {$n--; $p+=strlen($c);} + while ($n && $p = strpos($s,$c,$p) !== false) {$n--; $p += strlen($c);} return $p; } 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|wlan)[0-9]'",$other); -$bridge = count($custom)>0; +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|wlan)[0-9]'",$other); +$bridge = count($custom) > 0; $slaves = []; foreach ($other as $network) { - if (substr($network,0,4)=='bond') { + if (substr($network,0,4) == 'bond') { $br = str_replace('bond','br',$network); $bond = "/sys/class/net/$network/bonding/slaves"; if (file_exists($bond)) $slaves = array_merge($slaves,explode(' ',str_replace("\n","",file_get_contents($bond)))); if (!in_array($br,$custom)) $custom[] = $network; - } elseif (substr($network,0,3)=='eth') { + } elseif ($bridge && substr($network,0,3) == 'eth') { $br = str_replace('eth','br',$network); $bond = str_replace('eth','bond',$network); if (!in_array($br,$custom) && !in_array($bond,$custom)) $custom[] = $network; @@ -50,18 +50,18 @@ foreach ($other as $network) { } } -$include = $include6 = $address = $address6 = $gateway = $gateway6 = $unset = $protocol = []; -$wide = false; -$wlan = (array)@parse_ini_file('/var/local/emhttp/wireless.ini'); +$include = $include6 = $address = $address6 = $gateway = $gateway6 = $unset = $protocol = []; +$wide = false; +$wlan = (array)@parse_ini_file('/var/local/emhttp/wireless.ini'); foreach ($custom as $network) { if (in_array($network,$slaves)) continue; - $ip4 = exec("ip -4 -br addr show $network scope global | awk '{print $3;exit}'"); - $ip6 = exec("ip -6 -br addr show $network scope global -temporary -deprecated | awk '{print $3;exit}'"); - $gw4 = $ip4 ? exec("ip -4 route show dev $network default | awk '{print $3;exit}'") : ''; - $gw6 = $ip6 ? exec("ip -6 route show dev $network default | awk '{print $3;exit}'") : ''; - $route4 = $ip4 ? exec("ip -4 route show dev $network $ip4 | awk '{print $1;exit}'") : ''; - $route6 = $ip6 ? exec("ip -6 route show dev $network | awk '/^".substr($ip6,0,strposX($ip6,':',4))."/{print $1;exit}'") : ''; + $ip4 = exec("ip -4 -br addr show scope global primary dev $network | awk '{print $3;exit}'"); + $ip6 = exec("ip -6 -br addr show scope global primary -deprecated dev $network | awk '{print $3;exit}'"); + $gw4 = $ip4 ? exec("ip -4 route show to default dev $network | awk '{print $3;exit}'") : ''; + $gw6 = $ip6 ? exec("ip -6 route show to default dev $network | awk '{print $3;exit}'") : ''; + $route4 = $ip4 ? exec("ip -4 route show dev $network | awk '$1 !~ /^default/ {print $1;exit}'") : ''; + $route6 = $ip6 ? exec("ip -6 route show dev $network | awk '$1 !~ /^(default|f[a-f])/ {print $1;exit}'") : ''; if (substr($network,0,4) != 'wlan') { [$eth,$vlan] = my_explode('.',$network); $eth = str_replace(['bond','br'],'eth',$eth); @@ -89,6 +89,7 @@ foreach ($custom as $network) { } if ($protocol[$network] != 'ipv4') $wide = true; } + $ip4class = $wide ? 'ip6' : 'ip4'; $gw4class = $wide ? 'gw6' : 'gw4'; @@ -114,15 +115,6 @@ function base_net($route) { return substr(explode('/',$route)[0],0,-2); } -function hide_wlan($network) { - return $network=='wlan0' && lan_port(DockerUtil::port(),true)==1; -} - -function hide_eth($network) { - $mgmt_port = ['br0','bond0','eth0']; - return in_array($network,$mgmt_port) && lan_port('wlan0',true)==1; -} - $bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c'; //Check if docker.cfg does exist @@ -275,8 +267,8 @@ _(Template Authoring Mode)_: _(Docker custom network type)_: : - =mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '1', _('ipvlan'), $bridge?'':'disabled')?> - =mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '', _('macvlan'), $bridge?'':'selected')?> + =mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '1', _('ipvlan'), $bridge ? '' : 'disabled')?> + =mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '', _('macvlan'), $bridge ? '' : 'selected')?> _(Please read the Help carefully)_. _(Misconfiguration can cause problems)_. :docker_custom_network_type_help: @@ -302,14 +294,9 @@ _(Preserve user defined networks)_: $net = normalize($network); $docker_auto = "DOCKER_AUTO_$net"; $docker_dhcp = "DOCKER_DHCP_$net"; -$hide_wlan = hide_wlan($network); ?> - -