Break cluster lines on a bare carriage return
N1MM splits the telnet stream on CR, not LF, which says some nodes send CR with no LF after it. Against those the assembler was handing the whole session back as one unfinished line. Also adds "user:" to the login prompts, which N1MM matches and we did not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ public static class ClusterPrompts
|
||||
private static readonly string[] Callsign =
|
||||
[
|
||||
"login", "log in", "logon", "enter call", "enter your call",
|
||||
"your call", "callsign", "call:",
|
||||
"your call", "callsign", "call:", "user:",
|
||||
];
|
||||
|
||||
private static readonly string[] Password = ["password"];
|
||||
|
||||
@@ -8,27 +8,39 @@ namespace Nonemm.Spotting.Telnet;
|
||||
public sealed class LineAssembler
|
||||
{
|
||||
private readonly StringBuilder pending = new();
|
||||
private bool afterCarriageReturn;
|
||||
|
||||
/// What has arrived since the last line ending.
|
||||
public string Pending => pending.ToString();
|
||||
|
||||
/// Breaks on CR, LF or CRLF. Most nodes send CRLF, but N1MM splits on CR
|
||||
/// alone, which says some of them leave the LF out.
|
||||
public IReadOnlyList<string> Add(string text)
|
||||
{
|
||||
List<string> lines = [];
|
||||
foreach (char character in text)
|
||||
{
|
||||
if (character == '\n')
|
||||
bool wasAfterCarriageReturn = afterCarriageReturn;
|
||||
afterCarriageReturn = character == '\r';
|
||||
switch (character)
|
||||
{
|
||||
lines.Add(pending.ToString().TrimEnd('\r'));
|
||||
pending.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pending.Append(character);
|
||||
case '\n' when wasAfterCarriageReturn:
|
||||
break;
|
||||
case '\n' or '\r':
|
||||
lines.Add(pending.ToString());
|
||||
pending.Clear();
|
||||
break;
|
||||
default:
|
||||
pending.Append(character);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void Clear() => pending.Clear();
|
||||
public void Clear()
|
||||
{
|
||||
pending.Clear();
|
||||
afterCarriageReturn = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user