-
Notifications
You must be signed in to change notification settings - Fork 965
Added brave vpn connection manager interface and initial Windows impls #8920
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
Conversation
1cf2771
to
b89220b
Compare
91d7217
to
caaed8a
Compare
8302e74
to
1d41aa8
Compare
@bsclifton Ready to review! PTAL :) |
@deeppandya My PR will make some merge conflict to your PR (#7904). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments left; great job here! 😄
@bsclifton Addressed. Thanks for review! |
Approved, pending security review and also review by @deeppandya 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few suggestions around buffer sizes. Memory management is easy to get wrong in C so I tend to be extra-careful around these, but let me know if there's a reason why these were done with bare constants.
components/brave_vpn/utils_win.cc
Outdated
// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage | ||
void PrintSystemError(DWORD error) { | ||
DWORD c_buf_size = 512; | ||
TCHAR lpsz_error_string[512]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure there is never a mismatch between the buffer size and what we pass to FormatMessage()
, I would do something like:
constexpr DWORD c_buf_size = 512;
TCHAR lpsz_error_string[c_buf_size];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
components/brave_vpn/utils_win.cc
Outdated
credentials.dwMask = RASCM_UserName | RASCM_Password; | ||
|
||
wcscpy_s(credentials.szUserName, 256, username); | ||
wcscpy_s(credentials.szPassword, 256, password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of 256
, it might be better to use UNLEN+1
and PWLEN+1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed all comments for buf length.
and looking at https://github.com/brave/brave-core/pull/8920/files#r645919998
components/brave_vpn/utils_win.cc
Outdated
// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage | ||
void PrintSystemError(DWORD error) { | ||
DWORD c_buf_size = 512; | ||
TCHAR lpsz_error_string[512]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
components/brave_vpn/utils_win.cc
Outdated
credentials.dwMask = RASCM_UserName | RASCM_Password; | ||
|
||
wcscpy_s(credentials.szUserName, 256, username); | ||
wcscpy_s(credentials.szPassword, 256, password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
components/brave_vpn/utils_win.cc
Outdated
} | ||
lp_ras_dial_params->dwSize = sizeof(RASDIALPARAMS); | ||
wcscpy_s(lp_ras_dial_params->szEntryName, 256, entry_name); | ||
wcscpy_s(lp_ras_dial_params->szDomain, 15, L"*"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to DNLEN + 1
Hmm, I got |
Implementation will depends on OS platform.
and vpntool command line tool is introduced.
and used chromium api as many as possible.
ras api could block main thread. Client will get the result by observation.
and uses constness as many as possible.
6d7f61e
to
9ac70fe
Compare
9ac70fe
to
8ef351e
Compare
Thanks for the great review, @fmarier 😄👍 |
Added vpn connection manager interface
Added Initial impls for Windows OS.
fix brave/brave-browser#15805
Security review: https://github.com/brave/security/issues/468
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
vpntool
in bc directory -ninja -C ../out/Components vpntool
../out/Components/vpntool.exe --connections
../out/Components/vpntool.exe --entries
../out/Components/vpntool.exe --devices
../out/Components/vpntool.exe --create --host_name=xxx --vpn_name=xxx --user_name=xxx --password=xxx
../out/Components/vpntool.exe --remove --vpn_name=xxx
../out/Components/vpntool.exe --connect --vpn_name=xxx
../out/Components/vpntool.exe --disconnect --vpn_name=xxx