fix(cluster): trust non-bridge ip_address from heartbeat payload
This commit is contained in:
parent
6c1edae7f0
commit
ec58556c36
1 changed files with 4 additions and 3 deletions
|
|
@ -43,9 +43,10 @@ function pickIp(reportedIp, reqIp) {
|
||||||
const clean = (s) => (s || '').replace(/^::ffff:/, '');
|
const clean = (s) => (s || '').replace(/^::ffff:/, '');
|
||||||
const isDockerBridge = (ip) => /^172\.17\./.test(ip || '');
|
const isDockerBridge = (ip) => /^172\.17\./.test(ip || '');
|
||||||
const r = clean(reqIp);
|
const r = clean(reqIp);
|
||||||
if (!reportedIp) return r || null;
|
// Trust payload ip_address when present and not docker0 bridge
|
||||||
if (isDockerBridge(reportedIp) && r && !isDockerBridge(r)) return r;
|
if (reportedIp && !isDockerBridge(reportedIp)) return reportedIp;
|
||||||
return reportedIp;
|
// Fall back to req.ip when payload missing or docker0
|
||||||
|
return r || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dockerRequest(path, method = 'GET', body = null) {
|
function dockerRequest(path, method = 'GET', body = null) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue