mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 16:59:52 +00:00
feat(trusted-proxies): add switchable simple and legacy modes (#2674)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: houseme <4829346+houseme@users.noreply.github.com>
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
use std::sync::Arc;
|
||||
use tower::Layer;
|
||||
|
||||
use crate::LegacyTrustedProxyMiddleware;
|
||||
use crate::ProxyValidator;
|
||||
use crate::TrustedProxyConfig;
|
||||
use crate::TrustedProxyMiddleware;
|
||||
use crate::{CacheConfig, ProxyMetrics};
|
||||
|
||||
/// Tower Layer for the trusted proxy middleware.
|
||||
@@ -73,10 +73,10 @@ impl TrustedProxyLayer {
|
||||
}
|
||||
|
||||
impl<S> Layer<S> for TrustedProxyLayer {
|
||||
type Service = TrustedProxyMiddleware<S>;
|
||||
type Service = LegacyTrustedProxyMiddleware<S>;
|
||||
|
||||
fn layer(&self, inner: S) -> Self::Service {
|
||||
TrustedProxyMiddleware {
|
||||
LegacyTrustedProxyMiddleware {
|
||||
inner,
|
||||
validator: self.validator.clone(),
|
||||
enabled: self.enabled,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
//! Tower service implementation for the trusted proxy middleware.
|
||||
|
||||
use crate::{ClientInfo, ProxyValidator, TrustedProxyLayer};
|
||||
use crate::{ClientInfo, ProxyValidator};
|
||||
use http::Request;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
@@ -43,7 +43,7 @@ impl<S> TrustedProxyMiddleware<S> {
|
||||
}
|
||||
|
||||
/// Creates a new `TrustedProxyMiddleware` from a `TrustedProxyLayer`.
|
||||
pub fn from_layer(inner: S, layer: &TrustedProxyLayer) -> Self {
|
||||
pub fn from_layer(inner: S, layer: &super::layer::TrustedProxyLayer) -> Self {
|
||||
Self::new(inner, layer.validator.clone(), layer.enabled)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user