From ccc02a48b3d885dbafbb8def84e5c9b7e35d155b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 14 Jan 2023 10:16:46 +0100 Subject: [PATCH] Rimosso problema GetDns x app --- GPW.CORE.Comp/IpUtils.cs | 21 +++++++++++++-------- GPW.CORE.SMART/GPW.CORE.SMART.csproj | 3 +++ GPW.CORE.SMART/logs/.placeholder | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 GPW.CORE.SMART/logs/.placeholder diff --git a/GPW.CORE.Comp/IpUtils.cs b/GPW.CORE.Comp/IpUtils.cs index 19ed680..e714913 100644 --- a/GPW.CORE.Comp/IpUtils.cs +++ b/GPW.CORE.Comp/IpUtils.cs @@ -19,22 +19,27 @@ namespace GPW.CORE.Comp { string devIp = firstIp; IPAddress clientIP = IPAddress.Parse(devIp); - IPHostEntry GetIPHost = Dns.GetHostEntry(clientIP); - if (GetIPHost != null) + try { - // se trovo + di 1 ip cerco il primo NON IPV6... - if (GetIPHost.AddressList.Count() > 1) + IPHostEntry GetIPHost = Dns.GetHostEntry(clientIP); + if (GetIPHost != null) { - foreach (IPAddress item in GetIPHost.AddressList) + // se trovo + di 1 ip cerco il primo NON IPV6... + if (GetIPHost.AddressList.Count() > 1) { - if (item.AddressFamily == AddressFamily.InterNetwork) + foreach (IPAddress item in GetIPHost.AddressList) { - devIp = item.ToString(); - break; + if (item.AddressFamily == AddressFamily.InterNetwork) + { + devIp = item.ToString(); + break; + } } } } } + catch + { } return devIp; } } diff --git a/GPW.CORE.SMART/GPW.CORE.SMART.csproj b/GPW.CORE.SMART/GPW.CORE.SMART.csproj index 3ba7b78..35eb1d1 100644 --- a/GPW.CORE.SMART/GPW.CORE.SMART.csproj +++ b/GPW.CORE.SMART/GPW.CORE.SMART.csproj @@ -30,6 +30,9 @@ + + Always + TextTemplatingFileGenerator post-build.cs diff --git a/GPW.CORE.SMART/logs/.placeholder b/GPW.CORE.SMART/logs/.placeholder new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/GPW.CORE.SMART/logs/.placeholder @@ -0,0 +1 @@ + \ No newline at end of file