Process netmails from unlisted systems
This commit is contained in:
parent
016c1fb1b0
commit
67dad76bd1
@ -18,7 +18,7 @@ use App\Classes\File;
|
|||||||
use App\Classes\FTN\Packet;
|
use App\Classes\FTN\Packet;
|
||||||
use App\Exceptions\InvalidPacketException;
|
use App\Exceptions\InvalidPacketException;
|
||||||
use App\Models\{Echomail,Netmail,System};
|
use App\Models\{Echomail,Netmail,System};
|
||||||
use App\Notifications\Netmails\PacketPasswordInvalid;
|
use App\Notifications\Netmails\{PacketPasswordInvalid,UnexpectedPacketFromYou};
|
||||||
|
|
||||||
class PacketProcess implements ShouldQueue
|
class PacketProcess implements ShouldQueue
|
||||||
{
|
{
|
||||||
@ -80,17 +80,9 @@ class PacketProcess implements ShouldQueue
|
|||||||
break;
|
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 we dont have the tftn in the DB, then packet cannot be to us
|
||||||
if (! $pkt->tftn) {
|
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));
|
// @todo Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketToUs($this->filename));
|
||||||
break;
|
break;
|
||||||
@ -104,8 +96,15 @@ class PacketProcess implements ShouldQueue
|
|||||||
break;
|
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
|
// 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));
|
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()));
|
Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName()));
|
||||||
@ -122,9 +121,17 @@ class PacketProcess implements ShouldQueue
|
|||||||
foreach ($pkt as $msg) {
|
foreach ($pkt as $msg) {
|
||||||
if ($msg instanceof Netmail)
|
if ($msg instanceof Netmail)
|
||||||
Log::info(sprintf('%s:- Netmail from [%s] to [%s]',self::LOGKEY,$msg->fftn->ftn,$msg->tftn->ftn));
|
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));
|
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()) {
|
if ($msg->errors->count()) {
|
||||||
Log::error(sprintf('%s:! Message [%s] has [%d] errors, unable to process',self::LOGKEY,$msg->msgid,$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())
|
if ($count === $pkt->count())
|
||||||
$processed = TRUE;
|
$processed = TRUE;
|
||||||
|
elseif ($netmail_only)
|
||||||
|
Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketFromYou($f->pktName()));
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error(sprintf('%s:! Got an exception [%s] processing packet',self::LOGKEY,$e->getMessage()));
|
Log::error(sprintf('%s:! Got an exception [%s] processing packet',self::LOGKEY,$e->getMessage()));
|
||||||
|
@ -19,7 +19,7 @@ class NetmailBadAddress extends Netmails
|
|||||||
/**
|
/**
|
||||||
* Send a sysop a message if they give us a message with a bad address in it.
|
* Send a sysop a message if they give us a message with a bad address in it.
|
||||||
*
|
*
|
||||||
* @param Echomail $mo
|
* @param Netmail $mo
|
||||||
*/
|
*/
|
||||||
public function __construct(Netmail $mo)
|
public function __construct(Netmail $mo)
|
||||||
{
|
{
|
||||||
|
59
app/Notifications/Netmails/UnexpectedPacketFromYou.php
Normal file
59
app/Notifications/Netmails/UnexpectedPacketFromYou.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Netmails;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Notifications\Netmails;
|
||||||
|
use App\Models\{Echomail,Netmail};
|
||||||
|
use App\Traits\{MessagePath,PageTemplate};
|
||||||
|
|
||||||
|
class UnexpectedPacketFromYou extends Netmails
|
||||||
|
{
|
||||||
|
use MessagePath,PageTemplate;
|
||||||
|
|
||||||
|
private const LOGKEY = 'NUP';
|
||||||
|
|
||||||
|
private string $filename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a sysop a message if they send us echomail and they are not defined with us.
|
||||||
|
*
|
||||||
|
* @param Echomail $mo
|
||||||
|
*/
|
||||||
|
public function __construct(string $filename)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->filename = $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return Netmail
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function toNetmail(object $notifiable): Netmail
|
||||||
|
{
|
||||||
|
$o = $this->setupNetmail($notifiable);
|
||||||
|
$ao = $notifiable->routeNotificationFor(static::via);
|
||||||
|
|
||||||
|
Log::info(sprintf('%s:+ Creating NETMAIL UNEXPECTED PACKET netmail to [%s]',self::LOGKEY,$ao->ftn));
|
||||||
|
|
||||||
|
$o->subject = sprintf('Unexpected packet from you [%s]',$this->filename);
|
||||||
|
|
||||||
|
// Message
|
||||||
|
$msg = $this->page(FALSE,'unexpected');
|
||||||
|
|
||||||
|
$msg->addText("We received a packet from you with echomail, but your node is not defined here. Those echomail messages were ignored. If you think this is a mistake, please let me know.\r\r");
|
||||||
|
|
||||||
|
$o->msg = $msg->render();
|
||||||
|
$o->set_tagline = 'The unexpected moment is always sweeter';
|
||||||
|
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user