-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Enabling listening on tcp port when proxy is used for peer connections #7726
Open
Masong19hippows
wants to merge
5
commits into
arvidn:RC_2_0
Choose a base branch
from
Masong19hippows:listenOnTCPWithProxy
base: RC_2_0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30
−12
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3bacdcc
Enabling listening on tcp port when proxy is used for peer connections
4bf0c21
Correct natpmp
Masong19hippows 2db609b
Adding listen proxy setting
Masong19hippows eb2a910
Fixed always on listening
Masong19hippows 91081ce
Changing listen_on_proxy to proxy_accept_incoming
Masong19hippows File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -830,6 +830,8 @@ bool ssl_server_name_callback(ssl::stream_handle_type stream_handle, std::string | |
if (val) s.set_int(settings_pack::proxy_type, int(val.int_value())); | ||
val = settings.dict_find_int("proxy_hostnames"); | ||
if (val) s.set_bool(settings_pack::proxy_hostnames, val.int_value() != 0); | ||
val = settings.dict_find_int("proxy_accept_incoming"); | ||
if (val) s.set_bool(settings_pack::proxy_accept_incoming, val.int_value() != 0); | ||
val = settings.dict_find_int("proxy_peer_connections"); | ||
if (val) s.set_bool(settings_pack::proxy_peer_connections, val.int_value() != 0); | ||
val = settings.dict_find_string("hostname"); | ||
|
@@ -2056,7 +2058,8 @@ namespace { | |
// if we don't proxy peer connections, don't apply the special logic for | ||
// proxies | ||
if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections)) | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections) | ||
&& !m_settings.get_bool(settings_pack::proxy_accept_incoming)) | ||
{ | ||
// we will be able to accept incoming connections over UDP. so use | ||
// one of the ports the user specified to use a consistent port | ||
|
@@ -2820,12 +2823,12 @@ namespace { | |
async_accept(listener, ssl); | ||
|
||
// don't accept any connections from our local listen sockets if we're | ||
// using a proxy. We should only accept peers via the proxy, never | ||
// directly. | ||
// using a proxy and the correct setting isn't set. | ||
// This path is only for accepting incoming TCP sockets. The udp_socket | ||
// class also restricts incoming packets based on proxy settings. | ||
if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections)) | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections) | ||
&& !m_settings.get_bool(settings_pack::proxy_accept_incoming)) | ||
return; | ||
|
||
auto listen = std::find_if(m_listen_sockets.begin(), m_listen_sockets.end() | ||
|
@@ -5522,11 +5525,11 @@ namespace { | |
if (m_listen_sockets.empty()) return 0; | ||
if (sock) | ||
{ | ||
// if we're using a proxy, we won't be able to accept any TCP | ||
// connections. Not even uTP connections via the port we know about. | ||
// The DHT may use the implied port to make it work, but the port we | ||
// announce here has no relevance for that. | ||
if (sock->flags & listen_socket_t::proxy) | ||
|
||
if (sock->flags & listen_socket_t::proxy | ||
&& !m_settings.get_bool(settings_pack::proxy_accept_incoming)) | ||
return 0; | ||
|
||
if (!(sock->flags & listen_socket_t::accept_incoming)) | ||
|
@@ -5535,6 +5538,11 @@ namespace { | |
return std::uint16_t(sock->tcp_external_port()); | ||
} | ||
|
||
if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections) | ||
&& !m_settings.get_bool(settings_pack::proxy_accept_incoming)) | ||
return 0; | ||
|
||
#ifdef TORRENT_SSL_PEERS | ||
for (auto const& s : m_listen_sockets) | ||
{ | ||
|
@@ -5566,9 +5574,6 @@ namespace { | |
return std::uint16_t(sock->tcp_external_port()); | ||
} | ||
|
||
if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | ||
&& m_settings.get_bool(settings_pack::proxy_peer_connections)) | ||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have expected this also depend on the |
||
|
||
for (auto const& s : m_listen_sockets) | ||
{ | ||
|
@@ -5664,7 +5669,7 @@ namespace { | |
|
||
if (!s->natpmp_mapper | ||
&& !(s->flags & listen_socket_t::local_network) | ||
&& !(s->flags & listen_socket_t::proxy)) | ||
&& m_settings.get_bool(settings_pack::proxy_accept_incoming)) | ||
{ | ||
// the natpmp constructor may fail and call the callbacks | ||
// into the session_impl. | ||
|
@@ -6891,7 +6896,7 @@ namespace { | |
// connected to the internet. The whole point is to forward ports through | ||
// the gateway | ||
if ((s->flags & listen_socket_t::local_network) | ||
|| (s->flags & listen_socket_t::proxy)) | ||
|| (s->flags & !m_settings.get_bool(settings_pack::proxy_accept_incoming))) | ||
return; | ||
|
||
if (!s->upnp_mapper) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it would be better to update or extend this comment, rather than removing it