Skip to content

Commit

Permalink
do not unexpose published ports
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Nov 1, 2024
1 parent 41155fc commit c027fc7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/DockerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c027fc7

Please sign in to comment.