Enable full setup on the setup form

This commit is contained in:
Deon George 2023-07-05 22:42:59 +10:00
parent 6f298d778f
commit c3d4c1fc31
8 changed files with 89 additions and 88 deletions

View File

@ -179,9 +179,9 @@ final class Binkp extends BaseProtocol
$this->msgs(self::BPM_NUL,sprintf('OPT CRAM-MD5-%s',md5($random_key))); $this->msgs(self::BPM_NUL,sprintf('OPT CRAM-MD5-%s',md5($random_key)));
} }
$this->msgs(self::BPM_NUL,sprintf('SYS %s',$this->setup->system_name)); $this->msgs(self::BPM_NUL,sprintf('SYS %s',$this->setup->system->name));
$this->msgs(self::BPM_NUL,sprintf('ZYZ %s',$this->setup->sysop)); $this->msgs(self::BPM_NUL,sprintf('ZYZ %s',$this->setup->system->sysop));
$this->msgs(self::BPM_NUL,sprintf('LOC %s',$this->setup->location)); $this->msgs(self::BPM_NUL,sprintf('LOC %s',$this->setup->system->location));
$this->msgs(self::BPM_NUL,sprintf('NDL %d,TCP,BINKP',$this->client->speed)); $this->msgs(self::BPM_NUL,sprintf('NDL %d,TCP,BINKP',$this->client->speed));
$this->msgs(self::BPM_NUL,sprintf('TIME %s',Carbon::now()->toRfc2822String())); $this->msgs(self::BPM_NUL,sprintf('TIME %s',Carbon::now()->toRfc2822String()));
$this->msgs(self::BPM_NUL, $this->msgs(self::BPM_NUL,

View File

@ -209,9 +209,9 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// System Details // System Details
$makedata .= sprintf('{IDENT}{[%s][%s][%s][-Unpublished-][38400][%s]}', $makedata .= sprintf('{IDENT}{[%s][%s][%s][-Unpublished-][38400][%s]}',
$this->setup->system_name, $this->setup->system->name,
$this->setup->location, $this->setup->system->location,
$this->setup->sysop, $this->setup->system->sysop,
'XA' // Nodelist Flags 'XA' // Nodelist Flags
); );

View File

@ -157,25 +157,39 @@ class HomeController extends Controller
$o = Setup::findOrNew(config('app.id')); $o = Setup::findOrNew(config('app.id'));
if ($request->post()) { if ($request->post()) {
if (! $o->exists) { if (! $o->exists)
$o->id = config('app.id'); $o->id = config('app.id');
$o->zmodem = 0;
$o->emsi_protocols = 0;
$o->protocols = 0;
$o->permissions = 0;
}
$servers = collect(); $servers = collect();
$options = collect();
$binkp = collect(); $x = collect();
$binkp->put('options',collect($request->post('binkp'))->sum()); $x->put('options',collect($request->post('binkp'))->sum());
$binkp->put('port',$request->post('binkp_port')); $x->put('port',$request->post('binkp_port'));
$binkp->put('bind',$request->post('binkp_bind')); $x->put('bind',$request->post('binkp_bind'));
$servers->put('binkp',$binkp); $x->put('active',(bool)$request->post('binkp_active'));
$servers->put('binkp',$x);
$x = collect();
$x->put('options',collect($request->post('emsi'))->sum());
$x->put('port',$request->post('emsi_port'));
$x->put('bind',$request->post('emsi_bind'));
$x->put('active',(bool)$request->post('emsi_active'));
$servers->put('emsi',$x);
$x = collect();
$x->put('options',collect($request->post('dns'))->sum());
$x->put('port',$request->post('dns_port'));
$x->put('bind',$request->post('dns_bind'));
$x->put('active',(bool)$request->post('dns_active'));
$servers->put('dns',$x);
$options->put('options',collect($request->post('options'))->sum());
$options->put('msgs_pkt',$request->post('msgs_pkt'));
$o->options = collect($request->post('options'))->sum();
$o->system_id = $request->post('system_id');
$o->servers = $servers; $o->servers = $servers;
$o->options = $options;
$o->system_id = $request->post('system_id');
$o->save(); $o->save();
} }

View File

@ -22,12 +22,13 @@ class SetupRequest extends FormRequest
'system_id' => 'required|exists:systems,id', 'system_id' => 'required|exists:systems,id',
'binkp' => 'nullable|array', 'binkp' => 'nullable|array',
'binkp.*' => 'nullable|numeric', 'binkp.*' => 'nullable|numeric',
//'dns' => 'required|array', 'dns' => 'nullable|array',
'dns.*' => 'nullable|numeric', 'dns.*' => 'nullable|numeric',
//'emsi' => 'required|array', 'emsi' => 'nullable|array',
'emsi.*' => 'nullable|numeric', 'emsi.*' => 'nullable|numeric',
'*_bind' => 'required|ip', '*_bind' => 'required|ip',
'*_port' => 'required|numeric', '*_port' => 'required|numeric',
'*_active' => 'nullable|accepted',
'options' => 'nullable|array', 'options' => 'nullable|array',
'options.*' => 'nullable|numeric', 'options.*' => 'nullable|numeric',
]; ];

