Transfering netmail via EMSI

This commit is contained in:
Deon George
2021-07-17 15:48:07 +10:00
parent 6ce4e64cb6
commit 1fa566b26c
15 changed files with 226 additions and 83 deletions

View File

@@ -195,7 +195,7 @@ class Message extends FTNBase
if (($x=$o->validate($domain))->fails()) {
Log::debug('Message fails validation',['result'=>$x->errors()]);
throw new \Exception('Message validation fails:'.join(' ',$x->errors()->all()));
//throw new \Exception('Message validation fails:'.join(' ',$x->errors()->all()));
}
return $o;
@@ -249,7 +249,7 @@ class Message extends FTNBase
case 'date':
return Carbon::createFromFormat('d M y H:i:s O',
sprintf('%s %s',chop(Arr::get($this->header,$key)),($x=$this->kludge->get('tzutc')) < 0 ? $x : '+'.$x));
sprintf('%s %s',chop(Arr::get($this->header,$key)),(is_null($x=$this->kludge->get('tzutc')) || ($x < 0)) ? $x : '+'.$x));
case 'flags':
case 'cost': return Arr::get($this->header,$key);
@@ -404,7 +404,7 @@ class Message extends FTNBase
foreach ($this->_kludge as $k=>$v) {
if ($x=$this->kludge->get($k))
$return .= sprintf("\01%s %s\r",$v,$x);
$return .= sprintf("\01%s%s\r",$v,$x);
}
$return .= $this->message."\r";

View File

@@ -230,12 +230,17 @@ class Packet extends FTNBase
*/
public function __toString(): string
{
$return = $this->createHeader();
// Cache the packet creation
static $return = NULL;
foreach ($this->messages as $o)
$return .= "\02\00".(string)$o;
if (is_null($return)) {
$return = $this->createHeader();
$return .= "\00\00";
foreach ($this->messages as $o)
$return .= "\02\00".(string)$o;
$return .= "\00\00";
}
return $return;
}
@@ -296,7 +301,7 @@ class Packet extends FTNBase
/**
* When creating a new packet, set the header.
*
* @param array $header
* @param Address $o
*/
private function newHeader(Address $o): void
{
@@ -329,8 +334,8 @@ class Packet extends FTNBase
* Parse a message in a mail packet
*
* @param string $message
* @param Domain $domain
* @throws \Exception
* @param Domain|null $domain
* @throws InvalidPacketException
*/
public function parseMessage(string $message,Domain $domain=NULL): void
{

View File

@@ -21,7 +21,7 @@ abstract class Process
*/
protected static function format_msg(string $text): string
{
$msg = utf8_decode(join("\n",static::msg_header()))."\n";
$msg = utf8_decode(join("\r",static::msg_header()))."\r";
$c = 0;
$offset = 0;
@@ -35,7 +35,7 @@ abstract class Process
}
// Look for a return
$return = strpos($text,"\n",$offset);
$return = strpos($text,"\r",$offset);
if ($return !== FALSE)
$return -= $offset;
@@ -55,13 +55,13 @@ abstract class Process
$subtext = substr($text,$offset,$space);
}
$msg .= $ll.$subtext."\n";
$msg .= $ll.$subtext."\r";
$offset += strlen($subtext)+1;
}
// In case our text is shorter than the loo
for ($c; $c<count(static::$logo);$c++)
$msg .= utf8_decode(Arr::get(static::$logo,$c))."\n";
$msg .= utf8_decode(Arr::get(static::$logo,$c))."\r";
return $msg;
}

View File

@@ -26,17 +26,18 @@ final class Ping extends Process
if (strtolower($msg->user_to) !== 'ping')
return FALSE;
$reply = sprintf("Your ping was received here on %s and it took %s to get here.\n",
$reply = sprintf("Your ping was received here on %s and it took %s to get here.\r",
Carbon::now()->toDateTimeString(),
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
);
$reply .= "\n";
$reply .= "Your message travelled along this path to get here:\n";
$reply .= "\r";
$reply .= "\r";
$reply .= "Your message travelled along this path on the way here:\r";
foreach ($msg->via as $path)
$reply .= sprintf(" * %s\n",$path);
$reply .= sprintf(" * %s\r",$path);
$o = new Netmail();
$o = new Netmail;
$o->to = $msg->user_from;
$o->from = Setup::PRODUCT_NAME;
$o->subject = 'Ping Reply';