aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/General/Util.cs')
-rw-r--r--OpenSim/Framework/General/Util.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs
index 3333ced..97fe7da 100644
--- a/OpenSim/Framework/General/Util.cs
+++ b/OpenSim/Framework/General/Util.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System; 28using System;
29using System.Security.Cryptography; 29using System.Security.Cryptography;
30using System.Net;
30using System.Text; 31using System.Text;
31using libsecondlife; 32using libsecondlife;
32 33
@@ -176,6 +177,30 @@ namespace OpenSim.Framework.Utilities
176 177
177 return output.ToString(); 178 return output.ToString();
178 } 179 }
180
181 /// <summary>
182 /// Returns a IP address from a specified DNS, favouring IPv4 addresses.
183 /// </summary>
184 /// <param name="dnsAddress">DNS Hostname</param>
185 /// <returns>An IP address, or null</returns>
186 public static IPAddress GetHostFromDNS(string dnsAddress)
187 {
188 IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList;
189
190 foreach (IPAddress host in hosts)
191 {
192 if (host.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
193 {
194 return host;
195 }
196 }
197
198 if (hosts.Length > 0)
199 return hosts[0];
200
201 return null;
202 }
203
179 public Util() 204 public Util()
180 { 205 {
181 206