Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Report the Fake-IP refusal for translated server and cloud addresses
vincent9bc95a2acdc9
diff --git a/electron/egress-addresses.d.mts b/electron/egress-addresses.d.mtsindex 3514fc35da..8d6406f18a 100644--- a/electron/egress-addresses.d.mts+++ b/electron/egress-addresses.d.mts@@ -4,5 +4,6 @@ import type { networkInterfaces } from "node:os";export type AddressClass = "public" | "loopback" | "this-machine" | "private" | "link-local" | "metadata" | "reserved";export declare function ownAddresses(interfaces?: ReturnType<typeof networkInterfaces>): BlockList;export declare function ownSubnets(interfaces?: ReturnType<typeof networkInterfaces>): BlockList;+export declare function embeddedIPv4(address: string): string | undefined;export declare function addressClass(raw: string, own?: BlockList): AddressClass;export declare function listed(list: BlockList, raw: string): boolean;diff --git a/electron/egress-addresses.mjs b/electron/egress-addresses.mjsindex 18e9295174..c7330b241e 100644--- a/electron/egress-addresses.mjs+++ b/electron/egress-addresses.mjs@@ -47,7 +47,7 @@ function ipv6Groups(address) {}/** The IPv4 address a NAT64 or 6to4 address stands for, which a translator will route to. */-function embeddedIPv4(address) {+export function embeddedIPv4(address) {const at = NAT64.check(address, "ipv6") ? 6 : SIX_TO_FOUR.check(address, "ipv6") ? 1 : -1;if (at === -1) return undefined;const groups = ipv6Groups(address);diff --git a/server/browser/egress/policy.test.ts b/server/browser/egress/policy.test.tsindex baf21afbea..564769273a 100644--- a/server/browser/egress/policy.test.ts+++ b/server/browser/egress/policy.test.ts@@ -130,6 +130,8 @@ describe("what each host lets a bot's browser reach", () => {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");+ expect(await decide(host, "example.com:443", ["64:ff9b::c612:7"], open)).toBe("fakeIp");+ expect(await decide(host, "example.com:443", ["2002:c612:7::1"], 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 780a7da25f..4172c79801 100644--- a/server/browser/egress/policy.ts+++ b/server/browser/egress/policy.ts@@ -3,7 +3,7 @@import { BlockList, isIP } from "node:net";import { z } from "zod";-import { addressClass, listed, ownAddresses, type AddressClass } from "../../../electron/egress-addresses.mjs";+import { addressClass, embeddedIPv4, listed, ownAddresses, type AddressClass } from "../../../electron/egress-addresses.mjs";export { addressClass, ownAddresses, type AddressClass };@@ -130,6 +130,7 @@ export async function refusalFor(const { host, port } = target;for (const { address } of addresses) {let kind = addressClass(address, own);+ if (kind === "reserved" && rules.host !== "desktop" && isIP(address) === 6 && listed(FAKE_IP, embeddedIPv4(address) ?? address)) return "fakeIp";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.