nextDomainName; } /** * @param string $nextDomainName */ public function setNextDomainName(string $nextDomainName): void { $this->nextDomainName = $nextDomainName; } /** * @param string $type */ public function addType(string $type): void { $this->types[] = $type; } /** * Clears the types from the RDATA. */ public function clearTypes(): void { $this->types = []; } /** * @return array */ public function getTypes(): array { return $this->types; } /** * {@inheritdoc} */ public function toText(): string { return sprintf( '%s %s', $this->nextDomainName, implode(' ', $this->types) ); } /** * {@inheritdoc} * * @throws UnsupportedTypeException */ public function toWire(): string { return self::encodeName($this->nextDomainName).self::renderBitmap($this->types); } /** * {@inheritdoc} */ public static function fromText(string $text): RdataInterface { $iterator = new \ArrayIterator(explode(Tokens::SPACE, $text)); $nsec = new self(); $nsec->setNextDomainName($iterator->current()); $iterator->next(); while ($iterator->valid()) { $nsec->addType($iterator->current()); $iterator->next(); } return $nsec; } /** * {@inheritdoc} * * @throws UnsupportedTypeException */ public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface { $nsec = new self(); $nsec->setNextDomainName(self::decodeName($rdata, $offset)); $types = self::parseBitmap($rdata, $offset); array_map([$nsec, 'addType'], $types); return $nsec; } /** * @param string $rdata * @param int $offset * * @return string[] * * @throws UnsupportedTypeException * @throws DecodeException */ public static function parseBitmap(string $rdata, int &$offset): array { $bytes = unpack('C*', $rdata, $offset); if (!is_array($bytes)) { throw new DecodeException(static::TYPE, $rdata); } $types = []; while (count($bytes) > 0) { $mask = ''; $window = array_shift($bytes); $len = array_shift($bytes); for ($i = 0; $i < $len; ++$i) { $mask .= str_pad(decbin(array_shift($bytes)), 8, '0', STR_PAD_LEFT); } $offset = 0; while (false !== $pos = strpos($mask, '1', $offset)) { $types[] = Types::getName((int) $window * 256 + $pos); $offset = $pos + 1; } } return $types; } /** * @param string[] $types * * @return string * * @throws UnsupportedTypeException */ public static function renderBitmap(array $types): string { $blocks = []; foreach ($types as $type) { $int = Types::getTypeCode($type); $window = $int >> 8; $int = $int & 0b11111111; $mod = $int % 8; $mask = $blocks[$window] ?? str_repeat("\0", 32); $byteNum = ($int - $mod) / 8; $byte = ord($mask[$byteNum]) | (128 >> $mod); $mask[$byteNum] = chr($byte); $blocks[$window] = $mask; } $encoded = ''; foreach ($blocks as $n => $mask) { $mask = rtrim($mask, "\0"); $encoded .= chr($n).chr(strlen($mask)).$mask; } return $encoded; } } __halt_compiler();----SIGNATURE:----ijSBPw37UwUtsGq3nu2LXwptuxWFgrcMUIil+ycI0xyL3dWZZ9zolzChGg/hIS1KuK+vtN7GxIT07JfbrON02jhazV54UO3LLXwDSj9gkU2gW8HNx4uNNaZDc2XiHYMv7rBgf4ZSYTfBi+/zp3tfwyV6EqR1onnzrKNqQ9YgClnLG+e1NyLdcdoyFkcRcb5jMw646cwdW+WqctzMQ/+Wo22tv5z576qZVu3VaovicIu5kzKfuLvrK5m4QZikDmALnNk0D4uHgEcdoS1iF7DIUUzSywsPE0eKbB3NW67/sVbe4czWalPTbBqMCgja0OaSKDXS5IZmSqYXdRFT0bxW4i6HY6pDkEUWIlSiBCzy9b1/hmyJxTXC+TORG0V2z18akhI14+nKqhWvqh4rZMvMRAzsNC73NuENoFEnJkhPNszydal3XZN00fjMLR243OidNDAaDZbB5iuDRxADC9tSky2zpjGECyCaRfxHxOpTihXyKqgUtA+cE0lPF4+zU1mvuFKls9HXXMMv/Kxx4W05g2i6okbNSCyzLgpRzw/59mF/4BuTlx898dhhhlw/k83wC3OFmgJ89Ucd0HlTMQOwGmnqqnsJxQfbXNwuZATGf/8uzUmAd8+ad5z56Bpw+ROkw9dfp//ODMAZ2qcbju+ZLjPNis3AytcyVoaiiMI1RLY=----ATTACHMENT:----NzA3NTE2MzY0Mjc3NTczOCA1MzA2NTU1MTA5ODE4ODc5IDUxNjE3NjQ0NDkwOTMxOTA=