客户端ip输出

This commit is contained in:
xljiulang 2021-07-29 22:50:49 +08:00
parent 9dc2ab2d6c
commit 8ecfdf4577

View File

@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
namespace FastGithub.ReverseProxy
@ -46,6 +47,12 @@ namespace FastGithub.ReverseProxy
var response = context.Response;
var message = $"{request.Method} {request.Scheme}://{request.Host}{request.Path} responded {response.StatusCode} in {stopwatch.Elapsed.TotalMilliseconds} ms";
var client = context.Connection.RemoteIpAddress;
if (IPAddress.Loopback.Equals(client) == false)
{
message = $"{client} {message}";
}
var exception = context.GetForwarderErrorFeature()?.Exception;
if (exception == null)
{