Skip to content

Commit 2a3f820

Browse files
committed
remove boilerplate code'
1 parent 3eb46c5 commit 2a3f820

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

apps/sim/lib/core/security/input-validation.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { LookupAddress, LookupOptions } from 'dns'
21
import dns from 'dns/promises'
32
import http from 'http'
43
import https from 'https'
4+
import type { LookupFunction } from 'net'
55
import { createLogger } from '@sim/logger'
66
import * as ipaddr from 'ipaddr.js'
77

@@ -908,24 +908,16 @@ export async function secureFetchWithPinnedIP(
908908
const isIPv6 = resolvedIP.includes(':')
909909
const family = isIPv6 ? 6 : 4
910910

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+
}
927917
}
928918

919+
const agentOptions: http.AgentOptions = { lookup }
920+
929921
const agent = isHttps ? new https.Agent(agentOptions) : new http.Agent(agentOptions)
930922

931923
// Remove accept-encoding since Node.js http/https doesn't auto-decompress

0 commit comments

Comments
 (0)