clipboard: acceptHandshake returns Void; the handshake always ends the parse loop

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 04:59:50 -07:00
1 parent 1365db96e4
commit 9b5a05ce4e
1 file changed
+6 -5
+6 -5
View File
@@ -193,8 +193,10 @@ final class BulkConnection: @unchecked Sendable {
switch phase {
case .handshake:
guard inbox.count >= packageSizeEx else { return }
let bytes = take(packageSizeEx)
guard acceptHandshake(bytes) else { return }
// Either way this ends the loop: the handshake is followed by a
// wait for the Engine's answer, or by failure.
acceptHandshake(take(packageSizeEx))
return
case .header:
guard inbox.count >= ClipboardCodec.bulkHeaderSize else { return }
@@ -225,7 +227,7 @@ final class BulkConnection: @unchecked Sendable {
// MARK: - The handshake (`Clipboard.cs:996-1037`)
private func acceptHandshake(_ bytes: Data) -> Bool {
private func acceptHandshake(_ bytes: Data) {
// The package is raw here, not framed: Windows assigns the four type
// bytes straight into the struct (`DATA.cs:115-121`), so bytes 1..3
// must be zero or `Type` is not the value it looks like.
@@ -235,7 +237,7 @@ final class BulkConnection: @unchecked Sendable {
let name = packet.machineName, !name.isEmpty
else {
fail("clipboard handshake rejected")
return false
return
}
peerName = name
peerID = packet.src
@@ -251,7 +253,6 @@ final class BulkConnection: @unchecked Sendable {
guard let self else { return }
self.queue.async { self.authorised(allowed, peerPushes: peerPushes) }
})
return false
}
private func authorised(_ allowed: Bool, peerPushes: Bool) {