diff options
author | Adam Frisby | 2008-01-12 19:23:56 +0000 |
---|---|---|
committer | Adam Frisby | 2008-01-12 19:23:56 +0000 |
commit | 0b0df333dcbb84ce6ebee8a9369a22dca86195fd (patch) | |
tree | f7d98d2b90af93fd888f17cd3be746fa6dacfc7f /OpenSim/Grid/GridServer | |
parent | Added notice on console to change storage_plugin if set to OpenSim.DataStore.... (diff) | |
download | opensim-SC-0b0df333dcbb84ce6ebee8a9369a22dca86195fd.zip opensim-SC-0b0df333dcbb84ce6ebee8a9369a22dca86195fd.tar.gz opensim-SC-0b0df333dcbb84ce6ebee8a9369a22dca86195fd.tar.bz2 opensim-SC-0b0df333dcbb84ce6ebee8a9369a22dca86195fd.tar.xz |
* In the interests of making life difficult for everyone, the Grid Server now actually checks your authentication keys rather than ignoring them.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 241 |
1 files changed, 127 insertions, 114 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 52d087b..6af0767 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -243,20 +243,16 @@ namespace OpenSim.Grid.GridServer | |||
243 | 243 | ||
244 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID."); | 244 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID."); |
245 | } | 245 | } |
246 | else if (requestData.ContainsKey("region_handle")) | ||
247 | { | ||
248 | // TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); | ||
249 | // logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle."); | ||
250 | } | ||
251 | else | 246 | else |
252 | { | 247 | { |
253 | responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you"; | 248 | MainLog.Instance.Verbose("GRID", "Region connected without a UUID, ignoring."); |
249 | responseData["error"] = "No UUID passed to grid server - unable to connect you"; | ||
254 | return response; | 250 | return response; |
255 | } | 251 | } |
256 | 252 | ||
257 | if (TheSim == null) // Shouldnt this be in the REST Simulator Set method? | 253 | if (TheSim == null) // Shouldnt this be in the REST Simulator Set method? |
258 | { | 254 | { |
259 | Console.WriteLine("NEW SIM"); | 255 | MainLog.Instance.Verbose("GRID", "New region connecting"); |
260 | myword = "creation"; | 256 | myword = "creation"; |
261 | } | 257 | } |
262 | else | 258 | else |
@@ -286,6 +282,14 @@ namespace OpenSim.Grid.GridServer | |||
286 | TheSim.regionLocZ = 0; | 282 | TheSim.regionLocZ = 0; |
287 | TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]); | 283 | TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]); |
288 | 284 | ||
285 | try | ||
286 | { | ||
287 | TheSim.regionRecvKey = (string)requestData["recvkey"]; | ||
288 | TheSim.regionSendKey = (string)requestData["authkey"]; | ||
289 | } | ||
290 | catch (KeyNotFoundException) { } | ||
291 | |||
292 | |||
289 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); | 293 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); |
290 | TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; | 294 | TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; |
291 | 295 | ||
@@ -299,142 +303,151 @@ namespace OpenSim.Grid.GridServer | |||
299 | OldSim = getRegion(TheSim.regionHandle); | 303 | OldSim = getRegion(TheSim.regionHandle); |
300 | if (OldSim == null || OldSim.UUID == TheSim.UUID) | 304 | if (OldSim == null || OldSim.UUID == TheSim.UUID) |
301 | { | 305 | { |
302 | Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + | 306 | if (OldSim == null || (OldSim.regionRecvKey == TheSim.regionRecvKey && |
303 | TheSim.serverURI); | 307 | OldSim.regionSendKey == TheSim.regionSendKey)) |
304 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | ||
305 | { | 308 | { |
306 | try | 309 | MainLog.Instance.Verbose("GRID", "Adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + |
310 | TheSim.serverURI); | ||
311 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | ||
307 | { | 312 | { |
308 | DataResponse insertResponse = kvp.Value.AddProfile(TheSim); | 313 | try |
309 | switch (insertResponse) | 314 | { |
315 | DataResponse insertResponse = kvp.Value.AddProfile(TheSim); | ||
316 | switch (insertResponse) | ||
317 | { | ||
318 | case DataResponse.RESPONSE_OK: | ||
319 | MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); | ||
320 | break; | ||
321 | case DataResponse.RESPONSE_ERROR: | ||
322 | MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); | ||
323 | break; | ||
324 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: | ||
325 | MainLog.Instance.Warn("storage", | ||
326 | "New sim creation failed (Invalid Credentials): " + TheSim.regionName); | ||
327 | break; | ||
328 | case DataResponse.RESPONSE_AUTHREQUIRED: | ||
329 | MainLog.Instance.Warn("storage", | ||
330 | "New sim creation failed (Authentication Required): " + | ||
331 | TheSim.regionName); | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | catch (Exception e) | ||
310 | { | 336 | { |
311 | case DataResponse.RESPONSE_OK: | 337 | MainLog.Instance.Warn("storage", |
312 | MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); | 338 | "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); |
313 | break; | 339 | MainLog.Instance.Warn("storage", e.ToString()); |
314 | case DataResponse.RESPONSE_ERROR: | ||
315 | MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); | ||
316 | break; | ||
317 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: | ||
318 | MainLog.Instance.Warn("storage", | ||
319 | "New sim creation failed (Invalid Credentials): " + TheSim.regionName); | ||
320 | break; | ||
321 | case DataResponse.RESPONSE_AUTHREQUIRED: | ||
322 | MainLog.Instance.Warn("storage", | ||
323 | "New sim creation failed (Authentication Required): " + | ||
324 | TheSim.regionName); | ||
325 | break; | ||
326 | } | 340 | } |
327 | } | ||
328 | catch (Exception e) | ||
329 | { | ||
330 | MainLog.Instance.Warn("storage", | ||
331 | "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); | ||
332 | MainLog.Instance.Warn("storage", e.ToString()); | ||
333 | } | ||
334 | 341 | ||
335 | 342 | ||
336 | if (getRegion(TheSim.regionHandle) == null) | 343 | if (getRegion(TheSim.regionHandle) == null) |
337 | { | 344 | { |
338 | responseData["error"] = "Unable to add new region"; | 345 | responseData["error"] = "Unable to add new region"; |
339 | return response; | 346 | return response; |
347 | } | ||
340 | } | 348 | } |
341 | } | ||
342 | 349 | ||
343 | 350 | ||
344 | 351 | ||
345 | ArrayList SimNeighboursData = new ArrayList(); | 352 | ArrayList SimNeighboursData = new ArrayList(); |
346 | 353 | ||
347 | RegionProfileData neighbour; | 354 | RegionProfileData neighbour; |
348 | Hashtable NeighbourBlock; | 355 | Hashtable NeighbourBlock; |
349 | 356 | ||
350 | bool fastMode = false; // Only compatible with MySQL right now | 357 | bool fastMode = false; // Only compatible with MySQL right now |
351 | 358 | ||
352 | if (fastMode) | 359 | if (fastMode) |
353 | { | ||
354 | Dictionary<ulong, RegionProfileData> neighbours = | ||
355 | getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, | ||
356 | TheSim.regionLocY + 1); | ||
357 | |||
358 | foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) | ||
359 | { | 360 | { |
360 | NeighbourBlock = new Hashtable(); | 361 | Dictionary<ulong, RegionProfileData> neighbours = |
361 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString(); | 362 | getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, |
362 | NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); | 363 | TheSim.regionLocY + 1); |
363 | NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); | 364 | |
364 | NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); | 365 | foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) |
365 | NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); | ||
366 | NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString(); | ||
367 | |||
368 | if (aSim.Value.UUID != TheSim.UUID) | ||
369 | SimNeighboursData.Add(NeighbourBlock); | ||
370 | } | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | for (int x = -1; x < 2; x++) | ||
375 | for (int y = -1; y < 2; y++) | ||
376 | { | 366 | { |
377 | if ( | 367 | NeighbourBlock = new Hashtable(); |
378 | getRegion( | 368 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString(); |
379 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), | 369 | NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); |
380 | (uint)(TheSim.regionLocY + y) * 256)) != null) | 370 | NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); |
371 | NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); | ||
372 | NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); | ||
373 | NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString(); | ||
374 | |||
375 | if (aSim.Value.UUID != TheSim.UUID) | ||
376 | SimNeighboursData.Add(NeighbourBlock); | ||
377 | } | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | for (int x = -1; x < 2; x++) | ||
382 | for (int y = -1; y < 2; y++) | ||
381 | { | 383 | { |
382 | neighbour = | 384 | if ( |
383 | getRegion( | 385 | getRegion( |
384 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), | 386 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), |
385 | (uint)(TheSim.regionLocY + y) * 256)); | 387 | (uint)(TheSim.regionLocY + y) * 256)) != null) |
386 | 388 | { | |
387 | NeighbourBlock = new Hashtable(); | 389 | neighbour = |
388 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); | 390 | getRegion( |
389 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | 391 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), |
390 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); | 392 | (uint)(TheSim.regionLocY + y) * 256)); |
391 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | 393 | |
392 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | 394 | NeighbourBlock = new Hashtable(); |
393 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); | 395 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); |
394 | 396 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | |
395 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | 397 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); |
398 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | ||
399 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | ||
400 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); | ||
401 | |||
402 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | ||
403 | } | ||
396 | } | 404 | } |
397 | } | 405 | } |
398 | } | ||
399 | 406 | ||
400 | responseData["UUID"] = TheSim.UUID.ToString(); | 407 | responseData["UUID"] = TheSim.UUID.ToString(); |
401 | responseData["region_locx"] = TheSim.regionLocX.ToString(); | 408 | responseData["region_locx"] = TheSim.regionLocX.ToString(); |
402 | responseData["region_locy"] = TheSim.regionLocY.ToString(); | 409 | responseData["region_locy"] = TheSim.regionLocY.ToString(); |
403 | responseData["regionname"] = TheSim.regionName; | 410 | responseData["regionname"] = TheSim.regionName; |
404 | responseData["estate_id"] = "1"; | 411 | responseData["estate_id"] = "1"; |
405 | responseData["neighbours"] = SimNeighboursData; | 412 | responseData["neighbours"] = SimNeighboursData; |
406 | 413 | ||
407 | responseData["sim_ip"] = TheSim.serverIP; | 414 | responseData["sim_ip"] = TheSim.serverIP; |
408 | responseData["sim_port"] = TheSim.serverPort.ToString(); | 415 | responseData["sim_port"] = TheSim.serverPort.ToString(); |
409 | responseData["asset_url"] = TheSim.regionAssetURI; | 416 | responseData["asset_url"] = TheSim.regionAssetURI; |
410 | responseData["asset_sendkey"] = TheSim.regionAssetSendKey; | 417 | responseData["asset_sendkey"] = TheSim.regionAssetSendKey; |
411 | responseData["asset_recvkey"] = TheSim.regionAssetRecvKey; | 418 | responseData["asset_recvkey"] = TheSim.regionAssetRecvKey; |
412 | responseData["user_url"] = TheSim.regionUserURI; | 419 | responseData["user_url"] = TheSim.regionUserURI; |
413 | responseData["user_sendkey"] = TheSim.regionUserSendKey; | 420 | responseData["user_sendkey"] = TheSim.regionUserSendKey; |
414 | responseData["user_recvkey"] = TheSim.regionUserRecvKey; | 421 | responseData["user_recvkey"] = TheSim.regionUserRecvKey; |
415 | responseData["authkey"] = TheSim.regionSecret; | 422 | responseData["authkey"] = TheSim.regionSecret; |
416 | 423 | ||
417 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) | 424 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) |
418 | responseData["data_uri"] = TheSim.regionDataURI; | 425 | responseData["data_uri"] = TheSim.regionDataURI; |
419 | 426 | ||
420 | responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines; | 427 | responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines; |
421 | 428 | ||
422 | // Instead of sending a multitude of message servers to the registering sim | 429 | // Instead of sending a multitude of message servers to the registering sim |
423 | // we should probably be sending a single one and parhaps it's backup | 430 | // we should probably be sending a single one and parhaps it's backup |
424 | // that has responsibility over routing it's messages. | 431 | // that has responsibility over routing it's messages. |
425 | 432 | ||
426 | // The Sim won't be contacting us again about any of the message server stuff during it's time up. | 433 | // The Sim won't be contacting us again about any of the message server stuff during it's time up. |
427 | 434 | ||
428 | responseData["messageserver_count"] = _MessageServers.Count; | 435 | responseData["messageserver_count"] = _MessageServers.Count; |
429 | 436 | ||
430 | for (int i = 0; i < _MessageServers.Count; i++) | 437 | for (int i = 0; i < _MessageServers.Count; i++) |
438 | { | ||
439 | responseData["messageserver_uri" + i] = _MessageServers[i].URI; | ||
440 | responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey; | ||
441 | responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey; | ||
442 | } | ||
443 | return response; | ||
444 | } | ||
445 | else | ||
431 | { | 446 | { |
432 | responseData["messageserver_uri" + i] = _MessageServers[i].URI; | 447 | MainLog.Instance.Warn("grid", "Authentication failed when trying to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); |
433 | responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey; | 448 | responseData["error"] = "The key required to connect to your region did not match. Please check your send and recieve keys."; |
434 | responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey; | 449 | return response; |
435 | } | 450 | } |
436 | return response; | ||
437 | |||
438 | } | 451 | } |
439 | else | 452 | else |
440 | { | 453 | { |