diff options
author | UbitUmarov | 2017-05-26 21:26:51 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-26 21:26:51 +0100 |
commit | e7c2674dec2c9ea36313b51e7bc604753e16f24f (patch) | |
tree | f0576a4e48f6ebaed2c8b90f0c0b6b8f9dcd42d9 /OpenSim/Framework | |
parent | mantis 8181: don't try to delete contents of a non exitent folder (diff) | |
download | opensim-SC-e7c2674dec2c9ea36313b51e7bc604753e16f24f.zip opensim-SC-e7c2674dec2c9ea36313b51e7bc604753e16f24f.tar.gz opensim-SC-e7c2674dec2c9ea36313b51e7bc604753e16f24f.tar.bz2 opensim-SC-e7c2674dec2c9ea36313b51e7bc604753e16f24f.tar.xz |
cleanup (grid)region info endpoint; add log to try to find some xml decode issues
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 38 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 59 |
2 files changed, 61 insertions, 36 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 7de8c52..75ed999 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -420,6 +420,7 @@ namespace OpenSim.Framework | |||
420 | set { m_remotingPort = value; } | 420 | set { m_remotingPort = value; } |
421 | } | 421 | } |
422 | 422 | ||
423 | |||
423 | /// <value> | 424 | /// <value> |
424 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | 425 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. |
425 | /// | 426 | /// |
@@ -427,42 +428,7 @@ namespace OpenSim.Framework | |||
427 | /// </value> | 428 | /// </value> |
428 | public IPEndPoint ExternalEndPoint | 429 | public IPEndPoint ExternalEndPoint |
429 | { | 430 | { |
430 | get | 431 | get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); } |
431 | { | ||
432 | // Old one defaults to IPv6 | ||
433 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
434 | |||
435 | IPAddress ia = null; | ||
436 | // If it is already an IP, don't resolve it - just return directly | ||
437 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
438 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
439 | |||
440 | // Reset for next check | ||
441 | ia = null; | ||
442 | try | ||
443 | { | ||
444 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
445 | { | ||
446 | if (ia == null) | ||
447 | ia = Adr; | ||
448 | |||
449 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
450 | { | ||
451 | ia = Adr; | ||
452 | break; | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | catch (SocketException e) | ||
457 | { | ||
458 | throw new Exception( | ||
459 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
460 | e + "' attached to this exception", e); | ||
461 | } | ||
462 | |||
463 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
464 | } | ||
465 | |||
466 | set { m_externalHostName = value.ToString(); } | 432 | set { m_externalHostName = value.ToString(); } |
467 | } | 433 | } |
468 | 434 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5eedd29..83d9df1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -429,6 +429,65 @@ namespace OpenSim.Framework | |||
429 | return regionCoord << 8; | 429 | return regionCoord << 8; |
430 | } | 430 | } |
431 | 431 | ||
432 | public static IPEndPoint getEndPoint(IPAddress ia, int port) | ||
433 | { | ||
434 | if(ia == null) | ||
435 | return null; | ||
436 | |||
437 | IPEndPoint newEP = null; | ||
438 | try | ||
439 | { | ||
440 | newEP = new IPEndPoint(ia, port); | ||
441 | } | ||
442 | catch | ||
443 | { | ||
444 | newEP = null; | ||
445 | } | ||
446 | return newEP; | ||
447 | } | ||
448 | |||
449 | public static IPEndPoint getEndPoint(string hostname, int port) | ||
450 | { | ||
451 | IPAddress ia = null; | ||
452 | // If it is already an IP, don't resolve it - just return directly | ||
453 | // we should not need this | ||
454 | if (IPAddress.TryParse(hostname, out ia)) | ||
455 | { | ||
456 | if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any)) | ||
457 | return null; | ||
458 | return getEndPoint(ia, port); | ||
459 | } | ||
460 | |||
461 | // Reset for next check | ||
462 | ia = null; | ||
463 | try | ||
464 | { | ||
465 | foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) | ||
466 | { | ||
467 | if (ia == null) | ||
468 | ia = Adr; | ||
469 | |||
470 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
471 | { | ||
472 | ia = Adr; | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | catch // (SocketException e) | ||
478 | { | ||
479 | /*throw new Exception( | ||
480 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
481 | e + "' attached to this exception", e);*/ | ||
482 | // Don't throw a fatal exception here, instead, return Null and handle it in the caller. | ||
483 | // Reason is, on systems such as OSgrid it has occured that known hostnames stop | ||
484 | // resolving and thus make surrounding regions crash out with this exception. | ||
485 | return null; | ||
486 | } | ||
487 | |||
488 | return getEndPoint(ia,port); | ||
489 | } | ||
490 | |||
432 | public static bool checkServiceURI(string uristr, out string serviceURI) | 491 | public static bool checkServiceURI(string uristr, out string serviceURI) |
433 | { | 492 | { |
434 | serviceURI = string.Empty; | 493 | serviceURI = string.Empty; |