FTN Packet inspection
This commit is contained in:
71
app/Console/Commands/FtnPkt.php
Normal file
71
app/Console/Commands/FtnPkt.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Classes\FTNPacket;
|
||||
|
||||
class FtnPkt extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ftn:pkt {file : Fidonet Packet File PKT} {--dump : Dump packet}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import Packet into Database';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$pkt = new FTNPacket($this->argument('file'));
|
||||
|
||||
$this->info(sprintf('Packet: %s has %s messages. Addr: %s->%s (Date: %s)',
|
||||
$pkt->filename,
|
||||
$pkt->messages->count(),
|
||||
$pkt->pktsrc,
|
||||
$pkt->pktdst,
|
||||
$pkt->date
|
||||
));
|
||||
|
||||
foreach ($pkt->messages as $o)
|
||||
{
|
||||
$this->warn(sprintf('-- From: %s(%s)->%s(%s), Type: %s, Size: %d, FQFA: %s',
|
||||
$o->from,
|
||||
$o->src,
|
||||
$o->to,
|
||||
$o->dst,
|
||||
$o->description(),
|
||||
strlen($o->message),
|
||||
$o->fqfa
|
||||
));
|
||||
|
||||
if ($o->unknown->count())
|
||||
$this->error(sprintf('?? %s Unknown headers',$o->unknown->count()));
|
||||
}
|
||||
|
||||
if ($this->option('dump'))
|
||||
dump($o);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user