|
1 | | -import type { LookupAddress, LookupOptions } from 'dns' |
2 | 1 | import dns from 'dns/promises' |
3 | 2 | import http from 'http' |
4 | 3 | import https from 'https' |
| 4 | +import type { LookupFunction } from 'net' |
5 | 5 | import { createLogger } from '@sim/logger' |
6 | 6 | import * as ipaddr from 'ipaddr.js' |
7 | 7 |
|
@@ -908,24 +908,16 @@ export async function secureFetchWithPinnedIP( |
908 | 908 | const isIPv6 = resolvedIP.includes(':') |
909 | 909 | const family = isIPv6 ? 6 : 4 |
910 | 910 |
|
911 | | - const agentOptions: http.AgentOptions = { |
912 | | - lookup: ( |
913 | | - _hostname: string, |
914 | | - options: LookupOptions, |
915 | | - callback: ( |
916 | | - err: NodeJS.ErrnoException | null, |
917 | | - address: string | LookupAddress[], |
918 | | - family?: number |
919 | | - ) => void |
920 | | - ) => { |
921 | | - if (options.all) { |
922 | | - callback(null, [{ address: resolvedIP, family }]) |
923 | | - } else { |
924 | | - callback(null, resolvedIP, family) |
925 | | - } |
926 | | - }, |
| 911 | + const lookup: LookupFunction = (_hostname, options, callback) => { |
| 912 | + if (options.all) { |
| 913 | + callback(null, [{ address: resolvedIP, family }]) |
| 914 | + } else { |
| 915 | + callback(null, resolvedIP, family) |
| 916 | + } |
927 | 917 | } |
928 | 918 |
|
| 919 | + const agentOptions: http.AgentOptions = { lookup } |
| 920 | + |
929 | 921 | const agent = isHttps ? new https.Agent(agentOptions) : new http.Agent(agentOptions) |
930 | 922 |
|
931 | 923 | // Remove accept-encoding since Node.js http/https doesn't auto-decompress |
|
0 commit comments