Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions node/src/rpc_service/handler/proof_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ use std::sync::Arc;

/// Checks if the request host matches the configured proof builder host to prevent forwarding loops.
fn is_loop_detected(host: &str, request_host: Option<&str>) -> bool {
if let Some(request_host) = request_host {
host == request_host
|| host.starts_with(&format!("{}:", request_host.split(':').next().unwrap_or("")))
if let Some(req_host) = request_host {
let mut clean_host = host;

// Remove scheme if present (e.g. "http://")
if let Some(rest) = clean_host.strip_prefix("http://") {
clean_host = rest;
} else if let Some(rest) = clean_host.strip_prefix("https://") {
clean_host = rest;
}

// Remove trailing slash
clean_host = clean_host.trim_end_matches('/');

// Case-insensitive comparison
clean_host.eq_ignore_ascii_case(req_host)
} else {
false
}
Expand Down
Loading