clipboard: bulk channel on the TCP port, pull/push/accept
Listener and dials ported from SocketStuff.cs:475-495, 1566-1666 and Clipboard.cs:401-485, 1068-1099; the transfer from Clipboard.ShakeHand (961-1066), ReceiveAndProcessClipboardDataCore (498-923) and SocketStuff.SendClipboardData/SendFileEx/SendData (1673-1931). The 64-byte DATA on this connection is raw, not framed (docs/protocol.md §10.7 (a)): bytes 1..3 must be zero and are checked. Verified on loopback in the scratchpad: pull of text, push of a file, a 3 MB image across chunks, and an unauthorised peer refused. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
9ab4956551
commit
2276c20792
3 files changed
+837
-2
No files matched your search
@@ -215,8 +215,9 @@ public enum ClipboardCodec {
|
||||
repeat {
|
||||
var packet = Packet(type: type)
|
||||
packet.des = MachineID.all
|
||||
let end = min(index + Packet.clipboardChunkSize, payload.count)
|
||||
packet.payload48 = payload.subdata(in: index..<end) // zero-fills a short chunk
|
||||
// `dropFirst`/`prefix`, not `subdata(in:)`: `payload` may be a slice
|
||||
// whose indices do not start at zero.
|
||||
packet.payload48 = Data(payload.dropFirst(index).prefix(Packet.clipboardChunkSize))
|
||||
packets.append(packet)
|
||||
index += Packet.clipboardChunkSize
|
||||
} while index < payload.count
|
||||
|
||||
Reference in new issue
Block a user