The address a request came from, as opposed to the proxy that delivered it.
:remote-addr is the peer, which behind a reverse proxy is the proxy. Any
client can send X-Forwarded-For, so it is read only when the peer is a
trusted proxy, and from the right: each proxy appends the address it saw,
so the first hop that is not one of ours is the client.
The address a request came from, as opposed to the proxy that delivered it. `:remote-addr` is the peer, which behind a reverse proxy is the proxy. Any client can send X-Forwarded-For, so it is read only when the peer is a trusted proxy, and from the right: each proxy appends the address it saw, so the first hop that is not one of ours is the client.
(client-ip request cidrs)The client's address: :remote-addr, unless that is a trusted proxy, in
which case the right-most X-Forwarded-For hop that is not one. Nil when the
hop the walk stops at is not an address (unknown): the proxy's own address
would put an outside client inside the proxy's network. cidrs comes from
parse-trusted-proxies.
The client's address: `:remote-addr`, unless that is a trusted proxy, in which case the right-most X-Forwarded-For hop that is not one. Nil when the hop the walk stops at is not an address (`unknown`): the proxy's own address would put an outside client inside the proxy's network. `cidrs` comes from `parse-trusted-proxies`.
(in-any? ip cidrs)True when ip lies in one of cidrs, each read as the trust walk reads it
(strings or parse-ip / parse-cidr values). Anything unparseable, nil
included, is false.
True when `ip` lies in one of `cidrs`, each read as the trust walk reads it (strings or `parse-ip` / `parse-cidr` values). Anything unparseable, nil included, is false.
(in-network? ip cidr)True when ip lies in cidr; see in-any?.
True when `ip` lies in `cidr`; see `in-any?`.
(parse-cidr s){:bytes .. :prefix n} for "10.0.0.0/8", "2001:db8::/32", or a bare
address (a /32 or /128); nil when it is none of these.
`{:bytes .. :prefix n}` for "10.0.0.0/8", "2001:db8::/32", or a bare
address (a /32 or /128); nil when it is none of these.(parse-ip s)The bytes of an IPv4 (4) or IPv6 (16) literal, or nil. An IPv4-mapped IPv6 address parses as its IPv4 address, so a dual-stack socket matches IPv4 ranges.
The bytes of an IPv4 (4) or IPv6 (16) literal, or nil. An IPv4-mapped IPv6 address parses as its IPv4 address, so a dual-stack socket matches IPv4 ranges.
(parse-trusted-proxies entries){:cidrs [..]} for the :trusted-proxies setting, or a configuration error
naming the entries that are not CIDRs. Absent means trust nothing.
`{:cidrs [..]}` for the `:trusted-proxies` setting, or a configuration error
naming the entries that are not CIDRs. Absent means trust nothing.(request-ip request)The client address resolved on the request; nil when the middleware could not resolve one. The peer only when the request did not pass through the client-ip middleware.
The client address resolved on the request; nil when the middleware could not resolve one. The peer only when the request did not pass through the client-ip middleware.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |