mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 17:45:42 +00:00
fix(rdclient): encode protobuf string enums via fromObject (keyboard control keys)
serializeMessage used Message.create() which does NOT convert string enum names to numeric values. A KeyEvent with controlKey:'Backspace' (or Space/Tab/Return/arrows) and mode:'Legacy' was encoded as control_key=0 (Unknown), so every non-character key was silently dropped by the peer while numeric chr letter keys worked. Switched to Message.fromObject() which converts enum name strings to their numeric values and preserves Uint8Array byte fields (clipboard content, file blocks, password, public keys). Verified round-trip: Backspace->2, Space->30, mode Legacy->0, bytes/login/file-block/mouse intact. This commit was made possible thanks to Insolve.
This commit is contained in:
@@ -107,9 +107,16 @@ class RDProtocol {
|
||||
/**
|
||||
* Serialize a Message to raw protobuf bytes (NO frame header)
|
||||
* Use this when encryption will be applied before framing
|
||||
*
|
||||
* Uses fromObject() (not create()) so that string enum names — e.g. a
|
||||
* KeyEvent's `controlKey: 'Backspace'` or `mode: 'Legacy'` — are converted
|
||||
* to their numeric enum values. create() leaves them as strings, which the
|
||||
* encoder writes as 0 (Unknown), breaking every non-character key. Byte
|
||||
* fields supplied as Uint8Array (clipboard content, file blocks, keys) are
|
||||
* preserved as-is by fromObject().
|
||||
*/
|
||||
serializeMessage(msgObj) {
|
||||
const msg = this.types.Message.create(msgObj);
|
||||
const msg = this.types.Message.fromObject(msgObj);
|
||||
return this.types.Message.encode(msg).finish();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user