Better handling of badly addressed packets for netmails
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 33s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m46s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-10-22 19:17:03 +11:00
parent 86a15872b8
commit 7da09a1a9e
4 changed files with 16 additions and 5 deletions

View File

@ -878,11 +878,17 @@ class Message extends FTNBase
$validator->after(function($validator) {
if ($this->zone->domain->flatten) {
if (! $this->zone->domain->zones->pluck('zone_id')->contains($this->fz))
$validator->errors()->add('invalid-zone',sprintf('Message zone [%d] doesnt match any zone in domain for packet zone [%d].',$this->fz,$this->zone->zone_id));
$validator->errors()->add('invalid-zone',sprintf('Message from zone [%d] doesnt match any zone in domain for packet zone [%d].',$this->fz,$this->zone->zone_id));
if (! $this->zone->domain->zones->pluck('zone_id')->contains($this->tz))
$validator->errors()->add('invalid-zone',sprintf('Message to zone [%d] doesnt match any zone in domain for packet zone [%d].',$this->fz,$this->zone->zone_id));
} else {
if ($this->zone->zone_id !== $this->fz)
$validator->errors()->add('invalid-zone',sprintf('Message zone [%d] doesnt match packet zone [%d].',$this->fz,$this->zone->zone_id));
$validator->errors()->add('invalid-zone',sprintf('Message from zone [%d] doesnt match packet zone [%d].',$this->fz,$this->zone->zone_id));
if ($this->zone->zone_id !== $this->tz)
$validator->errors()->add('invalid-zone',sprintf('Message to zone [%d] doesnt match packet zone [%d].',$this->tz,$this->zone->zone_id));
}
if (! $this->fftn)

View File

@ -386,9 +386,8 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
// If the messages is not for the right zone, we'll ignore it
if ($msg->errors->has('invalid-zone')) {
Log::alert(sprintf('%s:! Message [%s] is from an invalid zone [%s], packet is from [%s] - ignoring it',self::LOGKEY,$msg->msgid,$msg->set_fftn,$this->fz));
Log::alert(sprintf('%s:! Message [%s] is from|to an invalid zone [%s|%s], packet is from [%s] - ignoring it',self::LOGKEY,$msg->msgid,$msg->get_fftn,$msg->get_tftn,$this->fz));
// @todo $msg might not be echomail
if (! $msg->kludges->get('RESCANNED'))
Notification::route('netmail',$this->fftn)->notify(($msg instanceof Echomail) ? new EchomailBadAddress($msg) : new NetmailBadAddress($msg));

View File

@ -46,6 +46,12 @@ final class Netmail extends Model implements Packet
public function __get($key)
{
switch ($key) {
case 'get_fftn':
return $this->set->get('set_fftn') ?: $this->fftn->ftn;
case 'get_tftn':
return $this->set->get('set_tftn') ?: $this->tftn->ftn;
case 'set_fftn':
case 'set_tftn':
case 'set_path':

View File

@ -49,7 +49,7 @@ class NetmailBadAddress extends Netmails
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$msg->addText(sprintf("The address in this netmail [%s] is the wrong address for the domain [%s].\r\r",$this->mo->set_fftn,$ao->zone->domain->name));
$msg->addText(sprintf("The from [%s] or to [%s] address in this netmail is the wrong address for the domain [%s].\r\r",$this->mo->get_fftn,$this->mo->get_tftn,$ao->zone->domain->name));
$msg->addText("This netmail has been rejected and not stored here - so no downstream node will receive it. If you think this is a mistake, please let me know.\r\r");