Fixed a non fatal endian issue when printing IP addresses on big endian systems

This commit is contained in:
Mike Nolan 2022-10-24 17:16:29 -05:00
parent ee5d42f8bb
commit 51d96a9659
2 changed files with 15 additions and 5 deletions

View File

@ -49,7 +49,17 @@ public static class EasyServerExtensions
foreach(var item in iface.GetIPProperties().UnicastAddresses)
{
if(item.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork){
ips.Add($"{url.scheme}://{item.Address.ToString()}:{url.port}/");
if(BitConverter.IsLittleEndian)
{
ips.Add($"{url.scheme}://{item.Address.ToString()}:{url.port}/");
}
else
{
var addrBytes = item.Address.GetAddressBytes();
ips.Add($"{url.scheme}://{addrBytes[3]}.{addrBytes[2]}.{addrBytes[1]}.{addrBytes[0]}:{url.port}/");
}
}
}
Console.WriteLine(string.Join(" , ",ips));
@ -60,4 +70,4 @@ public static class EasyServerExtensions
}
}
}
}
}

View File

@ -5,9 +5,9 @@
<PackageId>Tesses.WebServer.EasyServer</PackageId>
<Author>Mike Nolan</Author>
<Company>Tesses</Company>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Version>1.0.1</Version>
<AssemblyVersion>1.0.1</AssemblyVersion>
<FileVersion>1.0.1</FileVersion>
<Description>An easier way to setup server for Tesses.WebServer</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>HTTP, WebServer, Website</PackageTags>