1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! WiseGate Core - Reusable reverse proxy components
//!
//! This crate provides the core functionality for building reverse proxies with:
//! - Rate limiting with sliding window algorithm
//! - IP filtering and blocking
//! - HTTP method and URL pattern filtering
//! - Trusted proxy validation (RFC 7239 compliant)
//!
//! # Overview
//!
//! `wisegate-core` is designed to be framework-agnostic and can be integrated
//! into any Rust application. Configuration is provided via the [`ConfigProvider`]
//! trait, allowing flexible configuration from any source.
//!
//! # Example
//!
//! ```rust,no_run
//! use wisegate_core::{
//! RateLimitingProvider, ProxyProvider, FilteringProvider, ConnectionProvider,
//! AuthenticationProvider, Credentials,
//! RateLimiter, RateLimitConfig, RateLimitCleanupConfig, ProxyConfig,
//! };
//! use std::time::Duration;
//!
//! // Implement your own configuration provider using composable traits
//! struct MyConfig {
//! credentials: Credentials,
//! }
//!
//! impl RateLimitingProvider for MyConfig {
//! fn rate_limit_config(&self) -> &RateLimitConfig {
//! static CONFIG: RateLimitConfig = RateLimitConfig {
//! max_requests: 100,
//! window_duration: Duration::from_secs(60),
//! };
//! &CONFIG
//! }
//!
//! fn rate_limit_cleanup_config(&self) -> &RateLimitCleanupConfig {
//! static CONFIG: RateLimitCleanupConfig = RateLimitCleanupConfig {
//! threshold: 10_000,
//! interval: Duration::from_secs(60),
//! };
//! &CONFIG
//! }
//! }
//!
//! impl ProxyProvider for MyConfig {
//! fn proxy_config(&self) -> &ProxyConfig {
//! static CONFIG: ProxyConfig = ProxyConfig {
//! timeout: Duration::from_secs(30),
//! max_body_size: 100 * 1024 * 1024,
//! };
//! &CONFIG
//! }
//!
//! fn allowed_proxy_ips(&self) -> Option<&[String]> { None }
//! }
//!
//! impl FilteringProvider for MyConfig {
//! fn blocked_ips(&self) -> &[String] { &[] }
//! fn blocked_methods(&self) -> &[String] { &[] }
//! fn blocked_patterns(&self) -> &[String] { &[] }
//! }
//!
//! impl ConnectionProvider for MyConfig {
//! fn max_connections(&self) -> usize { 10_000 }
//! }
//!
//! impl AuthenticationProvider for MyConfig {
//! fn auth_credentials(&self) -> &Credentials { &self.credentials }
//! fn auth_realm(&self) -> &str { "WiseGate" }
//! fn bearer_token(&self) -> Option<&str> { None }
//! }
//!
//! // Create a rate limiter
//! let limiter = RateLimiter::new();
//! ```
//!
//! # Modules
//!
//! - [`types`] - Core types and the [`ConfigProvider`] trait
//! - [`error`] - Error types and result aliases
//! - [`headers`] - HTTP header constants
//! - [`ip_filter`] - IP validation, extraction, and filtering
//! - [`rate_limiter`] - Rate limiting implementation
//! - [`request_handler`] - HTTP request processing and forwarding
// Re-export commonly used items at crate root
pub use ;
pub use WiseGateError;
pub use ;