Skip to content

Commit 4a4df74

Browse files
committed
Try to discover peers that are behind a different port
1 parent 3e4e16d commit 4a4df74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tribler/core/tunnel/community.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from ipv8.messaging.anonymization.payload import CreatedPayload, CreatePayload, ExtendedPayload
3232
from ipv8.messaging.interfaces.endpoint import Endpoint
3333
from ipv8.messaging.interfaces.udp.endpoint import Address
34+
from ipv8.messaging.payload import IntroductionResponsePayload, NewIntroductionResponsePayload
35+
from ipv8.messaging.payload_headers import GlobalTimeDistributionPayload
3436
from ipv8.peer import Peer
3537
from ipv8_rust_tunnels.endpoint import RustEndpoint
3638

@@ -378,6 +380,19 @@ def get_download(self, lookup_info_hash: bytes) -> Download | None:
378380
return download
379381
return None
380382

383+
def introduction_response_callback(self, peer: Peer, dist: GlobalTimeDistributionPayload,
384+
payload: IntroductionResponsePayload | NewIntroductionResponsePayload) -> None:
385+
"""
386+
Try to discover peers that are behind a different port.
387+
"""
388+
if (payload.wan_introduction_address != ("0.0.0.0", 0)
389+
and payload.lan_introduction_address != ("0.0.0.0", 0)
390+
and payload.wan_introduction_address[0] != self.my_estimated_wan[0]):
391+
addr = (payload.wan_introduction_address[0], payload.lan_introduction_address[1])
392+
self.network.discover_address(peer, addr, self.community_id, payload.intro_supports_new_style)
393+
394+
return super().introduction_response_callback(peer, dist, payload)
395+
381396
@task
382397
async def create_introduction_point(self, info_hash: bytes, required_ip: Peer | None = None) -> None:
383398
"""

0 commit comments

Comments
 (0)