File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ public function isWhitelisted()
126
126
127
127
$ ips = $ this ->options ->whitelist_ips ;
128
128
129
+ if (is_null ($ this ->client ->ip )) {
130
+ return false ;
131
+ }
132
+
129
133
if (IpUtils::checkIp ($ this ->client ->ip , $ ips )) {
130
134
//Add this to the redis list as it is faster
131
135
Redis::sadd ($ this ->options ->whitelist_key , $ this ->client ->ip );
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ public function test_should_block_after_limit()
18
18
Queue::fake ();
19
19
$ middleware = new BlockBots ();
20
20
$ request = new Request ();
21
+ $ request ->server ->set ('REMOTE_ADDR ' , '192.168.2.1 ' );
21
22
22
23
$ limit = 10 ;
23
24
@@ -41,6 +42,7 @@ public function test_should_not_block_after_limit_if_mode_never()
41
42
Queue::fake ();
42
43
$ middleware = new BlockBots ();
43
44
$ request = new Request ();
45
+ $ request ->server ->set ('REMOTE_ADDR ' , '192.168.2.2 ' );
44
46
45
47
$ limit = 10 ;
46
48
@@ -75,6 +77,7 @@ public function test_should_always_block_if_mode_always()
75
77
76
78
$ middleware = new BlockBots ();
77
79
$ request = new Request ();
80
+ $ request ->server ->set ('REMOTE_ADDR ' , '192.168.2.3 ' );
78
81
79
82
$ limit = 100 ;
80
83
@@ -108,4 +111,4 @@ public function test_should_not_block_allowed_bot()
108
111
109
112
$ this ->assertContains ('0.0.0.0 ' , Redis::smembers (Config::get ('block-bots.pending_bot_list_key ' )));
110
113
}
111
- }
114
+ }
You can’t perform that action at this time.
0 commit comments