resolveClientAddress
Chooses the client address.
Chooses the client address. Without proxy trust it is the peer address. With it, the header is
read from the right (the closest proxy appends last) skipping hops - 1 entries; an invalid or
missing entry falls back to the peer, so a spoofed header cannot produce a non-address key.
Import#
ts
import { resolveClientAddress } from "@shadow-js/dusk/server";
Signature#
ts
function resolveClientAddress(
peer: string | undefined,
headers: Headers,
trust: false | TrustProxyOptions | undefined,
): string | undefined
Parameters#
| Name | Description |
|---|---|
peer |
The address of the TCP peer, as the host reports it. |
headers |
Request headers. |
trust |
The trust configuration. |
Returns#
The address, or undefined when nothing usable exists.
Examples#
ts
resolveClientAddress("10.0.0.2", request.headers, { hops: 1 });