Integrate Mailer::class into System_Log::class, removed Zmodem Server/Client

This commit is contained in:
2023-12-10 19:07:53 +11:00
parent 8fc0336314
commit 0526500ff0
10 changed files with 71 additions and 139 deletions

View File

@@ -9,7 +9,7 @@ use App\Classes\File\{Receive,Send};
use App\Classes\Protocol\EMSI;
use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Models\{Address,Setup,System,SystemLog};
use App\Models\{Address,Mailer,Setup,System,SystemLog};
abstract class Protocol
{
@@ -26,16 +26,6 @@ abstract class Protocol
protected const RCDO = -3;
protected const ERROR = -5;
// Our sessions Types
/** @deprecated use Mailer::class */
public const SESSION_AUTO = 0;
/** @deprecated Use mailers:class */
public const SESSION_EMSI = 1;
/** @deprecated Use mailers:class */
public const SESSION_BINKP = 2;
/** @deprecated Use mailers:class */
public const SESSION_ZMODEM = 3;
protected const MAX_PATH = 1024;
/* O_ options - [First 9 bits are protocol P_* (Interfaces/ZModem)] */
@@ -331,13 +321,13 @@ abstract class Protocol
/**
* Initialise our Session
*
* @param int $type
* @param Mailer $mo
* @param SocketClient $client
* @param Address|null $o
* @return int
* @throws \Exception
*/
public function session(int $type,SocketClient $client,Address $o=NULL): int
public function session(Mailer $mo,SocketClient $client,Address $o=NULL): int
{
if ($o->exists)
Log::withContext(['ftn'=>$o->ftn]);
@@ -371,10 +361,9 @@ abstract class Protocol
$this->optionSet(self::O_TCP);
$this->setClient($client);
switch ($type) {
/** @noinspection PhpMissingBreakStatementInspection */
case self::SESSION_AUTO:
Log::debug(sprintf('%s:- Trying EMSI',self::LOGKEY));
switch ($mo->name) {
case 'EMSI':
Log::debug(sprintf('%s:- Starting EMSI',self::LOGKEY));
$rc = $this->protocol_init();
if ($rc < 0) {
@@ -383,27 +372,19 @@ abstract class Protocol
return self::S_FAILURE;
}
case self::SESSION_EMSI:
Log::debug(sprintf('%s:- Starting EMSI',self::LOGKEY));
$rc = $this->protocol_session($this->originate);
break;
case self::SESSION_BINKP:
case 'BINKP':
Log::debug(sprintf('%s:- Starting BINKP',self::LOGKEY));
$rc = $this->protocol_session($this->originate);
break;
case self::SESSION_ZMODEM:
Log::debug(sprintf('%s:- Starting ZMODEM',self::LOGKEY));
$this->client->speed = self::TCP_SPEED;
$this->originate = FALSE;
return $this->protocol_session($this->originate);
default:
Log::error(sprintf('%s:! Unsupported session type [%d]',self::LOGKEY,$type));
Log::error(sprintf('%s:! Unsupported session type [%d]',self::LOGKEY,$mo->id));
return self::S_FAILURE;
}
@@ -448,7 +429,7 @@ abstract class Protocol
$slo->items_sent_size = $this->send->total_sent_bytes;
$slo->items_recv = $this->recv->total_recv;
$slo->items_recv_size = $this->recv->total_recv_bytes;
$slo->sessiontype = $type;
$slo->mailer_id = $mo->id;
$slo->sessiontime = $this->node->session_time;
$slo->result = ($rc & self::S_MASK);
$slo->originate = $this->originate;