KcpTransport: reuse IPEndPoint.PrettyAddress extension

This commit is contained in:
mischa 2024-05-16 17:05:53 +07:00 committed by MrGadget
parent ba219f7e41
commit 23b700d287

View File

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