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

feat: respect system proxy settings on Windows platform #704

Merged

Conversation

GoldJohnKing
Copy link
Contributor

Scope

closes TICKET-702

Implementation

Makes BSManager respect system proxy settings on Windows.

  1. Detect if BSManager is running on Windows. If it does, execute following steps.
  2. Read Windows system proxy settings from registry by using Winreg package.
  3. Force a global proxy by using global-agent package.

I am really not familiar to NodeJS, so implementation code should be ugly. Feel free to edit the code or give any suggestions.

I do not have Linux and macOS and is unlikely to use them. This implementation does not cover Linux or macOS.

How to Test

Without system proxy enabled on Windows:

  • Run BSManager, all functions works fine like before.
  • In the log of BSManager, you should see Proxy Enabled: false.

With system proxy enabled on Windows:

  • Set system proxy settings and enable it on Windows.
  • Run BSManager.
  • In the log of BSManager, you should see:
    [2024-12-18 17:08:04.386] [info]  Proxy Server:  http://127.0.0.1:7890
    [2024-12-18 17:08:04.403] [info]  Proxy Override:  localhost;127.*;192.168.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;<local>
    [2024-12-18 17:08:04.403] [info]  Using system proxy: http://127.0.0.1:7890
    
    That means BSManager is using system proxy.
  • If your have access to the proxy and can see which traffic goes through it, you can see BSManager's traffic goes through it.

Emoji Guide

For reviewers: Emojis can be added to comments to call out blocking versus non-blocking feedback.

E.g: Praise, minor suggestions, or clarifying questions that don’t block merging the PR.

🟢 Nice refactor!

🟡 Why was the default value removed?

E.g: Blocking feedback must be addressed before merging.

🔴 This change will break something important

Blocking 🔴 ❌ 🚨 RED
Non-blocking 🟡 💡 🤔 💭 Yellow, thinking, etc
Praise 🟢 💚 😍 👍 🙌 Green, hearts, positive emojis, etc

@silentrald
Copy link
Contributor

@GoldJohnKing
Can you try if you can make this toggle-able in the settings page. So that users can just turn this on if they need to when they have proxy issues.

Is it also possible to set the proxy string within BSManager itself as well 🤔?


Also not sure if Winreg is just viewing the Regedit values but can you check regedit-rs since its similar and already within the project's dependencies, much better to reuse existing deps rather than adding one.

Copy link
Owner

@Zagrios Zagrios left a comment

Choose a reason for hiding this comment

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

Hi, thanks a lot for your PR!
But can you use regedit-rs, which we already use for registry manipulation instead of winreg?
https://www.npmjs.com/package/regedit-rs

Edit: Oops, I hadn't seen @silentrald 's comment 😅

@GoldJohnKing GoldJohnKing force-pushed the feat/702-respect-system-proxy-windows branch from 6a1fdb7 to 57b7ee0 Compare December 23, 2024 10:11
@GoldJohnKing GoldJohnKing force-pushed the feat/702-respect-system-proxy-windows branch from e6a1e21 to 9e9fc14 Compare December 23, 2024 10:25
@GoldJohnKing GoldJohnKing requested a review from Zagrios December 23, 2024 10:29
@GoldJohnKing
Copy link
Contributor Author

Hi, I made the changes from winreg to regedit-rust.

As for the toggole-able setting page option suggested by @silentrald, I am not familiar to NodeJS and Electron. If it's a necessary function, would you please point me where to start from?

@silentrald
Copy link
Contributor

@GoldJohnKing

Try looking into advancedItems in settings-page.component.tsx. Then you can use staticConfig set and get from the client and server side code. We can just do the toggle input for now I guess, but if you can add the input text then it a nice to have feature.

Here's the reference in BSM itself.
image

@GoldJohnKing
Copy link
Contributor Author

@silentrald @Zagrios

Hi, toggle-able option is added, please check.

src/main/helpers/proxy.helpers.ts Show resolved Hide resolved
src/renderer/pages/settings-page.component.tsx Outdated Show resolved Hide resolved
assets/jsons/translations/en.json Outdated Show resolved Hide resolved
Copy link

@GoldJohnKing
Copy link
Contributor Author

@silentrald

Hi, all requested changes have been done, please check.

Thanks for your suggests!

@silentrald
Copy link
Contributor

@GoldJohnKing No more issues on my end, great job 😃.

Unfortunately I don't have merge permissions though, so just wait for @Zagrios to test it as well if everything's good. Hopefully this gets merged soon. gl gl.

Copy link
Owner

@Zagrios Zagrios left a comment

Choose a reason for hiding this comment

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

That's seems good to me 🙌
Thanks @GoldJohnKing ❤️

@Zagrios
Copy link
Owner

Zagrios commented Dec 26, 2024

Thanks @silentrald for the review ❤️
Github tells me their is still one requested change pending but I didn't see it anywhere, is it a ghost request changes ? 😅

@silentrald
Copy link
Contributor

@Zagrios let me double check if i can unblock it on my end

@Zagrios Zagrios merged commit 8a89777 into Zagrios:master Dec 26, 2024
2 checks passed
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.

3 participants