Process netmails from unlisted systems
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 31s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m30s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
2024-11-20 16:01:11 +09:30
parent 016c1fb1b0
commit 67dad76bd1
3 changed files with 81 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ use App\Classes\File;
use App\Classes\FTN\Packet;
use App\Exceptions\InvalidPacketException;
use App\Models\{Echomail,Netmail,System};
use App\Notifications\Netmails\PacketPasswordInvalid;
use App\Notifications\Netmails\{PacketPasswordInvalid,UnexpectedPacketFromYou};
class PacketProcess implements ShouldQueue
{
@@ -80,17 +80,9 @@ class PacketProcess implements ShouldQueue
break;
}
if (! our_nodes($pkt->fftn->zone->domain)->contains($pkt->fftn)) {
Log::error(sprintf('%s:! Packet [%s] is from a system that is not configured with us? [%s]',self::LOGKEY,$this->filename,$pkt->fftn_t));
// @todo Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketFromYou($this->filename));
// @todo Parse the packet for netmails and process them. We'll only accept netmails to us, and ignore all others
break;
}
// If we dont have the tftn in the DB, then packet cannot be to us
if (! $pkt->tftn) {
Log::error(sprintf('%s:! Packet [%s] is from a system [%s] we dont know about?',self::LOGKEY,$this->filename,$pkt->tftn_t));
Log::error(sprintf('%s:! Packet [%s] is for a system [%s] we dont know about?',self::LOGKEY,$this->filename,$pkt->tftn_t));
// @todo Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketToUs($this->filename));
break;
@@ -104,8 +96,15 @@ class PacketProcess implements ShouldQueue
break;
}
$netmail_only = FALSE;
if (! our_nodes($pkt->fftn->zone->domain)->contains($pkt->fftn)) {
Log::alert(sprintf('%s:! Packet [%s] is from a system that is not configured with us, only NETMAIL processed [%s]',self::LOGKEY,$this->filename,$pkt->fftn_t));
$netmail_only = TRUE;
// Check the packet password
if ($pkt->fftn->pass_packet !== strtoupper($pkt->password)) {
} elseif ($pkt->fftn->pass_packet !== strtoupper($pkt->password)) {
Log::error(sprintf('%s:! Packet from [%s] with password [%s] is invalid.',self::LOGKEY,$pkt->fftn->ftn,$pkt->password));
Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName()));
@@ -122,9 +121,17 @@ class PacketProcess implements ShouldQueue
foreach ($pkt as $msg) {
if ($msg instanceof Netmail)
Log::info(sprintf('%s:- Netmail from [%s] to [%s]',self::LOGKEY,$msg->fftn->ftn,$msg->tftn->ftn));
elseif ($msg instanceof Echomail)
elseif ($msg instanceof Echomail) {
Log::info(sprintf('%s:- Echomail from [%s]',self::LOGKEY,$msg->fftn->ftn));
if ($netmail_only) {
Log::alert(sprintf('%s:! Echomail IGNORED as packet is from an unknown system [%s]',self::LOGKEY,$pkt->fftn->ftn));
continue;
}
}
if ($msg->errors->count()) {
Log::error(sprintf('%s:! Message [%s] has [%d] errors, unable to process',self::LOGKEY,$msg->msgid,$msg->errors->count()));
@@ -155,6 +162,8 @@ class PacketProcess implements ShouldQueue
if ($count === $pkt->count())
$processed = TRUE;
elseif ($netmail_only)
Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketFromYou($f->pktName()));
} catch (\Exception $e) {
Log::error(sprintf('%s:! Got an exception [%s] processing packet',self::LOGKEY,$e->getMessage()));