mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
fix: Peer ID verification during dial (#7)
This commit is contained in:
committed by
lla-dane
parent
58433f9b52
commit
2c03ac46ea
@ -193,6 +193,7 @@ class Swarm(Service, INetworkService):
|
||||
# Dial peer (connection to peer does not yet exist)
|
||||
# Transport dials peer (gets back a raw conn)
|
||||
try:
|
||||
addr = Multiaddr(f"{addr}/p2p/{peer_id}")
|
||||
raw_conn = await self.transport.dial(addr)
|
||||
except OpenConnectionError as error:
|
||||
logger.debug("fail to dial peer %s over base transport", peer_id)
|
||||
|
||||
@ -263,9 +263,8 @@ class QUICTransport(ITransport):
|
||||
remote_peer_id = ID.from_base58(remote_peer_id)
|
||||
|
||||
if remote_peer_id is None:
|
||||
# TODO: Peer ID verification during dial
|
||||
logger.error("Unable to derive peer id from multiaddr")
|
||||
# raise QUICDialError("Unable to derive peer id from multiaddr")
|
||||
raise QUICDialError("Unable to derive peer id from multiaddr")
|
||||
quic_version = multiaddr_to_quic_version(maddr)
|
||||
|
||||
# Get appropriate QUIC client configuration
|
||||
|
||||
@ -72,9 +72,9 @@ def is_quic_multiaddr(maddr: multiaddr.Multiaddr) -> bool:
|
||||
has_ip = f"/{IP4_PROTOCOL}/" in addr_str or f"/{IP6_PROTOCOL}/" in addr_str
|
||||
has_udp = f"/{UDP_PROTOCOL}/" in addr_str
|
||||
has_quic = (
|
||||
addr_str.endswith(f"/{QUIC_V1_PROTOCOL}")
|
||||
or addr_str.endswith(f"/{QUIC_DRAFT29_PROTOCOL}")
|
||||
or addr_str.endswith("/quic")
|
||||
f"/{QUIC_V1_PROTOCOL}" in addr_str
|
||||
or f"/{QUIC_DRAFT29_PROTOCOL}" in addr_str
|
||||
or "/quic" in addr_str
|
||||
)
|
||||
|
||||
return has_ip and has_udp and has_quic
|
||||
|
||||
Reference in New Issue
Block a user