Change how our src is determined in packets, add hexdump to packet debug

This commit is contained in:
Deon George 2021-08-21 00:33:41 +10:00
parent 5243fabd63
commit 68a10af776
4 changed files with 64 additions and 48 deletions

View File

@ -101,8 +101,9 @@ class Message extends FTNBase
private int $tzutc; 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 $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 $path; // FTS-0004.001 The message PATH lines
private Collection $pathaddress; // Collection of Addresses after parsing seenby private Collection $pathaddress; // Collection of Addresses after parsing seenby
@ -180,7 +181,8 @@ class Message extends FTNBase
$this->tzutc = 0; $this->tzutc = 0;
$this->zone = []; $this->src = [];
$this->dst = [];
$this->point = []; $this->point = [];
$this->path = collect(); $this->path = collect();
@ -259,17 +261,17 @@ class Message extends FTNBase
{ {
switch ($key) { switch ($key) {
// From Addresses // From Addresses
case 'fz': return Arr::get($this->zone,'src',0); case 'fz': return Arr::get($this->src,'z');
case 'fn': return Arr::get($this->header,'onet'); case 'fn': return $this->src ? Arr::get($this->src,'n') : Arr::get($this->header,'onet');;
case 'ff': return Arr::get($this->header,'onode'); case 'ff': return $this->src ? Arr::get($this->src,'f') : Arr::get($this->header,'onode');;
case 'fp': return Arr::get($this->point,'src'); case 'fp': return Arr::get($this->src,'p');
// To Addresses // To Addresses
// Echomail doesnt have a zone, so we'll use the source zone // 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 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z');
case 'tn': return Arr::get($this->header,'dnet'); case 'tn': return $this->echoarea ? Arr::get($this->header,'dnet') : Arr::get($this->dst,'n');
case 'tf': return Arr::get($this->header,'dnode'); case 'tf': return $this->echoarea ? Arr::get($this->header,'dnode') : Arr::get($this->dst,'f');
case 'tp': return Arr::get($this->point,'dst'); case 'tp': return Arr::get($this->dst,'p');
case 'fftn': case 'fftn':
case 'fftn_o': case 'fftn_o':
@ -277,6 +279,15 @@ class Message extends FTNBase
case 'tftn_o': case 'tftn_o':
return parent::__get($key); 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': case 'date':
return Carbon::createFromFormat('d M y H:i:s O', 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))); 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?'); throw new InvalidPacketException('No address in Origin?');
// Double check, our src and origin match // Double check, our src and origin match
$ftn = Address::parseFTN($matches[1]); $this->src = Address::parseFTN($matches[1]);
// We'll double check our FTN // We'll double check our FTN
if ($this->isNetmail() && (($ftn['n'] !== $this->fn) || ($ftn['f'] !== $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'=>$ftn,'fn'=>$this->fn,'ff'=>$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? // The message is the rest?
} elseif (strlen($v) > $x+1) { } elseif (strlen($v) > $x+1) {
$this->message .= substr($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: // INTL kludge is in Netmail, so we'll do some validation:
list($dst,$src) = explode(' ',$t); list($dst,$src) = explode(' ',$t);
$ftn = Address::parseFTN($src); $this->src = Address::parseFTN($src);
if (($ftn['n'] !== $this->fn) || ($ftn['f'] !== $this->ff)) { if (($this->src['n'] !== $this->fn) || ($this->src['f'] !== $this->ff)) {
Log::error(sprintf('INTL src address [%s] doesnt match packet',$src)); 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); $this->dst = Address::parseFTN($dst);
if (($ftn['n'] !== $this->tn) || ($ftn['f'] !== $this->tf)) { if (($this->dst['n'] !== $this->tn) || ($this->dst['f'] !== $this->tf)) {
Log::error(sprintf('INTL dst address [%s] doesnt match packet',$dst)); 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")); $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 // Parse SEEN-BY
if ($this->seenby->count()) if ($this->seenby->count())
$this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen); $this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen);
@ -786,10 +790,10 @@ class Message extends FTNBase
if ($domain) { if ($domain) {
$validator->after(function($validator) { $validator->after(function($validator) {
if (! Address::findFTN($this->fftn)) if (! $this->fboss_o)
$validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fftn)); $validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fboss));
if (! Address::findFTN($this->tftn)) if (! $this->tboss_o)
$validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->fftn)); $validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->tboss));
}); });
} }

View File

@ -332,23 +332,23 @@ class Packet extends FTNBase
// Create Header // Create Header
$this->header = [ $this->header = [
'onode' => $ao->node_id, // Originating Node 'onode' => $ao->node_id, // Originating Node
'dnode' => $o->node_id, // Destination Node 'dnode' => $o->node_id, // Destination Node
'y' => $date->format('Y'), // Year 'y' => $date->format('Y'), // Year
'm' => $date->format('m')-1, // Month 'm' => $date->format('m')-1, // Month
'd' => $date->format('d'), // Day 'd' => $date->format('d'), // Day
'H' => $date->format('H'), // Hour 'H' => $date->format('H'), // Hour
'M' => $date->format('i'), // Minute 'M' => $date->format('i'), // Minute
'S' => $date->format('s'), // Second 'S' => $date->format('s'), // Second
'onet' => $ao->host_id ?: $ao->region_id, // Originating Net (0xffff when origPoint !=0 2+) '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 'password' => $o->session('pktpass'), // Packet Password
'qozone' => $ao->zone->zone_id, 'qozone' => $ao->zone->zone_id,
'qdzone' => $o->zone->zone_id, 'qdzone' => $o->zone->zone_id,
'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2) 'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2)
'dzone' => $o->zone->zone_id, // Destination Zone (Not used 2) 'dzone' => $o->zone->zone_id, // Destination Zone (Not used 2)
'opoint' => $ao->point_id, // Originating Point (Not used 2) 'opoint' => $ao->point_id, // Originating Point (Not used 2)
'dpoint' => $o->point_id, // Destination Point (Not used 2) 'dpoint' => $o->point_id, // Destination Point (Not used 2)
]; ];
} }

View File

@ -68,7 +68,8 @@ class HomeController extends Controller
return view('pkt') return view('pkt')
->with('file',$file) ->with('file',$file)
->with('result',$pkt); ->with('result',$pkt)
->with('hexdump',$file ? hex_dump(file_get_contents($file)) : '');
} }
/** /**

View File

@ -142,6 +142,17 @@
</div> </div>
</div> </div>
@endforeach @endforeach
<h4 class="accordion-header" id="packetdebug" data-bs-toggle="collapse" data-bs-target="#collapse_hex" aria-expanded="false" aria-controls="collapse_hex">
Packet Dump
</h4>
<div id="collapse_hex" class="accordion-collapse collapse" aria-labelledby="packetdebug" data-bs-parent="#accordion_packetdebug">
<div class="accordion-body">
<pre>
{{ $hexdump }}
</pre>
</div>
</div>
</div> </div>
@endif @endif
@endsection @endsection