countryHeader static method

DVWafCountryResolver countryHeader(
  1. String header
)

Reads the country from a header a CDN sets, such as cf-ipcountry, when the request came straight from a trusted proxy.

Opt-in by name, and believed only from a peer DVClientAddress.current trusts: a header is only as trustworthy as the proxy that overwrites it, and a client that reaches the origin directly can send any header it likes. From anywhere else the country is unknown, which is outside every allow-list.

Implementation

static DVWafCountryResolver countryHeader(String header) => (request) =>
    DVClientAddress.current.peerIsTrusted(request)
        ? dvEdgeHeader(request, header)
        : null;