Add packet info console command
This commit is contained in:
parent
393600f96f
commit
53ab8851fa
57
app/Console/Commands/PacketInfo.php
Normal file
57
app/Console/Commands/PacketInfo.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Jobs\ProcessPacket as Job;
|
||||
use App\Models\Domain;
|
||||
|
||||
class PacketInfo extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'packet:info {pkt : Packet to process} {domain : Domain the packet is from}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Packet Information';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \App\Classes\FTN\InvalidPacketException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$f = new File($this->argument('pkt'));
|
||||
$d = Domain::where('name',$this->argument('domain'))->singleOrFail();
|
||||
|
||||
$pkt = Packet::open($f,$d);
|
||||
|
||||
$this->info(sprintf('Packet Type: %s',$pkt->type));
|
||||
$this->info(sprintf('From: %s to %s',$pkt->fftn,$pkt->tftn));
|
||||
$this->info(sprintf('Dated: %s',$pkt->date));
|
||||
$this->info(sprintf('Password: %s (%s)',$pkt->password,$pkt->password ? 'SET' : 'NOT set'));
|
||||
$this->info(sprintf('Messages: %d',$pkt->messages->count()));
|
||||
$this->info(sprintf('Tosser %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver));
|
||||
$this->info(sprintf('Capabilities: %x',$pkt->capability));
|
||||
|
||||
foreach ($pkt->messages as $msg) {
|
||||
$this->warn(sprintf('- Date: %s',$msg->date));
|
||||
$this->warn(sprintf(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', ')));
|
||||
$this->warn(sprintf(' - From: %s (%s)',$msg->user_from,$msg->fftn));
|
||||
$this->warn(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn));
|
||||
$this->warn(sprintf(' - Subject: %s',$msg->subject));
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ class ProcessPacket extends Command
|
||||
$f = new File($this->argument('pkt'));
|
||||
$d = Domain::where('name',$this->argument('domain'))->singleOrFail();
|
||||
|
||||
foreach ((Packet::open($f,$d))->messages as $msg) {
|
||||
foreach (Packet::open($f,$d)->messages as $msg) {
|
||||
// @todo Quick check that the packet should be processed by us.
|
||||
// @todo validate that the packet's zone is in the domain.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user