From 51d96a9659ee3d05a5c108bf9012b451ef2b4873 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Mon, 24 Oct 2022 17:16:29 -0500 Subject: [PATCH] Fixed a non fatal endian issue when printing IP addresses on big endian systems --- Tesses.WebServer.EasyServer/Class1.cs | 14 ++++++++++++-- .../Tesses.WebServer.EasyServer.csproj | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tesses.WebServer.EasyServer/Class1.cs b/Tesses.WebServer.EasyServer/Class1.cs index ac71804..ac2cc48 100644 --- a/Tesses.WebServer.EasyServer/Class1.cs +++ b/Tesses.WebServer.EasyServer/Class1.cs @@ -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 } } } -} \ No newline at end of file +} diff --git a/Tesses.WebServer.EasyServer/Tesses.WebServer.EasyServer.csproj b/Tesses.WebServer.EasyServer/Tesses.WebServer.EasyServer.csproj index f51faab..5accf3e 100644 --- a/Tesses.WebServer.EasyServer/Tesses.WebServer.EasyServer.csproj +++ b/Tesses.WebServer.EasyServer/Tesses.WebServer.EasyServer.csproj @@ -5,9 +5,9 @@ Tesses.WebServer.EasyServer Mike Nolan Tesses - 1.0.0 - 1.0.0 - 1.0.0 + 1.0.1 + 1.0.1 + 1.0.1 An easier way to setup server for Tesses.WebServer MIT HTTP, WebServer, Website