@@ -99,29 +99,9 @@ private async Task HandleFallback(HttpContext context)
9999
100100 if ( _httpConfig . LogRequests )
101101 {
102- var isLocalRequest = IsLocalRequest ( clientIp ) ;
103- if ( isLocalRequest . HasValue )
104- {
105- if ( isLocalRequest . Value )
106- {
107- _logger . Info ( _localisationService . GetText ( "client_request" , context . Request . Path . Value ) ) ;
108- }
109- else
110- {
111- _logger . Info (
112- _localisationService . GetText (
113- "client_request_ip" , new
114- {
115- ip = clientIp ,
116- url = context . Request . Path . Value
117- }
118- )
119- ) ;
120- }
121- }
102+ LogRequest ( context , clientIp , IsLocalRequest ( clientIp ) ) ;
122103 }
123104
124-
125105 try
126106 {
127107 _httpListeners . SingleOrDefault ( l => l . CanHandle ( sessionId , context . Request ) ) ? . Handle ( sessionId , context . Request , context . Response ) ;
@@ -135,7 +115,33 @@ private async Task HandleFallback(HttpContext context)
135115 // This http request would be passed through the SPT Router and handled by an ICallback
136116 }
137117
138- protected static string ? GetClientIp ( HttpContext context , StringValues ? realIp )
118+ /// <summary>
119+ /// Log request - handle differently if request is local
120+ /// </summary>
121+ /// <param name="context">HttpContext of request</param>
122+ /// <param name="clientIp">Ip of requester</param>
123+ /// <param name="isLocalRequest">Is this local request</param>
124+ protected void LogRequest ( HttpContext context , string clientIp , bool isLocalRequest )
125+ {
126+ if ( isLocalRequest )
127+ {
128+ _logger . Info ( _localisationService . GetText ( "client_request" , context . Request . Path . Value ) ) ;
129+ }
130+ else
131+ {
132+ _logger . Info (
133+ _localisationService . GetText (
134+ "client_request_ip" , new
135+ {
136+ ip = clientIp ,
137+ url = context . Request . Path . Value
138+ }
139+ )
140+ ) ;
141+ }
142+ }
143+
144+ protected static string GetClientIp ( HttpContext context , StringValues ? realIp )
139145 {
140146 if ( realIp . HasValue )
141147 {
@@ -153,11 +159,11 @@ private async Task HandleFallback(HttpContext context)
153159 /// </summary>
154160 /// <param name="remoteAddress"> Address to check </param>
155161 /// <returns> True if its local </returns>
156- protected bool ? IsLocalRequest ( string ? remoteAddress )
162+ protected bool IsLocalRequest ( string ? remoteAddress )
157163 {
158164 if ( remoteAddress == null )
159165 {
160- return null ;
166+ return false ;
161167 }
162168
163169 return remoteAddress . StartsWith ( "127.0.0" ) ||
0 commit comments