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