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

Add Brave VPN WireGuard setting to brave://settings/system #19531

Merged
merged 14 commits into from
Aug 10, 2023

Conversation

spylogsster
Copy link
Contributor

@spylogsster spylogsster commented Aug 2, 2023

Resolves brave/brave-browser#32002

  • Added Brave VPN section brave://settings/system
  • Added option to enable/disable Brave VPN Wireguard protocol
  • Disabling the option if Brave VPN connected.
  • Checking if the wireguard service was not registered and register it with elevated request.
  • Removed Wireguard feature flag.

Videos:

  • Register the service:
register.wg.service.mp4
  • Disable the option if VPN connected:
disable.if.connected.mp4
  • Enable/disable wireguard protocol:
2023-08-02_13h02_21.mp4

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  • Go to brave://settings/system and enable/disable Use WireGuard for Brave VPN toggler.
  • The protocol used by Brave VPN should meet the option value.
  • If the service was not registered (try to remove it using sc delete [service name] from admin cmd). The browser should ask admin permissions to register the service if the option enabled.
  • if Brave VPN connected, the option should be reset to initial value and disabled while the vpn connected.
  • if Status Tray icon launched it should be stopped when Wireguard protocol is turned off.

@spylogsster spylogsster self-assigned this Aug 2, 2023
@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Aug 2, 2023
@spylogsster spylogsster changed the title Brave 32002 Add Brave VPN WireGuard setting to brave://settings/system Aug 2, 2023
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@spylogsster spylogsster force-pushed the brave-32002 branch 2 times, most recently from e6d3ad7 to 5274df7 Compare August 2, 2023 11:24
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@spylogsster spylogsster force-pushed the brave-32002 branch 2 times, most recently from 6a5ec6c to fee845f Compare August 3, 2023 11:24
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@spylogsster spylogsster force-pushed the brave-32002 branch 2 times, most recently from 4a42fd2 to 1059062 Compare August 4, 2023 04:51
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@spylogsster spylogsster marked this pull request as ready for review August 4, 2023 07:58
@spylogsster spylogsster requested review from a team as code owners August 4, 2023 07:58
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Lots of super small details here - checked them all out (both the code and trying the PR). Nicely done w/ the webui handler and moving the feature check code into utils methods. Everything LGTM and test plan works great 😄👍

Copy link
Contributor

@sangwoo108 sangwoo108 left a comment

Choose a reason for hiding this comment

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

LGTM with a few minor nits 👍

Comment on lines 95 to 101
EXPAND_FEATURE_ENTRIES({ \
kBraveVPNWireguardFeatureInternalName, \
"Enable experimental WireGuard Brave VPN service", \
"Experimental WireGuard VPN support. Not implemented yet", \
"Experimental WireGuard VPN support. Deprecated.", \
kOsWin, \
FEATURE_VALUE_TYPE(brave_vpn::features::kBraveVPNUseWireguardService), \
})
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could we remove this entirely? As the feature value would be migrated into pref, I think we can hide this flag from the brave://flags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have already tried, looks like no becuse we need to know the actual value to migrate

Copy link
Contributor

Choose a reason for hiding this comment

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

That's intersting. I thought leaving features.cc as is and removing only this part would work. 🤔

browser/ui/webui/settings/brave_vpn/brave_vpn_handler.h Outdated Show resolved Hide resolved
Comment on lines 43 to 45
if (service) {
Observe(service);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should consider it as a failure when |service| doesn't exist. If we should, I think CHECK(service) could make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -36,7 +36,10 @@ bool HasValidSubscriberCredential(PrefService* local_prefs);
std::string GetSubscriberCredential(PrefService* local_prefs);
bool HasValidSkusCredential(PrefService* local_prefs);
std::string GetSkusCredential(PrefService* local_prefs);

bool IsBraveVPNWireguardEnabled(PrefService* local_state);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move IsBraveVPNWireguardEnabled into the IS_WIN guard? It seems we're not using this when it's not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

We will be adding WireGuard support on other platforms - hopefully soon 🙂 (macOS and Linux)

Comment on lines +14 to +19
<settings-toggle-button id="toggleWireguardButton"
pref="{{prefs.brave.brave_vpn.wireguard_enabled}}"
label="$i18n{useWireguardLabel}"
sub-label="[[toggleWireguardSubLabel_]]"
disabled="[[braveVpnConnected_]]"
on-change="onChange_">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we render this only when it's os win?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@bsclifton bsclifton Aug 12, 2023

Choose a reason for hiding this comment

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

this seems to be causing a problem on macOS
image

if (!status.has_value()) {
return false;
}
return status.value() == SERVICE_RUNNING;
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why is SERVICE_START_PENDING is not considered as 'running' state unlike IsBraveVPNWireguardTunnelServiceRunning() does. Is it just because how each backend works is different?

Copy link
Contributor Author

@spylogsster spylogsster Aug 10, 2023

Choose a reason for hiding this comment

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

yep, IsBraveVPNWireguardTunnelServiceRunning reflects the status of the tunnel service in runtime to show necessary icons, but in IsWindowsServiceRunning mostly used to ensure we have vpn in working state which is not correct for SERVICE_START_PENDING event.

@spylogsster spylogsster enabled auto-merge (squash) August 10, 2023 16:06
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@spylogsster spylogsster merged commit 7fb458e into master Aug 10, 2023
13 checks passed
@spylogsster spylogsster deleted the brave-32002 branch August 10, 2023 18:34
@github-actions github-actions bot added this to the 1.59.x - Nightly milestone Aug 10, 2023
@github-actions github-actions bot added potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) labels Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) CI/storybook-url Deploy storybook and provide a unique URL for each build needs-security-review potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Brave VPN WireGuard setting to brave://settings/system
9 participants