|
@@ -3,6 +3,7 @@ import json
|
|
import logging
|
|
import logging
|
|
import os
|
|
import os
|
|
import secrets
|
|
import secrets
|
|
|
|
+import warnings
|
|
from collections.abc import AsyncIterable as AsyncIterableABC
|
|
from collections.abc import AsyncIterable as AsyncIterableABC
|
|
from contextlib import closing, suppress
|
|
from contextlib import closing, suppress
|
|
from dataclasses import dataclass
|
|
from dataclasses import dataclass
|
|
@@ -89,16 +90,16 @@ class P2P:
|
|
identity_path: Optional[str] = None,
|
|
identity_path: Optional[str] = None,
|
|
idle_timeout: float = 30,
|
|
idle_timeout: float = 30,
|
|
nat_port_map: bool = True,
|
|
nat_port_map: bool = True,
|
|
- quic: bool = False,
|
|
|
|
relay_hop_limit: int = 0,
|
|
relay_hop_limit: int = 0,
|
|
startup_timeout: float = 15,
|
|
startup_timeout: float = 15,
|
|
tls: bool = True,
|
|
tls: bool = True,
|
|
use_auto_relay: bool = False,
|
|
use_auto_relay: bool = False,
|
|
use_ipfs: bool = False,
|
|
use_ipfs: bool = False,
|
|
use_relay: bool = True,
|
|
use_relay: bool = True,
|
|
- use_relay_hop: bool = False,
|
|
|
|
- use_relay_discovery: bool = False,
|
|
|
|
persistent_conn_max_msg_size: int = DEFAULT_MAX_MSG_SIZE,
|
|
persistent_conn_max_msg_size: int = DEFAULT_MAX_MSG_SIZE,
|
|
|
|
+ quic: Optional[bool] = None,
|
|
|
|
+ use_relay_hop: Optional[bool] = None,
|
|
|
|
+ use_relay_discovery: Optional[bool] = None,
|
|
) -> "P2P":
|
|
) -> "P2P":
|
|
"""
|
|
"""
|
|
Start a new p2pd process and connect to it.
|
|
Start a new p2pd process and connect to it.
|
|
@@ -117,15 +118,15 @@ class P2P:
|
|
:param idle_timeout: kill daemon if client has been idle for a given number of
|
|
:param idle_timeout: kill daemon if client has been idle for a given number of
|
|
seconds before opening persistent streams
|
|
seconds before opening persistent streams
|
|
:param nat_port_map: Enables NAT port mapping
|
|
:param nat_port_map: Enables NAT port mapping
|
|
- :param quic: Enables the QUIC transport
|
|
|
|
:param relay_hop_limit: sets the hop limit for hop relays
|
|
:param relay_hop_limit: sets the hop limit for hop relays
|
|
:param startup_timeout: raise a P2PDaemonError if the daemon does not start in ``startup_timeout`` seconds
|
|
:param startup_timeout: raise a P2PDaemonError if the daemon does not start in ``startup_timeout`` seconds
|
|
:param tls: Enables TLS1.3 channel security protocol
|
|
:param tls: Enables TLS1.3 channel security protocol
|
|
:param use_auto_relay: enables autorelay
|
|
:param use_auto_relay: enables autorelay
|
|
:param use_ipfs: Bootstrap to IPFS (incompatible with initial_peers)
|
|
:param use_ipfs: Bootstrap to IPFS (incompatible with initial_peers)
|
|
:param use_relay: enables circuit relay
|
|
:param use_relay: enables circuit relay
|
|
- :param use_relay_hop: enables hop for relay
|
|
|
|
- :param use_relay_discovery: enables passive discovery for relay
|
|
|
|
|
|
+ :param quic: Deprecated, has no effect since libp2p 0.17.0
|
|
|
|
+ :param use_relay_hop: Deprecated, has no effect since libp2p 0.17.0
|
|
|
|
+ :param use_relay_discovery: Deprecated, has no effect since libp2p 0.17.0
|
|
:return: a wrapper for the p2p daemon
|
|
:return: a wrapper for the p2p daemon
|
|
"""
|
|
"""
|
|
|
|
|
|
@@ -133,6 +134,14 @@ class P2P:
|
|
initial_peers and use_ipfs
|
|
initial_peers and use_ipfs
|
|
), "User-defined initial_peers and use_ipfs=True are incompatible, please choose one option"
|
|
), "User-defined initial_peers and use_ipfs=True are incompatible, please choose one option"
|
|
|
|
|
|
|
|
+ if not all(arg is None for arg in [quic, use_relay_hop, use_relay_discovery]):
|
|
|
|
+ warnings.warn(
|
|
|
|
+ "Parameters `quic`, `use_relay_hop`, and `use_relay_discovery` of hivemind.P2P "
|
|
|
|
+ "have no effect since libp2p 0.17.0 and will be removed in hivemind 1.2.0+",
|
|
|
|
+ DeprecationWarning,
|
|
|
|
+ stacklevel=2,
|
|
|
|
+ )
|
|
|
|
+
|
|
self = cls()
|
|
self = cls()
|
|
with path(cli, P2PD_FILENAME) as p:
|
|
with path(cli, P2PD_FILENAME) as p:
|
|
p2pd_path = p
|
|
p2pd_path = p
|
|
@@ -168,10 +177,7 @@ class P2P:
|
|
idleTimeout=f"{idle_timeout}s",
|
|
idleTimeout=f"{idle_timeout}s",
|
|
listen=self._daemon_listen_maddr,
|
|
listen=self._daemon_listen_maddr,
|
|
natPortMap=nat_port_map,
|
|
natPortMap=nat_port_map,
|
|
- quic=quic,
|
|
|
|
relay=use_relay,
|
|
relay=use_relay,
|
|
- relayDiscovery=use_relay_discovery,
|
|
|
|
- relayHop=use_relay_hop,
|
|
|
|
relayHopLimit=relay_hop_limit,
|
|
relayHopLimit=relay_hop_limit,
|
|
tls=tls,
|
|
tls=tls,
|
|
persistentConnMaxMsgSize=persistent_conn_max_msg_size,
|
|
persistentConnMaxMsgSize=persistent_conn_max_msg_size,
|