mas_handlers/client_ip.rs
1// Copyright 2026 Element Creations Ltd.
2//
3// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
4// Please see LICENSE files in the repository root for full details.
5
6use std::net::IpAddr;
7
8/// The client IP address of the request.
9///
10/// This is set in the request extensions by the IP-detection middleware, ahead
11/// of the rest of the request handling, so that the logging middleware and the
12/// [`BoundActivityTracker`]/[`RequesterFingerprint`] extractors all observe the
13/// same value without re-inferring it. It is `None` when the client IP could
14/// not be determined.
15///
16/// [`BoundActivityTracker`]: crate::BoundActivityTracker
17/// [`RequesterFingerprint`]: crate::RequesterFingerprint
18#[derive(Clone, Copy, Debug)]
19pub struct ClientIp(pub Option<IpAddr>);