From ed43aaa8784f123394015dfee200054bb2504da7 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 6 Sep 2023 12:50:18 +1200 Subject: [PATCH] Fix for DNS query's using the domain's dnsdomain --- app/Classes/Protocol/DNS.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Classes/Protocol/DNS.php b/app/Classes/Protocol/DNS.php index c08484c..a7747d6 100644 --- a/app/Classes/Protocol/DNS.php +++ b/app/Classes/Protocol/DNS.php @@ -182,8 +182,11 @@ final class DNS extends BaseProtocol if (is_null($z=$this->parse('z',$labels->shift()))) return $this->nameerr(); - if (is_null($d=$labels->shift())) - return $this->nameerr(); + // If the query doesnt end with .ftn, then the remainder of the query is the domain name + if (($labels->search(self::TLD) !== FALSE)) + $d = $labels->shift(); + else + $d = ''; // Make sure we have a root/base domain if (! $labels->count()) @@ -191,15 +194,18 @@ final class DNS extends BaseProtocol $rootdn = $labels->join('.'); + if (! $d && ($rootdn !== self::TLD)) + $d = Domain::where('dnsdomain',$rootdn)->single()?->name; + $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 !== $d.'.'.$rootdn)))) { + if ((! $ao) || (! $ao->system->address) || (($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::debug(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn)); + Log::info(sprintf('%s:= Returning [%s] for DNS query [%s]',self::LOGKEY,$ao->system->address,$ao->ftn)); return $this->reply( self::DNS_NOERROR,