netray_common/lib.rs
1//! Shared utilities for the netray.info service ecosystem.
2//!
3//! This crate provides cross-cutting concerns used by multiple backend services:
4//!
5//! - [`ip_extract`] -- Extract real client IP from proxy headers with trusted-proxy CIDR matching.
6//! - [`error`] -- Structured JSON error responses via the [`error::ApiError`] trait.
7//! - [`rate_limit`] -- Keyed and global rate limiting wrappers around `governor`.
8//! - [`security_headers`] -- Axum middleware for CSP, HSTS, and other security headers.
9//!
10//! # Example
11//!
12//! ```rust
13//! use netray_common::ip_extract::IpExtractor;
14//!
15//! let extractor = IpExtractor::new(&["10.0.0.0/8".to_string()]).unwrap();
16//! // extractor.extract(&headers, peer_addr) returns the real client IP
17//! ```
18
19pub mod error;
20pub mod ip_extract;
21pub mod ip_filter;
22#[cfg(feature = "middleware")]
23pub mod middleware;
24pub mod rate_limit;
25pub mod security_headers;
26#[cfg(feature = "telemetry")]
27pub mod telemetry;
28#[cfg(feature = "cors")]
29pub mod cors;
30#[cfg(feature = "server")]
31pub mod server;
32#[cfg(feature = "enrichment")]
33pub mod enrichment;