From c027fc7dd9d57b5fb888c36c8f87336e0867b44a Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Fri, 1 Nov 2024 21:22:09 +0100 Subject: [PATCH] do not unexpose published ports --- src/DockerManager.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/DockerManager.ts b/src/DockerManager.ts index 53b48d4..fd99e86 100644 --- a/src/DockerManager.ts +++ b/src/DockerManager.ts @@ -147,16 +147,24 @@ export default class DockerManager { if (!network) continue; const customUnExposedPorts = (labels["hypergate.UNEXPOSE"] ?? "").split(","); - // @ts-ignore - const ports = customUnExposedPorts.includes("*") - ? [] - : [ - // @ts-ignore - ...container.data.Ports.filter((p: any) => { - return !customUnExposedPorts.includes(`${p.PrivatePort}/${p.Type}`) && !customUnExposedPorts.includes(`${p.PrivatePort}`); - }), - ]; + console.log(container.data.Ports); + // @ts-ignore + const ports = [ + // @ts-ignore + ...container.data.Ports.filter((p: any) => { + if (p.PublicPort) return true; + if ( + customUnExposedPorts.includes("*")|| + customUnExposedPorts.includes(`${p.PrivatePort}/${p.Type}`) || + customUnExposedPorts.includes(`${p.PrivatePort}`) + ) { + console.log("Unexposing", p.PrivatePort, p.Type); + return false; + } + return true; + }), + ]; const customExposedPorts = (labels["hypergate.EXPOSE"] ?? "").split(","); for (const customPort of customExposedPorts) {