diff options
| author | Greg Roach <fisharebest@gmail.com> | 2021-04-22 08:09:55 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2021-04-22 13:38:55 +0100 |
| commit | 996da80025bbb35c14d52f9608acffe3c847c118 (patch) | |
| tree | 6b0e360280b618fe9c63828de376e0daabfcbdbf | |
| parent | 99be02de16e416f4dbf79370e4384609a5027948 (diff) | |
| download | webtrees-996da80025bbb35c14d52f9608acffe3c847c118.tar.gz webtrees-996da80025bbb35c14d52f9608acffe3c847c118.tar.bz2 webtrees-996da80025bbb35c14d52f9608acffe3c847c118.zip | |
Facebook crawlers operate from an undocumented ASN
| -rw-r--r-- | app/Http/Middleware/BadBotBlocker.php | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/app/Http/Middleware/BadBotBlocker.php b/app/Http/Middleware/BadBotBlocker.php index ba0a8ec8e7..6c3688de96 100644 --- a/app/Http/Middleware/BadBotBlocker.php +++ b/app/Http/Middleware/BadBotBlocker.php @@ -143,10 +143,11 @@ class BadBotBlocker implements MiddlewareInterface * Some search engines operate from within a designated autonomous system. * * @see https://developers.facebook.com/docs/sharing/webmasters/crawler + * @see https://www.facebook.com/peering/ */ - private const ROBOT_ASN = [ - 'facebook' => 'AS32934', - 'twitter' => 'AS13414', + private const ROBOT_ASNS = [ + 'facebook' => ['AS32934', 'AS63293'], + 'twitter' => ['AS13414'], ]; /** @@ -194,15 +195,17 @@ class BadBotBlocker implements MiddlewareInterface } } - foreach (self::ROBOT_ASN as $robot => $asn) { - if (str_contains($ua, $robot)) { - foreach ($this->fetchIpRangesForAsn($asn) as $range) { - if ($range->contains($address)) { - continue 2; + foreach (self::ROBOT_ASNS as $robot => $asns) { + foreach ($asns as $asn) { + if (str_contains($ua, $robot)) { + foreach ($this->fetchIpRangesForAsn($asn) as $range) { + if ($range->contains($address)) { + continue 2; + } } - } - return $this->response(); + return $this->response(); + } } } |
