-
-
Notifications
You must be signed in to change notification settings - Fork 997
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 announce_port support #7771
Conversation
Example use-caseTo secure outbound connections, a proxy server on the same subnet can be used to tunnel requests through a VPN (e.g., using pufferffish/wireproxy). Some VPNs support NAT-PMP (e.g., ProtonVPN) which could technically allow the proxy server to perform dynamic port forwarding back. Through the |
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 good to have some test coverage of this feature. Maybe you could add a test case here:
https://github.com/arvidn/libtorrent/blob/RC_2_0/simulation/test_tracker.cpp#L384-L410
27501ad
to
adea10c
Compare
A simple test coverage has been added to ensure |
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.
looks good. would you mind adding a line to Changelog
too?
b7398b9
to
798ead8
Compare
Done as well, thanks! |
should this feature affect the port we announce to the DHT? |
and I imagine it should not affect local service discovery announcements (i.e. multicast on the local network) |
The For DHT/uTP there can however be appliances between the local and remote peers; It would make sense to support overriding the announced port. I'm not familiar with DHT/uTP, do they currently use the same listening port as the TCP listener but for UDP? |
Yes, libtorrent attempts to open the listen socket for TCP and UDP on the same port. The UDP socket is used for DHT, uTP (peer connections) and UDP trackers. |
My current understanding would be as follow: For UDP trackers I think we are covered as it uses libtorrent/src/udp_tracker_connection.cpp Line 732 in 6a2c1ee
For uTP (peer connections) I don't believe there is a notion of "announcing"; it is merely the transport protocol and does not define which ports are used. For DHT we need to ensure that libtorrent/src/session_impl.cpp Lines 6217 to 6221 in 6a2c1ee
Would that make sense? |
Another DHT option is to do it at node-level where the logic already replaces libtorrent/src/kademlia/node.cpp Lines 458 to 467 in 6a2c1ee
|
I can land this PR, and if you think the DHT behavior also should change, you could make another PR. I think having this logic in the session would make sense. It might also make sense to update the documentation for the setting to make it clear that it doesn't affect local service discovery and whether or not it affects DHT announces |
I'll update the PR today to reflect that |
798ead8
to
136ff93
Compare
I might be misunderstanding the relationship between a Lines 2816 to 2820 in e5fe95f
|
there's only one DHT node (technically, one per network interface you have). And to smooth-out the network traffic, torrents announces are staggered. The session loops over all the torrents and announces them one at a time, at a pace making them all announce once per 15 minutes (or whatever the setting has been set to). |
So on top of applying Apologies if I am missing something. |
136ff93
to
81b5780
Compare
thanks for your patience. I just did one more review pass |
81b5780
to
4151391
Compare
4151391
to
884384a
Compare
thanks! |
The
announce_port
setting permits to overwrite the port passed along to trackers as the&port=
parameter. If left as the default, the listening port is used. This setting is only meant for very special cases where a seed's listening port differs from the effectively exposed port (e.g., through external NAT-PMP).This PR would be complementary to the #7726
listen_on_proxy
setting.