Skip to content

Commit

Permalink
Merge pull request #5753 from qstokkink/fix_ipv8_ep_load
Browse files Browse the repository at this point in the history
Launch IPv8 with an IPv4 UDP endpoint only
  • Loading branch information
qstokkink committed Nov 27, 2020
2 parents aac6101 + 7f5f5fc commit 3c39dcf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pyipv8
Submodule pyipv8 updated 44 files
+56 −35 ipv8/REST/dht_endpoint.py
+4 −1 ipv8/REST/isolation_endpoint.py
+5 −4 ipv8/attestation/trustchain/community.py
+186 −70 ipv8/community.py
+14 −6 ipv8/configuration.py
+21 −13 ipv8/dht/churn.py
+95 −48 ipv8/dht/community.py
+3 −3 ipv8/dht/discovery.py
+10 −11 ipv8/dht/payload.py
+9 −9 ipv8/dht/provider.py
+14 −8 ipv8/dht/routing.py
+30 −2 ipv8/loader.py
+6 −5 ipv8/messaging/anonymization/community.py
+1 −1 ipv8/messaging/anonymization/hidden_services.py
+6 −6 ipv8/messaging/anonymization/pex.py
+16 −0 ipv8/messaging/interfaces/endpoint.py
+2 −1 ipv8/messaging/interfaces/udp/endpoint.py
+52 −55 ipv8/messaging/lazy_payload.py
+83 −51 ipv8/messaging/payload.py
+27 −16 ipv8/messaging/serialization.py
+2 −1 ipv8/peer.py
+2 −2 ipv8/peerdiscovery/community.py
+1 −1 ipv8/peerdiscovery/discovery.py
+18 −8 ipv8/peerdiscovery/network.py
+1 −1 ipv8/requestcache.py
+121 −0 ipv8/test/REST/test_isolation_endpoint.py
+301 −0 ipv8/test/REST/test_overlays_endpoint.py
+13 −0 ipv8/test/dht/base.py
+6 −6 ipv8/test/dht/test_churn.py
+43 −43 ipv8/test/dht/test_community.py
+5 −13 ipv8/test/dht/test_discovery.py
+1 −1 ipv8/test/dht/test_routing.py
+47 −0 ipv8/test/messaging/test_lazy_payload.py
+28 −8 ipv8/test/mocking/endpoint.py
+1 −1 ipv8/test/peerdiscovery/test_community.py
+27 −0 ipv8/test/peerdiscovery/test_network.py
+2 −1 ipv8/test/test_configuration.py
+31 −0 ipv8/test/test_loader.py
+10 −10 ipv8/test/test_peer.py
+9 −6 ipv8_service.py
+24 −1 scripts/exitnode_ipv8_only_plugin.py
+4 −2 scripts/tracker_plugin.py
+2 −1 stresstest/bootstrap_rtt.py
+5 −4 stresstest/peer_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ class GigaChannelCommunitySettings(RemoteQueryCommunitySettings):
class NonLegacyGigaChannelCommunity(RemoteQueryCommunity):
community_id = unhexlify('dc43e3465cbd83948f30d3d3e8336d71cce33aa7')

def create_introduction_response(self, *args, introduction=None, extra_bytes=b'', prefix=None):
def create_introduction_response(self, *args, introduction=None, extra_bytes=b'', prefix=None, new_style=False):
# ACHTUNG! We add extra_bytes here to identify the newer, 7.6+ version RemoteQuery/GigaChannel community
# dialect, so that other 7.6+ are able to distinguish between the older and newer versions.
return super().create_introduction_response(
*args, introduction=introduction, extra_bytes=MAGIC_GIGACHAN_VERSION_MARK, prefix=prefix
*args, introduction=introduction, extra_bytes=MAGIC_GIGACHAN_VERSION_MARK, prefix=prefix,
new_style=new_style
)

def __init__(self, my_peer, endpoint, network, metadata_store, **kwargs):
Expand Down
18 changes: 15 additions & 3 deletions src/tribler-core/tribler_core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,17 @@ async def start(self):
community_file._DEFAULT_ADDRESSES = [self.config.get_ipv8_bootstrap_override()]
community_file._DNS_ADDRESSES = []

if self.core_test_mode:
endpoint = DispatcherEndpoint([])
else:
# IPv8 includes IPv6 support by default.
# We only load IPv4 to not kill all Tribler overlays (currently, it would instantly crash all users).
# If you want to test IPv6 in Tribler you can set ``endpoint = None`` here.
endpoint = DispatcherEndpoint(["UDPIPv4"], UDPIPv4={'port': self.config.get_ipv8_port(),
'ip': self.config.get_ipv8_address()})
self.ipv8 = IPv8(ipv8_config_builder.finalize(),
enable_statistics=self.config.get_ipv8_statistics()) \
if not self.core_test_mode else IPv8(ipv8_config_builder.finalize(),
endpoint_override=DispatcherEndpoint([]))
enable_statistics=self.config.get_ipv8_statistics() and not self.core_test_mode,
endpoint_override=endpoint)
await self.ipv8.start()

self.config.set_anon_proxy_settings(2, ("127.0.0.1",
Expand Down Expand Up @@ -387,6 +394,11 @@ async def start(self):
if self.config.get_ipv8_enabled():
self.payout_manager = PayoutManager(self.bandwidth_community, self.dht_community)

if self.core_test_mode:
from ipv8.messaging.interfaces.udp.endpoint import UDPv4Address
from ipv8.dht.routing import RoutingTable
self.dht_community.routing_tables[UDPv4Address] = RoutingTable('\x00' * 20)

# GigaChannel Manager should be started *after* resuming the downloads,
# because it depends on the states of torrent downloads
if self.config.get_chant_enabled() and self.config.get_chant_manager_enabled() \
Expand Down

0 comments on commit 3c39dcf

Please sign in to comment.