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()]);
16//! // extractor.extract(&headers, peer_addr) returns the real client IP
17//! ```
18
19pub mod ecosystem;
20pub mod error;
21pub mod ip_extract;
22pub mod ip_filter;
23pub mod metrics;
24#[cfg(feature = "middleware")]
25pub mod middleware;
26pub mod rate_limit;
27pub mod security_headers;
28pub mod target_policy;
29#[cfg(feature = "telemetry")]
30pub mod telemetry;
31#[cfg(feature = "cors")]
32pub mod cors;
33#[cfg(feature = "server")]
34pub mod server;
35#[cfg(feature = "enrichment")]
36pub mod enrichment;