Recognise all AKAs for a system when we are polling it with one of it's AKAs in a domain

This commit is contained in:
Deon George 2024-06-26 16:03:58 +10:00
parent 91d4cd0b2f
commit 7c23971e58

View File

@ -38,6 +38,7 @@ class Node
private Collection $ftns_authed; // The FTNs we have validated private Collection $ftns_authed; // The FTNs we have validated
private Collection $ftns_other; // Other FTN addresses presented private Collection $ftns_other; // Other FTN addresses presented
private bool $authed; // Have we authenticated the remote. 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 private int $options; // This nodes capabilities/options
@ -84,9 +85,9 @@ class Node
// The nodes password // The nodes password
case 'password': case 'password':
// If we have already authed, we'll use that password. // If we are originating a session, we'll use that password.
if ($this->ftns_authed->count()) if (isset($this->originate))
return $this->ftns_authed->first()->pass_session; return $this->originate->pass_session;
else else
return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-'; return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-';
@ -194,6 +195,8 @@ class Node
throw new Exception('Already authed'); throw new Exception('Already authed');
foreach ($this->ftns as $o) { 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) if (! $sespass=$o->pass_session)
continue; continue;
@ -269,7 +272,8 @@ class Node
*/ */
public function originate(Address $o): void 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) if ($this->authed)
return TRUE; return TRUE;
if ($this->ftns_authed->count() !== 1 || ! $this->ftns->count()) Log::debug(sprintf('%s:- Making sure we called [%s] from [%s]',self::LOGKEY,$this->originate->ftn,$this->ftns->pluck('ftn')->join(',')));
return FALSE;
$ftn = $this->ftns_authed->first()->ftn; return $this->ftns->pluck('ftn')->contains($this->originate->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;
} }
public function optionClear(int $key): void public function optionClear(int $key): void