baseline: OpenMU upstream b5a0961 (fresh source)

This commit is contained in:
Acentech Dev
2026-07-14 19:00:35 +03:00
parent 450402e47d
commit 36fc125d5c
11968 changed files with 748705 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
// <copyright file="IpAddressExtensions.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.Network;
using System.Diagnostics.CodeAnalysis;
using System.Net;
/// <summary>
/// Extensions for <see cref="IPAddress"/>.
/// </summary>
public static class IpAddressExtensions
{
private static HashSet<IPAddress>? _localIpAddresses;
/// <summary>
/// Determines whether the address in on same (this) host.
/// </summary>
/// <param name="address">The next server address.</param>
/// <returns>
/// <c>true</c> if the specified address is on same host as this machine; otherwise, <c>false</c>.
/// </returns>
public static bool IsOnSameHost([NotNullWhen(true)] this IPAddress? address)
{
if (address is null)
{
return false;
}
if (IPAddress.IsLoopback(address))
{
return true;
}
_localIpAddresses ??= Dns.GetHostAddresses(Dns.GetHostName()).ToHashSet();
return _localIpAddresses.Contains(address);
}
}