Enabled configuration of EMSI tunables in setup

This commit is contained in:
Deon George 2023-07-06 09:20:33 +10:00
parent c3d4c1fc31
commit 0f7a42c503
4 changed files with 26 additions and 25 deletions

View File

@ -6,6 +6,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\File\{Receive,Send}; use App\Classes\File\{Receive,Send};
use App\Classes\Protocol\EMSI;
use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException; use App\Classes\Sock\SocketException;
use App\Models\{Address,Setup,System,SystemLog}; use App\Models\{Address,Setup,System,SystemLog};
@ -402,7 +403,7 @@ abstract class Protocol
// @todo These flags determine when we connect to the remote. // @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 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; $rc |= self::S_HOLDR;
if ($this->optionGet(self::O_HXT)) if ($this->optionGet(self::O_HXT))

View File

@ -39,6 +39,13 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
private const NL = "\n"; private const NL = "\n";
private const DEL = "\x08"; 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 EMSI_BUF = 8192;
private const TMP_LEN = 1024; private const TMP_LEN = 1024;
@ -825,6 +832,9 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if ($this->originate) { if ($this->originate) {
$gotreq = 0; $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 // Send a character to get a response from the remote
$t1 = $this->client->timer_set(self::EMSI_HSTIMEOUT); $t1 = $this->client->timer_set(self::EMSI_HSTIMEOUT);
do { do {
@ -848,8 +858,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
return self::TIMEOUT; return self::TIMEOUT;
if ($this->client->timer_expired($t2)) { if ($this->client->timer_expired($t2)) {
if ($this->setup->do_prevent && $tries === 0) { if ($this->capGet(EMSI::F_DO_PREVENT,self::O_YES) && $tries === 0) {
$this->setup->do_prevent = 0; $this->capSet(EMSI::F_DO_PREVENT,self::O_NO);
$this->client->buffer_add(self::EMSI_INQ.self::CR); $this->client->buffer_add(self::EMSI_INQ.self::CR);
$this->client->buffer_flush(5); $this->client->buffer_flush(5);

View File

@ -37,23 +37,11 @@ class Setup extends Model
public const MAX_MSGS_PKT = 50; public const MAX_MSGS_PKT = 50;
// Our non model attributes and values
private array $internal = [];
protected $casts = [ protected $casts = [
'options' => 'array', 'options' => 'array',
'servers' => '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 * @throws \Exception
*/ */
@ -83,10 +71,6 @@ class Setup extends Model
case 'emsi_options': case 'emsi_options':
return Arr::get($this->servers,str_replace('_','.',$key)); return Arr::get($this->servers,str_replace('_','.',$key));
case 'ignore_nrq':
case 'do_prevent':
return $this->internal[$key] ?? FALSE;
case 'msgs_pkt': case 'msgs_pkt':
return Arr::get($this->options,$key,self::MAX_MSGS_PKT); return Arr::get($this->options,$key,self::MAX_MSGS_PKT);
@ -115,11 +99,6 @@ class Setup extends Model
case 'emsi_options': case 'emsi_options':
return Arr::set($this->servers,str_replace('_','.',$key),$value); return Arr::set($this->servers,str_replace('_','.',$key),$value);
case 'ignore_nrq':
case 'do_prevent':
$this->internal[$key] = $value;
break;
default: default:
parent::__set($key,$value); parent::__set($key,$value);
} }

View File

@ -1,7 +1,7 @@
<!-- $o = Setup::class --> <!-- $o = Setup::class -->
@php @php
use App\Models\Setup; use App\Models\Setup;
use App\Classes\Protocol\Binkp; use App\Classes\Protocol\{Binkp,EMSI,DNS};
@endphp @endphp
@extends('layouts.app') @extends('layouts.app')
@ -212,6 +212,17 @@ use App\Classes\Protocol\Binkp;
<input class="form-check-input" type="checkbox" id="startemsi" name="emsi_active" value="1" @if(old('emsi_active',$o->emsi_active)) checked @endif> <input class="form-check-input" type="checkbox" id="startemsi" name="emsi_active" value="1" @if(old('emsi_active',$o->emsi_active)) checked @endif>
<label class="form-check-label" for="startemsi">Listen for EMSI connections</label> <label class="form-check-label" for="startemsi">Listen for EMSI connections</label>
</div> </div>
<div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="emsi_nrq" name="emsi[nrq]" value="{{ EMSI::F_IGNORE_NRQ }}" @if(old('emsi.nrq',$o->optionGet(EMSI::F_IGNORE_NRQ,'emsi_options'))) checked @endif>
<label class="form-check-label" for="emsi_nrq">Ignore NRQ</label>
</div>
<div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="emsi_doprevent" name="emsi[doprevent]" value="{{ EMSI::F_DO_PREVENT }}" @if(old('emsi.doprevent',$o->optionGet(EMSI::F_DO_PREVENT,'emsi_options'))) checked @endif>
<label class="form-check-label" for="emsi_doprevent">Send an EMSI_INQ on connect</label>
</div>
</div> </div>
</div> </div>