Still return TXT records even if a system doesnt have an address

This commit is contained in:
Deon George 2023-10-05 12:09:56 +11:00
parent 495a27cfed
commit 0cabdcd3c1

View File

@ -226,15 +226,18 @@ final class DNS extends BaseProtocol
$ao = Address::findFTN(sprintf('%d:%d/%d.%d@%s',$z,$n,$f,$p,$d)); $ao = Address::findFTN(sprintf('%d:%d/%d.%d@%s',$z,$n,$f,$p,$d));
// Check we have the right record // Check we have the right record
if ((! $ao) || (! $ao->system->address) || (($rootdn !== self::TLD) && ((! $ao->zone->domain->dnsdomain) || ($ao->zone->domain->dnsdomain !== $rootdn)))) { if ((! $ao) || (($rootdn !== self::TLD) && ((! $ao->zone->domain->dnsdomain) || ($ao->zone->domain->dnsdomain !== $rootdn)))) {
Log::alert(sprintf('%s:= No DNS record for [%d:%d/%d.%d@%s]',self::LOGKEY,$z,$n,$f,$p,$d)); Log::alert(sprintf('%s:= No DNS record for [%d:%d/%d.%d@%s]',self::LOGKEY,$z,$n,$f,$p,$d));
return $this->nameerr(); return $this->nameerr();
} }
Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn));
switch ($this->query->type) { switch ($this->query->type) {
case self::DNS_TYPE_SRV: case self::DNS_TYPE_SRV:
if (! $ao->system->address)
return $this->nameerr();
Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn));
if ($xx=$ao->system->mailers->where('id',$mailer->id)->pop()) { if ($xx=$ao->system->mailers->where('id',$mailer->id)->pop()) {
return $this->reply( return $this->reply(
self::DNS_NOERROR, self::DNS_NOERROR,
@ -250,15 +253,20 @@ final class DNS extends BaseProtocol
} }
case self::DNS_TYPE_TXT: case self::DNS_TYPE_TXT:
Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->name,$ao->ftn));
return $this->reply( return $this->reply(
self::DNS_NOERROR, self::DNS_NOERROR,
[serialize($ao->system->name) => self::DNS_TYPE_TXT]); [serialize($ao->system->name) => self::DNS_TYPE_TXT]);
default: default:
return $this->reply( Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn));
return (! $ao->system->address)
? $this->nameerr()
: $this->reply(
self::DNS_NOERROR, self::DNS_NOERROR,
[serialize($this->domain_split($ao->system->address)) => self::DNS_TYPE_CNAME]); [serialize($this->domain_split($ao->system->address)) => self::DNS_TYPE_CNAME]);
} }
// Other attributes return NOTIMPL // Other attributes return NOTIMPL