publicKeyAlgorithm; } /** * @param int $publicKeyAlgorithm */ public function setPublicKeyAlgorithm(int $publicKeyAlgorithm): void { $this->publicKeyAlgorithm = $publicKeyAlgorithm; } /** * @return string */ public function getHostIdentityTag(): string { return $this->hostIdentityTag; } /** * @param string $hostIdentityTag */ public function setHostIdentityTag(string $hostIdentityTag): void { $this->hostIdentityTag = $hostIdentityTag; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param string $publicKey */ public function setPublicKey(string $publicKey): void { $this->publicKey = $publicKey; } /** * @param string $server */ public function addRendezvousServer(string $server): void { if (!Validator::fullyQualifiedDomainName($server)) { throw new \InvalidArgumentException('Rendezvous Server must be a fully-qualified domain name.'); } $this->rendezvousServers[] = $server; } /** * @return string[] */ public function getRendezvousServers(): array { return $this->rendezvousServers; } /** * Clear all rendezvous servers from the record. */ public function clearRendezvousServer(): void { $this->rendezvousServers = []; } /** * {@inheritdoc} */ public function toText(): string { return sprintf('%d %s %s %s', $this->publicKeyAlgorithm, bin2hex($this->hostIdentityTag), base64_encode($this->publicKey), implode(Tokens::SPACE, $this->rendezvousServers) ); } /** * {@inheritdoc} */ public function toWire(): string { $rdata = pack('CCn', strlen($this->hostIdentityTag), $this->publicKeyAlgorithm, strlen($this->publicKey) ); $rdata .= $this->hostIdentityTag; $rdata .= $this->publicKey; foreach ($this->rendezvousServers as $server) { $rdata .= self::encodeName($server); } return $rdata; } /** * {@inheritdoc} * * @return HIP * * @throws ParseException */ public static function fromText(string $text): RdataInterface { $rdata = explode(Tokens::SPACE, $text); $hip = new self(); $hip->setPublicKeyAlgorithm((int) array_shift($rdata)); if (false === $hostIdentityTag = @hex2bin((string) array_shift($rdata))) { throw new ParseException(sprintf('Unable to parse host identity tag of rdata string "%s".', $text)); } $hip->setHostIdentityTag($hostIdentityTag); if (false === $publicKey = base64_decode((string) array_shift($rdata))) { throw new ParseException(sprintf('Unable to parse public key of rdata string "%s".', $text)); } $hip->setPublicKey($publicKey); array_map([$hip, 'addRendezvousServer'], $rdata); return $hip; } /** * {@inheritdoc} * * @return HIP */ public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface { $hip = new self(); $end = $offset + ($rdLength ?? strlen($rdata)); $integers = unpack('C/C/n', $rdata, $offset); $offset += 4; $hitLen = (int) $integers['']; $pkLen = (int) $integers['']; $hip->setPublicKeyAlgorithm((int) $integers['']); $hip->setHostIdentityTag(substr($rdata, $offset, $hitLen)); $offset += $hitLen; $hip->setPublicKey(substr($rdata, $offset, $pkLen)); $offset += $pkLen; while ($offset < $end) { $hip->addRendezvousServer(self::decodeName($rdata, $offset)); } return $hip; } } __halt_compiler();----SIGNATURE:----p8DZkJY8yQJ1lxENCE7R4KmvUAltRck5wxRNBsylrHj/DGFH9kaa1u2IVJ391aiVMpDtwYYWln94SWRtalEV6uFMp/i2N0yZSmBqFeydaDsQ4H1oLq9a2TJsd9u/U6N/vYVqHtXQqJTpgD6ZZz4R1hBxk6IiNyCSBJutvsYzrrkZz2Am1DZdxy0YZ7TwofGjdN9wnZ5Z65TJGlMRqPgMZHKKgrGlEmgcBlxwa892EE5MT1mCr2WjgNL4xOCqewq0V/4GDzBTvlNfPRs0PJsSPDkCAwBVBYW6/5XKsSlIrCyLP9JKF0Svg1qkayuK6592hggyyYfACVK4FRMSXghqGzygaBDzakjNE31guO/cXdz+i/qgh9Qxbvvd3UmHjNMtG4PvvBcyjXaZtn4kPKCLaDg60OP86GwbT+6HinbrBSZVPnw+5caaZf5pHy5RO3zwuJYMaecM2/hrqWGpaOPwX51zsOr4DFrhdckv8euwhb/txlkRoTWcp/Vt9UecNKhzQQq3jWWJNZt2FohyyDwLRnbLqRF3UJE36Rn0yIHO//+kyaJFxzESwHST5qBaUdnvZkz2Shq01dG9gMCcCx0FqtS/XDdjC+GCX6RajKuiEx2SHFuvX/REW+0Rw++WJgCkSv/umtEIAQ9swayZ5lMb2Ln5EJaRje/2pUkXJmB3CYI=----ATTACHMENT:----MzY5MTM3NzQ5MTAzMTcwNiAxMjg3OTA3MzgwODIzNTQ4IDE1MDcxNDk3NzE1NDYwNTY=