-
Notifications
You must be signed in to change notification settings - Fork 894
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
Port SOCKS5 authentication from muon. #290
Conversation
namespace net { | ||
|
||
HostPortPair::HostPortPair() : port_(0) {} | ||
+#if 0 // brave override |
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 should use BRAVE_CHROMIUM_BUILD
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.
5e8611a27cd370eb31c4b0e911a38e9fc0341c9f
std::unique_ptr<ClientSocketHandle> transport_socket, | ||
const HostResolver::RequestInfo& req_info, | ||
const NetworkTrafficAnnotationTag& traffic_annotation, | ||
const HostPortPair& proxy_host_port) |
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'm sure we talked about doing a subclass/friend for HostPortPair, but I can't remember why we didn't. The only place we create the auth version is in our own code so it seems like it should work?
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.
Would presumably require making several of HostPortPair's member functions virtual. Not sure what the tradeoff is of the extra members vs making those functions virtual is. Originally I didn't touch HostPortPair at all, but rather put it into ProxyServer.
patches/net-BUILD.gn.patch
Outdated
"ssl/token_binding.h", | ||
"third_party/quic/core/quic_error_codes.cc", | ||
"third_party/quic/core/quic_error_codes.h", | ||
+ "//brave/chromium_src/net/base/host_port_pair_auth.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.
we can actually add these using a patch on the cc files. For instance: create a chromium_src patch for host_port_part.cc, include the original host_port_part.cc file and then include host_port_pair_auth.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.
cb908db81cf50cf6eafbdbed8ffe7cd683188010
patches/net-BUILD.gn.patch
Outdated
"third_party/quic/core/quic_error_codes.cc", | ||
"third_party/quic/core/quic_error_codes.h", | ||
+ "//brave/chromium_src/net/base/host_port_pair_auth.cc", | ||
+ "//brave/chromium_src/net/base/url_auth_util.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.
same thing applies to these
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.
614d17f6149feded4eb20f9049a9050ba1a5cfd2
a9a045e0dd404ef76cc00a727f41118cc4ecc17d
I eliminated the BUILD.gn and net_log_event_type_list.h patches using overrides. I could go a little further with overrides, but in some cases I'm reluctant to do that because if the code I'm overriding has changed enough, I want there to be a merge conflict that requires human attention. I could replace the definition of ParseHostAndPort, but there are various callers beyond proxy_server.cc. I think it is safer to define a new function with the semantics we need there and patch proxy_server.cc to use it -- again, if the caller in that .cc file changes, it probably deserves human attention. I could reduce the diff in host_port_pair.h a tiny bit by using a subclass for the version with an authority, but that would require making a number of member functions virtual, including several that are written in-line in host_port_pair.h, which strikes me as a net negative. |
c4eb758
to
9d1c936
Compare
I spent some time going through this with @riastradh-brave and unfortunately we couldn't use the preprocessor method to subclass HostPortPair because it gets passed by value (copy constructor) |
- Work around Chromium's new in-line constructor size limits. - Get base::StringPiece forward declaration in url_auth_util.h. - Use `#if !defined(BRAVE_CHROMIUM_BUILD)', not #if 0. - Override and include, rather than patch, net_log_event_type_list.h. - Override and include host_port_pair.cc to reduce BUILD.gn diffs. - Override and include url_util.cc rather than add url_auth_util.cc. - Override and include socks5_client_socket.cc. - Don't patch HostPortPair(host, port) constructor. Instead, use a different constructor in proxy_server.cc. This adds another patch to our maintenance burden, but it avoids changing the semantics of (and adding parsing overhead to) the constructor that is used in a bazillion places all over Chromium.
9d1c936
to
c1da167
Compare
This ports the patches, makes them work, and adds unit tests, in separate commits. (If the unit tests should go again, they can be removed -- much easier this time since all the patches are in different files.)
fix brave/brave-browser#358
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
After a build, say a Debug build:
ninja -C src/out/Debug net:net_unittests
./src/out/Debug/net_unittests --gtest_filter='ProxyServerTest.*:SOCKS5ClientSocketTest.*'
./src/out/Debug/brave --user-data-dir=/tmp/test1 --proxy-server=socks5://foo:bar@127.0.0.1:9250 &
./src/out/Debug/brave --user-data-dir=/tmp/test2 --proxy-server=socks5://baz:quux@127.0.0.1:9250 &
Reviewer Checklist: