Skip to content

Commit 9e95a81

Browse files
authored
Merge branch 'main' into interop/py-rust
2 parents ca9db32 + fc9b289 commit 9e95a81

File tree

19 files changed

+2127
-31
lines changed

19 files changed

+2127
-31
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ PB = libp2p/crypto/pb/crypto.proto \
6060
libp2p/identity/identify/pb/identify.proto \
6161
libp2p/host/autonat/pb/autonat.proto \
6262
libp2p/relay/circuit_v2/pb/circuit.proto \
63+
libp2p/relay/circuit_v2/pb/dcutr.proto \
6364
libp2p/kad_dht/pb/kademlia.proto
6465

6566
PY = $(PB:.proto=_pb2.py)

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,47 @@ ______________________________________________________________________
3434
| -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
3535
| **`libp2p-tcp`** || [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
3636
| **`libp2p-quic`** | 🌱 | |
37-
| **`libp2p-websocket`** | | |
38-
| **`libp2p-webrtc-browser-to-server`** | | |
39-
| **`libp2p-webrtc-private-to-private`** | | |
37+
| **`libp2p-websocket`** | 🌱 | |
38+
| **`libp2p-webrtc-browser-to-server`** | 🌱 | |
39+
| **`libp2p-webrtc-private-to-private`** | 🌱 | |
4040

4141
______________________________________________________________________
4242

4343
### NAT Traversal
4444

45-
| **NAT Traversal** | **Status** |
46-
| ----------------------------- | :--------: |
47-
| **`libp2p-circuit-relay-v2`** | |
48-
| **`libp2p-autonat`** | |
49-
| **`libp2p-hole-punching`** | |
45+
| **NAT Traversal** | **Status** | **Source** |
46+
| ----------------------------- | :--------: | :-----------------------------------------------------------------------------: |
47+
| **`libp2p-circuit-relay-v2`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
48+
| **`libp2p-autonat`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/host/autonat) |
49+
| **`libp2p-hole-punching`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
5050

5151
______________________________________________________________________
5252

5353
### Secure Communication
5454

5555
| **Secure Communication** | **Status** | **Source** |
5656
| ------------------------ | :--------: | :---------------------------------------------------------------------------: |
57-
| **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58-
| **`libp2p-tls`** | | |
57+
| **`libp2p-noise`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58+
| **`libp2p-tls`** | 🌱 | |
5959

6060
______________________________________________________________________
6161

6262
### Discovery
6363

64-
| **Discovery** | **Status** |
65-
| -------------------- | :--------: |
66-
| **`bootstrap`** | |
67-
| **`random-walk`** | |
68-
| **`mdns-discovery`** | |
69-
| **`rendezvous`** | |
64+
| **Discovery** | **Status** | **Source** |
65+
| -------------------- | :--------: | :--------------------------------------------------------------------------------: |
66+
| **`bootstrap`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/bootstrap) |
67+
| **`random-walk`** | 🌱 | |
68+
| **`mdns-discovery`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/mdns) |
69+
| **`rendezvous`** | 🌱 | |
7070

7171
______________________________________________________________________
7272

7373
### Peer Routing
7474

75-
| **Peer Routing** | **Status** |
76-
| -------------------- | :--------: |
77-
| **`libp2p-kad-dht`** | |
75+
| **Peer Routing** | **Status** | **Source** |
76+
| -------------------- | :--------: | :--------------------------------------------------------------------: |
77+
| **`libp2p-kad-dht`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/kad_dht) |
7878

7979
______________________________________________________________________
8080

@@ -89,18 +89,18 @@ ______________________________________________________________________
8989

9090
### Stream Muxers
9191

92-
| **Stream Muxers** | **Status** | **Status** |
93-
| ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
94-
| **`libp2p-yamux`** | 🌱 | |
95-
| **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
92+
| **Stream Muxers** | **Status** | **Source** |
93+
| ------------------ | :--------: | :-------------------------------------------------------------------------------: |
94+
| **`libp2p-yamux`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/yamux) |
95+
| **`libp2p-mplex`** | | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/mplex) |
9696

9797
______________________________________________________________________
9898

9999
### Storage
100100

101101
| **Storage** | **Status** |
102102
| ------------------- | :--------: |
103-
| **`libp2p-record`** | |
103+
| **`libp2p-record`** | 🌱 |
104104

105105
______________________________________________________________________
106106

libp2p/abc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ def get_streams(self) -> tuple[INetStream, ...]:
357357
:return: A tuple containing instances of INetStream.
358358
"""
359359

360+
@abstractmethod
361+
def get_transport_addresses(self) -> list[Multiaddr]:
362+
"""
363+
Retrieve the transport addresses used by this connection.
364+
365+
:return: A list of multiaddresses used by the transport.
366+
"""
367+
360368

361369
# -------------------------- peermetadata interface.py --------------------------
362370

libp2p/network/connection/swarm_connection.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
TYPE_CHECKING,
44
)
55

6+
from multiaddr import Multiaddr
67
import trio
78

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

151+
def get_transport_addresses(self) -> list[Multiaddr]:
152+
"""
153+
Retrieve the transport addresses used by this connection.
154+
155+
Returns
156+
-------
157+
list[Multiaddr]
158+
A list of multiaddresses used by the transport.
159+
160+
"""
161+
# Return the addresses from the peerstore for this peer
162+
try:
163+
peer_id = self.muxed_conn.peer_id
164+
return self.swarm.peerstore.addrs(peer_id)
165+
except Exception as e:
166+
logging.warning(f"Error getting transport addresses: {e}")
167+
return []
168+
150169
def remove_stream(self, stream: NetStream) -> None:
151170
if stream not in self.streams:
152171
return

libp2p/relay/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
RelayLimits,
1616
RelayResourceManager,
1717
Reservation,
18+
DCUTR_PROTOCOL_ID,
19+
DCUtRProtocol,
20+
ReachabilityChecker,
21+
is_private_ip,
1822
)
1923

2024
__all__ = [
@@ -25,4 +29,9 @@
2529
"RelayLimits",
2630
"RelayResourceManager",
2731
"Reservation",
32+
"DCUtRProtocol",
33+
"DCUTR_PROTOCOL_ID",
34+
"ReachabilityChecker",
35+
"is_private_ip"
36+
2837
]

libp2p/relay/circuit_v2/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md
66
"""
77

8+
from .dcutr import (
9+
DCUtRProtocol,
10+
)
11+
from .dcutr import PROTOCOL_ID as DCUTR_PROTOCOL_ID
12+
13+
from .nat import (
14+
ReachabilityChecker,
15+
is_private_ip,
16+
)
17+
818
from .discovery import (
919
RelayDiscovery,
1020
)
@@ -29,4 +39,8 @@
2939
"RelayResourceManager",
3040
"CircuitV2Transport",
3141
"RelayDiscovery",
42+
"DCUtRProtocol",
43+
"DCUTR_PROTOCOL_ID",
44+
"ReachabilityChecker",
45+
"is_private_ip",
3246
]

0 commit comments

Comments
 (0)