mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:41:24 +00:00
fix(net): enable family fallback for pinned SSRF dispatcher
This commit is contained in:
35
src/infra/net/ssrf.dispatcher.test.ts
Normal file
35
src/infra/net/ssrf.dispatcher.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { agentCtor } = vi.hoisted(() => ({
|
||||
agentCtor: vi.fn(function MockAgent(this: { options: unknown }, options: unknown) {
|
||||
this.options = options;
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("undici", () => ({
|
||||
Agent: agentCtor,
|
||||
}));
|
||||
|
||||
import { createPinnedDispatcher, type PinnedHostname } from "./ssrf.js";
|
||||
|
||||
describe("createPinnedDispatcher", () => {
|
||||
it("enables network family auto-selection for pinned lookups", () => {
|
||||
const lookup = vi.fn();
|
||||
const pinned: PinnedHostname = {
|
||||
hostname: "api.telegram.org",
|
||||
addresses: ["149.154.167.220"],
|
||||
lookup,
|
||||
};
|
||||
|
||||
const dispatcher = createPinnedDispatcher(pinned);
|
||||
|
||||
expect(dispatcher).toBeDefined();
|
||||
expect(agentCtor).toHaveBeenCalledWith({
|
||||
connect: {
|
||||
lookup,
|
||||
autoSelectFamily: true,
|
||||
autoSelectFamilyAttemptTimeout: 300,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -296,6 +296,8 @@ export function createPinnedDispatcher(pinned: PinnedHostname): Dispatcher {
|
||||
return new Agent({
|
||||
connect: {
|
||||
lookup: pinned.lookup,
|
||||
autoSelectFamily: true,
|
||||
autoSelectFamilyAttemptTimeout: 300,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user