diff options
author | Adam Frisby | 2009-05-23 07:51:29 +0000 |
---|---|---|
committer | Adam Frisby | 2009-05-23 07:51:29 +0000 |
commit | 70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942 (patch) | |
tree | a430cb3dedf702f1294bdb8a9b14984ea6d15eb8 /OpenSim/Framework | |
parent | * Disables internal IPv6 Support - causing issues. (diff) | |
download | opensim-SC-70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942.zip opensim-SC-70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942.tar.gz opensim-SC-70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942.tar.bz2 opensim-SC-70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942.tar.xz |
* Fixes [irritating] edge case in Util.GetLocalHost which could return an IPv6 address if no non-loopback IPv4 address can be found.
* Restores internal IPv6 support to NetworkUtil.*
* Fixes bad login unit tests.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 45 | ||||
-rw-r--r-- | OpenSim/Framework/NetworkUtil.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 8 |
3 files changed, 47 insertions, 15 deletions
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index a2a388e..7fda38c 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -103,7 +103,10 @@ namespace OpenSim.Framework.Communications.Tests | |||
103 | 103 | ||
104 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 104 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
105 | 105 | ||
106 | XmlRpcResponse response = loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 106 | IPAddress tmpLocal = Util.GetLocalHost(); |
107 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
108 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
109 | |||
107 | Hashtable responseData = (Hashtable)response.Value; | 110 | Hashtable responseData = (Hashtable)response.Value; |
108 | 111 | ||
109 | Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); | 112 | Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); |
@@ -113,7 +116,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
113 | 116 | ||
114 | Regex capsSeedPattern | 117 | Regex capsSeedPattern |
115 | = new Regex("^http://" | 118 | = new Regex("^http://" |
116 | + m_regionExternalName | 119 | + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) |
117 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); | 120 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); |
118 | 121 | ||
119 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); | 122 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); |
@@ -140,7 +143,10 @@ namespace OpenSim.Framework.Communications.Tests | |||
140 | 143 | ||
141 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 144 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
142 | 145 | ||
143 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 146 | IPAddress tmpLocal = Util.GetLocalHost(); |
147 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
148 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
149 | |||
144 | Hashtable responseData = (Hashtable)response.Value; | 150 | Hashtable responseData = (Hashtable)response.Value; |
145 | 151 | ||
146 | UserAgentData uagent = m_userProfileData.CurrentAgent; | 152 | UserAgentData uagent = m_userProfileData.CurrentAgent; |
@@ -163,7 +169,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
163 | 169 | ||
164 | Regex capsSeedPattern | 170 | Regex capsSeedPattern |
165 | = new Regex("^http://" | 171 | = new Regex("^http://" |
166 | + m_regionExternalName | 172 | + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) |
167 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); | 173 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); |
168 | 174 | ||
169 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); | 175 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); |
@@ -194,14 +200,16 @@ namespace OpenSim.Framework.Communications.Tests | |||
194 | 200 | ||
195 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 201 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
196 | 202 | ||
197 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 203 | IPAddress tmpLocal = Util.GetLocalHost(); |
204 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
205 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
206 | |||
198 | Hashtable responseData = (Hashtable)response.Value; | 207 | Hashtable responseData = (Hashtable)response.Value; |
199 | 208 | ||
200 | ArrayList friendslist = (ArrayList) responseData["buddy-list"]; | 209 | ArrayList friendslist = (ArrayList) responseData["buddy-list"]; |
201 | 210 | ||
202 | Assert.That(friendslist,Is.Not.Null); | 211 | Assert.That(friendslist,Is.Not.Null); |
203 | 212 | ||
204 | |||
205 | Hashtable buddy1 = (Hashtable) friendslist[0]; | 213 | Hashtable buddy1 = (Hashtable) friendslist[0]; |
206 | Hashtable buddy2 = (Hashtable) friendslist[1]; | 214 | Hashtable buddy2 = (Hashtable) friendslist[1]; |
207 | Assert.That(friendslist.Count, Is.EqualTo(2)); | 215 | Assert.That(friendslist.Count, Is.EqualTo(2)); |
@@ -231,7 +239,10 @@ namespace OpenSim.Framework.Communications.Tests | |||
231 | 239 | ||
232 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 240 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
233 | 241 | ||
234 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 242 | IPAddress tmpLocal = Util.GetLocalHost(); |
243 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
244 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
245 | |||
235 | Hashtable responseData = (Hashtable)response.Value; | 246 | Hashtable responseData = (Hashtable)response.Value; |
236 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); | 247 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); |
237 | 248 | ||
@@ -256,7 +267,10 @@ namespace OpenSim.Framework.Communications.Tests | |||
256 | 267 | ||
257 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 268 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
258 | 269 | ||
259 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 270 | IPAddress tmpLocal = Util.GetLocalHost(); |
271 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
272 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
273 | |||
260 | Hashtable responseData = (Hashtable)response.Value; | 274 | Hashtable responseData = (Hashtable)response.Value; |
261 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); | 275 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); |
262 | 276 | ||
@@ -281,7 +295,10 @@ namespace OpenSim.Framework.Communications.Tests | |||
281 | 295 | ||
282 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 296 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
283 | 297 | ||
284 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 298 | IPAddress tmpLocal = Util.GetLocalHost(); |
299 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
300 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
301 | |||
285 | Hashtable responseData = (Hashtable)response.Value; | 302 | Hashtable responseData = (Hashtable)response.Value; |
286 | Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); | 303 | Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); |
287 | 304 | ||
@@ -312,20 +329,24 @@ namespace OpenSim.Framework.Communications.Tests | |||
312 | 329 | ||
313 | // First we log in. | 330 | // First we log in. |
314 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | 331 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); |
315 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 332 | |
333 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
334 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
335 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
336 | |||
316 | Hashtable responseData = (Hashtable)response.Value; | 337 | Hashtable responseData = (Hashtable)response.Value; |
317 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | 338 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); |
318 | 339 | ||
319 | // Then we try again, this time expecting failure. | 340 | // Then we try again, this time expecting failure. |
320 | request = new XmlRpcRequest("login_to_simulator", sendParams); | 341 | request = new XmlRpcRequest("login_to_simulator", sendParams); |
321 | response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 342 | response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); |
322 | responseData = (Hashtable)response.Value; | 343 | responseData = (Hashtable)response.Value; |
323 | Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); | 344 | Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); |
324 | 345 | ||
325 | // Finally the third time we should be able to get right back in. | 346 | // Finally the third time we should be able to get right back in. |
326 | request = new XmlRpcRequest("login_to_simulator", sendParams); | 347 | request = new XmlRpcRequest("login_to_simulator", sendParams); |
327 | 348 | ||
328 | response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); | 349 | response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); |
329 | responseData = (Hashtable)response.Value; | 350 | responseData = (Hashtable)response.Value; |
330 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | 351 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); |
331 | 352 | ||
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index d4fc1e2..328d3bc 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -73,9 +73,8 @@ namespace OpenSim.Framework | |||
73 | 73 | ||
74 | private static IPAddress GetExternalIPFor(IPAddress destination, string defaultHostname) | 74 | private static IPAddress GetExternalIPFor(IPAddress destination, string defaultHostname) |
75 | { | 75 | { |
76 | bool ipv6 = false; | ||
77 | // Adds IPv6 Support (Not that any of the major protocols supports it...) | 76 | // Adds IPv6 Support (Not that any of the major protocols supports it...) |
78 | if (ipv6 && destination.AddressFamily == AddressFamily.InterNetworkV6) | 77 | if (destination.AddressFamily == AddressFamily.InterNetworkV6) |
79 | { | 78 | { |
80 | foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) | 79 | foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) |
81 | { | 80 | { |
@@ -91,10 +90,14 @@ namespace OpenSim.Framework | |||
91 | return null; | 90 | return null; |
92 | 91 | ||
93 | // Check if we're accessing localhost. | 92 | // Check if we're accessing localhost. |
94 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) | 93 | foreach (KeyValuePair<IPAddress, IPAddress> pair in m_subnets) |
95 | { | 94 | { |
95 | IPAddress host = pair.Value; | ||
96 | if (host.Equals(destination) && host.AddressFamily == AddressFamily.InterNetwork) | 96 | if (host.Equals(destination) && host.AddressFamily == AddressFamily.InterNetwork) |
97 | { | ||
98 | m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + defaultHostname + "'"); | ||
97 | return destination; | 99 | return destination; |
100 | } | ||
98 | } | 101 | } |
99 | 102 | ||
100 | // Check for same LAN segment | 103 | // Check for same LAN segment |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0128735..ee47e0f 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -546,7 +546,15 @@ namespace OpenSim.Framework | |||
546 | } | 546 | } |
547 | 547 | ||
548 | if (hosts.Length > 0) | 548 | if (hosts.Length > 0) |
549 | { | ||
550 | foreach (IPAddress host in hosts) | ||
551 | { | ||
552 | if(host.AddressFamily == AddressFamily.InterNetwork) | ||
553 | return host; | ||
554 | } | ||
555 | // Well all else failed... | ||
549 | return hosts[0]; | 556 | return hosts[0]; |
557 | } | ||
550 | 558 | ||
551 | return null; | 559 | return null; |
552 | } | 560 | } |