@le-space/rootfs 0.9.6 → 0.9.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/rootfs",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,6 +17,7 @@ Environment=SERVICE_NAME=orbitdb-relay.service
17
17
  Environment=CADDY_SERVICE=caddy.service
18
18
  Environment=CADDYFILE=/etc/caddy/Caddyfile
19
19
  ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-autotls-refresh.py
20
+ ExecStartPost=/usr/bin/systemctl start --no-block orbitdb-relay-bootstrap-refresh.service
20
21
  StandardOutput=journal
21
22
  StandardError=journal
22
23
 
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  import os
3
3
  import re
4
+ import sys
4
5
  import subprocess
5
6
  import time
6
7
  from typing import Iterable
@@ -93,6 +94,57 @@ def wait_for_exact_hosts(ws_port: str) -> tuple[str, list[str], list[str]]:
93
94
  raise RuntimeError(last_error)
94
95
 
95
96
 
97
+ def resolve_external_ws_port(env_values: dict[str, str], ws_port: str) -> str:
98
+ """Port the AutoTLS websocket should be *announced* on.
99
+
100
+ `ws_port` is where the relay actually listens inside the guest. On Aleph
101
+ every port is published under a different number, so announcing the
102
+ internal one hands out an address the internet cannot reach.
103
+ """
104
+ external = env_values.get("EXTERNAL_RELAY_WS_PORT", "").strip()
105
+ if external:
106
+ return external
107
+ print(
108
+ f"[autotls] EXTERNAL_RELAY_WS_PORT is missing from the environment file; "
109
+ f"announcing the backend port {ws_port}, which is unreachable from "
110
+ f"outside the guest whenever the port is mapped",
111
+ file=sys.stderr,
112
+ )
113
+ return ws_port
114
+
115
+
116
+ def build_announce_addrs(
117
+ existing_announce: Iterable[str],
118
+ logged_addrs: Iterable[str],
119
+ ws_port: str,
120
+ external_ws_port: str,
121
+ proxy_hostname: str = "",
122
+ ) -> list[str]:
123
+ """Announce list for the concrete AutoTLS hostnames.
124
+
125
+ The relay logs its listeners on the internal port, which is what the log
126
+ scan had to match to find them. Re-announcing those strings verbatim was
127
+ the defect: `uc-go-peer-configure.sh` translates the port for every other
128
+ family, so tcp, quic, webtransport and webrtc-direct all advertised the
129
+ mapped port while the websocket — rewritten here, later — kept the
130
+ internal one. Measured on a live relay: `/tcp/9097/tls/sni/…/ws` was
131
+ announced and filtered, while the same listener answered on `/tcp/24013`.
132
+ Browsers dropped the address, `direct-wss` was left without a candidate,
133
+ and js-peer refused to bake a bootstrap list it could not verify.
134
+ """
135
+ wildcard_filtered = [entry for entry in existing_announce if "/tls/sni/*." not in entry]
136
+ exact_announces = [
137
+ addr.replace(f"/tcp/{ws_port}/", f"/tcp/{external_ws_port}/", 1)
138
+ for addr in logged_addrs
139
+ ]
140
+
141
+ if proxy_hostname:
142
+ exact_announces.append(f"/dns4/{proxy_hostname}/tcp/443/tls/ws")
143
+ exact_announces.append(f"/dns6/{proxy_hostname}/tcp/443/tls/ws")
144
+
145
+ return dedupe(list(wildcard_filtered) + exact_announces)
146
+
147
+
96
148
  def main() -> None:
97
149
  if not os.path.exists(READY_FILE):
98
150
  raise SystemExit(f"missing ready file: {READY_FILE}")
@@ -109,14 +161,13 @@ def main() -> None:
109
161
  raise RuntimeError("no AutoTLS websocket hostnames found in logs")
110
162
 
111
163
  existing = [entry.strip() for entry in env_values.get("LIBP2P_ANNOUNCE_ADDRS", "").split(",") if entry.strip()]
112
- wildcard_filtered = [entry for entry in existing if "/tls/sni/*." not in entry]
113
- exact_announces: list[str] = list(exact_logged_addrs)
114
-
115
- if proxy_hostname:
116
- exact_announces.append(f"/dns4/{proxy_hostname}/tcp/443/tls/ws")
117
- exact_announces.append(f"/dns6/{proxy_hostname}/tcp/443/tls/ws")
118
-
119
- merged = dedupe(wildcard_filtered + exact_announces)
164
+ merged = build_announce_addrs(
165
+ existing,
166
+ exact_logged_addrs,
167
+ ws_port,
168
+ resolve_external_ws_port(env_values, ws_port),
169
+ proxy_hostname,
170
+ )
120
171
  announce_value = ",".join(merged)
121
172
  write_env_var(ENV_FILE, "LIBP2P_ANNOUNCE_ADDRS", announce_value)
122
173
  if zone:
@@ -16,6 +16,7 @@ Environment=AUTOTLS_CADDY_READY_FILE=/etc/default/uc-go-peer.caddy-ready
16
16
  Environment=SERVICE_NAME=uc-go-peer.service
17
17
  Environment=WS_BACKEND_PORT=9097
18
18
  ExecStart=/usr/bin/python3 /usr/local/sbin/uc-go-peer-autotls-refresh.py
19
+ ExecStartPost=/usr/bin/systemctl start --no-block uc-go-peer-bootstrap-refresh.service
19
20
  Restart=on-failure
20
21
  RestartSec=43200
21
22
  StartLimitIntervalSec=0