diff --git a/app/Classes/Protocol.php b/app/Classes/Protocol.php index 2d61b97..4e70779 100644 --- a/app/Classes/Protocol.php +++ b/app/Classes/Protocol.php @@ -6,6 +6,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; 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}; @@ -402,7 +403,7 @@ abstract class Protocol // @todo These flags determine when we connect to the remote. // If the remote indicated that they dont support file requests (NRQ) or temporarily hold them (HRQ) - if (($this->node->optionGet(self::O_NRQ) && (! $this->setup->ignore_nrq)) || $this->node->optionGet(self::O_HRQ)) + if (($this->node->optionGet(self::O_NRQ) && (! $this->setup->optionGet(EMSI::F_IGNORE_NRQ,'emsi_options'))) || $this->node->optionGet(self::O_HRQ)) $rc |= self::S_HOLDR; if ($this->optionGet(self::O_HXT)) diff --git a/app/Classes/Protocol/EMSI.php b/app/Classes/Protocol/EMSI.php index 3804b96..65434c3 100644 --- a/app/Classes/Protocol/EMSI.php +++ b/app/Classes/Protocol/EMSI.php @@ -39,6 +39,13 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface private const NL = "\n"; private const DEL = "\x08"; + /* FEATURES */ + + /** Ignore NRQ */ + public const F_IGNORE_NRQ = 1<<0; + /** Send an immediate EMSI_INQ on connect */ + public const F_DO_PREVENT = 1<<1; + private const EMSI_BUF = 8192; private const TMP_LEN = 1024; @@ -825,6 +832,9 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface if ($this->originate) { $gotreq = 0; + if ($this->setup->optionGet(EMSI::F_DO_PREVENT,'emsi_options')) + $this->capSet(EMSI::F_DO_PREVENT,self::O_YES); + // Send a character to get a response from the remote $t1 = $this->client->timer_set(self::EMSI_HSTIMEOUT); do { @@ -848,8 +858,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface return self::TIMEOUT; if ($this->client->timer_expired($t2)) { - if ($this->setup->do_prevent && $tries === 0) { - $this->setup->do_prevent = 0; + if ($this->capGet(EMSI::F_DO_PREVENT,self::O_YES) && $tries === 0) { + $this->capSet(EMSI::F_DO_PREVENT,self::O_NO); $this->client->buffer_add(self::EMSI_INQ.self::CR); $this->client->buffer_flush(5); diff --git a/app/Models/Setup.php b/app/Models/Setup.php index d8f248e..c57a5d6 100644 --- a/app/Models/Setup.php +++ b/app/Models/Setup.php @@ -37,23 +37,11 @@ class Setup extends Model public const MAX_MSGS_PKT = 50; - // Our non model attributes and values - private array $internal = []; - protected $casts = [ 'options' => 'array', 'servers' => 'array', ]; - public function __construct(array $attributes = []) - { - parent::__construct($attributes); - - /* EMSI SETTINGS */ - $this->do_prevent = 1; /* EMSI - send an immediate EMSI_INQ on connect */ - $this->ignore_nrq = 0; - } - /** * @throws \Exception */ @@ -83,10 +71,6 @@ class Setup extends Model case 'emsi_options': return Arr::get($this->servers,str_replace('_','.',$key)); - case 'ignore_nrq': - case 'do_prevent': - return $this->internal[$key] ?? FALSE; - case 'msgs_pkt': return Arr::get($this->options,$key,self::MAX_MSGS_PKT); @@ -115,11 +99,6 @@ class Setup extends Model case 'emsi_options': return Arr::set($this->servers,str_replace('_','.',$key),$value); - case 'ignore_nrq': - case 'do_prevent': - $this->internal[$key] = $value; - break; - default: parent::__set($key,$value); } diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php index cf02b6d..e71772e 100644 --- a/resources/views/setup.blade.php +++ b/resources/views/setup.blade.php @@ -1,7 +1,7 @@ @php use App\Models\Setup; -use App\Classes\Protocol\Binkp; +use App\Classes\Protocol\{Binkp,EMSI,DNS}; @endphp @extends('layouts.app') @@ -212,6 +212,17 @@ use App\Classes\Protocol\Binkp; emsi_active)) checked @endif> + +