mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
fix(ssrf): answer a pinned lookup on a later tick so a failed connect cannot crash the server
Called back at once, a connect that fails right away (no route to an IPv6 address) tore the socket down while tls.connect was still setting it up; undici saw 'fetch failed' and the socket's own error then reached no listener and ended the process. The pinned lookup now answers on the next tick, as dns.lookup does.
This commit is contained in:
@@ -152,8 +152,9 @@ describe('createOutboundDispatcher, connections kept (the routing relay)', () =>
|
||||
const lookup = (
|
||||
built.agents[1] as { connect: { lookup: (h: string, o: object, cb: (...a: unknown[]) => void) => void } }
|
||||
).connect.lookup;
|
||||
const seen: unknown[] = [];
|
||||
lookup('valhalla.liketrek.com', {}, (...args: unknown[]) => seen.push(...args));
|
||||
const seen = await new Promise<unknown[]>((resolve) =>
|
||||
lookup('valhalla.liketrek.com', {}, (...args: unknown[]) => resolve(args)),
|
||||
);
|
||||
expect(seen).toContain('203.0.113.8');
|
||||
expect(seen).not.toContain('203.0.113.7');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user