diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index fe8449884f..061743d1b6 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1009,6 +1009,9 @@ namespace OpenSim.Framework public static IPAddress GetHostFromDNS(string dnsAddress) { // If it is already an IP, avoid possible broken mono from seeing it + if(String.IsNullOrWhiteSpace(dnsAddress)) + return null; + IPAddress ia = null; if (IPAddress.TryParse(dnsAddress, out ia) && ia != null) { @@ -1016,31 +1019,31 @@ namespace OpenSim.Framework return null; return ia; } - // Reset for next check - ia = null; + + IPHostEntry IPH; try { - foreach (IPAddress Adr in Dns.GetHostAddresses(dnsAddress)) - { - if (ia == null) - ia = Adr; - - if (Adr.AddressFamily == AddressFamily.InterNetwork) - { - ia = Adr; - break; - } - } + IPH = Dns.GetHostEntry(dnsAddress); } catch // (SocketException e) { - /*throw new Exception( - "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + - e + "' attached to this exception", e);*/ - // Don't throw a fatal exception here, instead, return Null and handle it in the caller. - // Reason is, on systems such as OSgrid it has occured that known hostnames stop - // resolving and thus make surrounding regions crash out with this exception. + return null; + } + + if(IPH == null || IPH.AddressList.Length == 0) return null; + + ia = null; + foreach (IPAddress Adr in IPH.AddressList) + { + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } } return ia; } @@ -1075,26 +1078,31 @@ namespace OpenSim.Framework return null; return getEndPoint(ia, port); } - - // Reset for next check - ia = null; + + IPHostEntry IPH; try { - foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) - { - if (ia == null) - ia = Adr; - - if (Adr.AddressFamily == AddressFamily.InterNetwork) - { - ia = Adr; - break; - } - } + IPH = Dns.GetHostEntry(hostname); } catch // (SocketException e) { - ia = null; + return null; + } + + if(IPH == null || IPH.AddressList.Length == 0) + return null; + + ia = null; + foreach (IPAddress Adr in IPH.AddressList) + { + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } } return getEndPoint(ia,port); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9959f6e606..7214414b22 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -157,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_idCache = new ExpiringCache(); m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(newTime)); } - m_idCache.Add(pRegionHandle, DateTime.UtcNow + TimeSpan.FromSeconds(extendTime), TimeSpan.FromSeconds(extendTime)); + m_idCache.Add(pRegionHandle, DateTime.UtcNow + TimeSpan.FromSeconds(extendTime), extendTime); } // Remove the agent from the region's banned list @@ -1488,13 +1488,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Math.Max(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY)); if (neighbourRegion == null) - { - failureReason = "no region found"; // debug -> to remove return null; - } + if (m_bannedRegionCache.IfBanned(neighbourRegion.RegionHandle, agentID)) { - failureReason = "Access Denied"; + failureReason = "Access Denied or Temporary not possible"; return null; } @@ -1506,14 +1504,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer pos.Z); string homeURI = scene.GetAgentHomeURI(agentID); - + if (!scene.SimulationService.QueryAccess( neighbourRegion, agentID, homeURI, false, newpos, scene.GetFormatsOffered(), ctx, out failureReason)) { // remember the fail m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID); - failureReason = "Access Denied"; + if(String.IsNullOrWhiteSpace(failureReason)) + failureReason = "Access Denied"; return null; } @@ -2171,7 +2170,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer InformClientOfNeighbourAsync(sp, cagents[count], neighbour, ipe, true); else { - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: DNS for neighbour {0} lost", neighbour.ExternalHostName); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: lost DNS resolution for neighbour {0}", neighbour.ExternalHostName); } count++; } diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index b261675572..f2bb52aa4d 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -70,9 +70,14 @@ namespace OpenSim.Services.Connectors.Hypergrid { Uri m_Uri = new Uri(m_ServerURL); IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); - m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); - if (!m_ServerURL.EndsWith("/")) - m_ServerURL += "/"; + if(ip != null) + { + m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); + if (!m_ServerURL.EndsWith("/")) + m_ServerURL += "/"; + } + else + m_log.DebugFormat("[USER AGENT CONNECTOR]: Failed to resolv address of {0}", url); } catch (Exception e) {