#[non_exhaustive]pub struct ClientIp {
pub ip: IpAddr,
}Expand description
Resolved client IP of the current request.
Inserted as a request extension on every request served by serve,
right after PeerAddr. Equals the direct peer’s IP unless
trusted-forwarder mode is active
(McpServerConfig::with_trusted_proxies) and the request arrived
through a trusted proxy with a verifiable forwarding chain — in that
case it is the rightmost-untrusted address from X-Forwarded-For
(or RFC 7239 Forwarded, per
McpServerConfig::with_forwarded_header).
All built-in per-IP rate limiters key by this value. PeerAddr
keeps its direct-socket-peer contract unchanged; applications that
need provenance can compare ClientIp.ip with PeerAddr.addr.ip().
§Security
Resolution only ever activates when the direct peer is inside the operator’s trusted-proxy CIDRs; every ambiguous chain (malformed or obfuscated entries, all-trusted chains, header bombs) falls back to the direct peer, never to a header value. The framework never logs this value outside rate-limit deny paths.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ip: IpAddrResolved client IP (direct peer unless trusted-forwarder resolution applied).
Trait Implementations§
impl Copy for ClientIp
impl Eq for ClientIp
impl StructuralPartialEq for ClientIp
Auto Trait Implementations§
impl Freeze for ClientIp
impl RefUnwindSafe for ClientIp
impl Send for ClientIp
impl Sync for ClientIp
impl Unpin for ClientIp
impl UnsafeUnpin for ClientIp
impl UnwindSafe for ClientIp
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.