IP Check Fixes

This commit is contained in:
2025-12-12 19:32:54 +00:00
parent 6ff29bb155
commit 131dec501a
+10 -2
View File
@@ -102,7 +102,7 @@ async fn main() {
println!("📋 Configuration loaded from .env and media_config.json"); println!("📋 Configuration loaded from .env and media_config.json");
let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap();
} }
fn load_config() -> Config { fn load_config() -> Config {
@@ -337,7 +337,15 @@ async fn download_file(
.and_then(|v| v.to_str().ok()) .and_then(|v| v.to_str().ok())
.map(|s| s.split(',').next().unwrap_or(s).trim()) .map(|s| s.split(',').next().unwrap_or(s).trim())
.map(|s| s.to_string()) .map(|s| s.to_string())
.unwrap_or_else(|| addr.ip().to_string()); .unwrap_or_else(|| {
match addr.ip() {
std::net::IpAddr::V4(ipv4) => ipv4.to_string(),
std::net::IpAddr::V6(ipv6) => ipv6
.to_ipv4()
.map(|v4| v4.to_string())
.unwrap_or_else(|| ipv6.to_string()),
}
});
// Check for Range header to support resume // Check for Range header to support resume
let range_header = headers.get(header::RANGE); let range_header = headers.get(header::RANGE);