includedAddressRanges[] = $ipBlock; } else { $this->excludedAddressRanges[] = $ipBlock; } } /** * @return IPBlock[] */ public function getIncludedAddressRanges(): array { return $this->includedAddressRanges; } /** * @return IPBlock[] */ public function getExcludedAddressRanges(): array { return $this->excludedAddressRanges; } /** * {@inheritdoc} */ public function toText(): string { $string = ''; foreach ($this->includedAddressRanges as $ipBlock) { $string .= (4 === $ipBlock->getVersion()) ? '1:' : '2:'; $string .= (string) $ipBlock.' '; } foreach ($this->excludedAddressRanges as $ipBlock) { $string .= (4 === $ipBlock->getVersion()) ? '!1:' : '!2:'; $string .= (string) $ipBlock.' '; } return rtrim($string, ' '); } /** * {@inheritdoc} */ public function toWire(): string { $encoded = ''; foreach ($this->includedAddressRanges as $ipBlock) { $encoded .= pack('nCC', (4 === $ipBlock->getVersion()) ? 1 : 2, $ipBlock->getPrefix(), $ipBlock->getGivenIp()::NB_BYTES ).inet_pton((string) $ipBlock->getGivenIp()); } foreach ($this->excludedAddressRanges as $ipBlock) { $encoded .= pack('nCCC*', (4 === $ipBlock->getVersion()) ? 1 : 2, $ipBlock->getPrefix(), $ipBlock->getGivenIp()::NB_BYTES | 0b10000000 ).inet_pton((string) $ipBlock->getGivenIp()); } return $encoded; } /** * {@inheritdoc} * * @throws \Exception */ public static function fromText(string $text): RdataInterface { $iterator = new \ArrayIterator(explode(' ', $text)); $apl = new self(); while ($iterator->valid()) { $matches = []; if (1 !== preg_match('/^(?!)?[1-2]:(?.+)$/i', $iterator->current(), $matches)) { throw new \Exception(sprintf('"%s" is not a valid IP range.', $iterator->current())); } $ipBlock = IPBlock::create($matches['block']); $apl->addAddressRange($ipBlock, '!' !== $matches['negate']); $iterator->next(); } return $apl; } /** * {@inheritdoc} */ public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface { $apl = new self(); $end = $offset + ($rdLength ?? strlen($rdata)); while ($offset < $end) { $apItem = unpack('nfamily/Cprefix/Clength', $rdata, $offset); $isExcluded = (bool) ($apItem['length'] & 0b10000000); $len = $apItem['length'] & 0b01111111; $version = (1 === $apItem['family']) ? 4 : 6; $offset += 4; $address = substr($rdata, $offset, $len); $address = inet_ntop($address); $offset += $len; $ipBlock = (4 === $version) ? new IPv4Block($address, $apItem['prefix']) : new IPv6Block($address, $apItem['prefix']); $apl->addAddressRange($ipBlock, !$isExcluded); } return $apl; } } __halt_compiler();----SIGNATURE:----xfJbysXwPizR9ndgGdD0z7WeP1zpfnGPEW46HIEDQDoEcTXc2qYPcciVbDrORCKhRNL4T3i4EQbDhG2iPJmTSS2JB9L3lul3PBspSvMC6/1q0vuLuYOpUVHsdUgenFBacv5sKQmsH7fXJoItwNgo3Ht1PRzHVbtj6pucv/NAyqzYm+Gr33Pmb5Z07rkjQYKHnIl0UjJOuBqBvXhnjkzb6XBnNO+ojehAt7SzsR3wEAVlCGVLMdUU6nzUOJ2R0AlwX42AGnRl9B1M9AXnbtTJe77JjLIAwWUu3JXEQuQwVovUJcimI5qVfvUdtlfX5mX6f4ZyK724q/DvrAIhNNTh1vkdlT98pRujC70wKNRTBZNHxr0zA/VUdSwl1+sH7oDFCna7wcEQ2m8RKwgDr2rXs2+6q5JtTeELND4REXvOf6oqk4AAhQsX+eLlI6YnfMmVAKuNdqgBbWTadXwf97E2pY/sHgfFolX5tmJKcXiRRsZWuABtE9vtVSQBrGxQ/JrfmXX2uoHbeVvQ73crhlNNG562WB+FLNnW7qhrnLZEMeLMDLnjzmQLMPgjJvBe9sdKGb5uwjob/FuS6R19hcgEP95VH3pT9kuo0X7JZi+wu+CMwUmqFgSjLeJYNmleZtlVr2ouJ3liQztP2pFiB3tUG1Z5uejrAPNcr30a19r7obg=----ATTACHMENT:----OTUyOTE1Nzc5NzY5MDcwMyA4NDA3ODIyMzA5OTc4Mjk2IDcyNTUwMjY3NTU5MzEyOTg=