From 5c81ad9d823034314dd42baee36f7ee84138aa15 Mon Sep 17 00:00:00 2001 From: Arif Er Date: Fri, 24 Jun 2022 13:35:47 +0800 Subject: [PATCH 1/2] feat(docker): use docker label as primary source for WebUI This commit makes the 'net.unraid.docker.webui' docker label the primary source when parsing the web UI address. If the docker label is missing, the template value will be used instead. --- plugins/dynamix.docker.manager/include/DockerClient.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/dynamix.docker.manager/include/DockerClient.php b/plugins/dynamix.docker.manager/include/DockerClient.php index 3c6b87b25..01dfe67f0 100644 --- a/plugins/dynamix.docker.manager/include/DockerClient.php +++ b/plugins/dynamix.docker.manager/include/DockerClient.php @@ -268,11 +268,12 @@ class DockerTemplates { return false; } - private function getControlURL(&$ct, $myIP) { + private function getControlURL(&$ct, $myIP, $WebUI) { global $host; $port = &$ct['Ports'][0]; $myIP = $myIP ?: $this->getTemplateValue($ct['Image'], 'MyIP') ?: ($ct['NetworkMode']=='host'||$port['NAT'] ? $host : ($port['IP'] ?: DockerUtil::myIP($ct['Name']))); - $WebUI = preg_replace("%\[IP\]%", $myIP, $this->getTemplateValue($ct['Image'], 'WebUI')); + // Get the WebUI address from the templates as a fallback + $WebUI = preg_replace("%\[IP\]%", $myIP, $WebUI ?: $this->getTemplateValue($ct['Image'], 'WebUI')); if (preg_match("%\[PORT:(\d+)\]%", $WebUI, $matches)) { $ConfigPort = $matches[1]; foreach ($ct['Ports'] as $port) { @@ -312,7 +313,7 @@ class DockerTemplates { $tmp['url'] = $webui; } else { $ip = ($ct['NetworkMode']=='host'||$port['NAT'] ? $host : $port['IP']); - $tmp['url'] = $ip ? (strpos($tmp['url'],$ip)!==false ? $tmp['url'] : $this->getControlURL($ct, $ip)) : $tmp['url']; + $tmp['url'] = $ip ? (strpos($tmp['url'],$ip)!==false ? $tmp['url'] : $this->getControlURL($ct, $ip, $tmp['url'])) : $tmp['url']; } $tmp['shell'] = $tmp['shell'] ?? $this->getTemplateValue($image, 'Shell'); } From b88df024144504f57269f3de0d33edb76fa0a094 Mon Sep 17 00:00:00 2001 From: Arif Er Date: Fri, 24 Jun 2022 16:00:51 +0800 Subject: [PATCH 2/2] fixup! feat(docker): use docker label as primary source for WebUI --- plugins/dynamix.docker.manager/include/DockerClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix.docker.manager/include/DockerClient.php b/plugins/dynamix.docker.manager/include/DockerClient.php index 01dfe67f0..40f5a0bb8 100644 --- a/plugins/dynamix.docker.manager/include/DockerClient.php +++ b/plugins/dynamix.docker.manager/include/DockerClient.php @@ -307,7 +307,7 @@ class DockerTemplates { } if ($ct['Running']) { $port = &$ct['Ports'][0]; - $webui = $this->getTemplateValue($ct['Image'], 'WebUI'); + $webui = $tmp['url'] ?: $this->getTemplateValue($ct['Image'], 'WebUI'); if (strlen($webui) > 0 && !preg_match("%\[(IP|PORT:(\d+))\]%", $webui)) { // non-templated webui, user specified $tmp['url'] = $webui;