Enable processing messages coming from a domain with multiple zones

This commit is contained in:
Deon George 2023-01-02 01:05:44 +11:00
parent c1ab14f2e6
commit 109beb4f4f
2 changed files with 7 additions and 22 deletions

View File

@ -222,7 +222,7 @@ class Message extends FTNBase
case 'fdomain':
// We'll use the zone's domain if this method class was called with a zone
if ($this->zone && ($this->zone->domain->name == Arr::get($this->src,'d')))
if ($this->zone && (($this->zone->domain->name == Arr::get($this->src,'d')) || ! Arr::get($this->src,'d')))
return $this->zone->domain;
// If we get the domain from the packet, we'll find it
@ -234,7 +234,7 @@ class Message extends FTNBase
case 'tdomain':
// We'll use the zone's domain if this method class was called with a zone
if ($this->zone && ($this->zone->domain->name == Arr::get($this->dst,'d')))
if ($this->zone && (($this->zone->domain->name == Arr::get($this->dst,'d')) || ! Arr::get($this->dst,'d')))
return $this->zone->domain;
// If we get the domain from the packet, we'll find it
@ -250,7 +250,6 @@ class Message extends FTNBase
if ($this->zone && ($this->fz == $this->zone->zone_id))
return $this->zone;
// If we have a domain, we'll use the zone from the domain
if ($this->fdomain) {
if (($x=$this->fdomain->zones->search(function($item) { return $item->zone_id == $this->fz; })) !== FALSE)
return $this->fdomain->zones->get($x);
@ -266,7 +265,6 @@ class Message extends FTNBase
if ($this->zone && ($this->tz == $this->zone->zone_id))
return $this->zone;
// If we have a domain, we'll use the zone from the domain
if ($this->tdomain) {
if (($x=$this->tdomain->zones->search(function($item) { return $item->zone_id == $this->tz; })) !== FALSE)
return $this->tdomain->zones->get($x);
@ -290,10 +288,11 @@ class Message extends FTNBase
case 'tftn_o':
return parent::__get($key);
// For 5D we need to include the domain
case 'fboss':
return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff);
return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff).(($x=$this->fdomain) ? '@'.$x->name : '');
case 'tboss':
return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf);
return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf).(($x=$this->tdomain) ? '@'.$x->name : '');
case 'fboss_o':
return Address::findFTN($this->fboss);
case 'tboss_o':

View File

@ -443,8 +443,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
// If the from address doenst exist, we'll create a new entry
if ($msg->errors->messages()->has('to') && $msg->tzone) {
$e = NULL;
try {
// @todo Need to work out the correct region for the host_id
Address::unguard();
@ -454,21 +452,16 @@ class Packet extends FTNBase implements \Iterator, \Countable
'host_id' => $msg->tn,
'node_id' => $msg->tf,
'point_id' => $msg->tp,
'active' => TRUE,
]);
Address::reguard();
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error finding/creating TO address [%s] for message',self::LOGKEY,$msg->tboss),['error'=>$e->getMessage()]);
}
// This shouldnt happen
if ($e || $ao->exists) {
Log::error(sprintf('%s:! Unexpected error attempting to create TO address [%s]',self::LOGKEY,$msg->tboss));
$this->errors->push($msg);
return;
}
$ao->active = TRUE;
$ao->role = Address::NODE_UNKNOWN;
System::unguard();
@ -486,8 +479,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
}
if ($msg->errors->messages()->has('from') && $msg->tzone) {
$e = NULL;
try {
// @todo Need to work out the correct region for the host_id
Address::unguard();
@ -497,21 +488,16 @@ class Packet extends FTNBase implements \Iterator, \Countable
'host_id' => $msg->fn,
'node_id' => $msg->ff,
'point_id' => $msg->fp,
'active'=> TRUE,
]);
Address::reguard();
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error finding/creating FROM address [%s] for message',self::LOGKEY,$msg->fboss),['error'=>$e->getMessage()]);
}
// This shouldnt happen
if ($e || $ao->exists) {
Log::error(sprintf('%s:! Unexpected error attempting to create FROM address [%s]',self::LOGKEY,$msg->fboss));
$this->errors->push($msg);
return;
}
$ao->active = TRUE;
$ao->role = Address::NODE_UNKNOWN;
System::unguard();