Public: anyone can read this; the crew can change it.

The forge running as an app never calls its own public host: the egress gate refused it 13 times #14668

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/14664-the-forge-running-as-an-app-never-calls → main 6 commits fork 2 threads · 2 unresolved

  • Merged. scout/14664-the-forge-running-as-an-app-never-calls was merged into main as 03b38cb.

Review

Sign in to review this change.
10 files changed +310 −15
AGENTS.md +1 −1

Diff not shown — a line 3,799 characters wide (limit 2,000). +1 −1

View file
forge.json +1 −2
@@ -1,8 +1,7 @@
11 {
22 "egress": [
33 "api.anthropic.com",
4 "api.github.com",
5 "lab--forge-trevato-apps.open-platform.sh"
4 "api.github.com"
65 ],
76 "app": {
87 "looks": ["/", "/docs", "/explore", "/board", "/notes", "/review", "/releases", "/apps", "/security", "/system", "/admin/limits", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/security/controls", "/settings/grants", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/cut-over", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/preview-admin/sample/space", "/looks/missing", "/looks/failed", "/nope/nothing"],
src/kernel/outbound.ts +30
@@ -17,6 +17,7 @@ import { isIP } from "node:net";
1717 import { err, ok, type Result } from "./result.ts";
1818 import { addressBytes, inCidr, inCidrs, parseCidr, type Cidr } from "./cidr.ts";
1919 import { cellProxy, UNRESOLVED_WORDS } from "../apps/egress.ts";
20 import { localFor } from "./own_host.ts";
2021
2122 const REFUSED = [
2223 "0.0.0.0/8",
@@ -81,6 +82,12 @@ export interface OutboundOptions {
8182 * runs in (`cellProxy`), and to none outside one. Injected by tests.
8283 */
8384 proxy?: string | undefined;
85 /**
86 * The caller is the forge's own code asking a URL that may be on this forge's own public host
87 * (#14664): such a URL is answered by the local listener, as a stranger would be. Without it,
88 * the own host is refused: a webhook or notify target a person set never reaches the listener.
89 */
90 self?: boolean;
8491 }
8592
8693 /** How a vetted host is reached: at the address that was judged, or by name through the cell's gate. */
@@ -101,6 +108,22 @@ const systemResolve: Resolve = async (host) =>
101108 export const REFUSED_SENTENCE = "refused: private address";
102109 export const PLAIN_SENTENCE = "refused: not https";
103110 export const UNRESOLVED_SENTENCE = "unresolved host";
111 export const OWN_HOST_SENTENCE = "refused: this forge's own host";
112
113 /**
114 * Headers for a call to the own listener that earns it nothing a remote caller lacks: no cookie or
115 * authorization, no client-naming header of the caller's, and `x-forwarded-for` set so the
116 * listener does not read it as the forge asking itself (`http/peer.ts` `isInternalPeer`).
117 */
118 export function asStranger(given: RequestInit["headers"], target: URL): Headers {
119 const headers = new Headers(given);
120 for (const name of ["cookie", "authorization", "proxy-authorization", "x-forwarded-for", "forwarded", "x-real-ip", "cf-connecting-ip", "true-client-ip"])
121 headers.delete(name);
122 headers.set("host", target.host);
123 headers.set("x-forwarded-proto", target.protocol.slice(0, -1));
124 headers.set("x-forwarded-for", "127.0.0.1");
125 return headers;
126 }
104127
105128 export class RefusedError extends Error {
106129 constructor(sentence = REFUSED_SENTENCE) {
@@ -174,6 +197,13 @@ export async function outboundFetch(
174197 options: OutboundOptions = {},
175198 ): Promise<Response> {
176199 const target = new URL(url);
200 // The forge's own public host never goes over the network (#14664): the forge's own code is
201 // answered by its listener, anyone else's URL is refused here.
202 const self = localFor(target);
203 if (self !== undefined) {
204 if (options.self !== true) throw new RefusedError(OWN_HOST_SENTENCE);
205 return fetch(self, { ...init, headers: asStranger(init.headers, target), redirect: "manual" });
206 }
177207 if (target.protocol !== "https:" && !options.plain)
178208 throw new RefusedError(PLAIN_SENTENCE);
179209 const vetted = await vetHost(target.hostname, options);
src/kernel/own_host.ts added +58
@@ -0,0 +1,58 @@
1 /**
2 * The forge's own public host, and the local listener that answers for it (#14664). A call to
3 * yourself should not leave the process's network: from a cell it is a hairpin through the
4 * uplink, and the egress gate refuses it unless forge.json declares the forge's own name.
5 * `localFor` turns a URL on the public host into the same path on the local listener;
6 * `outboundFetch` (`outbound.ts`), the one helper for what the forge fetches, asks it first: the
7 * forge's own code (`self`) is answered there as a stranger, every other caller is refused.
8 *
9 * Process memory: one pair, set once by `main.ts` when the listener is up (`setOwnHost`), read by
10 * every outbound fetch; gone on restart. `forgetOwnHost` is for tests.
11 */
12
13 let own: { readonly host: string; readonly local: URL } | undefined;
14
15 /** Set the public origin (`FORGE_APP_URL` hosted, `FORGE_URL` otherwise) and the listener's URL. */
16 export function setOwnHost(
17 publicUrl: string | undefined,
18 localUrl: string,
19 say: (line: string) => void = (line) => console.error(line),
20 ): void {
21 own = undefined;
22 if (publicUrl === undefined || publicUrl.trim() === "") return;
23 if (!URL.canParse(publicUrl) || !URL.canParse(localUrl)) {
24 // Said once, at boot: the guard stays off, and nobody would know why without this line.
25 say(`own host: not set, the public URL or listener is not a URL (${JSON.stringify(publicUrl.slice(0, 200))}); a fetch of this forge's own host is not kept off the network (#14664)`);
26 return;
27 }
28 own = { host: new URL(publicUrl).host.toLowerCase(), local: new URL(localUrl) };
29 }
30
31 export function forgetOwnHost(): void {
32 own = undefined;
33 }
34
35 /** The public host (`name[:port]`), or undefined when this forge was not told its public URL. */
36 export function ownHost(): string | undefined {
37 return own?.host;
38 }
39
40 /** Whether `url` names the forge's own public host. */
41 export function isOwnHost(url: string | URL): boolean {
42 if (own === undefined) return false;
43 try {
44 return new URL(url).host.toLowerCase() === own.host;
45 } catch {
46 return false;
47 }
48 }
49
50 /** The same path and query on the local listener, or undefined when `url` is not the own host. */
51 export function localFor(url: string | URL): URL | undefined {
52 if (own === undefined || !isOwnHost(url)) return undefined;
53 const from = new URL(url);
54 const to = new URL(own.local.href);
55 to.pathname = from.pathname;
56 to.search = from.search;
57 return to;
58 }
src/main.ts +3
@@ -152,6 +152,7 @@ import { timeStatements } from "./kernel/slow_sql.ts";
152152 import { waitForPeer } from "./runs/peer.ts";
153153 import { noteWritePause } from "./keeper/pause.ts";
154154 import { closeStaleSessions } from "./machines/shell.ts";
155 import { setOwnHost } from "./kernel/own_host.ts";
155156
156157 // `forge hook <name>` re-enters here from a git hook stub. It relays to the
157158 // running forge over its socket and exits — it must never boot a server.
@@ -462,6 +463,8 @@ await warmFlow(app);
462463 await warmPlans(app);
463464 await warmDisplays(app).catch(() => undefined);
464465 const servers = await serve(app, { warm: {} });
466 // A fetch of this forge's own public host is answered by this listener, not the network (#14664).
467 setOwnHost(canonicalUrl, servers.url);
465468 markReady();
466469 // From here the flow's forge-wide readings are read once and shared for half a minute
467470 // (`flow/kept.ts`).
src/maintain/duties/wait_split.ts +21 −9
@@ -8,6 +8,8 @@
88 * issue per layer (#13636), naming the setting that bounds that layer's time with its reason (or
99 * that none is held, and what to check) (`../wait_limits.ts`), so a repeat is loud, not a line
1010 * nobody reads.
11 * A forge in a cell (hosted as an app) reads loopback alone: calling its own public host from the
12 * cell is a hairpin its gate refuses (#14664).
1113 */
1214
1315 import { connect as tcpConnect } from "node:net";
@@ -15,6 +17,7 @@ import { connect as tlsConnect } from "node:tls";
1517 import { fileIssueOnce } from "../../checks/flake.ts";
1618 import { getRepo } from "../../core/repos.ts";
1719 import { ownRepoPath } from "../../kernel/own_repo.ts";
20 import { cellProxy } from "../../apps/egress.ts";
1821 import type { Duty, Finding } from "../duty.ts";
1922 import { alarmBody, alarmTitle } from "../wait_limits.ts";
2023 import { serverAppMs, splitLine, waitLayer, type Layer, type Timings } from "../wait_split.ts";
@@ -80,7 +83,10 @@ export const networkMeter: Meter = { handshake, get };
8083
8184 const why = (e: unknown): string => (e instanceof Error ? `${e.name}: ${e.message}` : String(e));
8285
83 export function waitSplit(meter: Meter = networkMeter, runMs: number = RUN_MS): Duty {
86 /** Whether this forge runs in a cell (hosted as an app): its way out is its parent's gate. */
87 const inACell = (): boolean => cellProxy() !== undefined;
88
89 export function waitSplit(meter: Meter = networkMeter, runMs: number = RUN_MS, inCell: () => boolean = inACell): Duty {
8490 return {
8591 name: "wait-split",
8692 intervalMs: 6 * 3_600_000,
@@ -94,6 +100,10 @@ export function waitSplit(meter: Meter = networkMeter, runMs: number = RUN_MS):
94100 const actions: string[] = [];
95101 const slow = new Map<Exclude<Layer, "none">, string[]>();
96102 const run = AbortSignal.timeout(runMs);
103 // A forge in a cell does not call its own public host: that is a hairpin through the
104 // uplink its gate refuses (#14664). It times loopback alone, and says the edge went unread.
105 const local = inCell();
106 if (local) actions.push(`public side not read: this forge runs in a cell and does not call its own host ${origin.host} (#14664)`);
97107 for (const [i, path] of PATHS.entries()) {
98108 if (run.aborted) {
99109 actions.push(`not read within this run's ${runMs} ms: ${PATHS.slice(i).join(", ")}`);
@@ -102,14 +112,16 @@ export function waitSplit(meter: Meter = networkMeter, runMs: number = RUN_MS):
102112 try {
103113 // A cell reaches out only through the egress proxy, where a bare handshake cannot go:
104114 // the GETs are still timed, and the line says the edge went unmeasured.
105 const connectMs = await meter.handshake(origin, run).catch((e: unknown) => {
106 actions.push(`${path} handshake unmeasured, counted as 0 ms: ${why(e)}`);
107 return 0;
108 });
109 const pub = await meter.get(new URL(path, origin).href, run);
110 const local = await meter.get(`${loopback}${path}`, run);
111 const t: Timings = { connectMs, ttfbMs: pub.ttfbMs, loopbackMs: local.ttfbMs, appMs: serverAppMs(pub.serverTiming) ?? serverAppMs(local.serverTiming) ?? 0 };
112 const said = splitLine(path, t, pub.totalMs);
115 const connectMs = local
116 ? 0
117 : await meter.handshake(origin, run).catch((e: unknown) => {
118 actions.push(`${path} handshake unmeasured, counted as 0 ms: ${why(e)}`);
119 return 0;
120 });
121 const pub = local ? undefined : await meter.get(new URL(path, origin).href, run);
122 const near = await meter.get(`${loopback}${path}`, run);
123 const t: Timings = { connectMs, ttfbMs: (pub ?? near).ttfbMs, loopbackMs: near.ttfbMs, appMs: serverAppMs(pub?.serverTiming) ?? serverAppMs(near.serverTiming) ?? 0 };
124 const said = splitLine(path, t, (pub ?? near).totalMs);
113125 actions.push(said);
114126 const layer = waitLayer(t);
115127 if (layer !== "none") slow.set(layer, [...(slow.get(layer) ?? []), said]);
src/origins/lineage.ts +2 −1
@@ -59,7 +59,8 @@ export async function lookupLineage(
5959 headers: { accept: "application/json", "user-agent": "forge-migrate" },
6060 signal: AbortSignal.timeout(TIMEOUT_MS),
6161 },
62 options,
62 // An address on this forge's own host is read from its listener, anonymously (#14664).
63 { ...options, self: true },
6364 );
6465 if (response.status !== 200) {
6566 await response.body?.cancel().catch(() => undefined);
test/maintain-wait-split.test.ts +16 −1
@@ -55,7 +55,7 @@ const appAt = (url: string, port = 3000): App => {
5555 made.push({ app, dir });
5656 return app;
5757 };
58 const runOn = (meter: Meter, app: App, now = new Date(), runMs?: number) => waitSplit(meter, runMs).run({ db: app.db, bus: app.bus, now, app });
58 const runOn = (meter: Meter, app: App, now = new Date(), runMs?: number) => waitSplit(meter, runMs, () => false).run({ db: app.db, bus: app.bus, now, app });
5959 afterAll(() => {
6060 for (const { app, dir } of made) {
6161 app.close();
@@ -120,3 +120,18 @@ test("the run's bound sits under the runner's deadline", () => {
120120 test("the forge runs it", () => {
121121 expect(duties.map((d) => d.name)).toContain("wait-split");
122122 });
123
124 test("in a cell the duty never asks its own public host: loopback alone, and the line says so (#14664)", async () => {
125 const asked: string[] = [];
126 let shaken = 0;
127 const meter: Meter = {
128 handshake: async () => (shaken++, 5),
129 get: async (url) => (asked.push(url), read(3, 1)),
130 };
131 const app = appAt("https://lab--forge.example.test", 4123);
132 const out = await waitSplit(meter, undefined, () => true).run({ db: app.db, bus: app.bus, now: new Date(), app });
133 expect(shaken).toBe(0);
134 expect(asked.every((u) => new URL(u).host === "127.0.0.1:4123")).toBe(true);
135 expect(asked).toHaveLength(PATHS.length);
136 expect(out.actions[0]).toContain("does not call its own host lab--forge.example.test");
137 });
test/outbound-sweep.test.ts +39 −1
@@ -22,7 +22,7 @@ const BROWSER = "browser script served by the forge: it fetches its own origin's
2222
2323 /** File → how many non-literal fetches it holds, and why none of them takes a caller-given host. */
2424 const ALLOWED: Record<string, { count: number; why: string }> = {
25 "src/kernel/outbound.ts": { count: 2, why: "the guard itself: dials the address it judged, or the cell's gate" },
25 "src/kernel/outbound.ts": { count: 3, why: "the guard itself: dials the address it judged, the cell's gate, or the forge's own local listener for its own public host" },
2626 "src/origins/origin_fetch.ts": { count: 1, why: "operator-allowed hosts (FORGE_ORIGIN_ALLOW) and dev loopback only; every other through the guard" },
2727 "src/origins/discover.ts": { count: 1, why: "the exempt branch of discovery; every other probe is outboundFetch" },
2828 "src/git/hook-address.ts": { count: 1, why: "the forge's own internal listener: a unix socket or 127.0.0.1" },
@@ -56,6 +56,31 @@ const ALLOWED: Record<string, { count: number; why: string }> = {
5656 "src/maintain/duties/wait_split.ts": { count: 1, why: "the forge's own public URL, timed" },
5757 };
5858
59 /**
60 * A name that holds this forge's own public URL (`FORGE_URL`, `FORGE_APP_URL`, its config's `url`).
61 */
62 const OWN_URL = /canonicalUrl|FORGE_APP_URL|FORGE_URL|forgeUrl|config\.url|ownHost|publicUrl/;
63
64 /**
65 * A file with a bare fetch that also names the forge's own public URL could fetch its own host
66 * past the guard (#14664). Each says what its fetch reaches now; a new one fails the sweep until
67 * it goes through `outboundFetch` (refused, or answered by the listener with `self`) or says why.
68 */
69 const OWN_HOST: Record<string, string> = {
70 "src/maintain/duties/wait_split.ts": "in a cell it reads loopback alone (#14664); outside one it times its own public URL on purpose, the edge being what it measures",
71 "src/http/server.ts": "the forge's own unix socket; the public URL only names links",
72 "src/apps/proxy.ts": "an app's socket or loopback port; the forge URL only builds links for the app",
73 "src/apps/toolbar.ts": BROWSER,
74 "src/http/rp.ts": "the parent forge's issuer; the forge URL only sets the cookie's secure flag",
75 "src/actions/upstream.ts": "the parent forge's API; the forge URL is never the target",
76 "src/crew/openai_runner.ts": "the model endpoint; FORGE_URL is only handed to the run's environment",
77 "src/release/small_forge.ts": "a forge the release check started on loopback",
78 "src/runner/main.ts": "a runner on its own machine, calling the forge it was enrolled with",
79 "src/chaos/report.ts": "a command an operator runs, not the forge's process: it reports to the FORGE_URL it is given",
80 "src/snapshot/probe.ts": "a command an operator runs, not the forge's process",
81 "src/snapshot/verdict.ts": "a command an operator runs, not the forge's process",
82 };
83
5984 /** Every non-literal fetch in src, as `file:line`. */
6085 async function sweep(): Promise<Map<string, string[]>> {
6186 const found = new Map<string, string[]>();
@@ -87,6 +112,19 @@ describe("the sweep of src", () => {
87112 for (const [file, { why }] of Object.entries(ALLOWED)) expect([file, why.length > 10]).toEqual([file, true]);
88113 });
89114
115 test("no bare fetch can reach the forge's own public host unnamed (#14664)", async () => {
116 const unnamed: string[] = [];
117 for (const [file] of await sweep()) {
118 if (file === "src/kernel/outbound.ts" || file.startsWith("src/web/")) continue;
119 if (OWN_URL.test(await Bun.file(file).text()) && OWN_HOST[file] === undefined) unnamed.push(file);
120 }
121 expect(unnamed).toEqual([]);
122 for (const [file, why] of Object.entries(OWN_HOST)) {
123 expect([file, why.length > 10]).toEqual([file, true]);
124 expect([file, OWN_URL.test(await Bun.file(file).text())]).toEqual([file, true]);
125 }
126 });
127
90128 test("the origin paths a member names go through the guard, not a bare fetch", async () => {
91129 const found = await sweep();
92130 expect(found.get("src/origins/oauth.ts")).toBeUndefined();
test/own-host.test.ts added +139
@@ -0,0 +1,139 @@
1 /**
2 * The forge never fetches its own public host over the network (#14664): `outboundFetch`, the one
3 * helper for what it fetches, hands such a URL to the local listener when the forge's own code
4 * asks (`self`), as a stranger, and refuses it for every other caller (webhooks, notify, the
5 * parity probe). `fetch` is watched while each path runs, so a call that reached the public host
6 * fails here; the network is never asked.
7 */
8 import { afterAll, afterEach, expect, test } from "bun:test";
9 import { OWN_HOST_SENTENCE, RefusedError, outboundFetch } from "../src/kernel/outbound.ts";
10 import { isInternalPeer, resolveClient } from "../src/http/peer.ts";
11 import { post } from "../src/crew/notify.ts";
12 import { statusOf } from "../src/apps/parity_probe.ts";
13 import { lookupLineage } from "../src/origins/lineage.ts";
14 import { forgetOwnHost, isOwnHost, localFor, ownHost, setOwnHost } from "../src/kernel/own_host.ts";
15
16 const PUBLIC = "https://lab--forge.example.test";
17
18 const server = Bun.serve({
19 hostname: "127.0.0.1",
20 port: 0,
21 fetch: (req, srv) => {
22 const peer = srv.requestIP(req)?.address;
23 const heard = {
24 path: new URL(req.url).pathname,
25 search: new URL(req.url).search,
26 host: req.headers.get("host"),
27 method: req.method,
28 cookie: req.headers.get("cookie"),
29 authorization: req.headers.get("authorization"),
30 // What the forge's listener would make of this caller (`http/peer.ts`, as `notePeer` does).
31 internal: isInternalPeer(peer, req.headers, { proxies: [] }),
32 client: resolveClient(peer, req.headers, { proxies: [] }),
33 };
34 return new URL(req.url).pathname.startsWith("/api/v1/repos/")
35 ? Response.json({ full_name: "me/fork", parent: { full_name: "up/root" } })
36 : Response.json(heard);
37 },
38 });
39 const local = `http://127.0.0.1:${server.port}`;
40
41 afterEach(() => forgetOwnHost());
42 afterAll(() => server.stop(true));
43
44 /** Run `fn` with `fetch` watched; every URL it was asked for comes back. */
45 async function watched<T>(fn: () => Promise<T>, network = true): Promise<{ result: T; asked: string[] }> {
46 const real = globalThis.fetch;
47 const asked: string[] = [];
48 globalThis.fetch = Object.assign(
49 (input: string | URL | Request, init?: RequestInit) => {
50 const url = input instanceof Request ? input.url : String(input);
51 asked.push(url);
52 // Only the test's own listener is reachable; anything else is rejected, never dialled.
53 if (network && new URL(url).host === `127.0.0.1:${server.port}`) return real(input, init);
54 return Promise.reject(new Error(`stubbed: no network for ${url}`));
55 },
56 real,
57 );
58 try {
59 return { result: await fn(), asked };
60 } finally {
61 globalThis.fetch = real;
62 }
63 }
64
65 test("only the configured public host is the own host, and its path keeps to the listener", () => {
66 expect(isOwnHost(`${PUBLIC}/x`)).toBe(false);
67 setOwnHost(PUBLIC, local);
68 expect(ownHost()).toBe("lab--forge.example.test");
outdated

Real network call to a .test host: stub fetch to reject so the test is hermetic.

69 expect(isOwnHost(`${PUBLIC}/x`)).toBe(true);
70 expect(isOwnHost("https://LAB--forge.example.test/")).toBe(true);
71 expect(isOwnHost("https://other.example.test/")).toBe(false);
72 expect(isOwnHost("https://lab--forge.example.test:8443/")).toBe(false);
73 expect(localFor(`${PUBLIC}/api/v1/x?y=1#z`)?.href).toBe(`${local}/api/v1/x?y=1`);
74 expect(localFor("https://other.example.test/")).toBeUndefined();
75 });
76
77 test("an unset or broken public URL makes no host the own host, and a broken one is said once", () => {
78 const said: string[] = [];
79 setOwnHost("", local, (l) => said.push(l));
80 expect(ownHost()).toBeUndefined();
81 expect(said).toEqual([]);
82 setOwnHost("not a url", local, (l) => said.push(l));
83 expect(isOwnHost(PUBLIC)).toBe(false);
84 expect(said).toHaveLength(1);
85 expect(said[0]).toContain("not a url");
86 });
87
88 test("the forge's own code is answered by the local listener, never the network", async () => {
89 setOwnHost(PUBLIC, local);
90 const { result, asked } = await watched(() => outboundFetch(`${PUBLIC}/hooks/self?a=1`, { method: "POST", body: "{}" }, { self: true }));
91 expect(await result.json()).toMatchObject({ path: "/hooks/self", search: "?a=1", host: "lab--forge.example.test", method: "POST" });
92 expect(asked).toEqual([`${local}/hooks/self?a=1`]);
93 });
94
95 test("a call to the own listener earns no trust a remote caller lacks: not internal, no credentials", async () => {
96 setOwnHost(PUBLIC, local);
97 const { result } = await watched(() =>
98 outboundFetch(`${PUBLIC}/x`, { headers: { cookie: "forge_session=s", authorization: "Bearer t", "x-forwarded-for": "10.0.0.9" } }, { self: true }),
99 );
100 const heard = (await result.json()) as Record<string, unknown>;
101 expect(heard["internal"]).toBe(false);
102 expect(heard["cookie"]).toBeNull();
103 expect(heard["authorization"]).toBeNull();
104 // Not the address the caller wrote: the listener keys its limits on the forge's word.
105 expect(heard["client"]).toBe("127.0.0.1");
106 });
107
108 test("every caller that did not opt in is refused the own host before any fetch: webhooks, notify, the parity probe", async () => {
109 setOwnHost(PUBLIC, local);
110 const { result, asked } = await watched(async () => {
111 const helper = await outboundFetch(`${PUBLIC}/hooks/x`, { method: "POST", headers: { cookie: "a=b" } }).catch((e: unknown) => e);
112 const notified = await post(`${PUBLIC}/notify`, "hi", {});
113 const probed = await statusOf(`${PUBLIC}/`);
114 return { helper, notified, probed };
115 });
116 expect(result.helper).toBeInstanceOf(RefusedError);
117 expect((result.helper as Error).message).toBe(OWN_HOST_SENTENCE);
118 expect(result.notified).toBe(false);
119 expect(result.probed).toBeNull();
120 expect(asked).toEqual([]);
121 });
122
123 test("lineage of an address on the own host reads the listener, anonymously", async () => {
124 setOwnHost(PUBLIC, local);
125 const { result, asked } = await watched(() => lookupLineage(`${PUBLIC}/me/fork`));
126 expect(result).toEqual(["up/root"]);
127 expect(asked.every((u) => new URL(u).host === `127.0.0.1:${server.port}`)).toBe(true);
128 expect(asked.length).toBeGreaterThan(0);
129 });
130
131 test("without its own host set, the same URL is not taken for the forge's", async () => {
132 // The network is stubbed to reject: the call fails out on the vetted path, not at the listener.
133 const { asked } = await watched(
134 () => outboundFetch(`${PUBLIC}/x`, {}, { self: true, resolve: async () => ["93.184.216.34"] }).catch(() => undefined),
135 false,
136 );
137 expect(asked.includes(`${local}/x`)).toBe(false);
138 expect(asked).toHaveLength(1);
139 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs