scufflecloud_geo_ip/
lib.rs

1use std::borrow::Cow;
2
3use crate::resolver::GeoIpResolver;
4
5mod http_ext;
6pub mod middleware;
7pub mod resolver;
8
9pub use http_ext::*;
10pub use maxminddb;
11
12pub struct ReverseProxyConfig<'a> {
13    /// List of networks that bypass the IP address extraction from the configured IP header.
14    /// These are typically internal networks and other services that directly connect to the server without going
15    /// through the reverse proxy.
16    pub internal_networks: Cow<'a, [ipnetwork::IpNetwork]>,
17    /// Request header to get the ip address from.
18    pub ip_header: Cow<'a, str>,
19    /// List of trusted proxy networks that the server accepts connections from.
20    /// These are typically the networks of the reverse proxies in front of the server, e.g. Cloudflare, etc.
21    pub trusted_proxies: Cow<'a, [ipnetwork::IpNetwork]>,
22}
23
24pub trait GeoIpInterface {
25    fn geo_ip_resolver(&self) -> &GeoIpResolver;
26    fn reverse_proxy_config(&self) -> Option<ReverseProxyConfig<'_>>;
27}