From 109beb4f4f45590c67cecd726e152d7dc8f72434 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 2 Jan 2023 01:05:44 +1100 Subject: [PATCH] Enable processing messages coming from a domain with multiple zones --- app/Classes/FTN/Message.php | 11 +++++------ app/Classes/FTN/Packet.php | 18 ++---------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index de87d59..755bd2c 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -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': diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 64b727b..ba1c46a 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -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();