Show netmails to admins, record netmail path in the DB

This commit is contained in:
2023-06-18 23:33:26 +10:00
parent f147b33b60
commit 58341db0fb
10 changed files with 214 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Validator as ValidatorResult;
use App\Classes\FTN as FTNBase;
use App\Http\Controllers\DomainController;
use App\Models\{Address,Domain,Zone};
use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero};
use App\Traits\EncodeUTF8;
@@ -97,7 +98,7 @@ class Message extends FTNBase
private string $msgid; // MSG ID
private string $replyid; // Reply ID
private string $gateid; // MSG ID if the message came via gate
private string $gateid; // MSG ID if the message came via gate
private string $echoarea; // FTS-0004.001
private string $intl; // Netmail details
@@ -632,7 +633,7 @@ class Message extends FTNBase
/**
* Parse the Seenby/path lines and return a collection of addresses
*
* @param string $type
* @param string $type Type of address, ie: seenby/path
* @param Collection $addresses
* @param Collection $rogue
* @return Collection
@@ -658,7 +659,7 @@ class Message extends FTNBase
$node = (int)$item;
};
$ftn = sprintf('%d:%d/%d',$this->fz,$net&0x7fff,$node&0x7fff);
$ftn = sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
// @todo This should be enhanced to include the address at the time of the message.
if ($aos->has($ftn))
$ao = $aos->get($ftn);
@@ -712,6 +713,48 @@ class Message extends FTNBase
}
}
/**
* Parse the via address and return a collection of addresses
*
* <FTN Address> @YYYYMMDD.HHMMSS[.Precise][.Time Zone] <Program Name> <Version> [Serial Number]
*
* @param Collection $via
* @param Collection $rogue
* @return Collection
*/
private function parseVia(Collection $via,Collection &$rogue): Collection
{
$nodes = collect();
foreach ($via as $line) {
$m = [];
if (preg_match('/^([0-9]+:[0-9]+\/[0-9]+(\..*)?)\s+@([0-9.a-zA-Z]+)\s+(.*)$/',$line,$m)) {
// Address
$ao = Address::findFTN($m[1]);
// Time
$t = [];
$datetime = '';
if (! preg_match('/^([0-9]+\.[0-9]+)(\.?(.*))?$/',$m[3],$t))
Log::alert(sprintf('%s:! Unable to determine time from [%s]',self::LOGKEY,$m[3]));
else
$datetime = Carbon::createFromFormat('Ymd.His',$t[1],$t[3] ?? '');
if (! $ao) {
Log::alert(sprintf('%s:! Undefined Node [%s] for Netmail.',self::LOGKEY,$m[1]));
//$rogue->push(['node'=>$m[1],'datetime'=>$datetime,'program'=>$m[4]]);
} else {
$nodes->push(['node'=>$ao,'datetime'=>$datetime,'program'=>$m[4]]);
}
}
}
return $nodes;
}
/**
* Extract information out of the message text.
*
@@ -904,6 +947,10 @@ class Message extends FTNBase
// Parse PATH
if ($this->path->count())
$this->pathaddress = $this->parseAddresses('path',$this->path,$this->rogue_path);
// Parse VIA
if ($this->via->count())
$this->pathaddress = $this->parseVia($this->via,$this->rogue_path);
}
/**