View File

@ -582,8 +582,8 @@ class Address extends Model
// Limit to max messages // Limit to max messages
Log::info(sprintf('%s:= Got [%d] echomails for [%s] for sending',self::LOGKEY,$x->count(),$this->ftn)); Log::info(sprintf('%s:= Got [%d] echomails for [%s] for sending',self::LOGKEY,$x->count(),$this->ftn));
if ($x->count() > $s->max_msgs_pkt) { if ($x->count() > $s->msgs_pkt) {
$x = $x->take($s->max_msgs_pkt); $x = $x->take($s->msgs_pkt);
Log::alert(sprintf('%s:= Only sending [%d] echomails for [%s]',self::LOGKEY,$x->count(),$this->ftn)); Log::alert(sprintf('%s:= Only sending [%d] echomails for [%s]',self::LOGKEY,$x->count(),$this->ftn));
} }
@ -678,7 +678,7 @@ class Address extends Model
$c = 0; $c = 0;
foreach ($msgs as $oo) { foreach ($msgs as $oo) {
// Only bundle up to max messages // Only bundle up to max messages
if (++$c > $s->max_msgs_pkt) if (++$c > $s->msgs_pkt)
break; break;
$o->addMail($oo->packet($this)); $o->addMail($oo->packet($this));

View File

@ -41,6 +41,7 @@ class Setup extends Model
private array $internal = []; private array $internal = [];
protected $casts = [ protected $casts = [
'options' => 'array',
'servers' => 'array', 'servers' => 'array',
]; ];
@ -51,7 +52,6 @@ class Setup extends Model
/* EMSI SETTINGS */ /* EMSI SETTINGS */
$this->do_prevent = 1; /* EMSI - send an immediate EMSI_INQ on connect */ $this->do_prevent = 1; /* EMSI - send an immediate EMSI_INQ on connect */
$this->ignore_nrq = 0; $this->ignore_nrq = 0;
$this->options = 0; /* EMSI - our capabilities */
} }
/** /**
@ -72,18 +72,23 @@ class Setup extends Model
case 'emsi_port': case 'emsi_port':
return Arr::get($this->servers,str_replace('_','.',$key),DNS::PORT); return Arr::get($this->servers,str_replace('_','.',$key),DNS::PORT);
case 'options_options':
return Arr::get($this->options,'options');
case 'binkp_active':
case 'dns_active':
case 'emsi_active':
case 'binkp_options': case 'binkp_options':
case 'dns_options': case 'dns_options':
case 'emsi_options': case 'emsi_options':
return Arr::get($this->servers,'binkp.options'); return Arr::get($this->servers,str_replace('_','.',$key));
case 'binkp_settings':
case 'ignore_nrq': case 'ignore_nrq':
case 'do_prevent': case 'do_prevent':
return $this->internal[$key] ?? FALSE; return $this->internal[$key] ?? FALSE;
case 'max_msgs_pkt': case 'msgs_pkt':
return self::MAX_MSGS_PKT; return Arr::get($this->options,$key,self::MAX_MSGS_PKT);
case 'version': case 'version':
return File::exists('VERSION') ? chop(File::get('VERSION')) : 'dev'; return File::exists('VERSION') ? chop(File::get('VERSION')) : 'dev';
@ -110,16 +115,7 @@ 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 'binkp_settings':
case 'ignore_nrq': case 'ignore_nrq':
case 'opt_nr':
case 'opt_nd':
case 'opt_nda':
case 'opt_md':
case 'opt_cr':
case 'opt_mb':
case 'opt_cht':
case 'opt_mpwd':
case 'do_prevent': case 'do_prevent':
$this->internal[$key] = $value; $this->internal[$key] = $value;
break; break;
@ -153,23 +149,6 @@ class Setup extends Model
return $this->belongsTo(System::class); return $this->belongsTo(System::class);
} }
/* ATTRIBUTES */
public function getLocationAttribute()
{
return $this->system->location;
}
public function getSysopAttribute()
{
return $this->system->sysop;
}
public function getSystemNameAttribute()
{
return $this->system->name;
}
/* METHODS */ /* METHODS */
public function optionClear(int $key,$index='options'): void public function optionClear(int $key,$index='options'): void

