From 0cabdcd3c1748fa13a4684b4dd8049d4f9aa3b42 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 5 Oct 2023 12:09:56 +1100 Subject: [PATCH] Still return TXT records even if a system doesnt have an address --- app/Classes/Protocol/DNS.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Classes/Protocol/DNS.php b/app/Classes/Protocol/DNS.php index bbc7b79..6bb6ca3 100644 --- a/app/Classes/Protocol/DNS.php +++ b/app/Classes/Protocol/DNS.php @@ -226,15 +226,18 @@ final class DNS extends BaseProtocol $ao = Address::findFTN(sprintf('%d:%d/%d.%d@%s',$z,$n,$f,$p,$d)); // 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)); return $this->nameerr(); } - Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn)); - switch ($this->query->type) { 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()) { return $this->reply( self::DNS_NOERROR, @@ -250,15 +253,20 @@ final class DNS extends BaseProtocol } 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( self::DNS_NOERROR, [serialize($ao->system->name) => self::DNS_TYPE_TXT]); default: - return $this->reply( - self::DNS_NOERROR, - [serialize($this->domain_split($ao->system->address)) => self::DNS_TYPE_CNAME]); + 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, + [serialize($this->domain_split($ao->system->address)) => self::DNS_TYPE_CNAME]); } // Other attributes return NOTIMPL