MCPcopy
hub / github.com/tinyhttp/tinyhttp / alladdrs

Function alladdrs

packages/proxy-addr/src/index.ts:23–40  ·  view source on GitHub ↗

* Get all addresses in the request, optionally stopping * at the first untrusted. * * @param request * @param trust

(
  req: Pick<IncomingMessage, 'headers' | 'connection'>,
  trust: ((...args: any[]) => any) | any[] | string[] | string
)

Source from the content-addressed store, hash-verified

21 * @param trust
22 */
23function alladdrs(
24 req: Pick<IncomingMessage, 'headers' | 'connection'>,
25 trust: ((...args: any[]) => any) | any[] | string[] | string
26) {
27 // get addresses
28
29 const addrs = forwarded(req)
30
31 if (!trust) return addrs
32
33 if (typeof trust !== 'function') trust = compile(trust)
34
35 for (let i = 0; i < addrs.length - 1; i++) {
36 if (trust(addrs[i], i)) continue
37 addrs.length = i + 1
38 }
39 return addrs
40}
41/**
42 * Compile argument into trust function.
43 *

Callers 1

proxyaddrFunction · 0.85

Calls 2

forwardedFunction · 0.90
compileFunction · 0.85

Tested by

no test coverage detected