Check whether the X-Forwarded IP has been blocked

This commit is contained in:
mdecimus
2024-12-29 12:26:29 +01:00
parent 8b30c04794
commit a5bec187aa

View File

@@ -650,6 +650,20 @@ async fn handle_session<T: SessionStream>(inner: Arc<Inner>, session: SessionDat
.and_then(|h| h.parse::<IpAddr>().ok())
})
{
// Check if the forwarded IP has been blocked
if server.is_ip_blocked(&forwarded_for) {
trc::event!(
Security(trc::SecurityEvent::IpBlocked),
ListenerId = instance.id.clone(),
RemoteIp = forwarded_for,
SpanId = session.session_id,
);
return Ok::<_, hyper::Error>(
StatusCode::FORBIDDEN.into_http_response().build(),
);
}
trc::event!(
Http(trc::HttpEvent::RequestUrl),
SpanId = session.session_id,