Added DynamicItem and PacketDump debug utilities
This commit is contained in:
parent
b460cd0196
commit
3d43a256ba
36
app/Console/Commands/Debug/DynamicItem.php
Normal file
36
app/Console/Commands/Debug/DynamicItem.php
Normal 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;
|
||||
}
|
||||
}
|
67
app/Console/Commands/Debug/PacketDump.php
Normal file
67
app/Console/Commands/Debug/PacketDump.php
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user