add --verbose flag and TCP RST on connection failure

Server (gatunad):
- New --verbose/-v flag: logs lifecycle events at info level
  (DISCOVER, MANIFEST sent, OPEN, session established, CLOSE,
  OPEN_NAK). Without the flag, errors only as before.

Client (gatuna):
- OPEN_NAK and session CLOSE now send TCP RST to the local app
  instead of a graceful FIN. LingerOption(true, 0) causes Winsock
  to emit RST on close. The local app (e.g. ssh) sees a broken
  connection instead of a clean close, which is more honest about
  what happened (upstream was unreachable).
This commit is contained in:
2026-08-14 13:59:15 +00:00
parent a700514849
commit f476f6b145
2 changed files with 28 additions and 4 deletions
+16 -2
View File
@@ -85,7 +85,7 @@ sealed class SessionManager : IDisposable
lock (_openLock)
{
if (_pending != null)
_pending.Client.Dispose();
NetUtil.RstClose(_pending.Client);
}
ProcessQueue();
break;
@@ -546,7 +546,21 @@ sealed class Session(
_cts.Cancel();
_deliverChannel.Writer.TryComplete();
SendClose();
try { client.Dispose(); } catch { }
NetUtil.RstClose(client);
_cts.Dispose();
}
}
/// Close a TcpClient with a TCP RST instead of a FIN.
static partial class NetUtil
{
public static void RstClose(TcpClient c)
{
try
{
c.LingerState = new LingerOption(true, 0);
c.Close();
}
catch { }
}
}