Some BINKP optimisation, implemented crypt, implemented receiving compressed transfers

This commit is contained in:
2023-07-02 23:40:08 +10:00
parent f9f9fb5345
commit 6f298d778f
28 changed files with 1614 additions and 904 deletions

View File

@@ -23,24 +23,27 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
use CRCTrait;
private const EMSI_BEG = '**EMSI_';
private const EMSI_ARGUS1 = '-PZT8AF6-';
private const EMSI_DAT = self::EMSI_BEG.'DAT';
private const EMSI_REQ = self::EMSI_BEG.'REQA77E';
private const EMSI_INQ = self::EMSI_BEG.'INQC816';
private const EMSI_ACK = self::EMSI_BEG.'ACKA490';
private const EMSI_NAK = self::EMSI_BEG.'NAKEEC3';
private const EMSI_HBT = self::EMSI_BEG.'HBTEAEE';
/* CONSTS */
private const CR = "\r";
private const NL = "\n";
private const DEL = "\x08";
public const PORT = 60179;
private const EMSI_BEG = '**EMSI_';
private const EMSI_ARGUS1 = '-PZT8AF6-';
private const EMSI_DAT = self::EMSI_BEG.'DAT';
private const EMSI_REQ = self::EMSI_BEG.'REQA77E';
private const EMSI_INQ = self::EMSI_BEG.'INQC816';
private const EMSI_ACK = self::EMSI_BEG.'ACKA490';
private const EMSI_NAK = self::EMSI_BEG.'NAKEEC3';
private const EMSI_HBT = self::EMSI_BEG.'HBTEAEE';
private const EMSI_BUF = 8192;
private const TMP_LEN = 1024;
private const CR = "\r";
private const NL = "\n";
private const DEL = "\x08";
private const SM_INBOUND = 0;
private const SM_OUTBOUND = 1;
private const EMSI_BUF = 8192;
private const TMP_LEN = 1024;
private const SM_INBOUND = 0;
private const SM_OUTBOUND = 1;
private const EMSI_HSTIMEOUT = 60; /* Handshake timeout */
private const EMSI_SEQ_LEN = 14;
@@ -54,6 +57,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
private const EMSI_RESEND_TO = 5;
protected const MO_CHAT = 4;
// Our session status
private int $session;
@@ -84,10 +89,9 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if (! parent::onConnect($client)) {
Log::withContext(['pid'=>getmypid()]);
// @todo Can this be SESSION_EMSI? if so, set an object class value that in EMSI of SESSION_EMSI, and move this method to the parent class
$this->session(self::SESSION_AUTO,$client,(new Address));
$this->client->close();
Log::info(sprintf('%s:= onConnect - Connection closed [%s]',self::LOGKEY,$client->address_remote));
exit(0);
}
@@ -101,7 +105,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/
private function emsi_banner(): void
{
Log::debug(sprintf('%s:+ emsi_banner',self::LOGKEY));
Log::debug(sprintf('%s:+ Showing EMSI banner',self::LOGKEY));
$banner = 'This is a mail only system - unless you are a mailer, you should disconnect :)';
$this->client->buffer_add(self::EMSI_REQ.str_repeat(self::DEL,strlen(self::EMSI_REQ)).$banner.self::CR);
@@ -212,7 +216,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
);
// TRAF - netmail/echomail traffic size (bytes)
$makedata .= sprintf('{TRAF}{%lX %lX}',$this->send->mail_size,$this->send->file_size);
$makedata .= sprintf('{TRAF}{%lX %lX}',$this->send->mail_size,$this->send->size);
// MOH# - Mail On Hold - bytes waiting
$makedata .= sprintf('{MOH#}{[%lX]}',$this->send->mail_size);
@@ -955,6 +959,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/
protected function protocol_session(): int
{
// @todo introduce emsi_init() to perform the job of protocol_init. Only needs to be done when we originate a session
Log::debug(sprintf('%s:+ Starting EMSI Protocol Session',self::LOGKEY));
$was_req = 0;
@@ -1015,7 +1021,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// @todo Lock Node AKAs
Log::info(sprintf('%s: - We have %lu%s mail, %lu%s files',self::LOGKEY,$this->send->mail_size,'b',$this->send->file_size,'b'));
Log::info(sprintf('%s: - We have %lu%s mail, %lu%s files',self::LOGKEY,$this->send->mail_size,'b',$this->send->files_size,'b'));
$proto = $this->originate ? $this->node->optionGet(self::P_MASK) : $this->optionGet(self::P_MASK);