Merge branch 'master' of github.com:TShock/TShock

This commit is contained in:
Zack Piispanen 2011-07-19 19:48:16 -04:00
commit 7bac787aa5
2 changed files with 7 additions and 12 deletions

View file

@ -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")]

View file

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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
/// <param name="hostname">string ip</param>
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() : "";
}
/// <summary>