Fix: throttle TLS/WS handshake failure logs
Exposed ports see a constant stream of scanners and HTTP probes. Every TLS handshake attempt logged an ioctlsocket(FIONBIO=0) failure, but WSAEINVAL is the documented result once WSAEventSelect owns the listening socket and the code already falls back to select; that line alone accounted for 6678 of the 8970 "handshake" lines in a four-day log. It is now logged only for other error codes. A failed handshake used to print three or four lines (recv EOF, AcceptSecurityContext, final status, failed-for-IP) with no per-peer dedup, and WS upgrade failures printed once per HTTP probe. ServerTlsSession now records a human-readable reason (Schannel status name for ASC failures) instead of logging per connection; IOCPServer prints one line per peer per hour with the reason and a suppressed count, for both TLS and WS. Peer close_notify is a normal shutdown and is no longer logged; MCP TLS failures now carry the same reason. Failure details are copied before the context's I/O reference is released, so the log path cannot touch a context that another thread may recycle. No handshake, crypto or connection behaviour changes. Verified with a Debug x64 build and a live probe run: six failed connections to the device port produced exactly one TLS and one WS line, with no ioctlsocket lines. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
3d2dd08be5
commit
5ee59415f9
4 files changed
+176
-19
No files matched your search
@@ -323,7 +323,8 @@ void McpTlsProxy::ServeConn(std::shared_ptr<Conn> sp)
|
||||
ServerTlsSession sess;
|
||||
if (!sess.HandshakeWithCred(client, NULL, 0, m_identity.cred))
|
||||
{
|
||||
Mprintf("[McpTls] TLS handshake failed; closing connection\n");
|
||||
Mprintf("[McpTls] TLS handshake failed: %s; closing connection\n",
|
||||
sess.LastError().empty() ? "unknown" : sess.LastError().c_str());
|
||||
CloseConn(c);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user