diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 38 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 59 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 21 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IGridService.cs | 45 |
4 files changed, 75 insertions, 88 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; |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index b17d7ba..aff6b4f 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -478,17 +478,22 @@ namespace OpenSim.Server.Base | |||
478 | 478 | ||
479 | XmlDocument doc = new XmlDocument(); | 479 | XmlDocument doc = new XmlDocument(); |
480 | 480 | ||
481 | doc.LoadXml(data); | 481 | try |
482 | 482 | { | |
483 | XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); | 483 | doc.LoadXml(data); |
484 | 484 | XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); | |
485 | if (rootL.Count != 1) | ||
486 | return ret; | ||
487 | 485 | ||
488 | XmlNode rootNode = rootL[0]; | 486 | if (rootL.Count != 1) |
487 | return ret; | ||
489 | 488 | ||
490 | ret = ParseElement(rootNode); | 489 | XmlNode rootNode = rootL[0]; |
491 | 490 | ||
491 | ret = ParseElement(rootNode); | ||
492 | } | ||
493 | catch (Exception e) | ||
494 | { | ||
495 | m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0} \n --- string: {1} - ",e.Message, data); | ||
496 | } | ||
492 | return ret; | 497 | return ret; |
493 | } | 498 | } |
494 | 499 | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 8068ff5..ead5d3c 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -462,50 +462,7 @@ namespace OpenSim.Services.Interfaces | |||
462 | /// </value> | 462 | /// </value> |
463 | public IPEndPoint ExternalEndPoint | 463 | public IPEndPoint ExternalEndPoint |
464 | { | 464 | { |
465 | get | 465 | get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); } |
466 | { | ||
467 | IPAddress ia = null; | ||
468 | // If it is already an IP, don't resolve it - just return directly | ||
469 | // we should not need this | ||
470 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
471 | { | ||
472 | if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any)) | ||
473 | return null; | ||
474 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
475 | } | ||
476 | |||
477 | // Reset for next check | ||
478 | ia = null; | ||
479 | try | ||
480 | { | ||
481 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
482 | { | ||
483 | if (ia == null) | ||
484 | ia = Adr; | ||
485 | |||
486 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
487 | { | ||
488 | ia = Adr; | ||
489 | break; | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | catch // (SocketException e) | ||
494 | { | ||
495 | /*throw new Exception( | ||
496 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
497 | e + "' attached to this exception", e);*/ | ||
498 | // Don't throw a fatal exception here, instead, return Null and handle it in the caller. | ||
499 | // Reason is, on systems such as OSgrid it has occured that known hostnames stop | ||
500 | // resolving and thus make surrounding regions crash out with this exception. | ||
501 | return null; | ||
502 | } | ||
503 | |||
504 | if(ia == null) | ||
505 | return null; | ||
506 | |||
507 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
508 | } | ||
509 | } | 466 | } |
510 | 467 | ||
511 | public string ExternalHostName | 468 | public string ExternalHostName |