Skip to content

Commit f878c52

Browse files
Improve IP address validation with subnet mask support
1 parent 43f552d commit f878c52

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Middleware/BlockBots.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Carbon\Carbon;
77
use Illuminate\Support\Facades\Auth;
88
use Illuminate\Support\Facades\Redis;
9+
use Symfony\Component\HttpFoundation\IpUtils;
910
use Potelo\LaravelBlockBots\Jobs\CheckIfBotIsReal;
1011
use Potelo\LaravelBlockBots\Events\UserBlockedEvent;
1112
use Potelo\LaravelBlockBots\Jobs\ProcessLogWithIpInfo;
@@ -120,8 +121,9 @@ public function isWhitelisted()
120121
return true;
121122
}
122123

123-
//Lets verify if its on our whitelist
124-
if (in_array($this->client->ip, $this->options->whitelist_ips)) {
124+
$ips = $this->options->whitelist_ips;
125+
126+
if (IpUtils::checkIp($this->client->ip, $ips)) {
125127
//Add this to the redis list as it is faster
126128
Redis::sadd($this->options->whitelist_key, $this->client->ip);
127129
if ($this->options->log) {

0 commit comments

Comments
 (0)