|
28 | 28 | from ipv8.messaging.anonymization.payload import CreatedPayload, CreatePayload, ExtendedPayload |
29 | 29 | from ipv8.messaging.interfaces.endpoint import Endpoint |
30 | 30 | from ipv8.messaging.interfaces.udp.endpoint import Address |
| 31 | + from ipv8.messaging.payload import IntroductionResponsePayload, NewIntroductionResponsePayload |
| 32 | + from ipv8.messaging.payload_headers import GlobalTimeDistributionPayload |
31 | 33 | from ipv8.peer import Peer |
32 | 34 | from ipv8_rust_tunnels.endpoint import RustEndpoint |
33 | 35 |
|
@@ -375,6 +377,19 @@ def get_download(self, lookup_info_hash: bytes) -> Download | None: |
375 | 377 | return download |
376 | 378 | return None |
377 | 379 |
|
| 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 | + |
378 | 393 | @task |
379 | 394 | async def create_introduction_point(self, info_hash: bytes, required_ip: Peer | None = None) -> None: |
380 | 395 | """ |
|
0 commit comments