Skip to content

Commit

Permalink
😊 新增 审计日志记录服务端源端口
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkSoul committed Mar 2, 2024
1 parent f9ebbde commit 9280b6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ private async Task MonitorAsync(MethodInfo actionMethod, IDictionary<string, obj
var localIPv4 = httpContext.GetLocalIpAddressToIPv4();
writer.WriteString(nameof(localIPv4), localIPv4);

// 获取服务端源端口
var localPort = httpContext.Connection.LocalPort;
writer.WriteNumber(nameof(localPort), localPort);

// 获取客户端 IPv4 地址
var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
writer.WriteString(nameof(remoteIPv4), remoteIPv4);
Expand Down Expand Up @@ -990,6 +994,7 @@ private async Task MonitorAsync(MethodInfo actionMethod, IDictionary<string, obj
, $"##客户端 IP 地址## {remoteIPv4}"
, $"##客户端源端口## {remotePort}"
, $"##服务端 IP 地址## {localIPv4}"
, $"##服务端源端口## {localPort}"
, $"##客户端连接 ID## {traceId}"
, $"##服务线程 ID## #{threadId}"
, $"##执行耗时## {timeOperation.ElapsedMilliseconds}ms"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ private async Task MonitorAsync(MethodInfo actionMethod, IDictionary<string, obj
var localIPv4 = httpContext.GetLocalIpAddressToIPv4();
writer.WriteString(nameof(localIPv4), localIPv4);

// 获取服务端源端口
var localPort = httpContext.Connection.LocalPort;
writer.WriteNumber(nameof(localPort), localPort);

// 获取客户端 IPv4 地址
var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
writer.WriteString(nameof(remoteIPv4), remoteIPv4);
Expand Down Expand Up @@ -990,6 +994,7 @@ private async Task MonitorAsync(MethodInfo actionMethod, IDictionary<string, obj
, $"##客户端 IP 地址## {remoteIPv4}"
, $"##客户端源端口## {remotePort}"
, $"##服务端 IP 地址## {localIPv4}"
, $"##服务端源端口## {localPort}"
, $"##客户端连接 ID## {traceId}"
, $"##服务线程 ID## #{threadId}"
, $"##执行耗时## {timeOperation.ElapsedMilliseconds}ms"
Expand Down

0 comments on commit 9280b6d

Please sign in to comment.