Exemplo n.º 1
0
 public static function getReverseHostName(Address $ipAddress)
 {
     $str = null;
     if ($ipAddress->isIpv4()) {
         $str = implode('.', array_reverse($ipAddress->getBytes()));
     } else {
         if ($ipAddress->isIpv6()) {
             $hexParts = $ipAddress->getHexBytes();
             $bytes = [];
             foreach ($hexParts as $part) {
                 $bytes[] = $part[0];
                 $bytes[] = $part[1];
             }
             $str = implode('.', array_reverse($bytes));
         } else {
             throw new Exception("Failed to build reverse host name: Passed ip address needs to be either ipv4 or ipv6");
         }
     }
     return "{$str}.in-addr.arpa";
 }