diff options
author | UbitUmarov | 2017-05-29 05:22:21 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-29 05:22:21 +0100 |
commit | 8f86de265c6187a61dde12fb122c1ae017b6ecf6 (patch) | |
tree | 66bfeb92d6847d30462cb9f2c2040151bc861ea0 /OpenSim/Framework | |
parent | no.. still a fail (diff) | |
download | opensim-SC_OLD-8f86de265c6187a61dde12fb122c1ae017b6ecf6.zip opensim-SC_OLD-8f86de265c6187a61dde12fb122c1ae017b6ecf6.tar.gz opensim-SC_OLD-8f86de265c6187a61dde12fb122c1ae017b6ecf6.tar.bz2 opensim-SC_OLD-8f86de265c6187a61dde12fb122c1ae017b6ecf6.tar.xz |
some cleanup and assume Linux/mono DNS is just broken...
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index fe84498..061743d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1009,6 +1009,9 @@ namespace OpenSim.Framework | |||
1009 | public static IPAddress GetHostFromDNS(string dnsAddress) | 1009 | public static IPAddress GetHostFromDNS(string dnsAddress) |
1010 | { | 1010 | { |
1011 | // If it is already an IP, avoid possible broken mono from seeing it | 1011 | // If it is already an IP, avoid possible broken mono from seeing it |
1012 | if(String.IsNullOrWhiteSpace(dnsAddress)) | ||
1013 | return null; | ||
1014 | |||
1012 | IPAddress ia = null; | 1015 | IPAddress ia = null; |
1013 | if (IPAddress.TryParse(dnsAddress, out ia) && ia != null) | 1016 | if (IPAddress.TryParse(dnsAddress, out ia) && ia != null) |
1014 | { | 1017 | { |
@@ -1016,31 +1019,31 @@ namespace OpenSim.Framework | |||
1016 | return null; | 1019 | return null; |
1017 | return ia; | 1020 | return ia; |
1018 | } | 1021 | } |
1019 | // Reset for next check | 1022 | |
1020 | ia = null; | 1023 | IPHostEntry IPH; |
1021 | try | 1024 | try |
1022 | { | 1025 | { |
1023 | foreach (IPAddress Adr in Dns.GetHostAddresses(dnsAddress)) | 1026 | IPH = Dns.GetHostEntry(dnsAddress); |
1024 | { | ||
1025 | if (ia == null) | ||
1026 | ia = Adr; | ||
1027 | |||
1028 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1029 | { | ||
1030 | ia = Adr; | ||
1031 | break; | ||
1032 | } | ||
1033 | } | ||
1034 | } | 1027 | } |
1035 | catch // (SocketException e) | 1028 | catch // (SocketException e) |
1036 | { | 1029 | { |
1037 | /*throw new Exception( | 1030 | return null; |
1038 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | 1031 | } |
1039 | e + "' attached to this exception", e);*/ | 1032 | |
1040 | // Don't throw a fatal exception here, instead, return Null and handle it in the caller. | 1033 | if(IPH == null || IPH.AddressList.Length == 0) |
1041 | // Reason is, on systems such as OSgrid it has occured that known hostnames stop | ||
1042 | // resolving and thus make surrounding regions crash out with this exception. | ||
1043 | return null; | 1034 | return null; |
1035 | |||
1036 | ia = null; | ||
1037 | foreach (IPAddress Adr in IPH.AddressList) | ||
1038 | { | ||
1039 | if (ia == null) | ||
1040 | ia = Adr; | ||
1041 | |||
1042 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1043 | { | ||
1044 | ia = Adr; | ||
1045 | break; | ||
1046 | } | ||
1044 | } | 1047 | } |
1045 | return ia; | 1048 | return ia; |
1046 | } | 1049 | } |
@@ -1075,26 +1078,31 @@ namespace OpenSim.Framework | |||
1075 | return null; | 1078 | return null; |
1076 | return getEndPoint(ia, port); | 1079 | return getEndPoint(ia, port); |
1077 | } | 1080 | } |
1078 | 1081 | ||
1079 | // Reset for next check | 1082 | IPHostEntry IPH; |
1080 | ia = null; | ||
1081 | try | 1083 | try |
1082 | { | 1084 | { |
1083 | foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) | 1085 | IPH = Dns.GetHostEntry(hostname); |
1084 | { | ||
1085 | if (ia == null) | ||
1086 | ia = Adr; | ||
1087 | |||
1088 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1089 | { | ||
1090 | ia = Adr; | ||
1091 | break; | ||
1092 | } | ||
1093 | } | ||
1094 | } | 1086 | } |
1095 | catch // (SocketException e) | 1087 | catch // (SocketException e) |
1096 | { | 1088 | { |
1097 | ia = null; | 1089 | return null; |
1090 | } | ||
1091 | |||
1092 | if(IPH == null || IPH.AddressList.Length == 0) | ||
1093 | return null; | ||
1094 | |||
1095 | ia = null; | ||
1096 | foreach (IPAddress Adr in IPH.AddressList) | ||
1097 | { | ||
1098 | if (ia == null) | ||
1099 | ia = Adr; | ||
1100 | |||
1101 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1102 | { | ||
1103 | ia = Adr; | ||
1104 | break; | ||
1105 | } | ||
1098 | } | 1106 | } |
1099 | 1107 | ||
1100 | return getEndPoint(ia,port); | 1108 | return getEndPoint(ia,port); |