mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
fix
This commit is contained in:
@@ -60,10 +60,12 @@ pub struct TrustedProxies {
|
|||||||
impl TrustedProxies {
|
impl TrustedProxies {
|
||||||
/// Create a new TrustedProxies configuration
|
/// Create a new TrustedProxies configuration
|
||||||
pub fn new(cidrs: Vec<String>, enable_validation: bool, max_chain_length: usize) -> Self {
|
pub fn new(cidrs: Vec<String>, enable_validation: bool, max_chain_length: usize) -> Self {
|
||||||
let cidrs = cidrs.into_iter()
|
let cidrs = cidrs.into_iter().filter_map(|s| s.parse::<IpNet>().ok()).collect();
|
||||||
.filter_map(|s| s.parse::<IpNet>().ok())
|
Self {
|
||||||
.collect();
|
cidrs,
|
||||||
Self { cidrs, enable_validation, max_chain_length }
|
enable_validation,
|
||||||
|
max_chain_length,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if an IP address is within the trusted proxy ranges
|
/// Check if an IP address is within the trusted proxy ranges
|
||||||
@@ -310,11 +312,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trusted_proxies_validation() {
|
fn test_trusted_proxies_validation() {
|
||||||
let trusted_proxies = TrustedProxies::new(
|
let trusted_proxies = TrustedProxies::new(vec!["192.168.1.0/24".to_string(), "10.0.0.0/8".to_string()], true, 5);
|
||||||
vec!["192.168.1.0/24".to_string(), "10.0.0.0/8".to_string()],
|
|
||||||
true,
|
|
||||||
5,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Trusted IPs
|
// Trusted IPs
|
||||||
assert!(trusted_proxies.is_trusted_proxy("192.168.1.1".parse().unwrap()));
|
assert!(trusted_proxies.is_trusted_proxy("192.168.1.1".parse().unwrap()));
|
||||||
@@ -395,6 +393,9 @@ mod tests {
|
|||||||
assert!(is_valid_client_ip("203.0.113.1, 198.51.100.1", 5));
|
assert!(is_valid_client_ip("203.0.113.1, 198.51.100.1", 5));
|
||||||
|
|
||||||
// Invalid chain (too long)
|
// Invalid chain (too long)
|
||||||
assert!(!is_valid_client_ip("203.0.113.1, 198.51.100.1, 192.0.2.1, 192.0.2.2, 192.0.2.3, 192.0.2.4", 5));
|
assert!(!is_valid_client_ip(
|
||||||
|
"203.0.113.1, 198.51.100.1, 192.0.2.1, 192.0.2.2, 192.0.2.3, 192.0.2.4",
|
||||||
|
5
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,14 +329,14 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
|
|
||||||
init_update_check();
|
init_update_check();
|
||||||
|
|
||||||
|
info!(target: "rustfs::main::run","server started successfully at {}", &server_address);
|
||||||
|
// 4. Mark as Full Ready now that critical components are warm
|
||||||
|
readiness.mark_stage(SystemStage::FullReady);
|
||||||
println!(
|
println!(
|
||||||
"RustFS server started successfully at {}, current time: {}",
|
"RustFS server started successfully at {}, current time: {}",
|
||||||
&server_address,
|
&server_address,
|
||||||
chrono::offset::Utc::now().to_string()
|
chrono::offset::Utc::now().to_string()
|
||||||
);
|
);
|
||||||
info!(target: "rustfs::main::run","server started successfully at {}", &server_address);
|
|
||||||
// 4. Mark as Full Ready now that critical components are warm
|
|
||||||
readiness.mark_stage(SystemStage::FullReady);
|
|
||||||
|
|
||||||
// Perform hibernation for 1 second
|
// Perform hibernation for 1 second
|
||||||
tokio::time::sleep(SHUTDOWN_TIMEOUT).await;
|
tokio::time::sleep(SHUTDOWN_TIMEOUT).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user