Expand description
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.
§Quick start
DefaultConfig pre-implements every configuration trait, so a minimal
setup needs no boilerplate. Mutate its public fields to customize behaviour:
use std::time::Duration;
use wisegate_core::{DefaultConfig, RateLimiter};
let mut config = DefaultConfig::default();
config.rate_limit.max_requests = 200;
config.rate_limit.window_duration = Duration::from_secs(30);
config.blocked_methods = vec!["TRACE".into(), "CONNECT".into()];
let _limiter = RateLimiter::new();When you need finer control, implement the composable traits directly
(RateLimitingProvider, ProxyProvider, FilteringProvider,
ConnectionProvider, AuthenticationProvider). See types for
a worked example of bespoke implementations.
§Wiring it into hyper
request_handler::handle_request is async and expects a Tokio runtime —
call it from inside #[tokio::main] or any other Tokio executor. It takes
an Arc<C: ConfigProvider> so the same configuration can be cloned cheaply
across spawned tasks.
§Modules
types- Core types and theConfigProvidertraiterror- Error types and result aliasesheaders- HTTP header constantsip_filter- IP validation, extraction, and filteringrate_limiter- Rate limiting implementationrequest_handler- HTTP request processing and forwarding
Re-exports§
pub use auth::Credential;pub use auth::Credentials;pub use auth::check_basic_auth;pub use auth::check_bearer_token;pub use default_config::DefaultConfig;pub use error::WiseGateError;pub use types::AuthenticationProvider;pub use types::ConfigProvider;pub use types::ConnectionProvider;pub use types::FilteringProvider;pub use types::ProxyConfig;pub use types::ProxyProvider;pub use types::RateLimitCleanupConfig;pub use types::RateLimitConfig;pub use types::RateLimitEntry;pub use types::RateLimiter;pub use types::RateLimitingProvider;
Modules§
- auth
- Authentication module for HTTP Basic Authentication (RFC 7617) and Bearer Token (RFC 6750).
- default_
config - Ready-to-use configuration for library consumers.
- defaults
- Default configuration values for WiseGate.
- error
- Error types for WiseGate.
- headers
- HTTP header constants for WiseGate.
- ip_
filter - IP filtering and validation for WiseGate.
- rate_
limiter - Rate limiting implementation for WiseGate.
- request_
handler - HTTP request handling and proxying.
- types
- Type definitions for WiseGate configuration and state management.