diff --git a/src/executor/docker.js b/src/executor/docker.js index ac05a28..7b536f9 100644 --- a/src/executor/docker.js +++ b/src/executor/docker.js @@ -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; } /** diff --git a/src/executor/nginx.js b/src/executor/nginx.js index a08351c..9f19a3e 100644 --- a/src/executor/nginx.js +++ b/src/executor/nginx.js @@ -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 { @@ -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; } }