@le-space/rootfs 0.6.25 → 0.6.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
@@ -70,10 +70,9 @@ def has_peer_id(addr: str) -> bool:
|
|
|
70
70
|
|
|
71
71
|
def is_browser_dialable(addr: str) -> bool:
|
|
72
72
|
normalized = addr.lower()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
73
|
+
if "/webtransport" in normalized or "/webrtc-direct" in normalized:
|
|
74
|
+
return "/certhash/" in normalized
|
|
75
|
+
return "/ws" in normalized or "/wss" in normalized
|
|
77
76
|
|
|
78
77
|
|
|
79
78
|
def is_public_multiaddr(addr: str) -> bool:
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
2
4
|
import json
|
|
3
5
|
import os
|
|
4
6
|
import re
|
|
@@ -48,6 +50,44 @@ def append_peer_id(addr: str, peer_id: str) -> str:
|
|
|
48
50
|
return addr if "/p2p/" in addr else f"{addr}/p2p/{peer_id}"
|
|
49
51
|
|
|
50
52
|
|
|
53
|
+
def browser_transport_suffixes(listening_addrs: list[str], transport: str) -> list[str]:
|
|
54
|
+
"""Return dial-critical transport suffixes advertised by the live libp2p host.
|
|
55
|
+
|
|
56
|
+
WebTransport and WebRTC Direct addresses include a certificate hash generated
|
|
57
|
+
by libp2p. Reconstructing these addresses from only the public IP and port
|
|
58
|
+
drops that hash and produces addresses browsers cannot dial.
|
|
59
|
+
"""
|
|
60
|
+
marker = f"/{transport}/"
|
|
61
|
+
suffixes: list[str] = []
|
|
62
|
+
for addr in listening_addrs:
|
|
63
|
+
normalized = addr.lower()
|
|
64
|
+
marker_index = normalized.find(marker)
|
|
65
|
+
if marker_index < 0:
|
|
66
|
+
continue
|
|
67
|
+
suffix = addr[marker_index:]
|
|
68
|
+
if "/certhash/" not in suffix.lower():
|
|
69
|
+
continue
|
|
70
|
+
suffixes.append(suffix)
|
|
71
|
+
return dedupe(suffixes)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def public_udp_multiaddrs(
|
|
75
|
+
public_ipv4: str,
|
|
76
|
+
public_ipv6: str,
|
|
77
|
+
udp_port: str,
|
|
78
|
+
suffixes: list[str],
|
|
79
|
+
peer_id: str,
|
|
80
|
+
) -> list[str]:
|
|
81
|
+
result: list[str] = []
|
|
82
|
+
for suffix in suffixes:
|
|
83
|
+
suffix_with_peer = append_peer_id(suffix, peer_id)
|
|
84
|
+
if public_ipv4:
|
|
85
|
+
result.append(f"/ip4/{public_ipv4}/udp/{udp_port}{suffix_with_peer}")
|
|
86
|
+
if public_ipv6:
|
|
87
|
+
result.append(f"/ip6/{public_ipv6}/udp/{udp_port}{suffix_with_peer}")
|
|
88
|
+
return dedupe(result)
|
|
89
|
+
|
|
90
|
+
|
|
51
91
|
def parse_logs() -> tuple[str | None, list[str]]:
|
|
52
92
|
result = subprocess.run(
|
|
53
93
|
["journalctl", "-u", SERVICE_NAME, "-n", "500", "--no-pager"],
|
|
@@ -121,12 +161,24 @@ def build_probe_multiaddrs(env_values: dict[str, str], peer_id: str, listening_a
|
|
|
121
161
|
public_ipv6 = env_values.get("PUBLIC_IPV6", "").strip()
|
|
122
162
|
udp_port = env_values.get("EXTERNAL_RELAY_UDP_PORT", "").strip()
|
|
123
163
|
if udp_port:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
webtransport_multiaddrs.extend(
|
|
165
|
+
public_udp_multiaddrs(
|
|
166
|
+
public_ipv4,
|
|
167
|
+
public_ipv6,
|
|
168
|
+
udp_port,
|
|
169
|
+
browser_transport_suffixes(listening_addrs, "quic-v1/webtransport"),
|
|
170
|
+
peer_id,
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
webrtc_direct_multiaddrs.extend(
|
|
174
|
+
public_udp_multiaddrs(
|
|
175
|
+
public_ipv4,
|
|
176
|
+
public_ipv6,
|
|
177
|
+
udp_port,
|
|
178
|
+
browser_transport_suffixes(listening_addrs, "webrtc-direct"),
|
|
179
|
+
peer_id,
|
|
180
|
+
)
|
|
181
|
+
)
|
|
130
182
|
|
|
131
183
|
probe_multiaddrs.extend(direct_tcp_multiaddrs)
|
|
132
184
|
probe_multiaddrs.extend(autotls_multiaddrs)
|