Skip to content

Commit 7987282

Browse files
committed
Try to discover peers that are behind a different port
1 parent 918bc6c commit 7987282

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
@@ -28,6 +28,8 @@
2828
from ipv8.messaging.anonymization.payload import CreatedPayload, CreatePayload, ExtendedPayload
2929
from ipv8.messaging.interfaces.endpoint import Endpoint
3030
from ipv8.messaging.interfaces.udp.endpoint import Address
31+
from ipv8.messaging.payload import IntroductionResponsePayload, NewIntroductionResponsePayload
32+
from ipv8.messaging.payload_headers import GlobalTimeDistributionPayload
3133
from ipv8.peer import Peer
3234
from ipv8_rust_tunnels.endpoint import RustEndpoint
3335

@@ -375,6 +377,19 @@ def get_download(self, lookup_info_hash: bytes) -> Download | None:
375377
return download
376378
return None
377379

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

0 commit comments

Comments
 (0)