diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index 4a6f79f..f2e0fcd 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -101,8 +101,9 @@ class Message extends FTNBase private int $tzutc; - private array $zone; // Zone the message belongs to. (src/dst - for netmail) private array $point; // Point the message belongs to (Netmail) + private array $src; // Address the message is from + private array $dst; // Address the message is to private Collection $path; // FTS-0004.001 The message PATH lines private Collection $pathaddress; // Collection of Addresses after parsing seenby @@ -180,7 +181,8 @@ class Message extends FTNBase $this->tzutc = 0; - $this->zone = []; + $this->src = []; + $this->dst = []; $this->point = []; $this->path = collect(); @@ -259,17 +261,17 @@ class Message extends FTNBase { switch ($key) { // From Addresses - case 'fz': return Arr::get($this->zone,'src',0); - case 'fn': return Arr::get($this->header,'onet'); - case 'ff': return Arr::get($this->header,'onode'); - case 'fp': return Arr::get($this->point,'src'); + case 'fz': return Arr::get($this->src,'z'); + case 'fn': return $this->src ? Arr::get($this->src,'n') : Arr::get($this->header,'onet');; + case 'ff': return $this->src ? Arr::get($this->src,'f') : Arr::get($this->header,'onode');; + case 'fp': return Arr::get($this->src,'p'); // To Addresses // Echomail doesnt have a zone, so we'll use the source zone - case 'tz': return Arr::get($this->zone,$this->echoarea ? 'src' : 'dst',0); - case 'tn': return Arr::get($this->header,'dnet'); - case 'tf': return Arr::get($this->header,'dnode'); - case 'tp': return Arr::get($this->point,'dst'); + case 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z'); + case 'tn': return $this->echoarea ? Arr::get($this->header,'dnet') : Arr::get($this->dst,'n'); + case 'tf': return $this->echoarea ? Arr::get($this->header,'dnode') : Arr::get($this->dst,'f'); + case 'tp': return Arr::get($this->dst,'p'); case 'fftn': case 'fftn_o': @@ -277,6 +279,15 @@ class Message extends FTNBase case 'tftn_o': return parent::__get($key); + case 'fboss': + return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff); + case 'tboss': + return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf); + case 'fboss_o': + return Address::findFTN($this->fboss); + case 'tboss_o': + return Address::findFTN($this->tboss); + case 'date': return Carbon::createFromFormat('d M y H:i:s O', sprintf('%s %s%04d',chop(Arr::get($this->header,$key)),($this->tzutc < 0) ? '-' : '+',abs($this->tzutc))); @@ -649,18 +660,13 @@ class Message extends FTNBase throw new InvalidPacketException('No address in Origin?'); // Double check, our src and origin match - $ftn = Address::parseFTN($matches[1]); + $this->src = Address::parseFTN($matches[1]); // We'll double check our FTN - if ($this->isNetmail() && (($ftn['n'] !== $this->fn) || ($ftn['f'] !== $this->ff))) { - Log::error(sprintf('FTN [%s] doesnt match message header',$matches[1]),['ftn'=>$ftn,'fn'=>$this->fn,'ff'=>$this->ff]); + if ($this->isNetmail() && (($this->src['n'] !== $this->fn) || ($this->src['f'] !== $this->ff))) { + Log::error(sprintf('FTN [%s] doesnt match message header',$matches[1]),['ftn'=>$this->src,'fn'=>$this->fn,'ff'=>$this->ff]); } - // http://ftsc.org/docs/fsc-0068.001 - // MSGID should be the basis of the source - $this->zone['src'] = $ftn['z']; - $this->point['src'] = $ftn['p']; - // The message is the rest? } elseif (strlen($v) > $x+1) { $this->message .= substr($v,$x+1); @@ -698,22 +704,14 @@ class Message extends FTNBase // INTL kludge is in Netmail, so we'll do some validation: list($dst,$src) = explode(' ',$t); - $ftn = Address::parseFTN($src); - if (($ftn['n'] !== $this->fn) || ($ftn['f'] !== $this->ff)) { + $this->src = Address::parseFTN($src); + if (($this->src['n'] !== $this->fn) || ($this->src['f'] !== $this->ff)) { Log::error(sprintf('INTL src address [%s] doesnt match packet',$src)); - - } else { - // We'll set our source zone - $this->zone['src'] = $ftn['z']; } - $ftn = Address::parseFTN($dst); - if (($ftn['n'] !== $this->tn) || ($ftn['f'] !== $this->tf)) { + $this->dst = Address::parseFTN($dst); + if (($this->dst['n'] !== $this->tn) || ($this->dst['f'] !== $this->tf)) { Log::error(sprintf('INTL dst address [%s] doesnt match packet',$dst)); - - } else { - // We'll set our source zone - $this->zone['dst'] = $ftn['z']; } } @@ -739,6 +737,12 @@ class Message extends FTNBase $this->unknown->push(chop($v,"\r")); } + // Work out our zone/point + // http://ftsc.org/docs/fsc-0068.001 + // MSGID should be the basis of the source, we'll overrite our src from origin if we have it + if ($this->msgid) + $this->src = Address::parseFTN(strstr($this->msgid,' ',TRUE)); + // Parse SEEN-BY if ($this->seenby->count()) $this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen); @@ -786,10 +790,10 @@ class Message extends FTNBase if ($domain) { $validator->after(function($validator) { - if (! Address::findFTN($this->fftn)) - $validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fftn)); - if (! Address::findFTN($this->tftn)) - $validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->fftn)); + if (! $this->fboss_o) + $validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fboss)); + if (! $this->tboss_o) + $validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->tboss)); }); } diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index ab1f408..97e12f1 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -332,23 +332,23 @@ class Packet extends FTNBase // Create Header $this->header = [ - 'onode' => $ao->node_id, // Originating Node - 'dnode' => $o->node_id, // Destination Node - 'y' => $date->format('Y'), // Year - 'm' => $date->format('m')-1, // Month - 'd' => $date->format('d'), // Day - 'H' => $date->format('H'), // Hour - 'M' => $date->format('i'), // Minute - 'S' => $date->format('s'), // Second + 'onode' => $ao->node_id, // Originating Node + 'dnode' => $o->node_id, // Destination Node + 'y' => $date->format('Y'), // Year + 'm' => $date->format('m')-1, // Month + 'd' => $date->format('d'), // Day + 'H' => $date->format('H'), // Hour + 'M' => $date->format('i'), // Minute + 'S' => $date->format('s'), // Second 'onet' => $ao->host_id ?: $ao->region_id, // Originating Net (0xffff when origPoint !=0 2+) - 'dnet' => $o->host_id ?: $o->region_id, // Destination Net + 'dnet' => $o->host_id ?: $o->region_id, // Destination Net 'password' => $o->session('pktpass'), // Packet Password 'qozone' => $ao->zone->zone_id, 'qdzone' => $o->zone->zone_id, - 'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2) - 'dzone' => $o->zone->zone_id, // Destination Zone (Not used 2) - 'opoint' => $ao->point_id, // Originating Point (Not used 2) - 'dpoint' => $o->point_id, // Destination Point (Not used 2) + 'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2) + 'dzone' => $o->zone->zone_id, // Destination Zone (Not used 2) + 'opoint' => $ao->point_id, // Originating Point (Not used 2) + 'dpoint' => $o->point_id, // Destination Point (Not used 2) ]; } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index c5ea6b5..ab0be4f 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -68,7 +68,8 @@ class HomeController extends Controller return view('pkt') ->with('file',$file) - ->with('result',$pkt); + ->with('result',$pkt) + ->with('hexdump',$file ? hex_dump(file_get_contents($file)) : ''); } /** diff --git a/resources/views/pkt.blade.php b/resources/views/pkt.blade.php index 58bead4..b503cad 100644 --- a/resources/views/pkt.blade.php +++ b/resources/views/pkt.blade.php @@ -142,6 +142,17 @@ @endforeach + + +
+
+
+{{ $hexdump }}
+
+
+
@endif @endsection \ No newline at end of file