Revert "Added docker host access to custom network option"

This reverts commit c16d7ee356.
This commit is contained in:
bergware
2020-01-07 08:04:59 +01:00
parent ce082b1bab
commit 2e75dacde9
4 changed files with 9 additions and 40 deletions
@@ -227,6 +227,7 @@ Docker LOG number of files:
> Specifies the number of LOG files when LOG rotation is done.
</div>
Template Authoring Mode:
: <select id="DOCKER_AUTHORING_MODE" name="DOCKER_AUTHORING_MODE">
<?=mk_option($dockercfg['DOCKER_AUTHORING_MODE'], 'no', 'No')?>
@@ -235,15 +236,6 @@ Template Authoring Mode:
> If set to **Yes**, when creating/editing containers the interface will be present with some extra fields related to template authoring.
Host access to custom networks:
: <select name="DOCKER_ALLOW_ACCESS">
<?=mk_option($dockercfg['DOCKER_ALLOW_ACCESS'], '', 'Disabled')?>
<?=mk_option($dockercfg['DOCKER_ALLOW_ACCESS'], 'yes', 'Enabled')?>
</select>
> Allows direct communication between the host and containers using a custom (macvlan) network.<br>
> By default this is prohibited.
Preserve user defined networks:
: <select name="DOCKER_USER_NETWORKS">
<?=mk_option($dockercfg['DOCKER_USER_NETWORKS'], 'remove', 'No')?>
@@ -440,12 +432,6 @@ Docker LOG rotation:
> By default a single unlimited LOG file is created. Otherwise LOG file size and number of files are limited when LOG rotation is enabled.
Host access to custom networks:
: <?=$dockercfg['DOCKER_ALLOW_ACCESS']==''?'Disabled':'Enabled'?>
> Allows direct communication between the host and containers using a custom (macvlan) network.<br>
> By default this is prohibited.
Preserve user defined networks:
: <?=$dockercfg['DOCKER_USER_NETWORKS']=='preserve'?'Yes':'No'?>
@@ -5,4 +5,3 @@ DOCKER_LOG_SIZE="50m"
DOCKER_LOG_FILES="1"
DOCKER_AUTHORING_MODE="no"
DOCKER_USER_NETWORKS="remove"
DOCKER_ALLOW_ACCESS=""
@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2019, Lime Technology
* Copyright 2015-2019, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2019, Bergware International.
/* Copyright 2005-2018, Lime Technology
* Copyright 2015-2018, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2018, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -20,6 +20,7 @@ require_once "$docroot/webGui/include/Helpers.php";
libxml_use_internal_errors(false); # Enable xml errors
$var = parse_ini_file('state/var.ini');
$cfg = parse_ini_file('boot/config/docker.cfg');
ignore_user_abort(true);
$DockerClient = new DockerClient();
@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2019, Lime Technology
* Copyright 2014-2019, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2019, Bergware International.
/* Copyright 2005-2018, Lime Technology
* Copyright 2014-2018, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2018, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -33,7 +33,6 @@ $dockerManPaths = [
// load network variables if needed.
if (!isset($eth0)) extract(parse_ini_file("$docroot/state/network.ini",true));
$host = $eth0['IPADDR:0'] ?? '0.0.0.0';
$system = '/sys/class/net';
// get network drivers
$driver = DockerUtil::driver();
@@ -713,10 +712,6 @@ class DockerClient {
}
public function startContainer($id) {
global $dockercfg, $system;
if ($dockercfg['DOCKER_ALLOW_ACCESS']=='yes') {
foreach (DockerUtil::shim($id) as $shim => $ip) if (file_exists("$system/$shim") && $ip) exec("ip route add $ip dev $shim 2>/dev/null");
}
$this->getDockerJSON("/containers/$id/start", 'POST', $code);
$this->flushCache($this::$containersCache);
return $code;
@@ -729,10 +724,6 @@ class DockerClient {
}
public function stopContainer($id, $t=10) {
global $dockercfg, $system;
if ($dockercfg['DOCKER_ALLOW_ACCESS']=='yes') {
foreach (DockerUtil::shim($id) as $shim => $ip) if (file_exists("$system/$shim") && $ip) exec("ip route del $ip dev $shim 2>/dev/null");
}
$this->getDockerJSON("/containers/$id/stop?t=$t", 'POST', $code);
$this->flushCache($this::$containersCache);
return $code;
@@ -951,17 +942,9 @@ class DockerUtil {
return $a ? $array : $data;
}
public static function shim($id) {
$shim = []; $i = 0;
$nets = static::docker("inspect --format='{{json .NetworkSettings.Networks}}' $id|jq|grep -Po '^ \"\\K[^\"]+'|grep -Pv 'host|bridge|none'",true);
$ips = explode(' ',static::docker("inspect --format='{{range .NetworkSettings.Networks}}{{.IPAMConfig.IPv4Address}} {{end}}' $id 2>/dev/null"));
foreach ($nets as $net) $shim["$net-shim"] = $ips[$i++];
return $shim;
}
public static function myIP($name, $version=4) {
$ipaddr = $version==4 ? 'IPAddress' : 'GlobalIPv6Address';
return rtrim(static::docker("inspect --format='{{range .NetworkSettings.Networks}}{{.$ipaddr}} {{end}}' $name"));
return static::docker("inspect --format='{{range .NetworkSettings.Networks}}{{.$ipaddr}}{{end}}' $name");
}
public static function driver() {
$list = [];