Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Expand a loopback allow entry to the other address only when it names a port
AdityaUmale6e7a948d55b0
diff --git a/server/browser/egress/policy.test.ts b/server/browser/egress/policy.test.tsindex 37be4443bc..693b7dc32d 100644--- a/server/browser/egress/policy.test.ts+++ b/server/browser/egress/policy.test.ts@@ -203,6 +203,8 @@ describe("browserEngine.egress.allow", () => {expect(allowList(["[::1]:4321"])("127.0.0.1", 4322)).toBe(false);expect(allowList(["127.0.0.0/8"])("::1", 80)).toBe(false);expect(allowList(["10.0.0.5:4321"])("::1", 4321)).toBe(false);+ expect(allowList(["127.0.0.1"])("::1", 4321)).toBe(false);+ expect(allowList(["::1"])("127.0.0.1", 4321)).toBe(false);// `localhost` resolves to both, so the page opens with only the IPv4 entry configured.expect(await decide("server", "localhost:4321", ["127.0.0.1", "::1"], { allowed: v4 })).toBeNull();expect(await decide("server", "localhost:4322", ["127.0.0.1", "::1"], { allowed: v4 })).toBe("this-computer");diff --git a/server/browser/egress/policy.ts b/server/browser/egress/policy.tsindex 9c2621f1c5..1cf5079dfb 100644--- a/server/browser/egress/policy.ts+++ b/server/browser/egress/policy.ts@@ -77,9 +77,9 @@ export function allowList(entries: readonly string[] | undefined): (address: strif (!parsed) return [];const list = new BlockList();list.addSubnet(parsed.network, parsed.prefix, family(parsed.network));- // `localhost` resolves to both 127.0.0.1 and ::1, so an entry for one loopback address also covers the other.- if (parsed.prefix === 32 && list.check("127.0.0.1", "ipv4")) list.addAddress("::1", "ipv6");- else if (parsed.prefix === 128 && list.check("::1", "ipv6")) list.addAddress("127.0.0.1", "ipv4");+ // `localhost` resolves to both 127.0.0.1 and ::1, so an entry for one loopback address and port also covers the other.+ if (parsed.port !== null && parsed.prefix === 32 && list.check("127.0.0.1", "ipv4")) list.addAddress("::1", "ipv6");+ else if (parsed.port !== null && parsed.prefix === 128 && list.check("::1", "ipv6")) list.addAddress("127.0.0.1", "ipv4");return [{ list, port: parsed.port }];});return (raw, port) => {