-
Notifications
You must be signed in to change notification settings - Fork 893
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
Tor profile service #357
Tor profile service #357
Conversation
c43af3c
to
187bcbc
Compare
C70 rebased |
tor::TorProfileService* TorProfileServiceFactory::GetForProfile( | ||
Profile* profile) { | ||
if (profile->IsOffTheRecord()) | ||
return NULL; |
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.
nit: prefer nullptr since that's the standard.
Brians-iMac-Pro-2:src brianbondy$ git grep return\ NULL | wc -l
3843
Brians-iMac-Pro-2:src brianbondy$ git grep return\ nullptr | wc -l
12074
browser/tor/BUILD.gn
Outdated
"//components/keyed_service/content", | ||
"//components/keyed_service/core", | ||
# for profile.h | ||
"//components/domain_reliability", |
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 think alphabetical is preferred?
if i understand correctly, this doesn't actually provide a Tor binary yet? FYI we will be updating to Tor 0.3.4 soon so i recommend testing with that: brave/tor_build_scripts#23 |
Tor binary is already provided as a crx installation, works the same way extension install works. |
See Tor scripts here: |
And we access it through TorClientUpdater #316 |
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.
Nothing major, awesome work!
void TorProxyConfigService::TorSetProxy( | ||
net::ProxyResolutionService* service, | ||
const std::string& tor_proxy, | ||
const std::string& site_url, |
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.
Since we bind these parameters, this will cause various crashes. These must be std::string
and not a const std::string&
if (url.scheme.is_valid()) { | ||
scheme_ = | ||
std::string(tor_proxy.begin() + url.scheme.begin, | ||
tor_proxy.begin() + url.scheme.begin + url.scheme.len); |
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.
Can all of these be expressed more simply like this?
scheme_ = tor_proxy.substr(url.scheme.begin, url.scheme.len);
tor_proxy.begin() + url.port.begin + url.port.len); | ||
} | ||
std::string proxy_url; | ||
if (tor_proxy_map && !username.empty()) { |
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.
What is the right thing to do if host_ is not filled or port_ is not filled?
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.
it actually doesn't matter here because the config will remain empty but I will still do a early return when scheme_ or host_ or port_ is empty.
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.
ok
// map, the old entry in the queue will cease to affect it because | ||
// the timestamps won't match, and they will simultaneously create a | ||
// new entry in the queue. | ||
map_.erase(username); |
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.
Should we wrap this to check if it exists in the map first? I think it will cause a crash if it doesn't if there was no Get
called.
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 don't get it, if you are able to call TorProxyMap::Erase
that means you have TorProxyMap
instance which always has a std::map<std::string, std::pair<std::string, base::Time> >
in it. Even if you specify non existent key, the erase operation just return 0. There shouldn't be any crashes.
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.
ok
static void TorSetProxy( | ||
net::ProxyResolutionService* service, | ||
const std::string& tor_proxy, | ||
const std::string& site_url, |
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.
Update to std::string.
diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc b/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc | ||
index a053f001493dc3815ee9bb0a6d4526bfe65718dd..348a783485741370796073076cbbf78666911665 100644 | ||
--- a/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc | ||
+++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc |
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 prefer a subclass for the tooltip patch since I envision multiple different types of things here in the future.
service_manager::switches::kNoSandbox)) { | ||
base::LaunchOptions options; | ||
options.handles_to_inherit = handles_to_inherit; | ||
+ options.start_hidden = true; |
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.
are there any other process types started here which we don't want hidden?
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.
for now, we only want to hide utility process type for audio service and tor launcher service specifically
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.
do you know for sure nothing else uses this code path though?
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.
seems like all child process on Window will enter this function but only non sandboxed child process would hit this block
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.
and in that case, you will see the popup terminal window so that would be only audio service and tor launcher service for now
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.
we can also enable service_manager::features::kAudioServiceSandbox
and I can add this specifically for tor launcher service
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.
Audio Service part is updated in the issue.
brave/brave-browser#714 (comment)
// artificial and background page shouldn't be created in it. | ||
// http://crbug.com/329498 | ||
- return is_normal_session || profile->IsOffTheRecord(); | ||
+ return is_normal_session || profile->IsOffTheRecord() || profile->IsTorProfile(); |
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.
Can we allow it for guest profiles here too? Or is there some problem why it's disallowed?
I think we can add this to fixed list if so:
brave/brave-browser#376
app/brave_generated_resources.grd
Outdated
<message name="IDS_PROFILES_OPEN_TOR_PROFILE_BUTTON" desc="Button in the avatar menu bubble view to open a tor window."> | ||
Open Tor Window | ||
</message> | ||
<message name="IDS_PROFILES_TOR_PROFILE_NAME" desc="Name of the tor profile."> |
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.
nit: I know it's only a description, but capitalization might help a localizer to know it's a name.
void TorProfileServiceImpl::SetNewTorCircuit(const GURL& request_url) {} | ||
void TorProfileServiceImpl::SetNewTorCircuitOnIOThread( | ||
const scoped_refptr<net::URLRequestContextGetter>& getter, | ||
const std::string& host) { |
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.
Use std::string host
here or it can introduce crashes.
0d0dcb7
to
30abf5c
Compare
// This needs to run after ChromeTestSuite::Initialize which calls content's | ||
// intialization which calls base's which initializes ICU. | ||
InitializeResourceBundle(); | ||
+ brave::InitializeResourceBundle(); |
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.
Pls move to brave_unit_test_suite.cc
after the Initialize call.
13c5cb5
to
243c5f3
Compare
defer my review to @riastradh-brave |
fd1613b
to
3e43852
Compare
doesn't block but i opened brave/brave-core-crx-packager#24 for updating the tor version |
build and browser/unit tests pass on all platforms. Also manually verify tor function works |
namespace { | ||
void BraveLaunchOption(base::CommandLine* cmd_line, | ||
base::LaunchOptions *options) { | ||
// tor::swtiches::kTorExecutablePath |
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.
so why not just use tor::swtiches::kTorExecutablePath
like the comment says?
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.
that will have to patch the BUILD.gn and also leads to circular deps.
Probably can do when we migrate to components/tor
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.
incremental commits lgtm
Note: brave::InitializeResourceBundle cannot be called per unit test suites, it can only be called each unittest run or it will lead to duplicate resources
1. const std::string => std::string in bind function 2. Tor resource strings descrition 3. Use substr(...) 4. Early return when scheme_, host_ or port_ is empty 5. nits
to prevent it from generating new terminal window on Windows
5735691
to
e81c259
Compare
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.
LGTM, sorry this took so long! A lot of the logic is essentially the same as in muon. The organization into keyed services is cleaner, as we discussed with brianjohnson.
args.AppendArg("--cookieauthentication"); | ||
args.AppendArg("1"); | ||
args.AppendArg("--cookieauthfile"); | ||
args.AppendArgPath(tor_watch_path.AppendASCII("control_auth_cookie")); |
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.
These are all basically the same as in muon, looks fine to me.
🎉 👍 💯 |
😻 |
- interface follow-up of #357
Bump patch version for new internal build
fix brave/brave-browser#361
fix brave/brave-browser#360
fix brave/brave-browser#376
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Manual test
cldoidikboihgcjfkhdeidbpclkineef
for mac ,cpoalefficncklhjfpglfiplenlpccdb
for Windows andbiahpgbdmdkfgndcmfiipgcebobojjkp
for Linux, in user dir)ps aux |grep <hash based on OS>
, there shouldn't be any torprocess left
Unit test
Reviewer Checklist: