Complete rework of packet parsing and packet generation

This commit is contained in:
2024-05-17 22:10:54 +10:00
parent 1650d07d5c
commit 29710c37c2
30 changed files with 1394 additions and 1403 deletions

View File

@@ -5,32 +5,32 @@
*/
namespace App\Traits;
use App\Classes\FTN\Message;
use App\Models\{Echomail,Netmail};
trait MessagePath
{
protected function message_path(Message $mo): string
protected function message_path(Echomail|Netmail $mo): string
{
$reply = "This is your original message:\r\r";
$reply .= "+--[ BEGIN MESSAGE ]----------------------------------+\r";
$reply .= sprintf("TO: %s\r",$mo->user_to);
$reply .= sprintf("TO: %s\r",$mo->to);
$reply .= sprintf("SUBJECT: %s\r",$mo->subject);
$reply .= str_replace("\r---","\r#--",$mo->message)."\r";
$reply .= str_replace("\r---","\r#--",$mo->msg)."\r";
$reply .= "+--[ CONTROL LINES ]----------------------------------+\r";
$reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s'));
$reply .= sprintf("MSGID: %s\r",$mo->msgid);
foreach ($mo->kludge as $k=>$v)
$reply .= sprintf("@%s: %s\r",strtoupper($k),$v);
foreach ($mo->kludges as $k=>$v)
$reply .= sprintf("%s %s\r",$k,$v);
$reply .= "+--[ PATH ]-------------------------------------------+\r";
if ($mo->isNetmail()) {
if ($mo instanceof Netmail) {
if ($mo->via->count())
foreach ($mo->via as $via)
$reply .= sprintf("VIA: %s\r",$via);
foreach ($mo->via as $ao)
$reply .= sprintf("VIA: %s\r",$mo->via($ao));
else
$reply .= "No path information? This would be normal if this message came directly to the hub\r";