View File

@ -13,6 +13,11 @@ return new class extends Migration
{ {
Schema::table('setups',function (Blueprint $table) { Schema::table('setups',function (Blueprint $table) {
$table->jsonb('servers')->nullable(); $table->jsonb('servers')->nullable();
$table->dropColumn(['binkp','zmodem','permissions','protocols','options','emsi_protocols']);
});
Schema::table('setups',function (Blueprint $table) {
$table->jsonb('options')->nullable();
}); });
} }
@ -21,8 +26,17 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::table('setups',function (Blueprint $table) {
$table->dropColumn(['options']);
});
Schema::table('setups',function (Blueprint $table) { Schema::table('setups',function (Blueprint $table) {
$table->dropColumn(['servers']); $table->dropColumn(['servers']);
$table->integer('binkp')->nullable();
$table->integer('zmodem')->nullable();
$table->integer('permissions')->nullable();
$table->integer('protocols')->nullable();
$table->integer('emsi_protocols')->nullable();
$table->integer('options')->nullable();
}); });
} }
}; };

View File

@ -79,7 +79,7 @@ use App\Classes\Protocol\Binkp;
<h3>Site Permissions</h3> <h3>Site Permissions</h3>
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="hideaka" name="options[hideaka]" value="{{ Setup::O_HIDEAKA }}" @if(old('options.hideaka',$o->optionGet(Setup::O_HIDEAKA))) checked @endif> <input class="form-check-input" type="checkbox" id="hideaka" name="options[hideaka]" value="{{ old('options.hideaka',$o->hideaka ?: Setup::O_HIDEAKA) }}" @if(old('options.hideaka',$o->optionGet(Setup::O_HIDEAKA,'options_options'))) checked @endif>
<label class="form-check-label" for="hideaka">Hide AKA to different Domains</label> <label class="form-check-label" for="hideaka">Hide AKA to different Domains</label>
</div> </div>
</div> </div>
@ -124,69 +124,62 @@ use App\Classes\Protocol\Binkp;
</div> </div>
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="startbinkd" name="options[binkd]" value="{{ Setup::O_BINKP }}" @if(old('options.binkd',$o->optionGet(Setup::O_BINKP))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_active" name="binkp_active" value="1" @if(old('binkp_active',$o->binkp_active)) checked @endif>
<label class="form-check-label" for="startbinkd">Listen for BINKP connections</label> <label class="form-check-label" for="binkp_active">Listen for BINKP connections</label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_cht" name="binkp[cht]" value="{{ Binkp::F_CHAT }}" @if(old('binkp.cht',$o->optionGet(Binkp::F_CHAT,'binkp_options'))) checked @endif disabled> <input class="form-check-input" type="checkbox" id="binkp_chat" name="binkp[cht]" value="{{ Binkp::F_CHAT }}" @if(old('binkp.cht',$o->optionGet(Binkp::F_CHAT,'binkp_options'))) checked @endif disabled>
<label class="form-check-label" for="opt_cht">Chat Mode <sup>not implemented</sup></label> <label class="form-check-label" for="binkp_chat">Chat Mode <sup>not implemented</sup></label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_comp" name="binkp[comp]" value="{{ Binkp::F_COMP }}" @if(old('binkp.comp',$o->optionGet(Binkp::F_COMP,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_comp" name="binkp[comp]" value="{{ Binkp::F_COMP }}" @if(old('binkp.comp',$o->optionGet(Binkp::F_COMP,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_comp">Compression Enabled <sup>*</sup></label> <label class="form-check-label" for="binkp_comp">Compression Enabled <sup>*</sup></label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_md" name="binkp[md]" value="{{ Binkp::F_MD }}" @if(old('binkp.md',$o->optionGet(Binkp::F_MD,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_md" name="binkp[md]" value="{{ Binkp::F_MD }}" @if(old('binkp.md',$o->optionGet(Binkp::F_MD,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_md">CRAM-MD5 Mode <sup>*</sup></label> <label class="form-check-label" for="binkp_md">CRAM-MD5 Mode <sup>*</sup></label>
</div> </div>
<!-- @todo Force turning off this toggle, if md5 is not selected --> <!-- @todo Force turning off this toggle, if md5 is not selected -->
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_mdforce" name="binkp[mdforce]" value="{{ Binkp::F_MDFORCE }}" @if(old('binkp.mdforce',$o->optionGet(Binkp::F_MDFORCE,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_mdforce" name="binkp[mdforce]" value="{{ Binkp::F_MDFORCE }}" @if(old('binkp.mdforce',$o->optionGet(Binkp::F_MDFORCE,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_mdforce">No Plaintext Passwords</label> <label class="form-check-label" for="binkp_mdforce">No Plaintext Passwords</label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_cr" name="binkp[cr]" value="{{ Binkp::F_CRYPT }}" @if(old('binkp.cr',$o->optionGet(Binkp::F_CRYPT,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_crypt" name="binkp[cr]" value="{{ Binkp::F_CRYPT }}" @if(old('binkp.cr',$o->optionGet(Binkp::F_CRYPT,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_cr">Crypt mode <sup>*</sup></label> <label class="form-check-label" for="binkp_crypt">Crypt mode <sup>*</sup></label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_mb" name="binkp[mb]" value="{{ Binkp::F_MULTIBATCH }}" @if(old('binkp.mb',$o->optionGet(Binkp::F_MULTIBATCH,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_mb" name="binkp[mb]" value="{{ Binkp::F_MULTIBATCH }}" @if(old('binkp.mb',$o->optionGet(Binkp::F_MULTIBATCH,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_mb">Multi-Batch mode <sup>*</sup></label> <label class="form-check-label" for="binkp_mb">Multi-Batch mode <sup>*</sup></label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_mpwd" name="binkp[mpwd]" value="{{ Binkp::F_MULTIPASS }}" @if(old('binkp.mpwd',$o->optionGet(Binkp::F_MULTIPASS,'binkp_options'))) checked @endif disabled> <input class="form-check-input" type="checkbox" id="binkp_mpwd" name="binkp[mpwd]" value="{{ Binkp::F_MULTIPASS }}" @if(old('binkp.mpwd',$o->optionGet(Binkp::F_MULTIPASS,'binkp_options'))) checked @endif disabled>
<label class="form-check-label" for="opt_mpwd">Multi-Password Mode <sup>not implemented</sup></label> <label class="form-check-label" for="binkp_mpwd">Multi-Password Mode <sup>not implemented</sup></label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_nd" name="binkp[nd]" value="{{ Binkp::F_NODUPE }}" @if(old('binkp.nd',$o->optionGet(Binkp::F_NODUPE,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_nd" name="binkp[nd]" value="{{ Binkp::F_NODUPE }}" @if(old('binkp.nd',$o->optionGet(Binkp::F_NODUPE,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_nd">No Dupes Mode</label> <label class="form-check-label" for="binkp_nd">No Dupes Mode</label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_nda" name="binkp[nda]" value="{{ Binkp::F_NODUPEA }}" @if(old('binkp.nda',$o->optionGet(Binkp::F_NODUPEA,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_nda" name="binkp[nda]" value="{{ Binkp::F_NODUPEA }}" @if(old('binkp.nda',$o->optionGet(Binkp::F_NODUPEA,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_nda">No Dupes Mode - Asymmetric</label> <label class="form-check-label" for="binkp_nda">No Dupes Mode - Asymmetric</label>
</div> </div>
<div class="mt-1 form-check form-switch"> <div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="opt_nr" name="binkp[nr]" value="{{ Binkp::F_NOREL }}" @if(old('binkp.nr',$o->optionGet(Binkp::F_NOREL,'binkp_options'))) checked @endif> <input class="form-check-input" type="checkbox" id="binkp_nr" name="binkp[nr]" value="{{ Binkp::F_NOREL }}" @if(old('binkp.nr',$o->optionGet(Binkp::F_NOREL,'binkp_options'))) checked @endif>
<label class="form-check-label" for="opt_nr">Non-Reliable Mode <sup>*</sup></label> <label class="form-check-label" for="binkp_nr">Non-Reliable Mode <sup>*</sup></label>
</div> </div>
<p class="pt-3"><sup>*</sup> Recommended Defaults</p> <p class="pt-3"><sup>*</sup> Recommended Defaults</p>
<!-- @todo What's this for again? -->
<table class="table monotable">
{{--
$this->binkp_options = ['m','d','r','b'];
--}}
</table>
</div> </div>
</div> </div>
</div> </div>
@ -216,7 +209,7 @@ use App\Classes\Protocol\Binkp;
</div> </div>
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="startemsi" name="options[emsi]" value="{{ Setup::O_EMSI }}" @if(old('options.emsi',$o->optionGet(Setup::O_EMSI))) 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> </div>
@ -245,7 +238,7 @@ use App\Classes\Protocol\Binkp;
</div> </div>
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="startdns" name="options[dns]" value="{{ Setup::O_DNS }}" @if(old('options.dns',$o->optionGet(Setup::O_DNS))) checked @endif> <input class="form-check-input" type="checkbox" id="startdns" name="dns_active" value="1" @if(old('dns_active',$o->dns_active)) checked @endif>
<label class="form-check-label" for="startdns">Listen for DNS connections</label> <label class="form-check-label" for="startdns">Listen for DNS connections</label>
</div> </div>
</div> </div>
@ -260,7 +253,7 @@ use App\Classes\Protocol\Binkp;
<div class="form-group row pt-0"> <div class="form-group row pt-0">
<div class="col-2"> <div class="col-2">
<input class="form-control text-end" type="text" id="msgs_pkt" name="msgs_pkt" value="{{ old('msgs_pkt',$o->max_msgs_pkt) }}" disabled> <input class="form-control text-end" type="text" id="msgs_pkt" name="msgs_pkt" value="{{ old('msgs_pkt',$o->msgs_pkt ?: Setup::MAX_MSGS_PKT) }}">
</div> </div>
<div class="col-10"> <div class="col-10">
<label class="col-form-label pt-2" for="msgs_pkt">Max Messages per Packet</label> <label class="col-form-label pt-2" for="msgs_pkt">Max Messages per Packet</label>