Transfering netmail via EMSI

This commit is contained in:
Deon George
2021-07-17 15:48:07 +10:00
parent 6ce4e64cb6
commit 1fa566b26c
15 changed files with 226 additions and 83 deletions

View File

@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\Protocol as BaseProtocol;
use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Models\Address;
use App\Models\{Address,Setup};
use App\Interfaces\CRC as CRCInterface;
use App\Interfaces\Zmodem as ZmodemInterface;
use App\Traits\CRC as CRCTrait;
@@ -82,7 +82,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if (! parent::onConnect($client)) {
$this->session(self::SESSION_AUTO,$client,(new Address));
$this->client->close();
Log::info(sprintf('%s: = End - Connection closed [%s]',__METHOD__,$client->getAddress()));
Log::info(sprintf('%s: = End - Connection closed [%s]',__METHOD__,$client->address_remote));
}
return NULL;
@@ -191,7 +191,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// Mailer Details
$makedata .= sprintf('{%s}{%s}{%s}{%s}',
self::product_code,
Setup::product_id(),
config('app.name'),
$this->setup->version,
'#000000' // Serial Numbers
@@ -346,7 +346,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
} else {
$this->node->optionSet(self::O_PWD);
Log::info(sprintf('%s: - Remote Authed [%d] AKAs',__METHOD__,$c));
$this->send->add('/tmp/aa');
// Add our mail to the queue if we have authenticated
if ($this->node->aka_authed)
foreach ($this->node->aka_remote as $ao) {
$this->send->mail($ao);
}
}
/* Link codes */
@@ -961,9 +966,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if ($rc < 0)
return (self::S_REDIAL|self::S_ADDTRY);
Log::info(sprintf('%s: - Starting outbound EMSI session to [%s]',__METHOD__,$this->client->getAddress()));
// @todo Lock Node AKAs
Log::info(sprintf('%s: - Starting outbound EMSI session to [%s]',__METHOD__,$this->client->address_remote));
// Inbound session
} else {
@@ -975,9 +978,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
return (self::S_REDIAL|self::S_ADDTRY);
}
Log::info(sprintf('%s: - Starting inbound EMSI session from [%s]',__METHOD__,$this->client->getAddress()));
// @todo Lock Node AKAs
Log::info(sprintf('%s: - Starting inbound EMSI session from [%s]',__METHOD__,$this->client->address_remote));
if ($this->node->aka_authed) {
$xproto = $this->is_freq_available();
@@ -1003,6 +1004,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
return (self::S_REDIAL|self::S_ADDTRY);
}
// @todo Lock Node AKAs
Log::info(sprintf('%s: - We have %lu%s mail, %lu%s files',__METHOD__,$this->send->mail_size,'b',$this->send->file_size,'b'));
$proto = $this->originate ? $this->node->optionGet(self::P_MASK) : $this->optionGet(self::P_MASK);
@@ -1172,6 +1175,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if (! $z->zmodem_sendinit($this->client,$zap) && $this->send->total_count)
$z->zmodem_sendfile($this->send);
Log::debug(sprintf('%s: - Finished sending',__METHOD__));
return ($z->zmodem_senddone()<0);
}
}

View File

@@ -500,29 +500,31 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
{
Log::debug(sprintf('%s: + Start',__METHOD__));
try {
$send->open();
$rc = $this->ls_zsendfile($send,$this->ls_SerialNum++,$send->total_count,$send->total_size);
while ($send->total_count && $send->open()) {
try {
$rc = $this->ls_zsendfile($send,$this->ls_SerialNum++,$send->total_count,$send->total_size);
switch ($rc) {
case self::LSZ_OK:
$send->close(TRUE);
switch ($rc) {
case self::LSZ_OK:
$send->close(TRUE);
break;
case self::ZSKIP:
case self::ZFERR:
$send->close(FALSE);
break;
case self::ZSKIP:
case self::ZFERR:
$send->close(FALSE);
break;
default:
$send->close(FALSE);
$this->ls_zabort();
break;
default:
$send->close(FALSE);
$this->ls_zabort();
break;
}
return $rc;
} catch (\Exception $e) {
Log::error(sprintf('%s: ! Error [%s]',__METHOD__,$e->getMessage()));
}
return $rc;
} catch (\Exception $e) {
Log::error(sprintf('%s: ! Error [%s]',__METHOD__,$e->getMessage()));
}
return self::OK;