@le-space/rootfs 0.6.34 → 0.6.36

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.6.34",
3
+ "version": "0.6.36",
4
4
  "description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -129,6 +129,13 @@ def build_secure_addrs(env_values: dict[str, str], zone: str) -> list[str]:
129
129
  if not ws_port:
130
130
  raise RuntimeError("missing EXTERNAL_RELAY_WS_PORT in environment file")
131
131
 
132
+ # IPv4 is NAT/port-mapped, so it is advertised on the externally assigned
133
+ # host port. IPv6 is globally routed with no NAT on the Aleph VM — reachable
134
+ # directly on the internal listen port, while the mapped host port is closed
135
+ # over IPv6. Advertise the IPv6 libp2p.direct AutoTLS addresses on the
136
+ # internal WS port so AutoNAT/AutoTLS dial-backs actually reach the relay.
137
+ ws_port_ipv6 = env_values.get("RELAY_WS_PORT", "").strip() or ws_port
138
+
132
139
  addrs: list[str] = []
133
140
 
134
141
  public_ipv4 = env_values.get("PUBLIC_IPV4", "").strip()
@@ -140,8 +147,8 @@ def build_secure_addrs(env_values: dict[str, str], zone: str) -> list[str]:
140
147
  public_ipv6 = env_values.get("PUBLIC_IPV6", "").strip()
141
148
  if public_ipv6:
142
149
  host6 = ipv6_domain(public_ipv6, zone)
143
- addrs.append(f"/ip6/{public_ipv6}/tcp/{ws_port}/tls/sni/{host6}/ws")
144
- addrs.append(f"/dns6/{host6}/tcp/{ws_port}/tls/ws")
150
+ addrs.append(f"/ip6/{public_ipv6}/tcp/{ws_port_ipv6}/tls/sni/{host6}/ws")
151
+ addrs.append(f"/dns6/{host6}/tcp/{ws_port_ipv6}/tls/ws")
145
152
 
146
153
  if not addrs:
147
154
  raise RuntimeError("missing PUBLIC_IPV4/PUBLIC_IPV6 in environment file")
@@ -117,6 +117,25 @@ write_env_var "RELAY_WS_PORT" "9092"
117
117
  write_env_var "RELAY_WEBRTC_PORT" "9093"
118
118
  write_env_var "RELAY_QUIC_PORT" "9094"
119
119
  write_env_var "RELAY_DISABLE_WEBRTC" "1"
120
- write_env_var "RELAY_DISABLE_BOOTSTRAP" "1"
120
+ # Bootstrap MUST stay enabled. The relay needs public IPFS/DHT peers so libp2p
121
+ # AutoNAT can confirm a public address — the precondition for AutoTLS to fetch
122
+ # the `*.libp2p.direct` certificate. With bootstrap disabled the relay comes up
123
+ # isolated (0 peers, empty DHT routing table), AutoNAT never confirms, and
124
+ # AutoTLS silently stops serving certs ("no public addresses"), so browsers can
125
+ # only reach it through the Caddy `2n6.me` proxy. RELAY_DISABLE_BOOTSTRAP=1 is
126
+ # for tests / deliberately isolated deployments only.
127
+ write_env_var "RELAY_DISABLE_BOOTSTRAP" "0"
128
+ # The kad-DHT must stay OFF on these 2 GB Aleph VMs. With it enabled the relay
129
+ # announces itself into the public DHT and is then flooded with inbound
130
+ # WebSocket connections: sockets pile up in CLOSE-WAIT (hundreds within
131
+ # minutes), the single-threaded Node event loop saturates, and the process
132
+ # hangs — /health, metrics and every libp2p transport stop responding while the
133
+ # VM, Caddy and the TCP listeners still look healthy. `connectionManager
134
+ # .maxConnections` does not prevent this: it bounds established connections,
135
+ # not the inbound churn. Bootstrap above stays enabled, which gives AutoNAT the
136
+ # handful of public peers it needs to confirm an address so AutoTLS can still
137
+ # fetch its `*.libp2p.direct` certificate. Set RELAY_DISABLE_DHT=0 only on a
138
+ # host that can absorb full DHT server load.
139
+ write_env_var "RELAY_DISABLE_DHT" "1"
121
140
  write_env_var "ENABLE_GENERAL_LOGS" "1"
122
141
  write_env_var "DEBUG" "'libp2p:websockets:listener'"
