mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +09:00
Don't convert Cloudflare IP if CF-Worker header is set
This commit is contained in:
parent
00db2ab402
commit
08d6db7657
2 changed files with 10 additions and 1 deletions
|
|
@ -135,7 +135,7 @@ class IpFilter
|
||||||
*/
|
*/
|
||||||
public static function getCloudFlareRealIP()
|
public static function getCloudFlareRealIP()
|
||||||
{
|
{
|
||||||
if (!isset($_SERVER['HTTP_CF_CONNECTING_IP']))
|
if (!isset($_SERVER['HTTP_CF_CONNECTING_IP']) || isset($_SERVER['HTTP_CF_WORKER']))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,5 +80,14 @@ class IpFilterTest extends \Codeception\Test\Unit
|
||||||
$_SERVER['REMOTE_ADDR'] = '192.168.10.1';
|
$_SERVER['REMOTE_ADDR'] = '192.168.10.1';
|
||||||
$this->assertFalse(Rhymix\Framework\Filters\IpFilter::getCloudFlareRealIP());
|
$this->assertFalse(Rhymix\Framework\Filters\IpFilter::getCloudFlareRealIP());
|
||||||
$this->assertEquals('192.168.10.1', $_SERVER['REMOTE_ADDR']);
|
$this->assertEquals('192.168.10.1', $_SERVER['REMOTE_ADDR']);
|
||||||
|
|
||||||
|
$_SERVER['HTTP_CF_CONNECTING_IP'] = '192.168.134.241';
|
||||||
|
$_SERVER['HTTP_CF_WORKER'] = 'anything';
|
||||||
|
$_SERVER['REMOTE_ADDR'] = '108.162.192.121';
|
||||||
|
$this->assertFalse(Rhymix\Framework\Filters\IpFilter::getCloudFlareRealIP());
|
||||||
|
$this->assertEquals('108.162.192.121', $_SERVER['REMOTE_ADDR']);
|
||||||
|
|
||||||
|
unset($_SERVER['HTTP_CF_CONNECTING_IP']);
|
||||||
|
unset($_SERVER['HTTP_CF_WORKER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue