Enable systems to configure their packet type
This commit is contained in:
parent
a26f61d75d
commit
75549590fc
@ -22,11 +22,11 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
private const BLOCKSIZE = 1024;
|
private const BLOCKSIZE = 1024;
|
||||||
protected const PACKED_MSG_LEAD = "\02\00";
|
protected const PACKED_MSG_LEAD = "\02\00";
|
||||||
|
|
||||||
private const PACKET_TYPES = [
|
public const PACKET_TYPES = [
|
||||||
FTNBase\Packet\FSC45::class,
|
'2.2' => FTNBase\Packet\FSC45::class,
|
||||||
FTNBase\Packet\FSC48::class,
|
'2+' => FTNBase\Packet\FSC48::class,
|
||||||
FTNBase\Packet\FSC39::class,
|
'2e' => FTNBase\Packet\FSC39::class,
|
||||||
FTNBase\Packet\FTS1::class,
|
'2.0' => FTNBase\Packet\FTS1::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected array $header; // Packet Header
|
protected array $header; // Packet Header
|
||||||
|
@ -276,7 +276,7 @@ class SystemController extends Controller
|
|||||||
$this->authorize('update',$o);
|
$this->authorize('update',$o);
|
||||||
|
|
||||||
if ($request->post()) {
|
if ($request->post()) {
|
||||||
foreach (['name','location','sysop','hold','phone','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id'] as $key)
|
foreach (['name','location','sysop','hold','phone','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id','pkt_type'] as $key)
|
||||||
$o->{$key} = $request->post($key);
|
$o->{$key} = $request->post($key);
|
||||||
|
|
||||||
$o->save();
|
$o->save();
|
||||||
|
@ -5,7 +5,9 @@ namespace App\Http\Requests;
|
|||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Packet;
|
||||||
use App\Models\System;
|
use App\Models\System;
|
||||||
|
|
||||||
class SystemRegister extends FormRequest
|
class SystemRegister extends FormRequest
|
||||||
@ -48,7 +50,6 @@ class SystemRegister extends FormRequest
|
|||||||
],
|
],
|
||||||
($this->so->exists || ($request->action !== 'create')) ? [
|
($this->so->exists || ($request->action !== 'create')) ? [
|
||||||
'location' => 'required|min:3',
|
'location' => 'required|min:3',
|
||||||
|
|
||||||
'sysop' => 'required|min:3',
|
'sysop' => 'required|min:3',
|
||||||
'phone' => 'nullable|regex:/^([0-9-]+)$/',
|
'phone' => 'nullable|regex:/^([0-9-]+)$/',
|
||||||
'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
||||||
@ -58,6 +59,7 @@ class SystemRegister extends FormRequest
|
|||||||
'mailer_address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
'mailer_address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
||||||
'mailer_port' => 'nullable|digits_between:2,5',
|
'mailer_port' => 'nullable|digits_between:2,5',
|
||||||
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($this->so->exists ? $this->so->id : 0),
|
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($this->so->exists ? $this->so->id : 0),
|
||||||
|
'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))],
|
||||||
] : [],
|
] : [],
|
||||||
$this->so->exists ? [
|
$this->so->exists ? [
|
||||||
'active' => 'required|boolean',
|
'active' => 'required|boolean',
|
||||||
|
@ -650,8 +650,9 @@ class Address extends Model
|
|||||||
if (! $ao)
|
if (! $ao)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// @todo make packet type configurable by each system
|
// Get packet type
|
||||||
$o = new Packet\FSC48;
|
$type = collect(Packet::PACKET_TYPES)->get($this->system->pkt_type ?: config('app.default_pkt'));
|
||||||
|
$o = new $type;
|
||||||
$o->addressHeader($ao,$this);
|
$o->addressHeader($ao,$this);
|
||||||
|
|
||||||
// $oo = Netmail/Echomail Model
|
// $oo = Netmail/Echomail Model
|
||||||
|
@ -20,6 +20,7 @@ return [
|
|||||||
|
|
||||||
// Number of messages in a packet that will result in them being queued for processing
|
// Number of messages in a packet that will result in them being queued for processing
|
||||||
'queue_msgs' => env('FIDO_QUEUE_MSGS', 50),
|
'queue_msgs' => env('FIDO_QUEUE_MSGS', 50),
|
||||||
|
'default_pkt' => env('FIDO_DEFAULT_PACKET', '2+'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -29,6 +29,8 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
//
|
Schema::table('files',function (Blueprint $table) {
|
||||||
|
$table->dropUnique(['filearea_id','name']);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
28
database/migrations/2023_06_26_185441_node_packet_type.php
Normal file
28
database/migrations/2023_06_26_185441_node_packet_type.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('systems',function (Blueprint $table) {
|
||||||
|
$table->string('pkt_type')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('systems',function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['pkt_type']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -151,6 +151,24 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-2">
|
||||||
|
<label for="pkt_type" class="form-label">Mail Packet</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text"><i class="bi bi-wifi"></i></span>
|
||||||
|
<select class="form-select @error('pkt_type') is-invalid @enderror" id="pkt_type" name="pkt_type" @cannot($action,$o)readonly @endcannot>
|
||||||
|
@foreach (\App\Classes\FTN\Packet::PACKET_TYPES as $type => $class)
|
||||||
|
<option value="{{ $type }}" @if(old('pkt_type',$o->pkt_type ?: config('app.default_pkt')) === $type)selected @endif>{{ $type }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
@error('pkt_type')
|
||||||
|
{{ $message }}
|
||||||
|
@enderror
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user