@@ -13,6 +13,17 @@ CADDYFILE="${CADDYFILE:-/etc/caddy/Caddyfile}"
13
13
  CADDY_UPSTREAM_WSS_PORT="${CADDY_UPSTREAM_WSS_PORT:-9092}"
14
14
  CADDY_UPSTREAM_HOST="${CADDY_UPSTREAM_HOST:-127.0.0.1}"
15
15
  CADDY_UPSTREAM_METRICS_PORT="${CADDY_UPSTREAM_METRICS_PORT:-9090}"
16
+ # Internal libp2p listen ports. On the Aleph VM, IPv4 is NAT/port-mapped (so it
17
+ # is announced on the externally assigned host ports), but IPv6 is globally
18
+ # routed with NO NAT — the VM is reachable directly on the real listen ports,
19
+ # and the mapped host ports are closed over IPv6. IPv6 must therefore be
20
+ # announced on these internal ports, otherwise AutoNAT/AutoTLS dial-backs to the
21
+ # IPv6 address hit a closed mapped port, the address is never confirmed, and
22
+ # `*.libp2p.direct` AutoTLS never provisions a certificate over IPv6.
23
+ RELAY_TCP_LISTEN_PORT="${RELAY_TCP_LISTEN_PORT:-9091}"
24
+ RELAY_WS_LISTEN_PORT="${RELAY_WS_LISTEN_PORT:-${CADDY_UPSTREAM_WSS_PORT}}"
25
+ RELAY_WEBRTC_LISTEN_PORT="${RELAY_WEBRTC_LISTEN_PORT:-9093}"
26
+ RELAY_QUIC_LISTEN_PORT="${RELAY_QUIC_LISTEN_PORT:-9094}"
16
27
  AUTOTLS_REFRESH_SERVICE="${AUTOTLS_REFRESH_SERVICE:-orbitdb-relay-autotls-refresh.service}"
17
28
  BOOTSTRAP_REFRESH_TIMER="${BOOTSTRAP_REFRESH_TIMER:-orbitdb-relay-bootstrap-refresh.timer}"
18
29
  BOOTSTRAP_REFRESH_SERVICE="${BOOTSTRAP_REFRESH_SERVICE:-orbitdb-relay-bootstrap-refresh.service}"
@@ -203,7 +214,7 @@ announce=(
203
214
 
204
215
  if [ -n "${PUBLIC_IPV6}" ]; then
205
216
  announce+=(
206
- "/ip6/${PUBLIC_IPV6}/tcp/${TCP_PORT}"
217
+ "/ip6/${PUBLIC_IPV6}/tcp/${RELAY_TCP_LISTEN_PORT}"
207
218
  )
208
219
  fi
209
220
 
@@ -214,20 +225,20 @@ fi
214
225
 
215
226
  announce+=("/ip4/${PUBLIC_IPV4}/tcp/${WS_PORT}/ws")
216
227
  if [ -n "${PUBLIC_IPV6}" ]; then
217
- announce+=("/ip6/${PUBLIC_IPV6}/tcp/${WS_PORT}/ws")
228
+ announce+=("/ip6/${PUBLIC_IPV6}/tcp/${RELAY_WS_LISTEN_PORT}/ws")
218
229
  fi
219
230
 
220
231
  if [ -n "${WEBRTC_PORT}" ]; then
221
232
  announce+=("/ip4/${PUBLIC_IPV4}/udp/${WEBRTC_PORT}/webrtc-direct")
222
233
  if [ -n "${PUBLIC_IPV6}" ]; then
223
- announce+=("/ip6/${PUBLIC_IPV6}/udp/${WEBRTC_PORT}/webrtc-direct")
234
+ announce+=("/ip6/${PUBLIC_IPV6}/udp/${RELAY_WEBRTC_LISTEN_PORT}/webrtc-direct")
224
235
  fi
225
236
  fi
226
237
 
227
238
  if [ -n "${QUIC_PORT}" ]; then
228
239
  announce+=("/ip4/${PUBLIC_IPV4}/udp/${QUIC_PORT}/quic-v1")
229
240
  if [ -n "${PUBLIC_IPV6}" ]; then
230
- announce+=("/ip6/${PUBLIC_IPV6}/udp/${QUIC_PORT}/quic-v1")
241
+ announce+=("/ip6/${PUBLIC_IPV6}/udp/${RELAY_QUIC_LISTEN_PORT}/quic-v1")
231
242
  fi
232
243
  fi
233
244