MCPcopy
hub / github.com/fastify/fastify / getTrustProxyFn

Function getTrustProxyFn

lib/request.js:42–60  ·  view source on GitHub ↗
(tp)

Source from the content-addressed store, hash-verified

40Request.instanceProperties = new Set(['id', 'params', 'raw', 'query', 'log', 'body'])
41
42function getTrustProxyFn (tp) {
43 if (typeof tp === 'function') {
44 return tp
45 }
46 if (tp === true) {
47 // Support trusting everything
48 return function () { return true }
49 }
50 if (typeof tp === 'number') {
51 // Support trusting hop count
52 return function (a, i) { return i < tp }
53 }
54 if (typeof tp === 'string') {
55 // Support comma-separated tps
56 const values = tp.split(',').map(it => it.trim())
57 return proxyAddr.compile(values)
58 }
59 return proxyAddr.compile(tp)
60}
61
62function buildRequest (R, trustProxy) {
63 if (trustProxy) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected