Compare commits

..

2 Commits

Author SHA1 Message Date
dc212d35fb Work to handle grunged packets as well as look for tearline/tagline/orgin line from the end of the content
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m44s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
2024-05-22 23:24:29 +10:00
3ce6a8ed61 Record the AKAs presented 2024-05-22 22:12:38 +10:00
3 changed files with 59 additions and 22 deletions

View File

@ -667,24 +667,30 @@ class Message extends FTNBase
$ptr_end = strpos($message,"\r",$ptr_start); $ptr_end = strpos($message,"\r",$ptr_start);
$m = []; $m = [];
$kludge = substr($message,$ptr_start+1,$ptr_end-$ptr_start-1); $kludge = ($x=substr($message,$ptr_start+1,$ptr_end-$ptr_start-1));
preg_match('/^([^\s]+:?)+\s+(.*)$/',$kludge,$m); preg_match('/^([^\s]+:?)+\s+(.*)$/',$kludge,$m);
$ptr_start = $ptr_end+1;
if (! $m) {
Log::alert(sprintf('%s:! Invalid Kluge Line [%s]',self::LOGKEY,$x));
continue;
}
// Catch any kludges we need to process here // Catch any kludges we need to process here
if (array_key_exists($m[1],self::kludges)) if (array_key_exists($m[1],self::kludges))
$this->{self::kludges[$m[1]]} = $m[2]; $this->{self::kludges[$m[1]]} = $m[2];
else else
$o->kludges = [$m[1],$m[2]]; $o->kludges = [$m[1],$m[2]];
$ptr_start = $ptr_end+1;
} }
// Next our message content ends with '\r * Origin: ... \r' or <soh>... // Next our message content ends with '\r * Origin: ... \r' or <soh>...
// FTS-0004.001 // FTS-0004.001
if ($ptr_end=strpos($message,"\r * Origin: ",$ptr_start)) { if ($ptr_end=strrpos($message,"\r * Origin: ",$ptr_start)) {
// Find the <cr> // Find the <cr>
$ptr_end = strpos($message,"\r",$ptr_end+1); $ptr_end = strpos($message,"\r",$ptr_end+1);
// If there is no ptr_end, then this is not an origin
if (! $ptr_end) if (! $ptr_end)
throw new InvalidPacketException('Couldnt find the end of the origin'); throw new InvalidPacketException('Couldnt find the end of the origin');
@ -692,6 +698,16 @@ class Message extends FTNBase
throw new InvalidPacketException('Couldnt parse the end of the content'); throw new InvalidPacketException('Couldnt parse the end of the content');
} }
$remaining = substr($message,$ptr_end+1);
// At this point, the remaining part of the message should start with \x01, PATH or SEEN-BY
if ((substr($remaining,0,9) !== 'SEEN-BY: ') && (substr($remaining,0,5) !== 'PATH:') && ($x=strpos($remaining,"\x01")) !== 0) {
if ($x)
$ptr_end += $x;
else
$ptr_end += strlen($remaining);
}
// Process the message content // Process the message content
if ($content=substr($message,$ptr_start,$ptr_end-$ptr_start)) { if ($content=substr($message,$ptr_start,$ptr_end-$ptr_start)) {
$o->msg_src = $content; $o->msg_src = $content;
@ -699,57 +715,70 @@ class Message extends FTNBase
$ptr_content_start = 0; $ptr_content_start = 0;
// See if we have a tagline // See if we have a tagline
if ($ptr_content_end=strpos($content,"\r\r... ",$ptr_content_start)) { if ($ptr_content_end=strrpos($content,"\r\r... ",$ptr_content_start)) {
$o->msg = substr($content,$ptr_content_start,$ptr_content_end); $o->msg = substr($content,$ptr_content_start,$ptr_content_end);
$ptr_content_start = $ptr_content_end+6; $ptr_content_start = $ptr_content_end+6;
$ptr_content_end = strpos($content,"\r",$ptr_content_start); $ptr_content_end = strpos($content,"\r",$ptr_content_start);
// If there is no terminating "\r", then that's it // If there is no terminating "\r", then that's it
if (! $ptr_content_end) if (! $ptr_content_end) {
$o->set_tagline = substr($content,$ptr_content_start); $o->set_tagline = substr($content,$ptr_content_start);
else $ptr_content_start = strlen($content);
$o->set_tagline = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end; } else {
$o->set_tagline = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end;
}
} }
// See if we have a tearline // See if we have a tearline
if ($ptr_content_end=strpos($content,"\r\r--- ",$ptr_content_start)) { if ($ptr_content_end=strrpos($content,"\r\r--- ",$ptr_content_start)) {
if (! $ptr_content_start) if (! $ptr_content_start)
$o->msg = substr($content,$ptr_content_start,$ptr_content_end-1); $o->msg = substr($content,$ptr_content_start,$ptr_content_end);
$ptr_content_start = $ptr_content_end+6; $ptr_content_start = $ptr_content_end+6;
$ptr_content_end = strpos($content,"\r",$ptr_content_start); $ptr_content_end = strpos($content,"\r",$ptr_content_start);
// If there is no terminating "\r", then that's it // If there is no terminating "\r", then that's it
if (! $ptr_content_end) if (! $ptr_content_end) {
$o->set_tearline = substr($content,$ptr_content_start); $o->set_tearline = substr($content,$ptr_content_start);
else $ptr_content_start = strlen($content);
$o->set_tearline = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end; } else {
$o->set_tearline = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end;
}
} }
// See if we have an origin // See if we have an origin
if ($ptr_content_end=strpos($content,"\r * Origin: ",$ptr_content_start)) { if ($ptr_content_end=strrpos($content,"\r * Origin: ",$ptr_content_start)) {
if (! $ptr_content_start) if (! $ptr_content_start)
$o->msg = substr($content,$ptr_content_start,$ptr_content_end-1); $o->msg = substr($content,$ptr_content_start,$ptr_content_end);
$ptr_content_start = $ptr_content_end+12; $ptr_content_start = $ptr_content_end+12;
$ptr_content_end = strpos($content,"\r",$ptr_content_start); $ptr_content_end = strpos($content,"\r",$ptr_content_start);
// If there is no terminating "\r", then that's it // If there is no terminating "\r", then that's it
if (! $ptr_content_end) if (! $ptr_content_end) {
$o->set_origin = substr($content,$ptr_content_start); $o->set_origin = substr($content,$ptr_content_start);
else $ptr_content_start = strlen($content);
$o->set_origin = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end; } else {
$o->set_origin = substr($content,$ptr_content_start,$ptr_content_end-$ptr_content_start);
$ptr_content_start = $ptr_content_end+1;
}
}
// If there wasnt any tagline/tearline/origin, then the whole content is the message
if (! $ptr_content_start) {
$o->msg = $content;
$ptr_content_start = $ptr_end-$ptr_start;
} }
// Quick validation that we are done // Quick validation that we are done
if ($ptr_content_start) if ($ptr_content_start !== strlen($content))
throw new InvalidPacketException('There is more data in the message content?'); throw new InvalidPacketException('There is more data in the message content?');
} }

