aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2010-03-03 02:07:03 +0000
committerMelanie2010-03-03 02:07:03 +0000
commit028a87fe37002e7a0611f66babf1deee46c83804 (patch)
tree387aec499fd60c2012bed8148e6a2ddc847c3d95 /OpenSim/Framework/Util.cs
parentRevert "test" (diff)
parentFixes Region.Framework tests. Although these tests don't fail, they need to b... (diff)
downloadopensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.zip
opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.gz
opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.bz2
opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.xz
Merge branch 'master' into careminster-presence-refactor
This brings careminster on the level of master. To be tested
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs47
1 files changed, 40 insertions, 7 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 58a0d77..0ccc193 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -553,7 +553,7 @@ namespace OpenSim.Framework
553 } 553 }
554 catch (Exception e) 554 catch (Exception e)
555 { 555 {
556 m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e); 556 m_log.WarnFormat("[UTIL]: An error occurred while resolving host name {0}, {1}", dnsAddress, e);
557 557
558 // Still going to throw the exception on for now, since this was what was happening in the first place 558 // Still going to throw the exception on for now, since this was what was happening in the first place
559 throw e; 559 throw e;
@@ -589,11 +589,17 @@ namespace OpenSim.Framework
589 589
590 public static IPAddress GetLocalHost() 590 public static IPAddress GetLocalHost()
591 { 591 {
592 string dnsAddress = "localhost"; 592 IPAddress[] iplist = GetLocalHosts();
593 593
594 IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList; 594 if (iplist.Length == 0) // No accessible external interfaces
595 {
596 IPAddress[] loopback = Dns.GetHostAddresses("localhost");
597 IPAddress localhost = loopback[0];
595 598
596 foreach (IPAddress host in hosts) 599 return localhost;
600 }
601
602 foreach (IPAddress host in iplist)
597 { 603 {
598 if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) 604 if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork)
599 { 605 {
@@ -601,15 +607,15 @@ namespace OpenSim.Framework
601 } 607 }
602 } 608 }
603 609
604 if (hosts.Length > 0) 610 if (iplist.Length > 0)
605 { 611 {
606 foreach (IPAddress host in hosts) 612 foreach (IPAddress host in iplist)
607 { 613 {
608 if (host.AddressFamily == AddressFamily.InterNetwork) 614 if (host.AddressFamily == AddressFamily.InterNetwork)
609 return host; 615 return host;
610 } 616 }
611 // Well all else failed... 617 // Well all else failed...
612 return hosts[0]; 618 return iplist[0];
613 } 619 }
614 620
615 return null; 621 return null;
@@ -1186,6 +1192,33 @@ namespace OpenSim.Framework
1186 return null; 1192 return null;
1187 } 1193 }
1188 1194
1195 public static OSDMap GetOSDMap(string data)
1196 {
1197 OSDMap args = null;
1198 try
1199 {
1200 OSD buffer;
1201 // We should pay attention to the content-type, but let's assume we know it's Json
1202 buffer = OSDParser.DeserializeJson(data);
1203 if (buffer.Type == OSDType.Map)
1204 {
1205 args = (OSDMap)buffer;
1206 return args;
1207 }
1208 else
1209 {
1210 // uh?
1211 m_log.Debug(("[UTILS]: Got OSD of unexpected type " + buffer.Type.ToString()));
1212 return null;
1213 }
1214 }
1215 catch (Exception ex)
1216 {
1217 m_log.Debug("[UTILS]: exception on GetOSDMap " + ex.Message);
1218 return null;
1219 }
1220 }
1221
1189 public static string[] Glob(string path) 1222 public static string[] Glob(string path)
1190 { 1223 {
1191 string vol=String.Empty; 1224 string vol=String.Empty;