diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index bf19be00..c9e58a9f 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.4.0716")] -[assembly: AssemblyFileVersion("2.3.4.0716")] +[assembly: AssemblyVersion("2.3.4.0719")] +[assembly: AssemblyFileVersion("2.3.4.0719")] diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index da958b16..16cbf6ef 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -18,6 +18,7 @@ along with this program. If not, see . using System; using System.Collections.Generic; using System.IO; +using System.Net.Sockets; using System.Security.Cryptography; using System.Text; using System.Net; @@ -479,16 +480,10 @@ namespace TShockAPI /// string ip public static string GetIPv4Address(string hostname) { - string IP4Address = String.Empty; - foreach (IPAddress IPA in Dns.GetHostAddresses(hostname)) - { - if (IPA.AddressFamily.ToString() == "InterNetwork") - { - IP4Address = IPA.ToString(); - break; - } - } - return IP4Address; + //Get the ipv4 address from GetHostAddresses, if an ip is passed it will return that ip + var ip = Dns.GetHostAddresses(hostname).FirstOrDefault(i => i.AddressFamily == AddressFamily.InterNetwork); + //if the dns query was successful then return it, otherwise return an empty string + return ip != null ? ip.ToString() : ""; } ///