Compare commits

...

4 Commits

Author SHA1 Message Date
48ed6eb8ea Remove ANSI* commands, they are part of the BBS branch
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 31s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m42s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
2024-05-28 12:44:47 +10:00
364815e8af Setup to present different mail bundle types 2024-05-28 12:23:59 +10:00
3d43a256ba Added DynamicItem and PacketDump debug utilities 2024-05-28 10:44:33 +10:00
b460cd0196 Fix display of addresses in pkt dump 2024-05-28 09:38:55 +10:00
11 changed files with 151 additions and 91 deletions

View File

@ -26,6 +26,9 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
protected const PACKED_MSG_LEAD = "\02\00"; protected const PACKED_MSG_LEAD = "\02\00";
protected const PACKED_END = "\00\00"; protected const PACKED_END = "\00\00";
public const MSG_TYPE2 = 1<<0;
public const MSG_TYPE4 = 1<<2;
// @todo Rename this regex to something more descriptive, ie: FILENAME_REGEX // @todo Rename this regex to something more descriptive, ie: FILENAME_REGEX
public const regex = '([[:xdigit:]]{4})(?:-(\d{4,10}))?-(.+)'; public const regex = '([[:xdigit:]]{4})(?:-(\d{4,10}))?-(.+)';
@ -242,10 +245,12 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
case 'tftn': case 'tftn':
return parent::__get($key); return parent::__get($key);
case 'product':
return Arr::get($this->header,'prodcode-hi')<<8|Arr::get($this->header,'prodcode-lo');
case 'software': case 'software':
$code = Arr::get($this->header,'prodcode-hi')<<8|Arr::get($this->header,'prodcode-lo');
Software::unguard(); Software::unguard();
$o = Software::singleOrNew(['code'=>$code,'type'=>Software::SOFTWARE_TOSSER]); $o = Software::singleOrNew(['code'=>$this->product,'type'=>Software::SOFTWARE_TOSSER]);
Software::reguard(); Software::reguard();
return $o; return $o;

View File

