protected function isRequestFromLocalAddress()
 {
     $addr = InetAddress::getRemoteAddress();
     return InetAddress::isClientLocalHost() || $addr->isLoopbackAddress() || $addr->isSiteLocalAddress() || $addr->isLinkLocalAddress();
 }
Пример #2
0
 /**
  * Get the IP address of our host. An empty host field or a DNS failure
  * will result in a null return.
  *
  * @param u a URL object
  * @return InetAddress an <code>InetAddress</code> representing the host
  * IP address.
  * @since 1.3
  */
 public function getHostAddress(URL $u)
 {
     if ($u->hostAddress != null) {
         return $u->hostAddress;
     }
     $host = $u->getHost();
     if ($host == null || $host->equals("")) {
         return null;
     } else {
         try {
             $u->hostAddress = InetAddress::getByName($host);
             //            } catch (UnknownHostException $ex) {
             //                return null;
             //            } catch (SecurityException $se) {
             //                return null;
         } catch (\blaze\lang\Exception $e) {
             return null;
         }
     }
     return $u->hostAddress;
 }
 /**
  * Try to perform reverse lookup for given address; if no reverse lookup
  * exists, returns NULL.
  *
  * @param   peer.InetAddress addr
  * @return  string
  */
 public function tryReverseLookup(InetAddress $addr)
 {
     $ptr = $this->_nativeLookup($addr->reversedNotation(), DNS_PTR);
     if (!isset($ptr[0]['target'])) {
         return NULL;
     }
     return $ptr[0]['target'];
 }
Пример #4
0
 /**
  * Determine whether given address is part of this network
  *
  * @param   peer.InetAddress addr
  * @return  bool
  */
 public function contains(InetAddress $addr)
 {
     return $addr->inSubnet($this);
 }