KcpTransport: reconvert mapped ipv4->ipv6 addresses to ipv4 in ServerGetClientAddress (#3460)

* Update KcpTransport.cs

"::ffff:127.0.0.1" -> "127.0.0.1"

* Update Assets/Mirror/Transports/KCP/KcpTransport.cs

---------

Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
This commit is contained in:
Meno000 2023-04-11 05:18:00 +03:00 committed by GitHub
parent fb8ae6c228
commit e9597b70ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,7 +203,13 @@ public override void ServerSend(int connectionId, ArraySegment<byte> segment, in
public override string ServerGetClientAddress(int connectionId)
{
IPEndPoint endPoint = server.GetClientEndPoint(connectionId);
return endPoint != null ? endPoint.Address.ToString() : "";
return endPoint != null
// Map to IPv4 if "IsIPv4MappedToIPv6"
// "::ffff:127.0.0.1" -> "127.0.0.1"
? (endPoint.Address.IsIPv4MappedToIPv6
? endPoint.Address.MapToIPv4().ToString()
: endPoint.Address.ToString())
: "";
}
public override void ServerStop() => server.Stop();
public override void ServerEarlyUpdate()