From e172e37c58c1d4ab48e3dcccacb8707c25e0d2bf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 30 Jul 2007 21:12:29 +0000 Subject: * Added GetLocalHost() to Util * ExternalHostName supports "SYSTEMIP" again. --- OpenSim/Framework/General/Util.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Framework/General/Util.cs') diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs index bbee4b2..9e687ba 100644 --- a/OpenSim/Framework/General/Util.cs +++ b/OpenSim/Framework/General/Util.cs @@ -256,6 +256,26 @@ namespace OpenSim.Framework.Utilities return null; } + public static IPAddress GetLocalHost() + { + string dnsAddress = "localhost"; + + IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList; + + foreach (IPAddress host in hosts) + { + if (!IPAddress.IsLoopback(host) && host.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + return host; + } + } + + if (hosts.Length > 0) + return hosts[0]; + + return null; + } + public Util() { -- cgit v1.1