More complete rework of packet parsing and packet generation with f279d85 - and testing passes

This commit is contained in:
Deon George 2024-05-20 21:31:21 +10:00
parent b30ab2f999
commit ab2e288f06
14 changed files with 227 additions and 210 deletions

View File

@ -242,25 +242,28 @@ class Message extends FTNBase
$o->mo->msg_crc = md5($o->mo->msg_src);
$o->mo->fftn_id = $o->fftn?->id;
if ($o->fftn)
$o->mo->fftn_id = $o->fftn->id;
else
$o->mo->set_fftn = $o->fftn_t;
switch (get_class($o->mo)) {
case Echomail::class:
// Echomails dont have a to address
break;
case Netmail::class:
$o->mo->tftn_id = $o->tftn?->id;
if ($o->tftn)
$o->mo->tftn_id = $o->tftn->id;
else
$o->mo->set_tftn = $o->tftn_t;
break;
default:
throw new InvalidPacketException('Unknown message class: '.get_class($o->mo));
}
if (($x=$o->validate())->fails()) {
$o->mo->errors = $x;
Log::debug(sprintf('%s:! Message fails validation (%s@%s->%s@%s)',self::LOGKEY,$o->mo->from,$o->fftn_t,$o->mo->to,$o->tftn_t),['result'=>$o->mo->errors->errors()]);
}
$o->validate();
return $o->mo;
}
@ -300,7 +303,7 @@ class Message extends FTNBase
public function __get($key)
{
// @todo Do we need all these key values?
Log::debug(sprintf('%s:/ Requesting key for Message::class [%s]',self::LOGKEY,$key));
//Log::debug(sprintf('%s:/ Requesting key for Message::class [%s]',self::LOGKEY,$key));
switch ($key) {
// From Addresses
@ -556,7 +559,7 @@ class Message extends FTNBase
foreach ($this->mo->kludges as $k=>$v)
$return .= sprintf("\01%s %s\r",$k,$v);
$return .= $this->mo->content;
$return .= $this->mo->content."\r";
if ($this->mo instanceof Netmail) {
foreach ($this->mo->path as $ao)
@ -830,14 +833,16 @@ class Message extends FTNBase
$validator->errors()->add('invalid-zone',sprintf('Message zone [%d] doesnt match packet zone [%d].',$this->fz,$this->zone->zone_id));
}
if (! $this->fboss_o)
$validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fboss));
if (! $this->tboss_o)
$validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->tboss));
if (! $this->fftn)
$validator->errors()->add('from',sprintf('Undefined Node [%s] sent message.',$this->fftn_t));
if ($this->isNetmail() && (! $this->tftn))
$validator->errors()->add('to',sprintf('Undefined Node [%s] for destination.',$this->tftn_t));
});
$this->mo->errors = $validator->errors();
if ($validator->fails())
$this->mo->errors = $validator;
Log::debug(sprintf('%s:! Message fails validation (%s@%s->%s@%s)',self::LOGKEY,$this->mo->from,$this->fftn_t,$this->mo->to,$this->tftn_t),['result'=>$validator->errors()]);
return $validator;
}

View File

