Example #1
0
 /**
  * {@inheritdoc}
  */
 public function checkVisitor(Visitor $visitor)
 {
     $ip = $visitor->getIP();
     $revip = Utils::isIPv6($ip) ? $this->getIPv6Arpa($ip) : $this->getIPv4Arpa($ip);
     foreach ($this->lists as $list) {
         if (checkdnsrr("{$revip}.{$list}.", 'A')) {
             return CheckInterface::RESULT_BLOCK;
         }
     }
     return CheckInterface::RESULT_OKAY;
 }
Example #2
0
 /**
  * Analyzes user agents claiming to be Baidu Spider.
  *
  * @param \FlameCore\Gatekeeper\Visitor $visitor The visitor information
  * @return int
  * @throws \FlameCore\Gatekeeper\Exceptions\StopScreeningException
  */
 protected function checkBaiduBot(Visitor $visitor)
 {
     if (Utils::isIPv6($visitor->getIP())) {
         return CheckInterface::RESULT_OKAY;
     }
     if (Utils::matchCIDR($visitor->getIP(), ['119.63.192.0/21', '123.125.71.0/24', '180.76.0.0/16', '220.181.0.0/16'])) {
         throw new StopScreeningException();
     }
     return CheckInterface::RESULT_UNSURE;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function match($value)
 {
     return Utils::matchCIDR($value, $this->list);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function checkVisitor(Visitor $visitor)
 {
     $ip = $visitor->getIP();
     // Can't use IPv6 addresses yet
     if (Utils::isIPv6($ip)) {
         return CheckInterface::RESULT_OKAY;
     }
     $revip = $this->getIPv4Arpa($ip);
     $result = gethostbynamel("{$this->apiKey}.{$revip}.dnsbl.httpbl.org.");
     if (!empty($result)) {
         $resip = explode('.', $result[0]);
         if ($resip[0] == 127 && $resip[3] & 7 && $resip[2] >= $this->threatLevel && $resip[1] <= $this->maxAge) {
             return CheckInterface::RESULT_BLOCK;
         }
     }
     return CheckInterface::RESULT_OKAY;
 }