Complete of logging received and sent packet names, and display them in the web ui for each node

This commit is contained in:
2023-07-15 22:10:05 +10:00
parent 61ab0614b6
commit a3302b4012
14 changed files with 257 additions and 121 deletions

View File

@@ -357,6 +357,9 @@ class Message extends FTNBase
case 'errors':
return $this->{$key};
case 'dbid':
return $this->kludge->get($key);
default:
throw new \Exception('Unknown key: '.$key);
}

View File

@@ -36,9 +36,9 @@ class Item
protected const I_RECV = (1<<0);
protected const I_SEND = (1<<1);
protected string $file_name = '';
protected int $file_size = 0;
protected int $file_mtime = 0;
protected string $file_name;
protected int $file_size;
protected int $file_mtime;
/** Current read/write pointer */
protected int $file_pos = 0;
/** File descriptor */
@@ -113,8 +113,27 @@ class Item
{
switch($key) {
case 'mtime':
if ($this instanceof Mail)
$this->youngest()->timestamp;
if ($this->action & self::I_RECV|self::I_SEND)
return $this->{'file_'.$key};
throw new \Exception('Invalid request for key: '.$key);
case 'name':
if ($this instanceof Mail)
return sprintf('%08x',timew($this->youngest()));
if ($this->action & self::I_RECV|self::I_SEND)
return $this->{'file_'.$key};
throw new \Exception('Invalid request for key: '.$key);
case 'size':
if ($this instanceof Mail)
return strlen($this->file);
if ($this->action & self::I_RECV|self::I_SEND)
return $this->{'file_'.$key};
@@ -124,6 +143,9 @@ class Item
return $this->file_name;
case 'sendas':
if ($this instanceof Mail)
return sprintf('%s.pkt',$this->name);
return $this->file_name ? basename($this->file_name) : $this->filemodel->name;
default:

View File

@@ -31,6 +31,7 @@ class Mail extends Item
public function __get($key) {
switch ($key) {
case 'file': return $this->file;
case 'messages': return $this->file->messages;
default:
return parent::__get($key);
}

View File

@@ -41,6 +41,9 @@ final class Send extends Item
public function __get($key)
{
switch ($key) {
case 'dbids':
return $this->sending->messages->pluck('echoarea','dbid');
case 'fd':
return is_resource($this->f) ?: $this->f;
@@ -242,13 +245,15 @@ final class Send extends Item
*/
public function open(string $compress=''): bool
{
Log::debug(sprintf('%s:+ open',self::LOGKEY));
Log::debug(sprintf('%s:+ Opening file to send',self::LOGKEY));
// If we have mail, we'll send that first
if ($this->sending = $this->packets
->filter(function($item) { return ($item->action & self::I_SEND) && $item->sent === FALSE; })
->first())
{
Log::debug(sprintf('%s:- Sending [%s]',self::LOGKEY,$this->sending->name));
$this->file_pos = 0;
$this->start = time();
$this->f = TRUE;

View File

@@ -5,11 +5,13 @@ namespace App\Classes\Protocol;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use League\Flysystem\UnreadableFileEncountered;
use App\Classes\Crypt;
use App\Classes\Protocol as BaseProtocol;
use App\Classes\FTN\Message;
use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Exceptions\FileGrewException;
@@ -991,8 +993,30 @@ final class Binkp extends BaseProtocol
Log::error(sprintf('%s:! M_got[skip] for unknown file [%s]',self::LOGKEY,$buf));
} else {
Log::info(sprintf('%s:= Packet/File [%s] sent.',self::LOGKEY,$this->send->name));
Log::info(sprintf('%s:= Packet/File [%s] sent with [%s].',self::LOGKEY,$this->send->name,$this->send->dbids->join(',')));
$this->sessionClear(self::SE_WAITGOT|self::SE_SENDFILE);
// Update netmail table
if ($x=$this->send->dbids->filter(function($item) { return (! $item); })->keys()->filter())
DB::table('netmails')
->whereIn('id',$x)
->update([
'sent_at'=>Carbon::now(),
'sent_pkt'=>$this->send->name,
'sent_id'=>$this->node->address->id,
'flags'=>DB::raw('flags | '.Message::FLAG_SENT),
]);
// Update echomails table
if ($x=$this->send->dbids->filter(function($item) { return $item; })->keys()->filter())
DB::table('echomail_seenby')
->whereIn('echomail_id',$x)
->where('address_id',$this->node->address->id)
->update([
'sent_at'=>Carbon::now(),
'sent_pkt'=>$this->send->name,
]);
$this->send->close(TRUE);
}
}