getName().Tokens::LINE_FEED; if (null !== $zone->getDefaultTtl()) { $master .= '$TTL '.$zone->getDefaultTtl().Tokens::LINE_FEED; } foreach ($zone as $rr) { if (null !== $rr->getRdata()) { $master .= preg_replace('/\s+/', ' ', trim(sprintf('%s %s %s %s %s', $rr->getName(), $rr->getTtl(), $rr->getClass(), $rr->getType(), $rr->getRdata()->toText() ))); } if (null !== $rr->getComment()) { $master .= '; '.$rr->getComment(); } $master .= Tokens::LINE_FEED; } return $master; } /** * Fills out all of the data of each resource record. The function will add the parent domain to all non-qualified * sub-domains, replace '@' with the zone name, ensure the class and TTL are on each record. * * @param Zone $zone */ public static function fillOutZone(Zone $zone): void { $class = $zone->getClass(); foreach ($zone as &$rr) { $rr->setName(self::fullyQualify($rr->getName(), $zone->getName())); $rr->setTtl($rr->getTtl() ?? $zone->getDefaultTtl()); $rr->setClass($class); $rdata = $rr->getRdata(); static::fillOutRdata($rdata, $zone); } } /** * Add the parent domain to the sub-domain if the sub-domain if it is not fully qualified. * * @param string|null $subDomain * @param string $parent * * @return string */ protected static function fullyQualify(?string $subDomain, string $parent): string { if ('@' === $subDomain || null === $subDomain) { return $parent; } if ('.' !== substr($subDomain, -1, 1)) { return $subDomain.'.'.$parent; } return $subDomain; } /** * @param RdataInterface $rdata * @param Zone $zone */ protected static function fillOutRdata(RdataInterface $rdata, Zone $zone): void { $mappings = [ SOA::TYPE => 'static::fillOutSoa', CNAME::TYPE => 'static::fillOutCname', DNAME::TYPE => 'static::fillOutCname', SRV::TYPE => 'static::fillOutSrv', NS::TYPE => 'static::fillOutCname', PTR::TYPE => 'static::fillOutCname', MX::TYPE => 'static::fillOutMx', AAAA::TYPE => 'static::fillOutAaaa', ]; if (!array_key_exists($rdata->getType(), $mappings)) { return; } /** @var callable $callable */ $callable = $mappings[$rdata->getType()]; call_user_func($callable, $rdata, $zone); } /** * @param SOA $rdata * @param Zone $zone */ protected static function fillOutSoa(SOA $rdata, Zone $zone): void { $rdata->setMname(self::fullyQualify($rdata->getMname(), $zone->getName())); $rdata->setRname(self::fullyQualify($rdata->getRname(), $zone->getName())); } /** * @param CNAME $rdata * @param Zone $zone */ protected static function fillOutCname(CNAME $rdata, Zone $zone): void { $rdata->setTarget(self::fullyQualify($rdata->getTarget(), $zone->getName())); } /** * @param SRV $rdata * @param Zone $zone */ protected static function fillOutSrv(SRV $rdata, Zone $zone): void { $rdata->setTarget(self::fullyQualify($rdata->getTarget(), $zone->getName())); } /** * @param MX $rdata * @param Zone $zone */ protected static function fillOutMx(MX $rdata, Zone $zone): void { $rdata->setExchange(self::fullyQualify($rdata->getExchange(), $zone->getName())); } /** * @param AAAA $rdata */ protected static function fillOutAaaa(AAAA $rdata): void { $rdata->setAddress(PTR::expandIpv6($rdata->getAddress() ?? '')); } } __halt_compiler();----SIGNATURE:----NVt1z25duVeNNSQrjWvSvRgobMjPlUZ9DHNiYXca64RFefdVuHVeHZSlX6D0+nev94CCp3DIYQpME64U9sL6xTgsiFfn2axNoQB/kY7m69gpc1oRubcqYsl4x07qwOVWTx7TcS85ImTmjVvFBTUlveSzBsyTTUSO1CUzqTUIGvvWFYF4swuUtQSYxoS65i0xSsxe8Pqdh9o0kqu4YmJoFSqTYCBoJeQDzptz7Iu6SIkqaiI3ITr0XI8teOXsqs45hIIG6Wp3mIxXXyq0d2Hs1bghDr3gtyE8yt1kiE2ecnxniamxv3BEN1cfRCQeyvTBesKQrgBqQ+j5CY6aUUpc5wmrhYl90bsi78X0YaRfbM0KhwL39LSnKUZomKXHeTJ/i3NTwgz67LCMAnluALMgojSNrGgoHflKNX+fTGlNjASpFCIGTm6JyGyM6+8dbmo4MUSa80l/B/hoSDp4e5s4/sYVeTwMm6rWRCwFBrBaTtLoHWUO2roubYGVikR2O2MGP1wYPJg6mUcru6I9cW3j9LQWG6252XSBiMhIMrh5Y5RDyPLp72WoHD0QVdLdgQ8xAwLzJHOYI7n5yvsgPTozA/5D0k0i2Ko5wuzn9JsoNrkQ9m+H/Rk4WLmgKk4T4czOZc4jEIcJ2EWVCLh95sBywLObDy7EZW/4/ZPpl+6cxKU=----ATTACHMENT:----MzgzNjAxNTUxODc2MDI0MCA0MzgxMTE1NDc4MDk4NjQzIDc5MDAxODI2OTQyMDIwMDc=