Skip to content

Commit bd2beef

Browse files
mogulOpenCode Agent
andcommitted
fix(opendesign): force relay upstream loopback source
Pin the relay's upstream socket localAddress to 127.0.0.1 so peer-loopback-gated OpenDesign routes see loopback consistently, and make live verification print guarded-route response bodies for diagnosis. Co-authored-by: OpenCode Agent <[email protected]>
1 parent e568770 commit bd2beef

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

‎integrations/isolation/acq-kits/opendesign/files/home/opendesign-relay.mjs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//
1919
// This relay resolves the conflict. The daemon binds 127.0.0.1 only. The relay
2020
// binds the guest network address(es) and forwards each connection to
21-
// 127.0.0.1, so the daemon always observes a loopback peer. It is a plain byte
22-
// relay: no parsing, no header rewriting, so websockets, SSE, and streaming
23-
// responses pass through untouched.
21+
// 127.0.0.1 from localAddress 127.0.0.1, so the daemon always observes a
22+
// loopback peer. It is a plain byte relay: no parsing, no header rewriting, so
23+
// websockets, SSE, and streaming responses pass through untouched.
2424
//
2525
// SECURITY POSTURE (unchanged by this file)
2626
//
@@ -82,7 +82,11 @@ const bound = new Set();
8282
const permanentlyFailed = new Set();
8383

8484
function relayConnection(client) {
85-
const upstream = net.connect(PORT, TARGET_HOST);
85+
const upstream = net.connect({
86+
port: PORT,
87+
host: TARGET_HOST,
88+
localAddress: TARGET_HOST,
89+
});
8690
// A relay must not inherit the default 'error' -> throw behaviour on either
8791
// side: a client that hangs up mid-response, or a daemon restart, is normal
8892
// operation here and must not take the relay down.

‎integrations/isolation/acq-kits/opendesign/scripts/verify‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ case "$relay_src" in
141141
*"TARGET_HOST = '127.0.0.1'"*) ok "relay forwards to loopback only" ;;
142142
*) bad "relay does not forward to loopback only" ;;
143143
esac
144+
case "$relay_src" in
145+
*'localAddress: TARGET_HOST'*) ok "relay originates upstream connections from loopback" ;;
146+
*) bad "relay does not originate upstream connections from loopback" ;;
147+
esac
144148
case "$relay_src" in
145149
*'entry.internal'*) ok "relay skips loopback interfaces so it cannot collide with the daemon" ;;
146150
*) bad "relay does not skip loopback interfaces" ;;
@@ -341,21 +345,34 @@ for line in sys.stdin:
341345
break
342346
')"
343347
if [ -n "$host_url" ]; then
344-
if curl -fsS "$host_url/" >/dev/null 2>&1 && curl -fsS "$host_url/api/daemon/status" >/dev/null 2>&1; then
348+
host_status_body="$WORK/daemon-status-host.json"
349+
if curl -fsS "$host_url/" >/dev/null 2>&1 && curl -fsS "$host_url/api/daemon/status" -o "$host_status_body" >/dev/null 2>&1; then
345350
ok "published host-loopback URL is reachable: $host_url"
351+
sed 's/^/ | daemon-status: /' "$host_status_body" 2>/dev/null || true
346352
else
347353
bad "published host-loopback URL is not reachable: $host_url"
348354
fi
349-
# Regression gate for the 0.0.0.0 bind bug: this is the exact request the
350-
# browser's Settings -> About -> Export diagnostics button makes. It returned
351-
# 403 FORBIDDEN ("request peer must be a loopback address") whenever the daemon
352-
# bound 0.0.0.0, because acq/msb publishing dials the guest network IP.
353-
export_code="$(curl -s -o /dev/null -w '%{http_code}' --max-time 120 \
355+
# Regression gates for the loopback-peer bug: these are browser-visible routes
356+
# guarded by requireLocalDaemonRequest. They returned 403 whenever the daemon
357+
# observed a non-loopback peer through create-time port publishing.
358+
rollout_body="$WORK/od-next-rollout.json"
359+
rollout_code="$(curl -s -o "$rollout_body" -w '%{http_code}' --max-time 30 \
360+
-H "Origin: $host_url" "$host_url/api/strategies/od-next/rollout" 2>/dev/null || true)"
361+
if [ "$rollout_code" = "200" ]; then
362+
ok "OD Next rollout route is reachable from the host browser path (HTTP 200)"
363+
else
364+
bad "OD Next rollout route returned HTTP ${rollout_code:-none} from the host"
365+
sed 's/^/ | /' "$rollout_body" 2>/dev/null || true
366+
fi
367+
368+
export_body="$WORK/diagnostics-export.body"
369+
export_code="$(curl -s -o "$export_body" -w '%{http_code}' --max-time 120 \
354370
-H "Origin: $host_url" "$host_url/api/diagnostics/export" 2>/dev/null || true)"
355371
if [ "$export_code" = "200" ]; then
356372
ok "diagnostics export is reachable from the host browser path (HTTP 200)"
357373
else
358-
bad "diagnostics export returned HTTP ${export_code:-none} from the host (expected 200; 403 means the daemon saw a non-loopback peer)"
374+
bad "diagnostics export returned HTTP ${export_code:-none} from the host"
375+
sed 's/^/ | /' "$export_body" 2>/dev/null || true
359376
fi
360377
else
361378
bad "could not parse host-loopback URL from acq ports output"

0 commit comments

Comments
 (0)