@ -37,7 +37,7 @@ final class FSC39 extends Packet
'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c) 'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c)
'prodcode-hi' => [0x2a,'C',1], // Product Code Hi 'prodcode-hi' => [0x2a,'C',1], // Product Code Hi
'prodrev-min' => [0x2b,'C',1], // Product Version Minor 'prodrev-min' => [0x2b,'C',1], // Product Version Minor
'capword' => [0x2c,'v',2], // Capability Word 'capword' => [0x2c,'v',2], // Capability Word fsc-0039.004/fsc-0048.002
'dozone' => [0x2e,'v',2], // Orig Zone 'dozone' => [0x2e,'v',2], // Orig Zone
'ddzone' => [0x30,'v',2], // Dest Zone 'ddzone' => [0x30,'v',2], // Dest Zone
'opoint' => [0x32,'v',2], // Orig Point 'opoint' => [0x32,'v',2], // Orig Point
@ -46,6 +46,7 @@ final class FSC39 extends Packet
]; ];
public const TYPE = '2e'; public const TYPE = '2e';
public const VERS = self::MSG_TYPE2; //|self::MSG_TYPE4;
public function __get($key) public function __get($key)
{ {
@ -85,10 +86,10 @@ final class FSC39 extends Packet
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved '', // Reserved
Arr::get($this->header,'capvalid',1<<0), // fsc-0039.004 (copy of 0x2c) static::VERS, // fsc-0039.004 (copy of 0x2c)
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi ((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor Setup::PRODUCT_VERSION_MIN, // Product Version Minor
1<<0, // Capability Word static::VERS, // Capability Word
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id, // Orig Point $this->fftn_p->point_id, // Orig Point

View File

@ -37,6 +37,20 @@ final class FSC45 extends Packet
public const TYPE = '2.2'; public const TYPE = '2.2';
public function __get($key)
{
switch ($key) {
case 'product':
return Arr::get($this->header,'prodcode');
case 'software_ver':
return Arr::get($this->header,'prodrev-maj');
default:
return parent::__get($key);
}
}
/** /**
* Create our message packet header * Create our message packet header
*/ */

View File

@ -11,6 +11,7 @@ use App\Models\Setup;
* FSC-0048 http://ftsc.org/docs/fsc-0048.002 * FSC-0048 http://ftsc.org/docs/fsc-0048.002
* *
* Commonly known as Type 2+ packets, based on FSC-0039 with improved support for FTS-0001 * Commonly known as Type 2+ packets, based on FSC-0039 with improved support for FTS-0001
* @note: These packets will be detected as FSC-0039 packets unless it is addressed to a point
*/ */
final class FSC48 extends Packet final class FSC48 extends Packet
{ {
@ -36,7 +37,7 @@ final class FSC48 extends Packet
'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c) 'capvalid' => [0x28,'n',2], // fsc-0039.004 (copy of 0x2c)
'prodcode-hi' => [0x2a,'C',1], // Product Code Hi 'prodcode-hi' => [0x2a,'C',1], // Product Code Hi
'prodrev-min' => [0x2b,'C',1], // Product Version Minor 'prodrev-min' => [0x2b,'C',1], // Product Version Minor
'capword' => [0x2c,'v',2], // Capability Word 'capword' => [0x2c,'v',2], // Capability Word fsc-0039.004/fsc-0048.002
'dozone' => [0x2e,'v',2], // Orig Zone 'dozone' => [0x2e,'v',2], // Orig Zone
'ddzone' => [0x30,'v',2], // Dest Zone 'ddzone' => [0x30,'v',2], // Dest Zone
'opoint' => [0x32,'v',2], // Orig Point 'opoint' => [0x32,'v',2], // Orig Point
@ -45,6 +46,7 @@ final class FSC48 extends Packet
]; ];
public const TYPE = '2+'; public const TYPE = '2+';
public const VERS = self::MSG_TYPE2; //|self::MSG_TYPE4;
public function __get($key) public function __get($key)
{ {
@ -84,10 +86,10 @@ final class FSC48 extends Packet
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net $this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net
1<<0, // fsc-0039.004 (copy of 0x2c) static::VERS, // fsc-0039.004 (copy of 0x2c)
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi ((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor Setup::PRODUCT_VERSION_MIN, // Product Version Minor
1<<0, // Capability Word static::VERS, // Capability Word
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id, // Orig Point $this->fftn_p->point_id, // Orig Point

View File

@ -38,6 +38,20 @@ final class FTS1 extends Packet
public const TYPE = '2'; public const TYPE = '2';
public function __get($key)
{
switch ($key) {
case 'product':
return Arr::get($this->header,'prodcode');
case 'software_ver':
return 'N/A';
default:
return parent::__get($key);
}
}
/** /**
* Create our message packet header * Create our message packet header
*/ */

View File

@ -1,37 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Classes\ANSI;
class ANSIDecode extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ansi:decode'
.' {file : ANS file to decode}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Decode ANS file from custom binary';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
echo ANSI::ansi($this->argument('file'));
return self::SUCCESS;
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Classes\ANSI;
class ANSIEncode extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ansi:encode'
.' {file : ANS file to encode}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Encode ANS file to custom binary';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
foreach (ANSI::binary($this->argument('file')) as $line) {
foreach (str_split(bin2hex($line),2) as $y)
echo hex2bin($y);
echo "\r";
}
return self::SUCCESS;
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use App\Classes\File\Send;
use App\Classes\File\Send\Dynamic;
use App\Models\Address;
use App\Models\Dynamic as DynamicModel;
class DynamicItem extends Command
{
protected $signature = 'debug:dynamic:item'
.' {name : Dynamic Item}'
.' {ftn : FTN Address}';
protected $description = 'Generate a dynamic item';
public function handle(): int
{
$do = DynamicModel::where('name',$this->argument('name'))->single();
if (! $do)
throw new \Exception(sprintf('Dynamic Item [%s] doesnt exist?',$this->argument('name')));
$ao = Address::findFTN($this->argument('ftn'));
$d = new Dynamic($do,$ao,Send::T_FILE);
$d->open();
echo $d->read($d->size);
return self::SUCCESS;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use App\Models\Address;
class PacketDump extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'debug:packet:dump'.
' {type : Type of packet, netmail|echomail }'.
' {ftn : FTN}'.
' {file? : filename}'.
' {--dump : Dump packet}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create an outgoing FTN packet';
/**
* Execute the console command.
*
* @return int
* @throws \Exception
*/
public function handle(): int
{
$ao = Address::findFTN($this->argument('ftn'));
switch (strtolower($this->argument('type'))) {
case 'netmail':
$pkt = $ao->getNetmail();
break;
case 'echomail':
$pkt = $ao->getEchomail();
break;
default:
$this->error('Unknown type: '.$this->argument('type'));
throw new \Exception('Unknown type: '.$this->argument('type'));
}
if ($this->option('dump')) {
$this->info('Item Name:'.$pkt->name);
$this->info('Item Type:'.get_class($pkt));
$this->info('Dump:');
echo hex_dump($pkt);
} else {
$f = fopen($this->argument('file'),'w+');
fputs($f,(string)$pkt);
fclose($f);
}
return self::SUCCESS;
}
}

View File

@ -55,12 +55,12 @@ class PacketInfo extends Command
$this->alert(sprintf('File Name: %s',$x)); $this->alert(sprintf('File Name: %s',$x));
$this->info(sprintf('Packet Type : %s (%s)',$pkt->type,get_class($pkt))); $this->info(sprintf('Packet Type : %s (%s)',$pkt->type,get_class($pkt)));
$this->info(sprintf('From : %s to %s',$pkt->fftn->ftn,$pkt->tftn->ftn)); $this->info(sprintf('From : %s to %s',$pkt->fftn->ftn,$pkt->tftn ? $pkt->tftn->ftn : $pkt->tftn_t));
$this->info(sprintf('Dated : %s (%s) [%s]',$pkt->date,$pkt->date->timestamp,$pkt->date->tz->toOffsetName())); $this->info(sprintf('Dated : %s (%s) [%s]',$pkt->date,$pkt->date->timestamp,$pkt->date->tz->toOffsetName()));
$this->info(sprintf('Password : %s (%s)',$pkt->password ?: '-',$pkt->password ? 'SET' : 'NOT set')); $this->info(sprintf('Password : %s (%s)',$pkt->password ?: '-',$pkt->password ? 'SET' : 'NOT set'));
$this->info(sprintf('Messages : %d',$pkt->count())); $this->info(sprintf('Messages : %d',$pkt->count()));
$this->info(sprintf('Tosser : %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver)); $this->info(sprintf('Tosser : %d (%s) version %s (%x)',$pkt->software->code,$pkt->software->name,$pkt->software_ver,$pkt->product));
$this->info(sprintf('Capabilities: %x',$pkt->capability)); $this->info(sprintf('Capabilities: %s',$pkt->capability));
$this->info(sprintf('Has Errors : %s',$pkt->errors->count() ? 'YES' : 'No')); $this->info(sprintf('Has Errors : %s',$pkt->errors->count() ? 'YES' : 'No'));
$this->info(sprintf('Messages : %d',$pkt->count())); $this->info(sprintf('Messages : %d',$pkt->count()));

View File

@ -71,7 +71,7 @@
<div id="collapse_item_{{ $loop->parent->index }}_{{ $loop->index }}" class="accordion-collapse collapse @if($loop->parent->first)show @endif" aria-labelledby="packet" data-bs-parent="#accordion_packet"> <div id="collapse_item_{{ $loop->parent->index }}_{{ $loop->index }}" class="accordion-collapse collapse @if($loop->parent->first)show @endif" aria-labelledby="packet" data-bs-parent="#accordion_packet">
<div class="accordion-body"> <div class="accordion-body">
<p>Packet <strong class="highlight">{{ $file }}</strong> (type <strong class="highlight">{{ $result->type }}</strong>) is from <strong class="highlight">{{ $result->fftn }}</strong> to <strong class="highlight">{{ $result->tftn }}</strong>, dated <strong class="highlight">{{ $result->date }}</strong>.</p> <p>Packet <strong class="highlight">{{ $file }}</strong> (type <strong class="highlight">{{ $result->type }}</strong>) is from <strong class="highlight">{{ $result->fftn->ftn }}</strong> to <strong class="highlight">{{ $result->tftn->ftn }}</strong>, dated <strong class="highlight">{{ $result->date }}</strong>.</p>
<p>This packet has <strong class="highlight">{{ $result->messages->count() }}</strong> messages and <strong class="highlight">{{ $result->password ? 'DOES' : 'does NOT' }}</strong> have a password.</p> <p>This packet has <strong class="highlight">{{ $result->messages->count() }}</strong> messages and <strong class="highlight">{{ $result->password ? 'DOES' : 'does NOT' }}</strong> have a password.</p>
<p>Tosser: <strong class="highlight">{{ $result->software->code }}</strong> (<strong class="highlight">{{ $result->software->name }}</strong>), version <strong class="highlight">{{ $result->software_ver }}</strong>. Capabilities: <strong class="highlight">{{ $result->capability }}</strong>.</p> <p>Tosser: <strong class="highlight">{{ $result->software->code }}</strong> (<strong class="highlight">{{ $result->software->name }}</strong>), version <strong class="highlight">{{ $result->software_ver }}</strong>. Capabilities: <strong class="highlight">{{ $result->capability }}</strong>.</p>
@if ($result->messages->count() > 1) @if ($result->messages->count() > 1)