View File

@ -699,10 +699,14 @@ final class Binkp extends BaseProtocol
// If we only present limited AKAs dont validate password against akas outside of the domains we present // If we only present limited AKAs dont validate password against akas outside of the domains we present
} elseif (is_null(our_address($o))) { } elseif (is_null(our_address($o))) {
Log::alert(sprintf('%s:/ AKA domain [%s] is not in our domain(s) [%s] - ignoring',self::LOGKEY,$o->zone->domain->name,our_address()->pluck('zone.domain.name')->unique()->join(','))); Log::alert(sprintf('%s:/ AKA domain [%s] is not in our domain(s) [%s] - ignoring',self::LOGKEY,$o->zone->domain->name,our_address()->pluck('zone.domain.name')->unique()->join(',')));
$this->node->ftn_other = $rem_aka;
continue; continue;
} elseif (! $o->active) { } elseif (! $o->active) {
Log::alert(sprintf('%s:/ AKA is not active [%s] - ignoring',self::LOGKEY,$rem_aka)); Log::alert(sprintf('%s:/ AKA is not active [%s] - ignoring',self::LOGKEY,$rem_aka));
$this->node->ftn_other = $rem_aka;
continue; continue;
} else { } else {

View File

@ -328,10 +328,14 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// If we only present limited AKAs dont validate password against akas outside of the domains we present // If we only present limited AKAs dont validate password against akas outside of the domains we present
} elseif (is_null(our_address($o))) { } elseif (is_null(our_address($o))) {
Log::alert(sprintf('%s:/ AKA domain [%s] is not in our domain(s) [%s] - ignoring',self::LOGKEY,$o->zone->domain->name,our_address()->pluck('zone.domain.name')->unique()->join(','))); Log::alert(sprintf('%s:/ AKA domain [%s] is not in our domain(s) [%s] - ignoring',self::LOGKEY,$o->zone->domain->name,our_address()->pluck('zone.domain.name')->unique()->join(',')));
$this->node->ftn_other = $rem_aka;
continue; continue;
} elseif (! $o->active) { } elseif (! $o->active) {
Log::alert(sprintf('%s:/ AKA is not active [%s] - ignoring',self::LOGKEY,$rem_aka)); Log::alert(sprintf('%s:/ AKA is not active [%s] - ignoring',self::LOGKEY,$rem_aka));
$this->node->ftn_other = $rem_aka;
continue; continue;
} else { } else {