control-channel: detect a machine-id collision on client sockets only
QA finding 2. The id check ran for every connection that finished its handshake, so an inbound peer announcing our own id could force-close every socket and make the app draw a new machine id. Windows runs the id comparison and the keep-the-first-client rule as two branches of one block gated by `status == Connected && tcp.IsClient` (SocketStuff.cs:1980-1981): a server-accepted socket reaches neither. Move the collision check inside the `isOutbound` gate the dedup half already had, and say so in the README and docs/protocol.md §10.3 note 3. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
43dc25ac71
commit
c9ea89ac50
3 files changed
+35
-17
No files matched your search
+9
-3
@@ -633,13 +633,19 @@ sees them. One subsection per lane, appended, never rewritten.
|
||||
negative sentinels are separate paths: `REOPEN_WHEN_HOTKEY (-10055)` reopens
|
||||
everything, `REOPEN_WHEN_WSAECONNRESET (-10054)` only re-runs the client loop
|
||||
(`frmScreen.cs:452-461`, `InitAndCleanup.cs:28-29`).
|
||||
3. **An id collision force-closes every socket, not just the offending one.** In
|
||||
`UpdateTcpSockets`, `tobeRemovedSockets` starts as the *whole* socket list and
|
||||
3. **An id collision force-closes every socket, not just the offending one —
|
||||
and it is only ever detected on a client socket.** In `UpdateTcpSockets`,
|
||||
`tobeRemovedSockets` starts as the *whole* socket list and
|
||||
is narrowed to "other clients with the same machine name" only in the `else`
|
||||
branch; the collision branch leaves it whole and sets `tcp = null` so the new
|
||||
socket's status is never written (`SocketStuff.cs:1978-1998`). A new
|
||||
`MachineId` is drawn and `PleaseReopenSocket = REOPEN_WHEN_HOTKEY` reopens
|
||||
everything (`:1985-1990`).
|
||||
everything (`:1985-1990`). The id comparison and the keep-the-first-client
|
||||
rule are two branches of one block gated by `status ==
|
||||
SocketStatus.Connected && tcp.IsClient` (`:1980-1981`), so a server-accepted
|
||||
socket reaches neither: a peer that announces our own `MachineId` over an
|
||||
inbound connection is silently tolerated. Note 4's client-only observation
|
||||
about the dedup half is the same gate.
|
||||
4. **Duplicate clients are suppressed twice; duplicate servers never are.** The
|
||||
newcomer closes itself just before it would become trusted
|
||||
(`SocketStuff.cs:1421-1428`), and `UpdateTcpSockets` independently keeps the
|
||||
|
||||
Reference in new issue
Block a user