* 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 )
| 21 | * @param trust |
| 22 | */ |
| 23 | function 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 | * |