@@ -963,6 +963,8 @@ async fn ax_get_file(
963963 None => "" ,
964964 } ;
965965
966+ let client_ip = client_ip_from_headers ( & rxheaders, remote_addr) ;
967+
966968 let semaphore = get_or_create_semaphore ( & state. file_locks , & filepath) . await ;
967969 // Wait for permit with timeout
968970 let _permit =
@@ -986,8 +988,8 @@ async fn ax_get_file(
986988
987989 if !received_file. valid {
988990 println ! (
989- "{:? } 404 0 {} {} {} {}" ,
990- remote_addr , human_time, method, filepath, user_agent_str
991+ "{} 404 0 {} {} {} {}" ,
992+ client_ip , human_time, method, filepath, user_agent_str
991993 ) ;
992994 return ( StatusCode :: NOT_FOUND , format ! ( "Not Found: {}" , filepath) ) . into_response ( ) ;
993995 }
@@ -1033,8 +1035,8 @@ async fn ax_get_file(
10331035 if let Some ( etag) = upstream_headers. get ( ETAG ) {
10341036 if if_none_match == etag {
10351037 println ! (
1036- "{:? } 304 0 {} {} {} {}" ,
1037- remote_addr , human_time, method, filepath, user_agent_str
1038+ "{} 304 0 {} {} {} {}" ,
1039+ client_ip , human_time, method, filepath, user_agent_str
10381040 ) ;
10391041 return ( StatusCode :: NOT_MODIFIED , headers, Body :: empty ( ) ) . into_response ( ) ;
10401042 }
@@ -1045,8 +1047,8 @@ async fn ax_get_file(
10451047 // TODO: Validate properly last_modified
10461048 if if_modified_since == last_modified {
10471049 println ! (
1048- "{:? } 304 0 {} {} {} {}" ,
1049- remote_addr , human_time, method, filepath, user_agent_str
1050+ "{} 304 0 {} {} {} {}" ,
1051+ client_ip , human_time, method, filepath, user_agent_str
10501052 ) ;
10511053 return ( StatusCode :: NOT_MODIFIED , headers, Body :: empty ( ) ) . into_response ( ) ;
10521054 }
@@ -1059,8 +1061,8 @@ async fn ax_get_file(
10591061 headers. insert ( header:: CONTENT_LENGTH , val) ;
10601062 }
10611063 println ! (
1062- "{:? } 200 0 {} {} {} {}" ,
1063- remote_addr , human_time, method, filepath, user_agent_str
1064+ "{} 200 0 {} {} {} {}" ,
1065+ client_ip , human_time, method, filepath, user_agent_str
10641066 ) ;
10651067 return ( headers, Body :: empty ( ) ) . into_response ( ) ;
10661068 }
@@ -1114,14 +1116,14 @@ async fn ax_get_file(
11141116 if start != 0 {
11151117 let body_size = end - start;
11161118 println ! (
1117- "{:? } 206 {} {} {} {} {}" ,
1118- remote_addr , body_size, human_time, method, filepath, user_agent_str
1119+ "{} 206 {} {} {} {} {}" ,
1120+ client_ip , body_size, human_time, method, filepath, user_agent_str
11191121 ) ;
11201122 return ( StatusCode :: PARTIAL_CONTENT , headers, axbody) . into_response ( ) ;
11211123 }
11221124 println ! (
1123- "{:? } 200 {} {} {} {} {}" ,
1124- remote_addr ,
1125+ "{} 200 {} {} {} {} {}" ,
1126+ client_ip ,
11251127 metadata. len( ) ,
11261128 human_time,
11271129 method,
@@ -1133,8 +1135,8 @@ async fn ax_get_file(
11331135 Err ( _) => {
11341136 eprintln ! ( "Error opening file in ax_get_file" ) ;
11351137 println ! (
1136- "{:? } 404 0 {} {} {} {}" ,
1137- remote_addr , human_time, method, filepath, user_agent_str
1138+ "{} 404 0 {} {} {} {}" ,
1139+ client_ip , human_time, method, filepath, user_agent_str
11381140 ) ;
11391141 ( StatusCode :: NOT_FOUND , headers, Body :: empty ( ) ) . into_response ( )
11401142 }
0 commit comments