More work to ensure messages from a node are valid for the domain, and fix domain flatten to check for zone if one is supplied

This commit is contained in:
Deon George 2023-09-17 15:46:09 +10:00
parent e611dcbe11
commit cc04ddd7b3
2 changed files with 20 additions and 6 deletions

View File

@ -236,7 +236,7 @@ class MessageProcess implements ShouldQueue
->single();
if (! $ea) {
Log::alert(sprintf('%s:! Echoarea [%s] doesnt exist for zone [%d]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->zone_id));
Log::alert(sprintf('%s:! Echoarea [%s] doesnt exist for zone [%d-%d]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->domain_id,$this->msg->fboss_o->zone->zone_id));
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotExist($this->msg));
return;
@ -244,6 +244,14 @@ class MessageProcess implements ShouldQueue
Log::debug(sprintf('%s:- Processing echomail [%s] in [%s].',self::LOGKEY,$this->msg->msgid,$this->msg->echoarea));
if (! $this->pktsrc->zone->domain->zones->pluck('zone_id')->contains($this->msg->fboss_o->zone->zone_id)) {
Log::alert(sprintf('%s:! The message [%s] is from a different zone [%d] than the packet sender [%d]',
self::LOGKEY,
$this->msg->msgid,
$this->msg->fboss_o->zone->zone_id,
$this->pktsrc->zone->zone_id));
}
// Check for duplicate messages
// FTS-0009.001
if ($this->msg->msgid) {
@ -295,16 +303,22 @@ class MessageProcess implements ShouldQueue
}
// @todo Can the sender create it if it doesnt exist?
// Can the system send messages to this area?
if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) {
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNoWrite($this->msg));
Log::alert(sprintf('%s:! FTN [%s] is not allowed to post [%s] to [%s].',self::LOGKEY,$this->msg->fboss,$this->msg->msgid,$ea->name));
if (! $this->msg->rescanned->count())
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNoWrite($this->msg));
return;
}
// If the node is not subscribed
if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE)
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg));
if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE) {
Log::alert(sprintf('%s:! FTN [%s] is not subscribed to [%s] for [%s].',self::LOGKEY,$this->msg->fboss,$ea->name,$this->msg->msgid));
if (! $this->msg->rescanned->count())
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg));
}
// We know about this area, store it
$o = new Echomail;

View File

@ -530,7 +530,7 @@ class Address extends Model
$do = $zo?->domain;
}
if ($do && $do->flatten)
if ($do && $do->flatten && (($ftn['z'] === 0) || $do->zones->pluck('zone_id')->contains($ftn['z'])))
$o = self::findZone($do,$ftn['n'],$ftn['f'],$ftn['p'],$trashed);
}