Check for duplicate echomails, validate system password
This commit is contained in:
parent
6af466605a
commit
bcf3297fdb
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
use App\Models\Domain;
|
||||
use App\Models\{Address,Domain};
|
||||
|
||||
abstract class FTN
|
||||
{
|
||||
@ -27,6 +27,11 @@ abstract class FTN
|
||||
$this->tp,
|
||||
).($this->domain ? sprintf('@%s',$this->domain->name) : '');
|
||||
|
||||
case 'fftn_o':
|
||||
return Address::findFTN($this->fftn);
|
||||
case 'tftn_o':
|
||||
return Address::findFTN($this->tftn);
|
||||
|
||||
default:
|
||||
throw new \Exception('Unknown key: '.$key);
|
||||
}
|
||||
|
@ -264,13 +264,10 @@ class Message extends FTNBase
|
||||
case 'tp': return Arr::get($this->point,'dst');
|
||||
|
||||
case 'fftn':
|
||||
case 'tftn':
|
||||
return parent::__get($key);
|
||||
|
||||
case 'fftn_o':
|
||||
return Address::findFTN($this->fftn);
|
||||
case 'tftn':
|
||||
case 'tftn_o':
|
||||
return Address::findFTN($this->tftn);
|
||||
return parent::__get($key);
|
||||
|
||||
case 'date':
|
||||
return Carbon::createFromFormat('d M y H:i:s O',
|
||||
@ -604,7 +601,7 @@ class Message extends FTNBase
|
||||
$ftn = Address::parseFTN($matches[1]);
|
||||
|
||||
// We'll double check our FTN
|
||||
if ($this->isNetmail() && ($ftn['n'] !== $this->fn) || ($ftn['f'] !== $this->ff)) {
|
||||
if ($this->isNetmail() && (($ftn['n'] !== $this->fn) || ($ftn['f'] !== $this->ff))) {
|
||||
Log::error(sprintf('FTN [%s] doesnt match message header',$matches[1]),['ftn'=>$ftn,'fn'=>$this->fn,'ff'=>$this->ff]);
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,9 @@ class Packet extends FTNBase
|
||||
return Arr::get($this->header,$key);
|
||||
|
||||
case 'fftn':
|
||||
case 'fftn_o':
|
||||
case 'tftn':
|
||||
case 'tftn_o':
|
||||
return parent::__get($key);
|
||||
|
||||
case 'software':
|
||||
|
@ -120,6 +120,19 @@ final class Receive extends Item
|
||||
break;
|
||||
}
|
||||
|
||||
// Check the messages are from the uplink
|
||||
if ($this->ao->system->addresses->search(function($item) use ($po) { return $item->id == $po->fftn_o->id; }) === FALSE) {
|
||||
Log::error(sprintf('%s: ! Packet [%s] is not from this link? [%d]',self::LOGKEY,$this->fftn_o->ftn,$this->ao->system_id));
|
||||
break;
|
||||
}
|
||||
|
||||
// Check the packet password
|
||||
if ($this->ao->session('pktpass') !== $po->password) {
|
||||
Log::error(sprintf('%s: ! Packet from [%s] with password [%s] is invalid (%s)',self::LOGKEY,$this->ao->ftn,$po->password));
|
||||
// @todo Generate message to system advising invalid password - that message should be sent without a packet password!
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($po->messages as $msg) {
|
||||
Log::info(sprintf('%s: - Mail from [%s] to [%s]',self::LOGKEY,$msg->fftn,$msg->tftn));
|
||||
|
||||
@ -151,6 +164,7 @@ final class Receive extends Item
|
||||
/**
|
||||
* Open the file descriptor to receive a file
|
||||
*
|
||||
* @param Address $ao
|
||||
* @param bool $check
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
|
@ -10,10 +10,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\{Message,Process};
|
||||
use App\Models\{Echoarea,Echomail,Netmail,Setup};
|
||||
use App\Models\{Echoarea,Echomail,Netmail,Setup,System};
|
||||
|
||||
class ProcessPacket implements ShouldQueue
|
||||
{
|
||||
private const LOGKEY = 'PP-';
|
||||
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
private Message $msg;
|
||||
@ -159,7 +161,8 @@ class ProcessPacket implements ShouldQueue
|
||||
|
||||
// Else we are echomail
|
||||
} else {
|
||||
Log::info(sprintf('Echomail [%s] in [%s] from (%s) [%s] to (%s).',
|
||||
Log::info(sprintf('%s: - Echomail [%s] in [%s] from (%s) [%s] to (%s).',
|
||||
self::LOGKEY,
|
||||
$this->msg->msgid,
|
||||
$this->msg->echoarea,
|
||||
$this->msg->user_to,$this->msg->tftn,
|
||||
@ -170,6 +173,23 @@ class ProcessPacket implements ShouldQueue
|
||||
->where('domain_id',$this->msg->fftn_o->zone->domain_id)
|
||||
->single();
|
||||
|
||||
// Check for duplicate messages
|
||||
if ($this->msg->msgid) {
|
||||
$o = Echomail::where('msgid',$this->msg->msgid)->single();
|
||||
|
||||
if ($o) {
|
||||
Log::alert(sprintf('%s:! Ignoring duplicate echomail [%s] in [%s] from (%s) [%s] to (%s).',
|
||||
self::LOGKEY,
|
||||
$this->msg->msgid,
|
||||
$this->msg->echoarea,
|
||||
$this->msg->user_to,$this->msg->tftn,
|
||||
$this->msg->user_from,
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// @todo Can the sender create it if it doesnt exist?
|
||||
// - Create it, or
|
||||
// - Else record in bad area
|
||||
|
Loading…
Reference in New Issue
Block a user