Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
47ebe61
feat: base implementation of dcutr for hole-punching
Winter-Soren Jun 9, 2025
fc14626
chore: removed circuit-relay imports from __init__
Winter-Soren Jun 9, 2025
c0d0c2b
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jun 9, 2025
a51dc33
Merge branch 'main' into feat/606-nat-traversal-hole-punching
Winter-Soren Jun 26, 2025
26f4a5c
feat: implemented dcutr protocol
Winter-Soren Jun 27, 2025
f3cd727
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jun 29, 2025
291286a
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jun 30, 2025
a8efbf5
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jun 30, 2025
a7ad667
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 2, 2025
9f6ba61
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 3, 2025
47a0496
Merge branch 'main' into feat/606-nat-traversal-hole-punching
Winter-Soren Jul 7, 2025
a3625c5
added test suite with mock setup
Winter-Soren Jul 7, 2025
80cac6e
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 10, 2025
8413c59
Fix pre-commit hook issues in DCUtR implementation
Winter-Soren Jul 10, 2025
4258292
Merge branch 'feat/606-nat-traversal-hole-punching' of https://github…
Winter-Soren Jul 12, 2025
26d0013
Merge branch 'main' into feat/606-nat-traversal-hole-punching
Winter-Soren Jul 12, 2025
c00b9df
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 16, 2025
223d9e7
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 16, 2025
7860c9e
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 17, 2025
ae00b7c
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 19, 2025
b162db9
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 21, 2025
926dfac
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 21, 2025
87038b8
usages of CONNECT_TYPE and SYNC_TYPE have been replaced with HolePunc…
Winter-Soren Jul 24, 2025
82071dd
Merge branch 'feat/606-nat-traversal-hole-punching' of https://github…
Winter-Soren Jul 24, 2025
5e5462c
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 25, 2025
66e0a01
added unit tests for dcutr and nat module and
Winter-Soren Jul 26, 2025
9079289
Merge branch 'feat/606-nat-traversal-hole-punching' of https://github…
Winter-Soren Jul 26, 2025
bf44179
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 26, 2025
ed95e5b
Merge branch 'main' into feat/606-nat-traversal-hole-punching
seetadev Jul 26, 2025
f68084a
added multiaddr.get_peer_id() with proper DNS address handling and fi…
Winter-Soren Aug 3, 2025
ee2d39d
added assertions to verify DCUtR hole punch result in integration test
Winter-Soren Aug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ PB = libp2p/crypto/pb/crypto.proto \
libp2p/identity/identify/pb/identify.proto \
libp2p/host/autonat/pb/autonat.proto \
libp2p/relay/circuit_v2/pb/circuit.proto \
libp2p/relay/circuit_v2/pb/dcutr.proto \
libp2p/kad_dht/pb/kademlia.proto

PY = $(PB:.proto=_pb2.py)
Expand Down
8 changes: 8 additions & 0 deletions libp2p/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ def get_streams(self) -> tuple[INetStream, ...]:
:return: A tuple containing instances of INetStream.
"""

@abstractmethod
def get_transport_addresses(self) -> list[Multiaddr]:
"""
Retrieve the transport addresses used by this connection.

:return: A list of multiaddresses used by the transport.
"""


# -------------------------- peermetadata interface.py --------------------------

Expand Down
19 changes: 19 additions & 0 deletions libp2p/network/connection/swarm_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TYPE_CHECKING,
)

from multiaddr import Multiaddr
import trio

from libp2p.abc import (
Expand Down Expand Up @@ -147,6 +148,24 @@ async def new_stream(self) -> NetStream:
def get_streams(self) -> tuple[NetStream, ...]:
return tuple(self.streams)

def get_transport_addresses(self) -> list[Multiaddr]:
"""
Retrieve the transport addresses used by this connection.

Returns
-------
list[Multiaddr]
A list of multiaddresses used by the transport.

"""
# Return the addresses from the peerstore for this peer
try:
peer_id = self.muxed_conn.peer_id
return self.swarm.peerstore.addrs(peer_id)
except Exception as e:
logging.warning(f"Error getting transport addresses: {e}")
return []

def remove_stream(self, stream: NetStream) -> None:
if stream not in self.streams:
return
Expand Down
9 changes: 9 additions & 0 deletions libp2p/relay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
RelayLimits,
RelayResourceManager,
Reservation,
DCUTR_PROTOCOL_ID,
DCUtRProtocol,
ReachabilityChecker,
is_private_ip,
)

__all__ = [
Expand All @@ -25,4 +29,9 @@
"RelayLimits",
"RelayResourceManager",
"Reservation",
"DCUtRProtocol",
"DCUTR_PROTOCOL_ID",
"ReachabilityChecker",
"is_private_ip"

]
14 changes: 14 additions & 0 deletions libp2p/relay/circuit_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md
"""

from .dcutr import (
DCUtRProtocol,
)
from .dcutr import PROTOCOL_ID as DCUTR_PROTOCOL_ID

from .nat import (
ReachabilityChecker,
is_private_ip,
)

from .discovery import (
RelayDiscovery,
)
Expand All @@ -29,4 +39,8 @@
"RelayResourceManager",
"CircuitV2Transport",
"RelayDiscovery",
"DCUtRProtocol",
"DCUTR_PROTOCOL_ID",
"ReachabilityChecker",
"is_private_ip",
]
Loading
Loading