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

Support http proxies #11043

Merged
merged 6 commits into from
May 26, 2022
Merged

Support http proxies #11043

merged 6 commits into from
May 26, 2022

Conversation

msujew
Copy link
Member

@msujew msujew commented Apr 19, 2022

What it does

Closes #7797
Closes #10267

For some reason GitHub force-closed my old PR while force-pushing and doesn't allow me to reopen it, so I had to create a new PR. See #10958 for previous discussion.

Adds general proxy support to the whole application (backend+frontend) by using a RequestService which comes with automatic proxy support. Other services and downstream applications are encouraged to use that service whenever requests to non-origin or non-localhost web-services are performed.

Also patches the http and https node.js imports for the extension host. This enables extensions to perform requests through proxies as well.

For electron there's currently a large TODO: Automatic OS proxy detection doesn't work yet, since that requires access to the electron-main process (see also #10698).

How to test

Generally, testing this PR requires setting up firewall rules which block all outgoing traffic and configuring a local proxy rule. I used Fiddler Classic (Windows only?) which sets itself up at http://localhost:8888. I assume Mac and Linux users have a simpler time configuring such a proxy.

Also, these tests should preferably performed using the Electron version. The browser version will automatically use the OS proxy for stuff like fetching vsx search results, whereas the electron version will fail if the proxy is not configured.

  1. Open the vsx registry and search for java. Nothing should appear if outbound traffic is blocked.
  2. Search in the preferences for proxy and set the Http: Proxy preference to your local proxy url.
  3. Confirm that re-searching displays results (frontend request) and allows to install the extension (backend request).
  4. Install the proxy-test extension.
  5. Execute the Hello World Request command. It will send a request to https://www.google.com and display the error message/success code.
  6. Change the Http: Proxy support preference. override, fallback and on should all provide the same success result, while off should display an error, since the extension proxy support has been turned off.

There are now proxy settings for fetching packages from ovsx registries using the theia download:plugins command.

  1. Delete your plugins folder.
  2. Executing theia download:plugins should result in an error, since the outgoing download requests are blocked
  3. Adding the --proxy-url <url> parameter should enable successful download of these extensions.

Review checklist

Reminder for reviewers

@msujew msujew requested a review from colin-grant-work April 19, 2022 15:14
@msujew msujew force-pushed the msujew/http-proxy branch from b5c878d to 35c380d Compare April 20, 2022 09:35
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on the code after a more thorough read through. I am setting up my proxy settings now to test the functionality...

dev-packages/ovsx-client/src/ovsx-client.ts Outdated Show resolved Hide resolved
dev-packages/ovsx-client/src/ovsx-client.ts Outdated Show resolved Hide resolved
dev-packages/request-service/README.md Outdated Show resolved Hide resolved
dev-packages/request-service/src/request-service.ts Outdated Show resolved Hide resolved
dev-packages/request-service/src/node-request-service.ts Outdated Show resolved Hide resolved
packages/core/src/node/request/backend-request-facade.ts Outdated Show resolved Hide resolved
packages/core/src/node/request/proxy.ts Outdated Show resolved Hide resolved
@colin-grant-work
Copy link
Contributor

Functionally, I believe that this is working more or less as advertised. I'm not an expert on proxies or firewalls, but having set both up naïvely, traffic for Electron appears to be running through the configured proxy and making it through the firewall. @paul-marechal, I know you have some experience setting up proxies / throttlers on Linux, so if you'd be willing to give it a test, I'd appreciate it.

@msujew msujew force-pushed the msujew/http-proxy branch from 35c380d to 7782fa3 Compare April 21, 2022 17:20
@msujew msujew force-pushed the msujew/http-proxy branch from 7782fa3 to 07491ac Compare May 17, 2022 13:24
Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks mostly good to me, just a few oddities.

@msujew msujew force-pushed the msujew/http-proxy branch from b9d3f7c to a935b5e Compare May 25, 2022 11:07
Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as first iteration. We can take care of the missing bits in Electron later with IPC/RPC.

@vince-fugnitto
Copy link
Member

@msujew I believe the proxy part of download:plugins should actually fix #10267 😃

@msujew msujew force-pushed the msujew/http-proxy branch from 85423b5 to 89a9f97 Compare May 25, 2022 22:42
@msujew msujew force-pushed the msujew/http-proxy branch from 89a9f97 to 671b477 Compare May 26, 2022 11:10
@msujew msujew mentioned this pull request Mar 7, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requests issues related to requests / proxies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yarn download:plugins disregard proxy settings Theia Electron Application - Proxy settings
4 participants