clrghouz/app/Console/Commands/Debug/PacketDump.php
Deon George 1b2358b5a9
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 48s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m57s
Create Docker Image / Final Docker Image Manifest (push) Successful in 12s
Mail bundling and processing performance improvements
2024-06-21 09:09:50 +10:00

66 lines
1.3 KiB
PHP

<?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}';
/**
* 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->argument('file')) {
$this->info('Item Name:'.$pkt->name);
$this->info('Item Type:'.get_class($pkt));
$this->info('Dump:');
echo hex_dump((string)$pkt);
} else {
$f = fopen($this->argument('file'),'w+');
fputs($f,(string)$pkt);
fclose($f);
}
return self::SUCCESS;
}
}