diff --git a/src/Swoole/Request.php b/src/Swoole/Request.php index 948545a..7459241 100644 --- a/src/Swoole/Request.php +++ b/src/Swoole/Request.php @@ -127,7 +127,8 @@ public function getServer(string $key, $default = null) */ public function getIP(): string { - return $this->getHeader('x-forwarded-for', $this->getServer('remote_addr', '0.0.0.0')); + $ips = explode(',',$this->getHeader('x-forwarded-for', $this->getServer('remote_addr', '0.0.0.0'))); + return trim($ips[0] ?? ''); } /**