Fix messages to points, and fix netmail coming from systems which dont include an Origin line
This commit is contained in:
parent
db37cc7aa4
commit
8d9bde9692
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ final class Test extends Process
|
||||
$reply .= "------------------------------ BEGIN MESSAGE ------------------------------\r";
|
||||
$reply .= sprintf("TO: %s\r",$msg->user_to);
|
||||
$reply .= sprintf("SUBJECT: %s\r",$msg->subject);
|
||||
$reply .= $msg->message."\r";
|
||||
$reply .= str_replace("\r---","\r#--",$msg->message)."\r";
|
||||
$reply .= "------------------------------ CONTROL LINES ------------------------------\r";
|
||||
$reply .= sprintf("DATE: %s\r",$msg->date->utc()->format('Y-m-d H:i:s'));
|
||||
$reply .= sprintf("MSGID: %s\r",$msg->msgid);
|
||||
|
@ -5,14 +5,11 @@ namespace App\Classes\Protocol;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\Flysystem\UnreadableFileEncountered;
|
||||
|
||||
use App\Classes\Crypt;
|
||||
use App\Classes\Protocol as BaseProtocol;
|
||||
use App\Classes\File\Send;
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Classes\Sock\SocketClient;
|
||||
use App\Classes\Sock\SocketException;
|
||||
use App\Exceptions\FileGrewException;
|
||||
|
@ -33,7 +33,8 @@ class MessageProcess implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* When calling MessageProcess - we assume that the packet is from a valid source
|
||||
* When calling MessageProcess - we assume that the packet is from a valid source, and
|
||||
* the destination (netmail/echomail) is also valid
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
@ -86,8 +87,8 @@ class MessageProcess implements ShouldQueue
|
||||
$o->set_pkt = $this->packet;
|
||||
$o->set_sender = $this->sender;
|
||||
$o->set_path = $this->msg->pathaddress;
|
||||
// Strip any local flag
|
||||
$o->flags &= ~Message::FLAG_LOCAL;
|
||||
// Strip any local/transit flags
|
||||
$o->flags &= ~(Message::FLAG_LOCAL|Message::FLAG_INTRANSIT);
|
||||
|
||||
// Determine if the message is to this system, or in transit
|
||||
if ($ftns->search(function($item) { return $this->msg->tftn === $item->ftn; }) !== FALSE) {
|
||||
@ -145,10 +146,10 @@ class MessageProcess implements ShouldQueue
|
||||
$reply .= "\r";
|
||||
$reply .= "\r";
|
||||
$reply .= "This is your original message:\r";
|
||||
$reply .= "------------------------------ BEING MESSAGE ------------------------------\r";
|
||||
$reply .= "------------------------------ BEGIN MESSAGE ------------------------------\r";
|
||||
$reply .= sprintf("TO: %s\r",$this->msg->user_to);
|
||||
$reply .= sprintf("SUBJECT: %s\r",$this->msg->subject);
|
||||
$reply .= $this->msg->message;
|
||||
$reply .= str_replace("\r---","\r#--",$this->msg->message)."\r";
|
||||
$reply .= "------------------------------ CONTROL LINES ------------------------------\r";
|
||||
$reply .= sprintf("DATE: %s\r",$this->msg->date->format('Y-m-d H:i:s'));
|
||||
$reply .= sprintf("MSGID: %s\r",$this->msg->msgid);
|
||||
|
@ -646,7 +646,7 @@ class Address extends Model
|
||||
* @param Collection $msgs of message models (Echomail/Netmail)
|
||||
* @return Packet|null
|
||||
*/
|
||||
private function getPacket(Collection $msgs): ?Packet
|
||||
public function getPacket(Collection $msgs): ?Packet
|
||||
{
|
||||
$s = Setup::findOrFail(config('app.id'));
|
||||
$ao = $s->system->match($this->zone)->first();
|
||||
|
@ -143,7 +143,9 @@ final class Netmail extends Model implements Packet
|
||||
'dnode' => $ao->node_id,
|
||||
'onet' => $this->fftn->host_id,
|
||||
'dnet' => $ao->host_id,
|
||||
'flags' => 0, // @todo?
|
||||
'opoint' => $this->fftn->point_id,
|
||||
'dpoint' => $ao->point_id,
|
||||
'flags' => 0,
|
||||
'cost' => 0,
|
||||
'date'=>$this->datetime->format('d M y H:i:s'),
|
||||
];
|
||||
@ -154,7 +156,6 @@ final class Netmail extends Model implements Packet
|
||||
$o->subject = $this->subject;
|
||||
|
||||
// INTL kludge
|
||||
// @todo Point handling FMPT/TOPT
|
||||
$o->intl = sprintf('%s %s',$this->tftn->ftn3d,$this->fftn->ftn3d);
|
||||
$o->flags = $this->flags;
|
||||
|
||||
|
@ -136,7 +136,7 @@ class PacketTest extends TestCase
|
||||
|
||||
$this->assertNotTrue($msg->isNetmail());
|
||||
$this->assertSame('21:1/151 6189F64C',$msg->msgid);
|
||||
$this->assertSame('a8791fd3d261734bb524bc5ed929aa4c',md5($msg->message));
|
||||
$this->assertSame('db727bd3778ddd457784ada4bf016010',md5($msg->message));
|
||||
$this->assertSame('5b627ab5936b0550a97b738f4deff419',md5($msg->message_src));
|
||||
$this->assertCount(3,$msg->rogue_path);
|
||||
$this->assertCount(170,$msg->rogue_seenby);
|
||||
@ -162,7 +162,7 @@ class PacketTest extends TestCase
|
||||
|
||||
$this->assertNotTrue($msg->isNetmail());
|
||||
$this->assertSame('21:1/126 eec6e958',$msg->msgid);
|
||||
$this->assertSame('c0b00abfc3eff7e297bf14f5812a7261',md5($msg->message));
|
||||
$this->assertSame('5a525cc1c393292dc65160a852d4d615',md5($msg->message));
|
||||
$this->assertSame('a3193edcc68521d4ed07da6db2aeb0b6',md5($msg->message_src));
|
||||
$this->assertCount(3,$msg->rogue_path);
|
||||
$this->assertCount(161,$msg->rogue_seenby);
|
||||
|
Loading…
Reference in New Issue
Block a user