Docker: add route for remote WireGuard access

This commit is contained in:
bergware
2022-04-18 11:39:42 +02:00
parent 3dbd85ff5e
commit 02c2bdb3ef
2 changed files with 8 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2014-2018, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2018, Bergware International.
/* Copyright 2005-2022, Lime Technology
* Copyright 2014-2022, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2022, 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,
@@ -26,5 +26,8 @@ if (file_exists($user_prefs)) {
array_multisort($sort, ($action=='start'?SORT_ASC:SORT_DESC), SORT_NUMERIC, $containers);
}
foreach ($containers as $ct) DockerUtil::docker("$action $ct >/dev/null");
foreach ($containers as $ct) {
DockerUtil::docker("$action $ct >/dev/null");
addRoute($ct);
}
?>

View File

@@ -16,7 +16,7 @@ function addRoute($ct) {
// add static route(s) for remote WireGuard access
[$pid,$net] = explode(' ',exec("docker inspect --format='{{.State.Pid}} {{.NetworkSettings.Networks}}' $ct"));
$net = substr($net,4,strpos($net,':')-4);
if ($net != 'br0') return;
if ($pid==0 || $net!='br0') return;
$thisip = ipaddr();
foreach (glob('/etc/wireguard/wg*.cfg') as $cfg) {
$network = exec("grep -Pom1 '^Network:0=\"\\K[^\"]+' $cfg");