Enable us to create an outbound packet without updating send details. Determine the send address for packets earlier

This commit is contained in:
Deon George
2022-01-20 17:54:02 +11:00
parent d930c410dc
commit 421cd565bd
2 changed files with 38 additions and 24 deletions

View File

@@ -95,7 +95,11 @@ class Packet extends FTNBase implements \Iterator, \Countable
return (! is_null($this->key())) && ($this->use_cache ? Cache::has($this->key()) : $this->messages->has($this->key()));
}
public function __construct(Address $o=NULL)
/**
* @param Address|NULL $oo Origin Address
* @param Address|NULL $o Destination Address
*/
public function __construct(Address $oo=NULL,Address $o=NULL)
{
$this->messages = collect();
$this->errors = collect();
@@ -103,8 +107,8 @@ class Packet extends FTNBase implements \Iterator, \Countable
$this->name = sprintf('%08x',timew());
// If we are creating an outbound packet, we need to set our header
if ($o)
$this->newHeader($o);
if ($oo && $o)
$this->newHeader($oo,$o);
}
/**
@@ -384,16 +388,16 @@ class Packet extends FTNBase implements \Iterator, \Countable
/**
* When creating a new packet, set the header.
*
* @param Address $oo
* @param Address $o
*/
private function newHeader(Address $o): void
private function newHeader(Address $oo,Address $o): void
{
$date = Carbon::now();
$ao = Setup::findOrFail(config('app.id'))->system->match($o->zone)->first();
// Create Header
$this->header = [
'onode' => $ao->node_id, // Originating Node
'onode' => $oo->node_id, // Originating Node
'dnode' => $o->node_id, // Destination Node
'y' => $date->format('Y'), // Year
'm' => $date->format('m')-1, // Month
@@ -401,14 +405,14 @@ class Packet extends FTNBase implements \Iterator, \Countable
'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+)
'onet' => $oo->host_id ?: $oo->region_id, // Originating Net (0xffff when origPoint !=0 2+)
'dnet' => $o->host_id ?: $o->region_id, // Destination Net
'password' => $o->session('pktpass'), // Packet Password
'qozone' => $ao->zone->zone_id,
'qozone' => $oo->zone->zone_id,
'qdzone' => $o->zone->zone_id,
'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2)
'ozone' => $oo->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)
'opoint' => $oo->point_id, // Originating Point (Not used 2)
'dpoint' => $o->point_id, // Destination Point (Not used 2)
];
}