diff --git a/src/raklib/protocol/Packet.php b/src/raklib/protocol/Packet.php index 69357a064..ef2e3dd66 100755 --- a/src/raklib/protocol/Packet.php +++ b/src/raklib/protocol/Packet.php @@ -78,11 +78,28 @@ protected function getAddress(&$addr, &$port, &$version = null){ if($version === 4){ $addr = ((~$this->getByte()) & 0xff) .".". ((~$this->getByte()) & 0xff) .".". ((~$this->getByte()) & 0xff) .".". ((~$this->getByte()) & 0xff); $port = $this->getShort(false); + + } elseif($version === 6) { + //http://man7.org/linux/man-pages/man7/ipv6.7.html + + Binary::readLShort($this->get(2)); //Family, AF_INET6 + + $port = $this->getShort(false); + + $this->getInt(); //flow info + + $addr = inet_ntop($this->get(16)); + + $this->getInt(); //scope ID + }else{ - //TODO: IPv6 + + throw new \UnexpectedValueException("Unknown IP address version $version"); + } - } + } + protected function feof(){ return !isset($this->buffer{$this->offset}); }