From 3d43a256bae30df80415bbe5481b2236329c98d5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 28 May 2024 10:44:33 +1000 Subject: [PATCH] Added DynamicItem and PacketDump debug utilities --- app/Console/Commands/Debug/DynamicItem.php | 36 ++++++++++++ app/Console/Commands/Debug/PacketDump.php | 67 ++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 app/Console/Commands/Debug/DynamicItem.php create mode 100644 app/Console/Commands/Debug/PacketDump.php diff --git a/app/Console/Commands/Debug/DynamicItem.php b/app/Console/Commands/Debug/DynamicItem.php new file mode 100644 index 0000000..aa6f50b --- /dev/null +++ b/app/Console/Commands/Debug/DynamicItem.php @@ -0,0 +1,36 @@ +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; + } +} \ No newline at end of file diff --git a/app/Console/Commands/Debug/PacketDump.php b/app/Console/Commands/Debug/PacketDump.php new file mode 100644 index 0000000..1cf1fb4 --- /dev/null +++ b/app/Console/Commands/Debug/PacketDump.php @@ -0,0 +1,67 @@ +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; + } +} \ No newline at end of file