Fix messages to points, and fix netmail coming from systems which dont include an Origin line

This commit is contained in:
2023-07-20 20:04:41 +10:00
parent db37cc7aa4
commit 8d9bde9692
7 changed files with 40 additions and 26 deletions

View File

@@ -227,7 +227,7 @@ class Message extends FTNBase
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');
case 'fp': return Arr::get($this->point,'src',Arr::get($this->src,'p',Arr::get($this->header,'opoint',0)));
case 'fd': return Arr::get($this->src,'d');
case 'fdomain':
@@ -290,7 +290,7 @@ class Message extends FTNBase
case 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z');
case 'tn': return Arr::get($this->header,'dnet');
case 'tf': return Arr::get($this->header,'dnode');
case 'tp': return Arr::get($this->dst,'p',0); // @todo this wont work for netmails, since dst is not set for in transit messages
case 'tp': return Arr::get($this->point,'dst',Arr::get($this->header,'dpoint',0));
case 'fftn':
case 'fftn_o':
@@ -317,7 +317,7 @@ class Message extends FTNBase
sprintf('%s %s%04d',$x,($this->tzutc < 0) ? '-' : '+',abs($this->tzutc)));
} catch (InvalidFormatException|\Exception $e) {
Log::error(sprintf('%s: ! Date doesnt parse [%s] (%s)',self::LOGKEY,$e->getMessage(),Arr::get($this->header,$key)));
Log::error(sprintf('%s:! Date doesnt parse [%s] (%s)',self::LOGKEY,$e->getMessage(),Arr::get($this->header,$key)));
throw new \Exception(sprintf('%s (%s)',$e->getMessage(),hex_dump(Arr::get($this->header,$key))));
}
@@ -422,7 +422,7 @@ class Message extends FTNBase
$this->tf,
$this->fn,
$this->tn,
$this->flags,
$this->flags&~(self::FLAG_INTRANSIT|self::FLAG_LOCAL), // Turn off our local/intransit bits
$this->cost,
$this->date->format('d M y H:i:s'),
);
@@ -436,9 +436,15 @@ class Message extends FTNBase
// If the message is local, then our kludges are not in the msg itself, we'll add them
if ($this->isFlagSet(self::FLAG_LOCAL)) {
if ($this->isNetmail())
if ($this->isNetmail()) {
$return .= sprintf("\01INTL %s\r",$this->intl);
if ($this->fp)
$return .= sprintf("\01FMPT %d\r",$this->fp);
if ($this->tp)
$return .= sprintf("\01TOPT %d\r",$this->tp);
}
$return .= sprintf("\01TZUTC: %s\r",str_replace('+','',$this->date->getOffsetString('')));
// Add some kludges
@@ -464,6 +470,15 @@ class Message extends FTNBase
$return .= sprintf(" * Origin: %s\r",$this->origin);
} else {
if ($this->isFlagSet(self::FLAG_INTRANSIT) && $this->isNetmail()) {
$return .= sprintf("\01INTL %s\r",$this->intl);
if ($this->fp)
$return .= sprintf("\01FMPT %d\r",$this->fp);
if ($this->tp)
$return .= sprintf("\01TOPT %d\r",$this->tp);
}
$return .= $this->message;
}
@@ -502,7 +517,7 @@ class Message extends FTNBase
*/
public static function parseMessage(string $msg,Zone $zone=NULL): self
{
Log::info(sprintf('%s:Processing message [%d] bytes from zone [%d]',self::LOGKEY,strlen($msg),$zone?->zone_id));
Log::info(sprintf('%s:= Processing message [%d] bytes from zone [%d]',self::LOGKEY,strlen($msg),$zone?->zone_id));
$o = new self($zone);
$o->dump = $msg;
@@ -546,7 +561,7 @@ class Message extends FTNBase
$o->unpackMessage(substr($msg,self::HEADER_LEN+$ptr));
if (($x=$o->validate())->fails()) {
Log::debug(sprintf('%s:Message fails validation (%s@%s->%s@%s)',self::LOGKEY,$o->user_from,$o->fftn,$o->user_to,$o->tftn),['result'=>$x->errors()]);
Log::debug(sprintf('%s:! Message fails validation (%s@%s->%s@%s)',self::LOGKEY,$o->user_from,$o->fftn,$o->user_to,$o->tftn),['result'=>$x->errors()]);
//throw new \Exception('Message validation fails:'.join(' ',$x->errors()->all()));
}
@@ -838,15 +853,15 @@ class Message extends FTNBase
// We'll double check our FTN
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]);
Log::error(sprintf('%s:! FTN [%s] doesnt match message header',self::LOGKEY,$matches[1]),['ftn'=>$this->src,'fn'=>$this->fn,'ff'=>$this->ff]);
}
// The message is the rest?
} elseif (strlen($kl) > $retpos+1) {
// Since netmail doesnt have an origin - our source:
$this->message .= substr($message, 0, $msgpos);
$this->message .= substr($kl,$retpos+1);
$this->message_src = substr($kl,$retpos+1);
$this->message_src = substr($message, 0, $msgpos);
$kl = substr($kl,0,$retpos);
}
@@ -885,12 +900,12 @@ class Message extends FTNBase
$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));
Log::error(sprintf('%s:! INTL src address [%s] doesnt match packet',self::LOGKEY,$src),['src'=>$this->src,'fn'=>$this->fn,'ff'=>$this->ff]);
}
$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));
Log::error(sprintf('%s:! INTL dst address [%s] doesnt match packet',self::LOGKEY,$dst),['dst'=>$this->dst,'tn'=>$this->tn,'tf'=>$this->tf]);
}
}