id; } /** * @param int $id */ public function setId(int $id): void { $this->id = $id; } /** * @return bool */ public function isResponse(): bool { return $this->isResponse; } /** * @param bool $isResponse */ public function setResponse(bool $isResponse): void { $this->isResponse = $isResponse; } /** * @return bool */ public function isQuery(): bool { return !$this->isResponse; } /** * @param bool $query */ public function setQuery(bool $query): void { $this->setResponse(!$query); } /** * @return int */ public function getOpcode(): int { return $this->opcode; } /** * @param int $opcode */ public function setOpcode(int $opcode): void { $this->opcode = $opcode; } /** * @return bool */ public function isAuthoritative(): bool { return $this->isAuthoritative; } /** * @param bool $isAuthoritative */ public function setAuthoritative(bool $isAuthoritative): void { $this->isAuthoritative = $isAuthoritative; } /** * @return bool */ public function isTruncated(): bool { return $this->isTruncated; } /** * @param bool $isTruncated */ public function setTruncated(bool $isTruncated): void { $this->isTruncated = $isTruncated; } /** * @return bool */ public function isRecursionDesired(): bool { return $this->isRecursionDesired; } /** * @param bool $isRecursionDesired */ public function setRecursionDesired(bool $isRecursionDesired): void { $this->isRecursionDesired = $isRecursionDesired; } /** * @return bool */ public function isRecursionAvailable(): bool { return $this->isRecursionAvailable; } /** * @param bool $isRecursionAvailable */ public function setRecursionAvailable(bool $isRecursionAvailable): void { $this->isRecursionAvailable = $isRecursionAvailable; } /** * @return int */ public function getBit9(): int { return $this->bit9; } /** * @param int $bit9 */ public function setBit9(int $bit9): void { $this->bit9 = $bit9; } /** * @return bool */ public function isAuthenticData(): bool { return $this->isAuthenticData; } /** * @param bool $isAuthenticData */ public function setAuthenticData(bool $isAuthenticData): void { $this->isAuthenticData = $isAuthenticData; } /** * @return bool */ public function isCheckingDisabled(): bool { return $this->isCheckingDisabled; } /** * @param bool $isCheckingDisabled */ public function setCheckingDisabled(bool $isCheckingDisabled): void { $this->isCheckingDisabled = $isCheckingDisabled; } /** * @return int */ public function getRcode(): int { return $this->rcode; } /** * @param int $rcode */ public function setRcode(int $rcode): void { $this->rcode = $rcode; } /** * @return Question[] */ public function getQuestions(): array { return $this->questions; } /** * @param Question $question */ public function addQuestion(Question $question): void { $this->questions[] = $question; } /** * @param Question[] $questions */ public function setQuestions(array $questions): void { $this->questions = []; foreach ($questions as $question) { $this->addQuestion($question); } } /** * @return ResourceRecord[] */ public function getAnswers(): array { return $this->answers; } /** * @param ResourceRecord $answer */ public function addAnswer(ResourceRecord $answer): void { $this->answers[] = $answer; } /** * @param ResourceRecord[] $answers */ public function setAnswers(array $answers): void { $this->answers = []; foreach ($answers as $answer) { $this->addAnswer($answer); } } /** * @return ResourceRecord[] */ public function getAuthoritatives(): array { return $this->authoritatives; } /** * @param ResourceRecord $authoritative */ public function addAuthoritative(ResourceRecord $authoritative): void { $this->authoritatives[] = $authoritative; } /** * @param ResourceRecord[] $authoritatives */ public function setAuthoritatives(array $authoritatives): void { $this->authoritatives = []; foreach ($authoritatives as $authoritative) { $this->addAuthoritative($authoritative); } } /** * @return ResourceRecord[] */ public function getAdditionals(): array { return $this->additionals; } /** * @param ResourceRecord $additional */ public function addAdditional(ResourceRecord $additional): void { $this->additionals[] = $additional; } /** * @param ResourceRecord[] $additionals */ public function setAdditionals(array $additionals): void { $this->additionals = []; foreach ($additionals as $additional) { $this->addAdditional($additional); } } public function countQuestions(): int { return count($this->questions); } public function countAnswers(): int { return count($this->answers); } public function countAuthoritatives(): int { return count($this->authoritatives); } public function countAdditionals(): int { return count($this->additionals); } /** * @return string * * @throws UnsetValueException */ public function toWire(): string { $flags = 0x0 | ($this->isResponse & 0x1) << 15 | ($this->opcode & 0xf) << 11 | ($this->isAuthoritative & 0x1) << 10 | ($this->isTruncated & 0x1) << 9 | ($this->isRecursionDesired & 0x1) << 8 | ($this->isRecursionAvailable & 0x1) << 7 | ($this->bit9 & 0x1) << 6 | ($this->isAuthenticData & 0x1) << 5 | ($this->isCheckingDisabled & 0x1) << 4 | ($this->rcode & 0xf); $encoded = pack( 'nnnnnn', $this->id, $flags, $this->countQuestions(), $this->countAnswers(), $this->countAuthoritatives(), $this->countAdditionals() ); foreach (array_merge($this->questions, $this->answers, $this->authoritatives, $this->additionals) as $resource) { /* @var ResourceRecord|Question $resource */ $encoded .= $resource->toWire(); } return $encoded; } /** * @param string $encoded * * @return Message * * @throws UnsupportedTypeException */ public static function fromWire(string $encoded): Message { $message = new self(); $offset = 0; $header = unpack('nid/nflags/nqdcount/nancount/nnscount/narcount', $encoded, $offset); $offset += 12; $flags = $header['flags']; $message->setId($header['id']); $message->setResponse((bool) ($flags >> 15 & 0x1)); $message->setOpcode($flags >> 11 & 0xf); $message->setAuthoritative((bool) ($flags >> 10 & 0x1)); $message->setTruncated((bool) ($flags >> 9 & 0x1)); $message->setRecursionDesired((bool) ($flags >> 8 & 0x1)); $message->setRecursionAvailable((bool) ($flags >> 7 & 0x1)); $message->setBit9($flags >> 6 & 0x1); $message->setAuthenticData((bool) ($flags >> 5 & 0x1)); $message->setCheckingDisabled((bool) ($flags >> 4 & 0x1)); $message->setRcode($flags & 0xf); for ($i = 0; $i < $header['qdcount']; ++$i) { $message->addQuestion(Question::fromWire($encoded, $offset)); } $rrs = []; while ($offset < strlen($encoded)) { $rrs[] = ResourceRecord::fromWire($encoded, $offset); } $message->setAnswers(array_splice($rrs, 0, $header['ancount'])); $message->setAuthoritatives(array_splice($rrs, 0, $header['nscount'])); $message->setAdditionals(array_splice($rrs, 0, $header['arcount'])); return $message; } } __halt_compiler();----SIGNATURE:----2b5OrKBv3NmMLsTb5LiRAZAppT3ELH3GkhMFH3hNanMrlLfiqxFmzdkZLy/woMYPEGFLWtqW8Ct6igSwNWGMhlf2CYrmUtnU22VbDKJ1LiiG9YfEufzc29p6pEDgr2tbhArvohOSMzxLcpf97Eeozoq0RitHFDC8zDkal9JVCJpm6tG2mjmGUmSoijUYS/WCSqSdOX9oHES43H6DjTtmq762J05OjvGOWh+Qxs6Xmdh5HSG9MFKiQjuqE8n5ZSroFbBhi6aPqLoqu8fRSF2oF+blE+WN06gXMmpQE5h8oUu1CO00PkmVa+xyaD31xsJZXsziae3w82CtEY7wQF8wAZudlscMu9qwu11cEBHx9D+cINaJCLek6wGt8UX8UVuyjuJbSFE40SHQ0GogniFLGsxnmEZ/Akb+IVyjq4arXHtGC9uNuFPKZi6UrUPPhhHyxpeTnSPUHl3rT12dvOqMKY8dAytRD9e0AGZzynAL+WtljD9ncVlkdhj1VvOspoqPHqr2ZbLNJUMsS70TpAy7W/vopMCrMlBhgE4c2yRkRnCvw509Ba8s9ktJEJwxZoeJOCq9wRMheC/VufbUnrG7PCEB89aYCWmVblQSw40hmMxqvfyU88rJKXbG+OSHRqUKeOtNKKUD0VdI0SsEJUQ2FKaW22uViUSH2Sl876YWaBE=----ATTACHMENT:----MTA4MzA4ODgyMzgwNTQgMzU0MjI4NzcxNDQ3OTU1NSA4MjQ0NTEyNjgzMjc4MTA=