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:
@@ -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 { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user