Limen.Signal.ClientIP (limen v0.2.1)

Copy Markdown View Source

Resolves the client address and prefix.

The peer address of the connection is the client unless the peer is one of the configured :trusted_proxies. In that case the address is read from the configured :client_ip_header:

  • "x-forwarded-for" and "forwarded" are chains each proxy appends to. They are walked from the right, skipping trusted proxies; the first untrusted address is the client. Anything to its left was written by the client and is ignored, so sending the header yourself spoofs nothing.
  • "x-real-ip" holds a single address set by the proxy.

When the header is missing or malformed the peer address is used, and the evidence records why. The client address is then aggregated to its prefix (see Limen.IP.prefix/3).

The context's via_proxy is true when the address was read from the header, and false when it is the peer's own, whether or not the peer is a trusted proxy.

Provides :client_ip and :prefix; evidence for :client_ip is :peer, {:header, name} or {:invalid, name}.

Summary

Functions

Resolves the client identity with an explicit configuration.

Functions

resolve(ctx, config)

Resolves the client identity with an explicit configuration.