mirror of
https://github.com/loewexy/pdnsmanager.git
synced 2025-01-26 15:34:09 +01:00
Fixed client ip error on X-Forwarded-For
This commit is contained in:
parent
091f27e9e5
commit
600c7acdc1
2 changed files with 3 additions and 4 deletions
|
@ -38,9 +38,8 @@ class ClientIp
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
for ($i = count($parts) - 1; $i >= 0; $i--) {
|
for ($i = count($parts) - 1; $i >= 0; $i--) {
|
||||||
if (in_array($parts[$i], $proxys) && $i > 0) {
|
if (!in_array($parts[$i], $proxys)) {
|
||||||
$ip = $parts[$i - 1];
|
$ip = $parts[$i];
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,6 @@ test.run(async function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(res.status, 200);
|
assert.equal(res.status, 200);
|
||||||
assert.equal(res.data, { ip: '127.0.0.1' }, 'X-Forwarded-For Test 3');
|
assert.equal(res.data, { ip: '1.2.3.4' }, 'X-Forwarded-For Test 3');
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue