This commit is contained in:
hashbro
2026-09-19 01:03:23 +08:00
parent 2729fd561b
commit 5be0313ccd
17 changed files with 180 additions and 34 deletions
+19
View File
@@ -124,6 +124,25 @@ class PageVisitTest extends TestCase
$this->assertSame('203.0.113.50', $row->ip);
}
#[Test]
public function hit_prefers_cf_connecting_ip_over_x_forwarded_for(): void
{
Cache::flush();
$this->call('GET', '/statistic/t', [
'c' => self::CHANNEL,
'u' => '11111111-2222-4333-8444-555555555555',
], [], [], [
'REMOTE_ADDR' => '104.16.1.1',
'HTTP_X_FORWARDED_FOR' => '1.2.3.4',
'HTTP_CF_CONNECTING_IP' => '203.0.113.88',
])->assertOk();
$row = PageVisit::query()->first();
$this->assertNotNull($row);
$this->assertSame('203.0.113.88', $row->ip);
}
#[Test]
public function hit_stores_cf_ipcountry(): void
{