Now correctly showing packet receive time, and sending Notifications based on the packet address, not the node address

This commit is contained in:
2023-08-05 21:32:45 +10:00
parent c8a2affbfa
commit 74a56d1e17
9 changed files with 74 additions and 24 deletions

View File

@@ -23,14 +23,18 @@ class MessageProcess implements ShouldQueue
private Address $sender;
private Message $msg;
private Address $pktsrc;
private Carbon $recvtime;
private bool $skipbot;
private string $packet;
public function __construct(Message $msg,string $packet,Address $sender,bool $skipbot=FALSE)
public function __construct(Message $msg,string $packet,Address $sender,Address $pktsrc,Carbon $recvtime,bool $skipbot=FALSE)
{
$this->msg = $msg;
$this->packet = $packet;
$this->sender = $sender;
$this->pktsrc = $pktsrc;
$this->recvtime = $recvtime;
$this->skipbot = $skipbot;
}
@@ -111,6 +115,7 @@ class MessageProcess implements ShouldQueue
$o->set_pkt = $this->packet;
$o->set_sender = $this->sender;
$o->set_path = $this->msg->pathaddress;
$o->set_recvtime = $this->recvtime;
// Strip any local/transit flags
$o->flags &= ~(Message::FLAG_LOCAL|Message::FLAG_INTRANSIT);
@@ -222,7 +227,7 @@ class MessageProcess implements ShouldQueue
if (! $ea) {
Log::alert(sprintf('%s:! Echoarea [%s] doesnt exist for zone [%d]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->zone_id));
Notification::route('netmail',$this->sender)->notify(new EchoareaNotExist($this->msg));
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotExist($this->msg));
return;
}
@@ -281,14 +286,14 @@ class MessageProcess implements ShouldQueue
// @todo Can the sender create it if it doesnt exist?
// Can the system send messages to this area?
if (! $ea->sec_write || ($this->sender->security < $ea->sec_write)) {
Notification::route('netmail',$this->sender)->notify(new EchoareaNoWrite($this->msg));
if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) {
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNoWrite($this->msg));
return;
}
// If the node is not subsccribed
if ($this->sender->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE)
Notification::route('netmail',$this->sender)->notify(new EchoareaNotSubscribed($this->msg));
// If the node is not subscribed
if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE)
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg));
// We know about this area, store it
$o = new Echomail;
@@ -312,6 +317,7 @@ class MessageProcess implements ShouldQueue
$o->rogue_path = $this->msg->rogue_path;
$o->set_path = $this->msg->pathaddress;
$o->set_seenby = $this->msg->seenaddress;
$o->set_recvtime = $this->recvtime;
// Record receiving packet and sender
$o->set_pkt = $this->packet;