Repository navigation
Conversation
6152af4 to
d22d24c
Compare
|
Hi. I merged current master into this branch, including the extended-key modifier. Sunshine and Moonlight Qt are both waiting on this protocol change. Could you review it when you have time? |
|
Hi @cgutman ReenigneArcher approved this on October 3 and Sunshine and the Moonlight Qt setting are waiting on it. Could you take a look when you have time? Thanks |
|
Hello |
| } | ||
|
|
||
| // The unencrypted input path encrypts into a 128-byte stack buffer. | ||
| if (!isControlStreamEncrypted()) { |
There was a problem hiding this comment.
We need to check IS_SUNSHINE() here too.
| token ^= token << 5; | ||
| if (token == 0) { | ||
| token = 1; | ||
| } |
There was a problem hiding this comment.
What is the purpose of the token?
| char stackBuffer[256]; | ||
| char* plainBuffer = stackBuffer; | ||
|
|
||
| if (paylen < 0 || paylen > 65535) { |
There was a problem hiding this comment.
You can drop these changes. We encrypt in place now.
| packet = (PNVCTL_ENET_PACKET_HEADER_V2)plainBuffer; | ||
| packet->type = ptype; | ||
| packet->payloadLength = paylen; | ||
| packet->payloadLength = (unsigned short)paylen; |
There was a problem hiding this comment.
This is an unsafe truncating cast.
|
|
||
| // The unencrypted input path encrypts into a 128-byte stack buffer. | ||
| if (!isControlStreamEncrypted()) { | ||
| return -1; |
| int LiSendUtf8TextEvent(const char *text, unsigned int length); | ||
|
|
||
| // Send clipboard text to a Sunshine host. length 0 subscribes to host clipboard | ||
| // updates and does not change the host clipboard. Requires an encrypted control stream. |
There was a problem hiding this comment.
Client authors don't know what an encrypted control stream is. I would just remove that detail.
| return -1; | ||
| } | ||
|
|
||
| holder->channelId = 0; |
There was a problem hiding this comment.
Use a new channel ID for this. You can take 0x6 which used to be for UTF-8 data.
| break; | ||
| case IDX_CLIPBOARD_TEXT: | ||
| if (ListenerCallbacks.clipboardText != NULL) { | ||
| ListenerCallbacks.clipboardText(queuedCb->data.clipboardText.token, |
There was a problem hiding this comment.
Null check is not necessary, since the callback infrastructure ensures all callback pointers are populated
Clipboard sends are Sunshine-only on channel 0x6, and the unused echo token is gone. The control stream keeps master's in-place encryption.
|
I think the 32KB limit might be a problem in practice, so I introduced a new jumbo control message for you in 4853e70. Your Sunshine PR will need to be updated to add support for parsing this new header, but that should be pretty easy. Can you adapt your changes to increase the limit clipboard data on to something larger like a few MB? |
|
Yes i agree with you, i initially gave it a small limit for testing What size do you think would be sufficient? Also should we do images and other files? Personally I use copy/paste images all the time but idk if it fits this thing without hacky workarounds |
|
I think we could model something after the SDL3 clipboard API with a bidirectional protocol with 3 message types:
We would likely need some sort of chunking scheme for cases where the clipboard data is larger than 32 MB (the default ENet packet size limit). Edit: I can take a stab at a protocol design later. |
Either side offers the MIME types on its clipboard when it changes. The other side requests the types it wants and receives each one as data, tied to the offer by a sequence number. Data over 4 MB is sent in chunks of jumbo control messages, up to 64 MB. An offer with no types subscribes to host clipboard changes. This replaces the text-only clipboard messages.
|
@cgutman reworked this based on your offer/request payload idea:
Other side of it:
Tested 6 MB both ways between a Mac client and a Linux host, fully working Can you take another look when you get a chance? |
Summary
LiSendClipboardText()so a client can send UTF-8 clipboard text to the host. A zero-length send subscribes to host updates and does not change the host clipboard.0x5505. Clients that do not implement the new callback ignore it.This is the protocol piece for Sunshine and Moonlight Qt pull requests that use the same commit.
Test plan