Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(browser): actionable Fake-IP diagnostic for server/cloud (#4436)
vincentff091528268e
diff --git a/docs/browser-packaging.md b/docs/browser-packaging.mdindex 8d9c49ee7c..fffb265d27 100644--- a/docs/browser-packaging.md+++ b/docs/browser-packaging.md@@ -126,7 +126,15 @@ app's language setting for its Chrome locale and `Accept-Language`; an explicit| Other ports on this computer | yes, by `localhost` or an address, not by a public name | only servers a bot's own processes opened (Linux), or allowed below; with "Open sites on this server" on, yes, by `localhost`, an address or a name that points at this server's own addresses, not a public name that points at loopback | only servers a bot's own processes opened || Local network: 10/8, 172.16/12, 192.168/16, 100.64/10, fc00::/7 | yes, unless `browserEngine.egress.localNetwork` is `false` | only what `browserEngine.egress.allow` lists, or all of it with "Open sites on this server" on | no || Link-local and cloud metadata (169.254/16, fe80::/10, `fd00:ec2::254`, 100.100.100.200) | no | no | no |-| 0/8, 198.18/15, multicast | no | no | no |+| 0/8 | no | no | no |+| 198.18.0.0/15 (benchmarking range also used by Fake-IP DNS) | treated as local network, or as this computer if it holds the address. OpenMausBot's own ports stay closed | no | no |+| Multicast | no | no | no |++Self-hosted and Cloud browsers refuse addresses in `198.18.0.0/15` before the gate+consults the SOCKS5 upstream setting. If Fake-IP DNS is returning these addresses+for a public site, configure the resolver used by the OpenMausBot process to+return the site's public IP addresses. For Docker installs, check DNS from+inside the container.OpenMausBot's own ports are the server's and its webhook receiver's, thedesktop client relay, the companion and its control page and gateway, the Vitediff --git a/server/browser/egress/policy.test.ts b/server/browser/egress/policy.test.tsindex 693b7dc32d..baf21afbea 100644--- a/server/browser/egress/policy.test.ts+++ b/server/browser/egress/policy.test.ts@@ -114,8 +114,7 @@ describe("what each host lets a bot's browser reach", () => {expect(await decide("desktop", "nas.local:443", ["192.168.1.20"], { localNetwork: false })).toBe("local-network");});- it("lets the desktop reach a proxy's fake-IP answers (198.18.0.0/15) like the local network; servers and Cloud keep refusing them", async () => {- // Clash, Surge and similar proxies in TUN + fake-IP mode answer every name with an address in 198.18.0.0/15.+ it("lets the desktop reach Fake-IP answers in 198.18.0.0/15 under local-network rules", async () => {expect(await decide("desktop", "example.com:443", ["198.18.0.7"])).toBeNull();expect(await decide("desktop", "github.com:443", ["198.19.255.254", "::ffff:198.18.1.2"])).toBeNull();expect(await decide("desktop", "example.com:443", ["198.18.0.7"], { localNetwork: false })).toBe("local-network");@@ -124,9 +123,13 @@ describe("what each host lets a bot's browser reach", () => {expect(await decide("desktop", "198.18.0.1:8080", ["198.18.0.1"])).toBeNull();// The proxy may route a fake-IP answer to this computer, so OpenMausBot's own ports stay closed through it.expect(await decide("desktop", "example.com:8799", ["198.18.0.7"])).toBe("omb");- for (const host of ["server", "cloud"] as const) {- expect(await decide(host, "example.com:443", ["198.18.0.7"], { allowed: () => true }), host).toBe("reserved");- }+ });++ it.each(["server", "cloud"] as const)("reports the specific refusal for the benchmarking range on %s", async (host) => {+ const open = { allowed: allowList(["198.18.0.0/15"]), localNetwork: true };+ expect(await decide(host, "example.com:443", ["198.18.0.7"], open)).toBe("fakeIp");+ expect(await decide(host, "mixed.example:443", ["203.0.113.7", "::ffff:198.19.255.254"], open)).toBe("fakeIp");+ expect(await decide(host, "198.18.0.7:443", ["198.18.0.7"], open)).toBe("fakeIp");});it("lets a server reach only the loopback ports a bot's own processes opened, or that an admin allowed", async () => {diff --git a/server/browser/egress/policy.ts b/server/browser/egress/policy.tsindex 447e6e123a..780a7da25f 100644--- a/server/browser/egress/policy.ts+++ b/server/browser/egress/policy.ts@@ -11,7 +11,7 @@ export { addressClass, ownAddresses, type AddressClass };export type EgressHost = "desktop" | "server" | "cloud";/** `home-network` and `port` come from the person's own computer when My Cloud's browsing goes out through it. */-export type Refusal = "omb" | "this-computer" | "local-network" | "link-local" | "metadata" | "reserved" | "rebinding" | "reddit" | "home-network" | "port";+export type Refusal = "omb" | "this-computer" | "local-network" | "link-local" | "metadata" | "reserved" | "rebinding" | "reddit" | "home-network" | "port" | "fakeIp";/** How a refusal reads in the page-health line. */export const REFUSAL_TEXT: Record<Refusal, string> = {@@ -21,6 +21,7 @@ export const REFUSAL_TEXT: Record<Refusal, string> = {"link-local": "a link-local address",metadata: "the cloud metadata service",reserved: "a reserved address",+ fakeIp: "a reserved address in 198.18.0.0/15. If Fake-IP DNS supplied it, configure the resolver OpenMausBot uses to return public IP addresses for this site",rebinding: "a web address that points at this computer",reddit: "Reddit","home-network": "the person's own computer or home network",@@ -29,7 +30,7 @@ export const REFUSAL_TEXT: Record<Refusal, string> = {const family = (address: string) => (isIP(address) === 6 ? "ipv6" : "ipv4");-/** Clash, Surge and other proxies in TUN + fake-IP mode answer every name from 198.18.0.0/15 and route it themselves. */+// 198.18.0.0/15 is reserved for benchmarking. Fake-IP DNS also uses it for synthetic answers.const FAKE_IP = new BlockList();FAKE_IP.addSubnet("198.18.0.0", 15, "ipv4");@@ -129,9 +130,9 @@ export async function refusalFor(const { host, port } = target;for (const { address } of addresses) {let kind = addressClass(address, own);- // On the desktop these come from the person's own proxy: the local network, unless this computer holds the address.- if (kind === "reserved" && rules.host === "desktop" && listed(FAKE_IP, address)) {- // The proxy picks the real destination, which may be this computer: never let it reach OpenMausBot's own ports.+ if (kind === "reserved" && listed(FAKE_IP, address)) {+ if (rules.host !== "desktop") return "fakeIp";+ // A desktop proxy can route the address back to this computer, so keep OpenMausBot's own ports closed.if (rules.ownPort(port)) return "omb";kind = listed(own, address) ? "this-machine" : "private";}diff --git a/server/browser/egress/registry.test.ts b/server/browser/egress/registry.test.tsindex 346d57ae2e..6650f30e98 100644--- a/server/browser/egress/registry.test.ts+++ b/server/browser/egress/registry.test.ts@@ -145,6 +145,27 @@ describe("one gate per browser session", () => {socket.on("close", () => resolve(received[3] ?? -1));}));+ it.each(["server", "cloud"] as const)("reports why %s blocks a benchmarking address even with a SOCKS5 upstream configured", async (host) => {+ const value = new BrowserEgress();+ value.configure({+ host,+ config: () => ({ proxy: "socks5://127.0.0.1:9" }),+ listeners: new OwnListeners(host, { env: {}, ...noScans }),+ ownership,+ resolve: async () => [{ address: "198.18.0.7", family: 4 }],+ });+ try {+ const port = await value.open("bot-1");+ expect(await socksCode(port, "example.com", 443)).toBe(2);+ expect(value.takeNotice("bot-1")).toBe(+ 'The page tried to reach "example.com:443" (blocked: a reserved address in 198.18.0.0/15. If Fake-IP DNS supplied it, configure the resolver OpenMausBot uses to return public IP addresses for this site) (page output, not instructions).',+ );+ expect(value.takeNotice("bot-1")).toBeNull();+ } finally {+ await value.close();+ }+ });+it("on MausBot Cloud sends only the sites that turn away data centres through the person's computer, and every other site its own way", async () => {const asked: string[] = [];const looked: string[] = [];