More complete rework of packet parsing and packet generation with 29710c
This commit is contained in:
@@ -12,9 +12,9 @@ use Illuminate\Validation\Validator as ValidatorResult;
|
||||
|
||||
use App\Classes\FTN as FTNBase;
|
||||
use App\Exceptions\InvalidPacketException;
|
||||
use App\Models\{Address,Domain,Echomail,Netmail,Zone};
|
||||
use App\Models\{Address,Domain,Echomail,Netmail,Setup,Zone};
|
||||
use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero};
|
||||
use App\Traits\{EncodeUTF8,ObjectIssetFix};
|
||||
use App\Traits\ObjectIssetFix;
|
||||
|
||||
/**
|
||||
* Class Message
|
||||
@@ -91,6 +91,7 @@ class Message extends FTNBase
|
||||
private array $header; // Message Header
|
||||
private int $tzutc = 0; // TZUTC that needs to be converted to be used by Carbon @see self::kludges
|
||||
private Echomail|Netmail $mo; // The object storing this packet message
|
||||
private Address $us; // Our address for this message
|
||||
|
||||
/** @deprecated Not sure why this is needed? */
|
||||
public bool $packed = FALSE; // Has the message been packed successfully
|
||||
@@ -156,6 +157,7 @@ class Message extends FTNBase
|
||||
{
|
||||
$oo = new self($o->fftn->zone);
|
||||
$oo->mo = $o;
|
||||
$oo->us = our_address($o->tftn);
|
||||
|
||||
return $oo;
|
||||
}
|
||||
@@ -507,6 +509,8 @@ class Message extends FTNBase
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
$s = Setup::findOrFail(config('app.id'));
|
||||
|
||||
$return = pack(collect(self::HEADER)->pluck(1)->join(''),
|
||||
$this->mo->fftn->node_id, // Originating Node
|
||||
$this->mo->tftn->node_id, // Destination Node
|
||||
@@ -521,22 +525,26 @@ class Message extends FTNBase
|
||||
$return .= $this->mo->from."\00";
|
||||
$return .= $this->mo->subject."\00";
|
||||
|
||||
if (($this->mo instanceof Netmail) && $this->mo->isFlagSet(self::FLAG_LOCAL)) {
|
||||
// If there isnt an INTL kludge, we'll add it
|
||||
if (! $this->mo->kludges->has('INTL'))
|
||||
$this->mo->kludges->put('INTL',sprintf('%s %s',$this->mo->tftn->ftn3d,$this->mo->fftn->ftn3d));
|
||||
|
||||
if ((! $this->mo->kludges->has('FMPT')) && $this->mo->fftn->point_id)
|
||||
$this->mo->kludges->put('FMPT',$this->mo->fftn->point_id);
|
||||
|
||||
if ((! $this->mo->kludges->has('TOPT')) && $this->mo->tftn->point_id)
|
||||
$this->mo->kludges->put('TOPT',$this->mo->tftn->point_id);
|
||||
}
|
||||
|
||||
if ($this->mo->isFlagSet(self::FLAG_LOCAL))
|
||||
$this->mo->kludges->put('PID',sprintf('clrghouz %s',$s->version));
|
||||
else
|
||||
$this->mo->kludges->put('TID',sprintf('clrghouz %s',$s->version));
|
||||
|
||||
if ($this->mo instanceof Echomail)
|
||||
$return .= sprintf("AREA:%s\r",strtoupper($this->mo->echoarea->name));
|
||||
|
||||
if ($this->mo instanceof Netmail) {
|
||||
// @todo If the message is local, then our kludges are not in the msg itself, we'll add them
|
||||
if ($this->isFlagSet(self::FLAG_LOCAL))
|
||||
Log::debug(sprintf('%s:^ Local message, we may need to set our INTL/FMPT/TOPT',self::LOGKEY));
|
||||
|
||||
$return .= sprintf("\01INTL %s\r",$this->mo->kludges->get('INTL'));
|
||||
|
||||
if ($this->mo->kludges->has('FMPT'))
|
||||
$return .= sprintf("\01FMPT %d\r",$this->mo->kludges->get('FMPT'));
|
||||
if ($this->mo->kludges->has('TOPT'))
|
||||
$return .= sprintf("\01TOPT %d\r",$this->mo->kludges->get('TOPT'));
|
||||
}
|
||||
|
||||
// Add some kludges
|
||||
$return .= sprintf("\01TZUTC: %s\r",str_replace('+','',$this->mo->date->getOffsetString('')));
|
||||
|
||||
@@ -551,11 +559,15 @@ class Message extends FTNBase
|
||||
$return .= $this->mo->content;
|
||||
|
||||
if ($this->mo instanceof Netmail) {
|
||||
// @todo automatically include our address in the path
|
||||
|
||||
foreach ($this->mo->path as $ao)
|
||||
$return .= sprintf("\x01Via %s\r",$this->mo->via($ao));
|
||||
|
||||
// Add our address
|
||||
$return .= sprintf("\x01Via %s @%s.UTC %s (%04X)\r",
|
||||
$this->us->ftn3d,
|
||||
Carbon::now()->format('Ymd.His'),
|
||||
Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
|
||||
} else {
|
||||
// FTS-0004.001/FSC-0068.001 The message SEEN-BY lines
|
||||
// FTS-0004.001/FSC-0068.001 The message PATH lines
|
||||
|
Reference in New Issue
Block a user