Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmunns committed Aug 22, 2024
1 parent 4ccbb7f commit e532317
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
8 changes: 4 additions & 4 deletions source/river/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Modifiers {
other => {
tracing::warn!("Unknown request filter: '{other}'");
return Err(Error::new(pingora::ErrorType::Custom("Bad configuration")));
},
}
};
request_filter_mods.push(f);
}
Expand All @@ -187,7 +187,7 @@ impl Modifiers {
other => {
tracing::warn!("Unknown upstream request filter: '{other}'");
return Err(Error::new(pingora::ErrorType::Custom("Bad configuration")));
},
}
};
upstream_request_filters.push(f);
}
Expand All @@ -205,7 +205,7 @@ impl Modifiers {
other => {
tracing::warn!("Unknown upstream response filter: '{other}'");
return Err(Error::new(pingora::ErrorType::Custom("Bad configuration")));
},
}
};
upstream_response_filters.push(f);
}
Expand Down Expand Up @@ -249,7 +249,7 @@ where
// If Err: we return that
e @ Err(_) => return e,
// If Ok(false), we move on to the next filter
Ok(false) => {},
Ok(false) => {}
}
}
Ok(false)
Expand Down
18 changes: 5 additions & 13 deletions source/river/src/proxy/request_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::collections::BTreeMap;
use async_trait::async_trait;
use cidr::IpCidr;
use pingora::ErrorType;
use pingora_proxy::Session;
use pingora_core::{protocols::l4::socket::SocketAddr, Error, Result};
use pingora_proxy::Session;

use crate::proxy::{extract_val, RiverContext};

Expand All @@ -13,11 +13,7 @@ use crate::proxy::{extract_val, RiverContext};
#[async_trait]
pub trait RequestFilterMod: Send + Sync {
/// See [ProxyHttp::request_filter] for more details
async fn request_filter(
&self,
session: &mut Session,
ctx: &mut RiverContext,
) -> Result<bool>;
async fn request_filter(&self, session: &mut Session, ctx: &mut RiverContext) -> Result<bool>;
}

pub struct CidrRangeFilter {
Expand All @@ -37,11 +33,11 @@ impl CidrRangeFilter {
match addr.parse::<IpCidr>() {
Ok(a) => {
blocks.push(a);
},
}
Err(_) => {
tracing::error!("Failed to parse '{addr}' as a valid CIDR notation range");
return Err(Error::new(ErrorType::Custom("Invalid configuration")));
},
}
};
}

Expand All @@ -51,11 +47,7 @@ impl CidrRangeFilter {

#[async_trait]
impl RequestFilterMod for CidrRangeFilter {
async fn request_filter(
&self,
session: &mut Session,
_ctx: &mut RiverContext,
) -> Result<bool> {
async fn request_filter(&self, session: &mut Session, _ctx: &mut RiverContext) -> Result<bool> {
let Some(addr) = session.downstream_session.client_addr() else {
// Unable to determine source address, assuming it should be blocked
return Err(Error::new_down(ErrorType::Custom("Missing Client Address")));
Expand Down

0 comments on commit e532317

Please sign in to comment.