mirror of
https://github.com/loewexy/pdnsmanager.git
synced 2025-01-25 06:54: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
backend
|
@ -38,9 +38,8 @@ class ClientIp
|
|||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
for ($i = count($parts) - 1; $i >= 0; $i--) {
|
||||
if (in_array($parts[$i], $proxys) && $i > 0) {
|
||||
$ip = $parts[$i - 1];
|
||||
} else {
|
||||
if (!in_array($parts[$i], $proxys)) {
|
||||
$ip = $parts[$i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@ test.run(async function () {
|
|||
});
|
||||
|
||||
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