feat(marmot-interop): patch wnd to honour \$WHITENOISE_DISCOVERY_RELAYS
Without this, wnd exits on startup with NoRelayConnections in any environment that can't reach wnd's baked-in public discovery relay set (nos.lol, relay.damus.io, …). The headless harness runs entirely on a loopback relay, so hitting the public internet is never OK. Changes: - headless/patches/whitenoise-discovery-env.patch: adds an env-var override at the top of DiscoveryPlaneConfig::curated_default_relays. When \$WHITENOISE_DISCOVERY_RELAYS is set (comma-separated) we use that list instead of the hardcoded public one. - headless/setup.sh: applies the patch in preflight (idempotent — checks for a .headless-discovery-patched marker), invalidates the previous wn/wnd build on first patch, rebuilds, and threads \$WHITENOISE_DISCOVERY_RELAYS=\$RELAY_URL into every start_daemon invocation. https://claude.ai/code/session_01M6dCKAF5Y1VyHGZPjzwDXq
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
--- a/src/relay_control/discovery.rs
|
||||||
|
+++ b/src/relay_control/discovery.rs
|
||||||
|
@@ -87,6 +87,20 @@
|
||||||
|
|
||||||
|
/// Initial curated relay set from the planning doc.
|
||||||
|
pub(crate) fn curated_default_relays() -> Vec<RelayUrl> {
|
||||||
|
+ // marmot-interop-headless patch: honour $WHITENOISE_DISCOVERY_RELAYS
|
||||||
|
+ // (comma-separated list) when present, so the harness can force wnd
|
||||||
|
+ // to use a loopback relay instead of the baked-in public set.
|
||||||
|
+ if let Ok(from_env) = std::env::var("WHITENOISE_DISCOVERY_RELAYS") {
|
||||||
|
+ let parsed: Vec<RelayUrl> = from_env
|
||||||
|
+ .split(',')
|
||||||
|
+ .map(str::trim)
|
||||||
|
+ .filter(|s| !s.is_empty())
|
||||||
|
+ .filter_map(|u| RelayUrl::parse(u).ok())
|
||||||
|
+ .collect();
|
||||||
|
+ if !parsed.is_empty() {
|
||||||
|
+ return parsed;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
[
|
||||||
|
"wss://index.hzrd149.com",
|
||||||
|
"wss://indexer.coracle.social",
|
||||||
@@ -30,16 +30,34 @@ preflight() {
|
|||||||
info "amy: $AMY_BIN"
|
info "amy: $AMY_BIN"
|
||||||
|
|
||||||
# Clone/build whitenoise-rs if needed (shared between both harnesses).
|
# Clone/build whitenoise-rs if needed (shared between both harnesses).
|
||||||
|
if [[ ! -d "$WN_REPO/.git" ]]; then
|
||||||
|
if [[ "$NO_BUILD" -eq 1 ]]; then
|
||||||
|
fail_msg "whitenoise-rs checkout missing at $WN_REPO and --no-build set"; exit 1
|
||||||
|
fi
|
||||||
|
step "cloning whitenoise-rs into $WN_REPO"
|
||||||
|
git clone --depth 1 https://github.com/marmot-protocol/whitenoise-rs.git "$WN_REPO" \
|
||||||
|
2>&1 | tee -a "$LOG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Patch wnd's hardcoded discovery relays so $WHITENOISE_DISCOVERY_RELAYS
|
||||||
|
# wins — without this the daemon exits immediately in sandboxes / offline
|
||||||
|
# environments where public relays are unreachable.
|
||||||
|
local patch_file="$SCRIPT_DIR/headless/patches/whitenoise-discovery-env.patch"
|
||||||
|
local patch_marker="$WN_REPO/.headless-discovery-patched"
|
||||||
|
if [[ ! -f "$patch_marker" ]]; then
|
||||||
|
step "patching whitenoise-rs: honour WHITENOISE_DISCOVERY_RELAYS"
|
||||||
|
( cd "$WN_REPO" && patch -p1 --forward --reject-file=- <"$patch_file" ) \
|
||||||
|
2>&1 | tee -a "$LOG_FILE"
|
||||||
|
touch "$patch_marker"
|
||||||
|
# Invalidate the previous build so the patched source is picked up.
|
||||||
|
rm -f "$WN_BIN" "$WND_BIN"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -x "$WN_BIN" || ! -x "$WND_BIN" ]]; then
|
if [[ ! -x "$WN_BIN" || ! -x "$WND_BIN" ]]; then
|
||||||
if [[ "$NO_BUILD" -eq 1 ]]; then
|
if [[ "$NO_BUILD" -eq 1 ]]; then
|
||||||
fail_msg "wn/wnd not found and --no-build set"; exit 1
|
fail_msg "wn/wnd not found and --no-build set"; exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "$WN_REPO/.git" ]]; then
|
step "building wn + wnd (~5 min first run; incremental thereafter)"
|
||||||
step "cloning whitenoise-rs into $WN_REPO"
|
|
||||||
git clone --depth 1 https://github.com/marmot-protocol/whitenoise-rs.git "$WN_REPO" \
|
|
||||||
2>&1 | tee -a "$LOG_FILE"
|
|
||||||
fi
|
|
||||||
step "building wn + wnd (~5 min first run)"
|
|
||||||
( cd "$WN_REPO" && cargo build --release --features cli --bin wn --bin wnd ) \
|
( cd "$WN_REPO" && cargo build --release --features cli --bin wn --bin wnd ) \
|
||||||
2>&1 | tee -a "$LOG_FILE"
|
2>&1 | tee -a "$LOG_FILE"
|
||||||
fi
|
fi
|
||||||
@@ -143,8 +161,12 @@ start_daemon() {
|
|||||||
fi
|
fi
|
||||||
rm -f "$socket"
|
rm -f "$socket"
|
||||||
mkdir -p "$data_dir/logs" "$data_dir/release"
|
mkdir -p "$data_dir/logs" "$data_dir/release"
|
||||||
nohup "$WND_BIN" --data-dir "$data_dir" --logs-dir "$data_dir/logs" \
|
# Point wnd's discovery plane at our loopback relay. Needs the env-var
|
||||||
>"$data_dir/logs/stdout.log" 2>"$data_dir/logs/stderr.log" &
|
# patch applied in preflight to take effect; without it wnd falls back
|
||||||
|
# to the baked-in public set and exits with NoRelayConnections.
|
||||||
|
WHITENOISE_DISCOVERY_RELAYS="$RELAY_URL" \
|
||||||
|
nohup "$WND_BIN" --data-dir "$data_dir" --logs-dir "$data_dir/logs" \
|
||||||
|
>"$data_dir/logs/stdout.log" 2>"$data_dir/logs/stderr.log" &
|
||||||
echo "$!" > "$data_dir/pid"
|
echo "$!" > "$data_dir/pid"
|
||||||
local deadline=$(( $(date +%s) + 30 ))
|
local deadline=$(( $(date +%s) + 30 ))
|
||||||
while [[ $(date +%s) -lt $deadline ]]; do
|
while [[ $(date +%s) -lt $deadline ]]; do
|
||||||
|
|||||||
Reference in New Issue
Block a user