Compare commits

...

2 Commits

Author SHA1 Message Date
86a15872b8 Better catching bad TZUTC in messages, continue parsing mail bundles in an archive if a packet has an error
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 36s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m48s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2024-10-22 17:08:48 +11:00
eb61c5ea6e Change wording of forwarding netmail, no functional changes 2024-10-22 15:29:41 +11:00
5 changed files with 247 additions and 207 deletions

View File

@ -89,7 +89,7 @@ class Message extends FTNBase
public const AREATAG_LEN = 35; // public const AREATAG_LEN = 35; //
private array $header; // Message Header private array $header; // Message Header
private int $tzutc = 0; // TZUTC that needs to be converted to be used by Carbon @see self::kludges private Collection $kludges; // TZUTC that needs to be converted to be used by Carbon @see self::kludges
private Echomail|Netmail $mo; // The object storing this packet message private Echomail|Netmail $mo; // The object storing this packet message
private Address $us; // Our address for this message private Address $us; // Our address for this message
@ -294,6 +294,7 @@ class Message extends FTNBase
public function __construct(Zone $zone) public function __construct(Zone $zone)
{ {
$this->zone = $zone; $this->zone = $zone;
$this->kludges = collect();
} }
public function __get($key) public function __get($key)
@ -476,11 +477,25 @@ class Message extends FTNBase
break; break;
case 'tzutc':
return $this->kludges->get($key);
default: default:
throw new \Exception('Unknown key: '.$key); throw new \Exception('Unknown key: '.$key);
} }
} }
public function __set(string $key,mixed $value): void
{
switch ($key) {
case 'tzutc':
if (! is_numeric($value))
throw new InvalidPacketException('TZUTC is not numeric '.$value);
$this->kludges->put($key,$value);
}
}
/** /**
* Export an FTN message, ready for sending. * Export an FTN message, ready for sending.
* *
@ -654,7 +669,9 @@ class Message extends FTNBase
// First find our kludge lines // First find our kludge lines
$ptr_start = 0; $ptr_start = 0;
$ptr_end = 0;
try {
while (substr($message,$ptr_start,1) === "\x01") { while (substr($message,$ptr_start,1) === "\x01") {
$ptr_end = strpos($message,"\r",$ptr_start); $ptr_end = strpos($message,"\r",$ptr_start);
@ -797,6 +814,15 @@ class Message extends FTNBase
$o->kludges = [$m[1],$m[2]]; $o->kludges = [$m[1],$m[2]];
} }
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error parsing message, now at offset [0x%02x] (%s)',
self::LOGKEY,
$ptr_start,
$e->getMessage()),['dump'=>hex_dump($message)]);
throw new InvalidPacketException('Error parsing message');
}
return $o; return $o;
} }

View File

@ -174,6 +174,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|| (($end=strpos($msgbuf,"\x00".self::PACKED_END,$leader)) !== FALSE)) || (($end=strpos($msgbuf,"\x00".self::PACKED_END,$leader)) !== FALSE))
{ {
// Parse our message // Parse our message
Log::debug(sprintf('%s:- Message at offset [%d] in [%s]',self::LOGKEY,$read_ptr-strlen($readbuf),$name));
$o->parseMessage(substr($msgbuf,0,$end)); $o->parseMessage(substr($msgbuf,0,$end));
$msgbuf = substr($msgbuf,$end+3); $msgbuf = substr($msgbuf,$end+3);

View File

@ -83,6 +83,11 @@ class File extends FileBase implements \Iterator
/* METHODS */ /* METHODS */
public function isArchive(): bool
{
return $this->isArchive;
}
/** /**
* Determine if the file is a mail packet * Determine if the file is a mail packet
* *

View File

@ -67,8 +67,10 @@ class PacketProcess implements ShouldQueue
$f = new File($fs->path($this->filename)); $f = new File($fs->path($this->filename));
$processed = FALSE; $processed = FALSE;
$bad_archive = FALSE;
foreach ($f as $packet) { foreach ($f as $packet) {
try {
$pkt = Packet::process($packet,Arr::get(stream_get_meta_data($packet),'uri'),$f->itemSize(),$this->do); $pkt = Packet::process($packet,Arr::get(stream_get_meta_data($packet),'uri'),$f->itemSize(),$this->do);
// Check that the packet is from a system that is defined in the DB // Check that the packet is from a system that is defined in the DB
@ -153,9 +155,15 @@ class PacketProcess implements ShouldQueue
if ($count === $pkt->count()) if ($count === $pkt->count())
$processed = TRUE; $processed = TRUE;
} catch (\Exception $e) {
Log::error(sprintf('%s:! Got an exception [%s] processing packet',self::LOGKEY,$e->getMessage()));
$bad_archive = TRUE;
}
} }
if (! $processed) { if ((! $processed) || $bad_archive) {
Log::alert(sprintf('%s:- Not deleting packet [%s], it doesnt seem to be processed?',self::LOGKEY,$this->filename)); Log::alert(sprintf('%s:- Not deleting packet [%s], it doesnt seem to be processed?',self::LOGKEY,$this->filename));
} else { } else {

View File

@ -58,7 +58,7 @@ class NetmailForward extends Netmails
$this->mo->to, $this->mo->to,
$this->ao->ftn3d, $this->ao->ftn3d,
)); ));
$msg->addText(sprintf("To avoid receiving this netmail, send messages to [%s] to [%s].\r\r",$this->mo->to,$this->ao->ftn3d)); $msg->addText(sprintf("To avoid receiving this netmail, you can send messages directly to [%s] at [%s].\r\r",$this->mo->to,$this->ao->ftn3d));
$o->msg = $msg->render(); $o->msg = $msg->render();
$o->set_tagline = 'Thank you so much for your mail. I love it already.'; $o->set_tagline = 'Thank you so much for your mail. I love it already.';