Skip to content

Commit

Permalink
Assign 127.128.0.0/9 for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Sep 18, 2024
1 parent 52279d0 commit 172f610
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/executor/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ class DockerExecutor {
});
}
generateRandomIPv4() {
// Generate random octets (numbers between 0 and 255)
const octet1 = Math.trunc(Math.random() * 256);
// Valid docker IP is in range 127.128.0.0/9
const octet1 = Math.trunc(Math.random() * 128) + 128;
const octet2 = Math.trunc(Math.random() * 256);
const octet3 = Math.trunc(Math.random() * 256);

// Construct the address with the "10." prefix
const ipAddress = `10.${octet1}.${octet2}.${octet3}`;
const ipAddress = `127.${octet1}.${octet2}.${octet3}`;
return ipAddress;
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/executor/nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NginxExecutor {
if (port > 0x400 && port < 0xFFFF) {
node._add(key, `http://${info.docker_ip}:${port}`);
}
} else if (/^http:\/\/(10|127)\.\d+\.\d+\.\d+:\d+(\$.+|\/.+)?$/.test(config[key])) {
} else if (/^http:\/\/127\.\d+\.\d+\.\d+:\d+(\$.+|\/.+)?$/.test(config[key])) {
node._add(key, config[key]);
}
} else {
Expand Down Expand Up @@ -271,7 +271,7 @@ class NginxExecutor {
}
const findDockerIp = (l) => {
if (l.proxy_pass && l.proxy_pass[0]) {
if (/^http:\/\/10\.\d+\.\d+\.\d+:\d+$/.test(l.proxy_pass[0]._value)) {
if (/^http:\/\/127\.[12]\d\d\.\d+\.\d+:\d+$/.test(l.proxy_pass[0]._value)) {
return new URL(l.proxy_pass[0]._value).hostname;
}
}
Expand Down

0 comments on commit 172f610

Please sign in to comment.