Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Protocol.js to enable tcp-encryption #255

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

jhgoebbert
Copy link
Contributor

This fixes issues I had with tcp-encryption in combination with the html5 client.
With this MR I can connect from the browser to a xpra server started with:
xpra start --start=xterm --bind-tcp=0.0.0.0:10000 --html=on --tcp-encryption=AES --tcp-encryption-keyfile=auth.txt

  • uintToString(..) does not exist. Hence, Uint8ToString(..) from lib/rencode.js imported at line 627 is used
  • Utilities is not in scope so Utilities.StringToUint8(..) fails. Hence, StringToUint8(..) got added to class XpraProtocol
  • Utilities is not in scope so Utilities.Uint8ToString(..) fails. Hence, Uint8ToString(..) from lib/rencode.js imported at line 627 is used
  • ord(..) is not defined. Hence, ord(..) got added to class XpraProtocol

I couldn't figure out why Utilities is out of scope in places where it is needed in Protocol.js - that's a mystery to me.
First I thought it is because of the wrong order Utilities.js and Protocol.js is included in index.html - but fixing this did not help.
(btw: another thing I came across was that Uint8ToString() is defined in Utilities.js and rencode.js the same way ... )

- uintToString(..) does not exist. Hence, Uint8ToString(..) from lib/rencode.js imported at line 627 is used
- Utilities is not in scope so Utilities.StringToUint8(..) fails. Hence, StringToUint8(..) got added to class XpraProtocol
- Utilities is not in scope so Utilities.Uint8ToString(..) fails. Hence, Uint8ToString(..) from lib/rencode.js imported at line 627 is used
- ord(..) is not defined. Hence, ord(..) got added to class XpraProtocol
@totaam totaam merged commit be138d1 into Xpra-org:master Jul 5, 2023
1 check passed
@totaam
Copy link
Collaborator

totaam commented Jul 5, 2023

Odd, I remember testing AES mode after fixing lz4 (or was it rencodeplus?).

another thing I came across was that Uint8ToString() is defined in Utilities.js and rencode.js the same way ...

This one also rings a bell. IIRC, copying the function was easier than fixing the import mess.

@jhgoebbert
Copy link
Contributor Author

I couldn't figure out why Utilities is out of scope in places where it is needed in Protocol.js - that's a mystery to me.
A colleague of mine had a second look at this and comments:
Protocol.js is loaded twice: First with scripts in index.html - (changing the order of the scripts would in principle make the Utilities visible to Protocol.js) BUT that doesn’t matter at all, as what is inside the main if-clause in Protocol.js is not run this first time. That is only called by the line this.worker = new Worker("js/Protocol.js"); (line 40 of Protocol.js) when Protocol.js is loaded the second time. And this time, the scripts that are outside are not loaded as workers run in another global context that is different from the current window.
Therefore the importScripts (on line 615) would need an additional "Utilities.js”.

@totaam
Copy link
Collaborator

totaam commented Jul 6, 2023

Therefore the importScripts (on line 615) would need an additional "Utilities.js”.

Wouldn't that be a cleaner fix?

@jhgoebbert
Copy link
Contributor Author

🤔 probably yes. I will fix that in a new MR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants