Skip to content

Commit

Permalink
MapToIPv4
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 12, 2024
1 parent 0074541 commit 85752b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Stardust.Server/Controllers/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ private async Task Handle(WebSocket socket, App app, String clientId)

var sid = Rand.Next();
var connection = HttpContext.Connection;
var remote = new IPEndPoint(connection.RemoteIpAddress, connection.RemotePort);
var address = connection.RemoteIpAddress ?? IPAddress.Loopback;
if (address.IsIPv4MappedToIPv6) address = address.MapToIPv4();
var remote = new IPEndPoint(address, connection.RemotePort);
WriteHistory("WebSocket连接", true, $"State={socket.State} sid={sid} Remote={remote}", clientId);

var olt = AppOnline.FindByClient(clientId);
Expand Down
4 changes: 3 additions & 1 deletion Stardust.Server/Controllers/NodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ private async Task Handle(WebSocket socket, String token, String ip)

var sid = Rand.Next();
var connection = HttpContext.Connection;
var remote = new IPEndPoint(connection.RemoteIpAddress, connection.RemotePort);
var address = connection.RemoteIpAddress ?? IPAddress.Loopback;
if (address.IsIPv4MappedToIPv6) address = address.MapToIPv4();
var remote = new IPEndPoint(address, connection.RemotePort);
WriteHistory(node, "WebSocket连接", true, $"State={socket.State} sid={sid} Remote={remote}");

var olt = _nodeService.GetOrAddOnline(node, token, ip);
Expand Down

0 comments on commit 85752b3

Please sign in to comment.