From 7c23971e58297cc9b31fa3fd88ff669875a0353f Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 26 Jun 2024 16:03:58 +1000 Subject: [PATCH] Recognise all AKAs for a system when we are polling it with one of it's AKAs in a domain --- app/Classes/Node.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/Classes/Node.php b/app/Classes/Node.php index 3cd5ee8..677059a 100644 --- a/app/Classes/Node.php +++ b/app/Classes/Node.php @@ -38,6 +38,7 @@ class Node private Collection $ftns_authed; // The FTNs we have validated private Collection $ftns_other; // Other FTN addresses presented private bool $authed; // Have we authenticated the remote. + private Address $originate; // When we originate a call, this is who we are after private int $options; // This nodes capabilities/options @@ -84,9 +85,9 @@ class Node // The nodes password case 'password': - // If we have already authed, we'll use that password. - if ($this->ftns_authed->count()) - return $this->ftns_authed->first()->pass_session; + // If we are originating a session, we'll use that password. + if (isset($this->originate)) + return $this->originate->pass_session; else return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-'; @@ -194,6 +195,8 @@ class Node throw new Exception('Already authed'); foreach ($this->ftns as $o) { + Log::debug(sprintf('%s:- Attempting to authenticate [%s] with [%s]',self::LOGKEY,$o->ftn,$o->pass_session)); + if (! $sespass=$o->pass_session) continue; @@ -269,7 +272,8 @@ class Node */ public function originate(Address $o): void { - $this->ftns_authed->push($o); + $this->originate = $o; + $this->ftns_authed = $o->system->match($o->zone); } /** @@ -283,19 +287,9 @@ class Node if ($this->authed) return TRUE; - if ($this->ftns_authed->count() !== 1 || ! $this->ftns->count()) - return FALSE; + Log::debug(sprintf('%s:- Making sure we called [%s] from [%s]',self::LOGKEY,$this->originate->ftn,$this->ftns->pluck('ftn')->join(','))); - $ftn = $this->ftns_authed->first()->ftn; - - return $this->ftns->search(function($item) use ($ftn) { - if ($item->ftn === $ftn) { - $item->system->last_session = Carbon::now(); - $item->system->save(); - $this->authed = TRUE; - return TRUE; - } - }) !== FALSE; + return $this->ftns->pluck('ftn')->contains($this->originate->ftn); } public function optionClear(int $key): void