Skip to content

Commit 2a91c14

Browse files
committed
Fix getting IP
1 parent fb0066e commit 2a91c14

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Deployer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,16 @@ protected function getIp()
246246

247247
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
248248
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
249-
}
250-
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
249+
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
251250
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
252-
}
253-
if (!empty($_SERVER['REMOTE_ADDR'])) {
251+
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
254252
$ip = $_SERVER['REMOTE_ADDR'];
255253
}
256254

255+
if (!$ip) {
256+
return null;
257+
}
258+
257259
// If there are multiple proxies, X_FORWARDED_FOR is a comma and space separated list of IPs
258260
$ip = explode(', ', $ip);
259261

0 commit comments

Comments
 (0)