@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\File\File;
use App\Classes\FTN as FTNBase;
use App\Exceptions\InvalidPacketException;
use App\Models\{Address,Domain,Echomail,Netmail,Software,Zone};
use App\Models\{Address,Domain,Echomail,Netmail,Software,System,Zone};
use App\Notifications\Netmails\EchomailBadAddress;
/**
@ -206,7 +206,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
*/
public function __get($key)
{
Log::debug(sprintf('%s:/ Requesting key for Packet::class [%s]',self::LOGKEY,$key));
//Log::debug(sprintf('%s:/ Requesting key for Packet::class [%s]',self::LOGKEY,$key));
switch ($key) {
// From Addresses
@ -418,15 +418,13 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
$msg = Message::parseMessage($message,$this->zone);
// @todo If the message from domain (eg: $msg->fftn->zone->domain) is different to the packet address domain ($pkt->fftn->zone->domain), we'll skip this message
Log::debug(sprintf('%s:^ Message [%s] - Packet from domain [%d], Message domain [%d]',self::LOGKEY,$msg->msgid,$this->fftn->zone->domain_id,$msg->fftn->zone->domain_id));
// If the message is invalid, we'll ignore it
if ($msg->errors) {
Log::info(sprintf('%s:- Message [%s] has errors',self::LOGKEY,$msg->msgid));
if ($msg->errors->count()) {
Log::info(sprintf('%s:- Message [%s] has [%d] errors',self::LOGKEY,$msg->msgid ?: 'No ID',$msg->errors->count()));
// If the messages is not for the right zone, we'll ignore it
if ($msg->errors->messages()->has('invalid-zone')) {
if ($msg->errors->has('invalid-zone')) {
Log::alert(sprintf('%s:! Message [%s] is from an invalid zone [%s], packet is from [%s] - ignoring it',self::LOGKEY,$msg->msgid,$msg->fftn->zone->zone_id,$this->fftn->zone->zone_id));
if (! $msg->rescanned->count())
@ -435,81 +433,60 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
return;
}
// @todo If the $msg->fftn doesnt exist, we'll need to create it
// @todo If the $msg->tftn doesnt exist (netmail), we'll need to create it (ergo intransit)
/*
// If the to address doenst exist, we'll create a new entry
if ($msg->errors->messages()->has('to') && $msg->tzone) {
try {
// @todo Need to work out the correct region for the host_id
Address::unguard();
$ao = Address::firstOrNew([
'zone_id' => $msg->tzone->id,
//'region_id' => 0,
'host_id' => $msg->tn,
'node_id' => $msg->tf,
'point_id' => $msg->tp,
'active' => TRUE, // @todo This should be false, as it hasnt been assigned to the node
]);
Address::reguard();
// If the $msg->fftn doesnt exist, we'll need to create it
if ($msg->errors->has('from') && $this->fftn && $this->fftn->zone_id) {
Log::debug(sprintf('%s:^ From address [%s] doesnt exist, it needs to be created',self::LOGKEY,$msg->set->get('set_fftn')));
if (is_null($ao->region_id))
$ao->region_id = $ao->host_id;
$ao = Address::findFTN($msg->set->get('set_fftn'),TRUE);
if ($ao?->exists && ($ao->zone?->domain_id !== $this->fftn->zone->domain_id)) {
Log::alert(sprintf('%s:! From address [%s] domain [%d] doesnt match packet domain [%d]?',self::LOGKEY,$msg->set->get('set_fftn'),$ao->zone?->domain_id,$this->fftn->zone->domain_id));
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error finding/creating TO address [%s] for message',self::LOGKEY,$msg->tboss),['error'=>$e->getMessage()]);
$this->errors->push($msg);
return;
}
$so = System::createUnknownSystem();
if (! $ao) {
$so = System::createUnknownSystem();
$ao = Address::createFTN($msg->set->get('set_fftn'),$so);
}
$so->addresses()->save($ao);
Log::alert(sprintf('%s:- To FTN is not defined, creating new entry for [%s] (%d)',self::LOGKEY,$msg->tboss,$ao->id));
$msg->fftn_id = $ao->id;
Log::alert(sprintf('%s:- From FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_fftn'),$ao->id));
}
// If the from address doenst exist, we'll create a new entry
if ($msg->errors->messages()->has('from') && $msg->tzone) {
try {
// @todo Need to work out the correct region for the host_id
Address::unguard();
$ao = Address::firstOrNew([
'zone_id' => $msg->fzone->id,
//'region_id' => 0,
'host_id' => $msg->fn,
'node_id' => $msg->ff,
'point_id' => $msg->fp,
'active'=> TRUE, // @todo This should be FALSE as it hasnt been assigned to the node
]);
Address::reguard();
// If the $msg->tftn doesnt exist, we'll need to create it
if ($msg->errors->has('to') && $this->tftn && $this->tftn->zone_id) {
Log::debug(sprintf('%s:^ To address [%s] doesnt exist, it needs to be created',self::LOGKEY,$msg->set->get('set_tftn')));
if (is_null($ao->region_id))
$ao->region_id = $ao->host_id;
$ao = Address::findFTN($msg->set->get('set_tftn'),TRUE);
if ($ao?->exists && ($ao->zone?->domain_id !== $this->tftn->zone->domain_id)) {
Log::alert(sprintf('%s:! To address [%s] domain [%d] doesnt match packet domain [%d]?',self::LOGKEY,$msg->set->get('set_tftn'),$ao->zone?->domain_id,$this->fftn->zone->domain_id));
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error finding/creating FROM address [%s] for message',self::LOGKEY,$msg->fboss),['error'=>$e->getMessage()]);
$this->errors->push($msg);
return;
}
$so = System::createUnknownSystem();
if (! $ao) {
$so = System::createUnknownSystem();
$ao = Address::createFTN($msg->set->get('set_fftn'),$so);
}
$so->addresses()->save($ao);
Log::alert(sprintf('%s:- From FTN is not defined, creating new entry for [%s] (%d)',self::LOGKEY,$msg->fboss,$ao->id));
$msg->tftn_id = $ao->id;
Log::alert(sprintf('%s:- To FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_tftn'),$ao->id));
}
*/
// If the from/to user is missing
if ($msg->errors->messages()->has('from') || $msg->errors->messages()->has('to')) {
Log::error(sprintf('%s:! Skipping message [%s] due to errors (%s)...',self::LOGKEY,$msg->msgid,join(',',$msg->errors->messages()->keys())));
$this->errors->push($msg);
// If there is no fftn, then its from a system that we dont know about
if (! $this->fftn) {
Log::alert(sprintf('%s:! No further message processing, packet is from a system we dont know about [%s]',self::LOGKEY,$this->fftn_t));
$this->messages->push($msg);
return;
}
}
// @todo If the message from domain (eg: $msg->fftn->zone->domain) is different to the packet address domain ($pkt->fftn->zone->domain), we'll skip this message
Log::debug(sprintf('%s:^ Message [%s] - Packet from domain [%d], Message domain [%d]',self::LOGKEY,$msg->msgid,$this->fftn->zone->domain_id,$msg->fftn->zone->domain_id));
$this->messages->push($msg);
}

View File

@ -63,34 +63,36 @@ final class FSC39 extends Packet
*/
protected function header(): string
{
$oldest = $this->messages->sortBy('datetime')->last();
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
Arr::get($this->header,'y'), // Year
Arr::get($this->header,'m'), // Month
Arr::get($this->header,'d'), // Day
Arr::get($this->header,'H'), // Hour
Arr::get($this->header,'M'), // Minute
Arr::get($this->header,'S'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
'', // Reserved
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$oldest->datetime->format('Y'), // Year
$oldest->datetime->format('m')-1, // Month
$oldest->datetime->format('d'), // Day
$oldest->datetime->format('H'), // Hour
$oldest->datetime->format('i'), // Minute
$oldest->datetime->format('s'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved
Arr::get($this->header,'capvalid',1<<0), // fsc-0039.004 (copy of 0x2c)
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor
Arr::get($this->header,'capword',1<<0), // Capability Word
$this->fz, // Orig Zone
$this->tz, // Dest Zone
$this->fp, // Orig Point
$this->tp, // Dest Point
((Setup::PRODUCT_ID >> 8) & 0xff), // Product Code Hi
Setup::PRODUCT_VERSION_MIN, // Product Version Minor
1<<0, // Capability Word
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id, // Orig Point
$this->tftn_p->point_id, // Dest Point
strtoupper(hexstr(Setup::PRODUCT_ID)), // ProdData
);

View File

@ -44,22 +44,22 @@ final class FSC45 extends Packet
{
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
$this->fp, // Orig Point
$this->tp, // Dest Point
'', // Reserved
2, // Sub Version (should be 2)
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code
Setup::PRODUCT_VERSION_MAJ, // Product Version
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
$this->fd, // Orig Domain
$this->td, // Dest Domain
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$this->fp, // Orig Point
$this->tp, // Dest Point
'', // Reserved
2, // Sub Version (should be 2)
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code
Setup::PRODUCT_VERSION_MAJ, // Product Version
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->zone->domain->name, // Orig Domain
$this->tftn_p->zone->domain->name, // Dest Domain
strtoupper(hexstr(Setup::PRODUCT_ID)), // ProdData
);

View File

@ -43,26 +43,28 @@ final class FTS1 extends Packet
*/
protected function header(): string
{
$oldest = $this->messages->sortBy('datetime')->last();
try {
return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->ff, // Orig Node
$this->tf, // Dest Node
Arr::get($this->header,'y'), // Year
Arr::get($this->header,'m'), // Month
Arr::get($this->header,'d'), // Day
Arr::get($this->header,'H'), // Hour
Arr::get($this->header,'M'), // Minute
Arr::get($this->header,'S'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fn, // Orig Net
$this->tn, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->password, // Packet Password
$this->fz, // Orig Zone
$this->tz, // Dest Zone
'', // Reserved
$this->fftn_p->node_id, // Orig Node
$this->tftn_p->node_id, // Dest Node
$oldest->datetime->format('Y'), // Year
$oldest->datetime->format('m')-1, // Month
$oldest->datetime->format('d'), // Day
$oldest->datetime->format('H'), // Hour
$oldest->datetime->format('i'), // Minute
$oldest->datetime->format('s'), // Second
0, // Baud
2, // Packet Version (should be 2)
$this->fftn_p->host_id, // Orig Net
$this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved
);
} catch (\Exception $e) {

View File

@ -69,7 +69,7 @@ class PacketInfo extends Command
try {
$this->warn(sprintf('- Date : %s (%s)',$msg->datetime,$msg->datetime->tz->toOffsetName()));
$this->warn(sprintf(' - Errors : %s',$msg->errors?->errors()->count() ? 'YES' : 'No'));
$this->warn(sprintf(' - Errors : %s',$msg->errors->count() ? 'YES' : 'No'));
$this->warn(sprintf(' - Flags : %s',$msg->flags()->keys()->join(', ')));
$this->warn(sprintf(' - Cost : %d',$msg->cost));
$this->warn(sprintf(' - From : %s (%s)',$msg->from,$msg->fftn->ftn));
@ -81,10 +81,10 @@ class PacketInfo extends Command
if ($msg instanceof Echomail)
$this->warn(sprintf(' - Area : %s',$msg->echoarea->name));
if ($msg->errors) {
if ($msg->errors->count()) {
echo "\n";
$this->error("Errors:");
foreach ($msg->errors->errors()->all() as $error)
foreach ($msg->errors->all() as $error)
$this->error(' - '.$error);
}
@ -103,7 +103,7 @@ class PacketInfo extends Command
$this->error(sprintf(' - To: %s (%s)',$msg->to,$msg->tftn));
$this->error(sprintf(' - Subject: %s',$msg->subject));
foreach ($msg->errors->errors()->all() as $error)
foreach ($msg->errors->all() as $error)
$this->line(' - '.$error);
}

View File

@ -115,8 +115,8 @@ class PacketProcess implements ShouldQueue
elseif ($msg instanceof Echomail)
Log::info(sprintf('%s:- Echomail from [%s]',self::LOGKEY,$msg->fftn->ftn));
if ($msg->errors) {
Log::error(sprintf('%s:! Message [%s] has [%d] errors, unable to process',self::LOGKEY,$msg->msgid,$msg->errors->errors()->count()));
if ($msg->errors->count()) {
Log::error(sprintf('%s:! Message [%s] has [%d] errors, unable to process',self::LOGKEY,$msg->msgid,$msg->errors->count()));
continue;
}

View File

@ -154,7 +154,7 @@ class Address extends Model
$o = new self;
$o->active = TRUE;
$o->zone_id = $zo->id;
$o->region_id = 0; // @todo Automatically determine region
$o->region_id = $ftn['r'];
$o->host_id = $ftn['n'];
$o->node_id = $ftn['f'];
$o->point_id = $ftn['p'];
@ -307,8 +307,39 @@ class Address extends Model
if ((! empty($matches[4])) AND ((! is_numeric($matches[$i])) || ($matches[4] > self::ADDRESS_FIELD_MAX)))
throw new InvalidFTNException(sprintf('Invalid FTN: [%s] - point address invalid [%d]',$ftn,$matches[4]));
// Work out region
$region_id = 0;
$zone_id = NULL;
// We can only work out region if we have a domain
if ($matches[5] ?? NULL) {
$o = new self;
$o->host_id = $matches[2];
$o->node_id = $matches[3];
$o->point_id = empty($matches[4]) ? 0 : (int)$matches[4];
$zo = Zone::select('zones.*')->where('zone_id',$matches[1])->join('domains',['domains.id'=>'zones.domain_id'])->where('domains.name',$matches[5])->single();
$o->zone_id = $zo?->id;
$parent = $o->parent();
$zone_id = $parent?->zone->zone_id;
// For flattened domains
if ($zo->domain->flatten && is_null($zone_id))
foreach ($zo->domain->zones as $zoo) {
$o->zone_id = $zoo->id;
$parent = $o->parent();
if ($parent)
break;
}
$region_id = $parent?->region_id;
$zone_id = $parent?->zone->zone_id;
}
return [
'z'=>(int)$matches[1],
'z'=>(int)$zone_id ?: $matches[1],
'r'=>(int)$region_id,
'n'=>(int)$matches[2],
'f'=>(int)$matches[3],
'p'=>empty($matches[4]) ? 0 : (int)$matches[4],

View File

@ -59,6 +59,7 @@ final class Echomail extends Model implements Packet
$this->{$key} = $value;
break;
case 'set_fftn':
// Values that we pass to boot() to record how we got this echomail
case 'set_pkt':
case 'set_recvtime':

View File

@ -55,6 +55,8 @@ final class Netmail extends Model implements Packet
break;
case 'set_fftn':
case 'set_tftn':
// Values that we pass to boot() to record how we got this netmail
case 'set_pkt':
case 'set_recvtime':

View File

@ -8,7 +8,7 @@ namespace App\Traits;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator as ValidatorResult;
use Illuminate\Support\MessageBag;
use App\Classes\FTN\Message;
use App\Models\Address;
@ -20,7 +20,7 @@ trait MessageAttributes
// Items we need to set when creating()
public Collection $set;
// Validation Errors
public ?ValidatorResult $errors = NULL;
public ?MessageBag $errors = NULL;
private const cast_utf8 = [
'to',
@ -46,7 +46,7 @@ trait MessageAttributes
public function getContentAttribute(): string
{
if ($this->msg_src)
return $this->msg_src."\r";
return $this->msg_src;
// If we have a msg_src attribute, we'll use that
$result = $this->msg."\r\r";
@ -60,7 +60,7 @@ trait MessageAttributes
if ($this->origin)
$result .= sprintf("%s",$this->origin);
return rtrim($result,"\r")."\r";
return rtrim($result,"\r");
}
public function getDateAttribute(): Carbon

View File

@ -94,7 +94,7 @@
<div id="collapse_msg_{{ $loop->parent->parent->index }}_{{ $loop->index }}" class="accordion-collapse collapse @if($result->messages->count() === 1 && $loop->parent->first)show @endif" aria-labelledby="pktmsg" data-bs-parent="#accordion_file_{{ $loop->parent->parent->index }}">
<div class="accordion-body">
@if ($msg->errors)
@foreach ($msg->errors->messages()->all() as $error)
@foreach ($msg->errors->all() as $error)
<div class="alert alert-danger">
{{ $error }}
</div>

View File

@ -7,8 +7,8 @@ use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
use App\Classes\File;
use App\Classes\FTN\{Message,Packet};
use App\Models\{Address,Domain,System,Zone};
use App\Classes\FTN\Packet;
use App\Models\{Address,Domain,Echomail,System,Zone};
class PacketTest extends TestCase
{
@ -116,15 +116,16 @@ class PacketTest extends TestCase
$this->assertEquals(1,count($pkt));
$this->assertEquals('3634/27 12 154/10 221/6 218/840 770/1 633/280',$pkt->messages[0]->path[0]);
$this->assertEquals('1/120 18/0 116/116 120/616 123/0 10 25 126 160 180 200 525 755 3001',$pkt->messages[0]->seenby[0]);
$this->assertEquals('*The Gate BBS*Shelby, NC USA*thegateb.synchro.net* (1:3634/27)',$pkt->messages[0]->origin);
$this->assertEquals('1:3634/27.0@fidonet',$pkt->messages[0]->fftn);
$this->assertEquals('1:633/2744.0@fidonet',$pkt->messages[0]->tftn);
$this->assertEquals('Gate Keeper',$pkt->messages[0]->user_from);
$this->assertEquals('Meitsi',$pkt->messages[0]->user_to);
$this->assertEquals(' * Origin: *The Gate BBS*Shelby, NC USA*thegateb.synchro.net* (1:3634/27)',$pkt->messages[0]->origin);
$this->assertEquals('1:3634/27.0@fidonet',$pkt->messages[0]->fftn->ftn);
$this->assertEquals('3:633/2744.0@fidonet',$pkt->tftn->ftn);
$this->assertEquals('Gate Keeper',$pkt->messages[0]->from);
$this->assertEquals('Meitsi',$pkt->messages[0]->to);
$this->assertEquals('Status of HAM radio in FidoNet',$pkt->messages[0]->subject);
$this->assertEquals('275.fidonet_ham@1:3634/27 29ddab74',$pkt->messages[0]->msgid);
$this->assertEquals('1:229/428 012c0322',$pkt->messages[0]->replyid);
$this->assertEquals('bc291b3ea15750c2d0c39c9221093901',md5($pkt->messages[0]->message));
$this->assertEquals('93a956cbde8b1215f4cf67e514116487',md5($pkt->messages[0]->content));
$this->assertEquals('93a956cbde8b1215f4cf67e514116487',$pkt->messages[0]->msg_crc);
}
}
@ -142,15 +143,16 @@ class PacketTest extends TestCase
$this->assertEquals(43,count($pkt));
$this->assertEquals('229/664 426 633/280',$pkt->messages[0]->path[0]);
$this->assertEquals('15/0 106/201 128/260 129/305 153/7715 218/700 221/6 226/30 227/114',$pkt->messages[0]->seenby[0]);
$this->assertEquals('Northern Realms (1:229/664)',$pkt->messages[0]->origin);
$this->assertEquals('1:229/664.0@fidonet',$pkt->messages[0]->fftn);
$this->assertEquals('1:633/2744.0@fidonet',$pkt->messages[0]->tftn);
$this->assertEquals('Northern Realms',$pkt->messages[0]->user_from);
$this->assertEquals('All',$pkt->messages[0]->user_to);
$this->assertEquals(' * Origin: Northern Realms (1:229/664)',$pkt->messages[0]->origin);
$this->assertEquals('1:229/664.0@fidonet',$pkt->messages[0]->fftn->ftn);
$this->assertEquals('3:633/2744.0@fidonet',$pkt->tftn->ftn);
$this->assertEquals('Northern Realms',$pkt->messages[0]->from);
$this->assertEquals('All',$pkt->messages[0]->to);
$this->assertEquals('NYPost Daily Horoscope',$pkt->messages[0]->subject);
$this->assertEquals('1:229/664 56db6f89',$pkt->messages[0]->msgid);
$this->assertEquals('',$pkt->messages[0]->replyid);
$this->assertEquals('b8c33987647e88f86456f0e571e98398',md5($pkt->messages[0]->message));
$this->assertEquals('ad761cfc02d87383056cc29e026b3d57',md5($pkt->messages[0]->content));
$this->assertEquals('ad761cfc02d87383056cc29e026b3d57',$pkt->messages[0]->msg_crc);
}
}
@ -166,18 +168,19 @@ class PacketTest extends TestCase
$this->assertInstanceOf(Packet\FSC48::class,$pkt);
$this->assertEquals('ABCDEFG#',$pkt->password);
$this->assertEquals(4,count($pkt));
$this->assertInstanceOf(Message::class,$pkt->messages[0]);
$this->assertInstanceOf(Echomail::class,$pkt->messages[0]);
$this->assertEquals('3/165 100 184',$pkt->messages[0]->path[0]);
$this->assertEquals('1/100 179 2/100 116 3/100 105 107 108 109 110 111 113 119 120 126 127',$pkt->messages[0]->seenby[0]);
$this->assertEquals('www.theunderground.us Telnet 10023 SSH 7771 (21:3/165)',$pkt->messages[0]->origin);
$this->assertEquals('21:3/165.0@fsxnet',$pkt->messages[0]->fftn);
$this->assertEquals('21:3/2744.0@fsxnet',$pkt->messages[0]->tftn);
$this->assertEquals('ibbslastcall',$pkt->messages[0]->user_from);
$this->assertEquals('All',$pkt->messages[0]->user_to);
$this->assertEquals(' * Origin: www.theunderground.us Telnet 10023 SSH 7771 (21:3/165)',$pkt->messages[0]->origin);
$this->assertEquals('21:3/165.0@fsxnet',$pkt->messages[0]->fftn->ftn);
$this->assertEquals('21:3/2744.0@fsxnet',$pkt->tftn->ftn);
$this->assertEquals('ibbslastcall',$pkt->messages[0]->from);
$this->assertEquals('All',$pkt->messages[0]->to);
$this->assertEquals('ibbslastcall-data',$pkt->messages[0]->subject);
$this->assertEquals('21:3/165 6b42fe09',$pkt->messages[0]->msgid);
$this->assertEquals('',$pkt->messages[0]->replyid);
$this->assertEquals('aa6bc82b63355ab68889f61822305072',md5($pkt->messages[0]->message));
$this->assertEquals('413eb972809e1ce8ac5f5cf7b545fc10',md5($pkt->messages[0]->content));
$this->assertEquals('413eb972809e1ce8ac5f5cf7b545fc10',$pkt->messages[0]->msg_crc);
}
}
@ -185,6 +188,7 @@ class PacketTest extends TestCase
{
$this->init_private();
// @note this pkt is from/to a sender not defined
$f = $this->mail_file('mail/test_nomsgid_origin.pkt');
foreach ($f as $packet) {
$pkt = Packet::process($packet,$f->itemName(),$f->itemSize());
@ -193,21 +197,21 @@ class PacketTest extends TestCase
$this->assertEquals(1,$pkt->count());
foreach ($pkt as $msg) {
$this->assertNotTrue($msg->isNetmail());
$this->assertEquals('PVT_TEST',$msg->echoarea);
$this->assertInstanceOf(Echomail::class,$msg);
$this->assertEquals('PVT_TEST',$msg->set->get('set_echoarea'));
}
$this->assertInstanceOf(Message::class,$pkt->messages[0]);
$this->assertEquals('1/1 999/1',$pkt->messages[0]->path[0]);
$this->assertEquals('Daytona BBS (Netherlands) (10:3/151)',$pkt->messages[0]->origin);
$this->assertEquals('10:3/151.0@private',$pkt->messages[0]->fftn);
$this->assertEquals('10:999/999.0@private',$pkt->messages[0]->tftn);
$this->assertEquals('Hub Robot',$pkt->messages[0]->user_from);
$this->assertEquals('Henk Hilgersum',$pkt->messages[0]->user_to);
$this->assertEquals(' * Origin: Daytona BBS (Netherlands) (10:3/151)',$pkt->messages[0]->origin);
$this->assertEquals('10:3/151.0@private',$pkt->messages[0]->set->get('set_fftn'));
$this->assertEquals('10:999/999.0@private',$pkt->tftn_t);
$this->assertEquals('Hub Robot',$pkt->messages[0]->from);
$this->assertEquals('Henk Hilgersum',$pkt->messages[0]->to);
$this->assertEquals('LEMEIN',$pkt->messages[0]->subject);
$this->assertEquals('',$pkt->messages[0]->msgid);
$this->assertEquals('',$pkt->messages[0]->replyid);
$this->assertEquals('6bbe3d0475cf60804ca4e942212d3456',md5($pkt->messages[0]->message));
$this->assertEquals('a5933ea2bbcddf955d6940e1dad5cc1b',md5($pkt->messages[0]->content));
$this->assertEquals('a5933ea2bbcddf955d6940e1dad5cc1b',$pkt->messages[0]->msg_crc);
}
}
@ -227,7 +231,7 @@ class PacketTest extends TestCase
foreach ($pkt as $msg) {
dump($msg);
$this->assertNotTrue($msg->isNetmail());
$this->assertInstanceOf(Echomail::class,$msg);
$this->assertNotFalse($msg->path->search('1/1 999/1'));
$this->assertNotFalse($msg->seenby->search('1/1 4 3/0 999/1 999'));
}
@ -248,22 +252,22 @@ class PacketTest extends TestCase
$this->assertEquals(1,$pkt->count());
foreach ($pkt as $msg) {
$this->assertNotTrue($msg->isNetmail());
$this->assertEquals('PVT_TEST',$msg->echoarea);
$this->assertInstanceOf(Echomail::class,$msg);
$this->assertEquals('PVT_TEST',$msg->set->get('set_echoarea'));
$this->assertNotFalse($msg->seenby->search('1/1 999/1 999'));
}
$this->assertInstanceOf(Message::class,$pkt->messages[0]);
$this->assertEquals('999/1',$pkt->messages[0]->path[0]);
$this->assertEquals('Alterant MailHUB at your service (10:999/1)',$pkt->messages[0]->origin);
$this->assertEquals('10:999/1.0@private',$pkt->messages[0]->fftn);
$this->assertEquals('10:999/999.0@private',$pkt->messages[0]->tftn);
$this->assertEquals('Hub Robot',$pkt->messages[0]->user_from);
$this->assertEquals('deon',$pkt->messages[0]->user_to);
$this->assertEquals(' * Origin: Alterant MailHUB at your service (10:999/1)',$pkt->messages[0]->origin);
$this->assertEquals('10:999/1.0@private',$pkt->messages[0]->set->get('set_fftn'));
$this->assertEquals('10:999/999.0@private',$pkt->tftn_t);
$this->assertEquals('Hub Robot',$pkt->messages[0]->from);
$this->assertEquals('deon',$pkt->messages[0]->to);
$this->assertEquals('Hub Robot Report',$pkt->messages[0]->subject);
$this->assertEquals('10:999/1 612aecda',$pkt->messages[0]->msgid);
$this->assertEquals('',$pkt->messages[0]->replyid);
$this->assertEquals('61078e680cda04c8b5eba0f712582e70',md5($pkt->messages[0]->message));
$this->assertEquals('354e42649bc4e6aea5f0833ce5ad43c5',md5($pkt->messages[0]->content));
$this->assertEquals('354e42649bc4e6aea5f0833ce5ad43c5',$pkt->messages[0]->msg_crc);
}
}
@ -282,14 +286,13 @@ class PacketTest extends TestCase
foreach ($pkt as $msg) {
$messages = TRUE;
$this->assertNotTrue($msg->isNetmail());
$this->assertInstanceOf(Echomail::class,$pkt->messages[0]);
$this->assertSame('21:1/151 6189F64C',$msg->msgid);
$this->assertSame('db727bd3778ddd457784ada4bf016010',md5($msg->message));
$this->assertSame('5b627ab5936b0550a97b738f4deff419',md5($msg->message_src));
$this->assertSame('1fe499b444ba7e391fbb4f1bc8a18ac1',md5($msg->content));
$this->assertSame('1fe499b444ba7e391fbb4f1bc8a18ac1',$msg->msg_crc);
$this->assertContains('3/2744 4/100 106 5/100',$msg->seenby);
$this->assertContains('1/151 100 3/100',$msg->path);
$this->assertCount(11,$msg->seenby);
$this->assertCount(0,$msg->unknown);
}
$this->assertTrue($messages);
@ -311,14 +314,13 @@ class PacketTest extends TestCase
foreach ($pkt as $msg) {
$messages = TRUE;
$this->assertNotTrue($msg->isNetmail());
$this->assertInstanceOf(Echomail::class,$msg);
$this->assertSame('21:1/126 eec6e958',$msg->msgid);
$this->assertSame('5a525cc1c393292dc65160a852d4d615',md5($msg->message));
$this->assertSame('a3193edcc68521d4ed07da6db2aeb0b6',md5($msg->message_src));
$this->assertSame('a354ed6afcb436081e123e12dc0c8764',md5($msg->content));
$this->assertSame('a354ed6afcb436081e123e12dc0c8764',$msg->msg_crc);
$this->assertContains('1/995 2/100 116 1202 3/100 105 107 108 109 110 111 112 113 117 119',$msg->seenby);
$this->assertContains('1/126 100 3/100',$msg->path);
$this->assertCount(10,$msg->seenby);
$this->assertCount(0,$msg->unknown);
}
$this->assertTrue($messages);
@ -340,14 +342,13 @@ class PacketTest extends TestCase
foreach ($pkt as $msg) {
$messages = TRUE;
$this->assertNotTrue($msg->isNetmail());
$this->assertInstanceOf(Echomail::class,$msg);
$this->assertSame('10:999/1 612aecda',$msg->msgid);
$this->assertSame('61078e680cda04c8b5eba0f712582e70',md5($msg->message));
$this->assertSame('b9d65d4f7319ded282f3f1986276ae79',md5($msg->message_src));
$this->assertSame('354e42649bc4e6aea5f0833ce5ad43c5',md5($msg->content));
$this->assertSame('354e42649bc4e6aea5f0833ce5ad43c5',$msg->msg_crc);
$this->assertContains('1/1 999/1 999',$msg->seenby);
$this->assertContains('999/1',$msg->path);
$this->assertCount(1,$msg->seenby);
$this->assertCount(0,$msg->unknown);
}
$this->assertTrue($messages);
@ -371,27 +372,25 @@ class PacketTest extends TestCase
$c++;
$messages = TRUE;
$this->assertNotTrue($msg->isNetmail());
$this->assertInstanceOf(Echomail::class,$msg);
switch ($c) {
case 1:
$this->assertSame('3:712/886 220da89f',$msg->msgid);
$this->assertSame('9f5544bea46ef57a45f561b9e07dd71e',md5($msg->message));
$this->assertSame('9bf4b8c348ac235cc218577abf7140af',md5($msg->message_src));
$this->assertSame('49caf318b7bebedc652f31622d014430',md5($msg->content));
$this->assertSame('49caf318b7bebedc652f31622d014430',$msg->msg_crc);
$this->assertContains('633/0 267 280 281 408 410 412 509 509 640/1384 712/114 550 620 848',$msg->seenby);
$this->assertContains('712/886 848 633/280',$msg->path);
$this->assertCount(2,$msg->seenby);
$this->assertCount(0,$msg->unknown);
break;
case 4:
$this->assertSame('',$msg->msgid);
$this->assertSame('b975057002def556c5a9497aacd000fb',md5($msg->message));
$this->assertSame('c90dd234d2aa029af22c453a25b79a4e',md5($msg->message_src));
$this->assertNull($msg->msgid);
$this->assertSame('514205c1670312887a68272b21df593c',md5($msg->content));
$this->assertSame('514205c1670312887a68272b21df593c',$msg->msg_crc);
$this->assertContains('633/267 280 281 384 408 410 412 418 420 509 509 712/848 770/1 100 330',$msg->seenby);
$this->assertContains('772/210 770/1 633/280',$msg->path);
$this->assertCount(2,$msg->seenby);
$this->assertCount(0,$msg->unknown);
default:
continue 2;

View File

@ -323,8 +323,6 @@ class RoutingTest extends TestCase
// Create a child
$ao = Address::createFTN('100:10/21.2@a',$so);
$ao->region_id = 1; // @todo This should be worked out from the parent node (if exists), or another node on the same host
$ao->save();
$ao = Address::findFTN('100:10/21.0@a');
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);