diff options
author | Brian McBee | 2008-01-06 19:59:58 +0000 |
---|---|---|
committer | Brian McBee | 2008-01-06 19:59:58 +0000 |
commit | 9985d53681942567c7fef8bba1659aaf3b0eb385 (patch) | |
tree | b6aa180634147370f2cba07cb3ba0ed080a0c283 /OpenSim | |
parent | * Added some userserver glue for communications with the message server (diff) | |
download | opensim-SC_OLD-9985d53681942567c7fef8bba1659aaf3b0eb385.zip opensim-SC_OLD-9985d53681942567c7fef8bba1659aaf3b0eb385.tar.gz opensim-SC_OLD-9985d53681942567c7fef8bba1659aaf3b0eb385.tar.bz2 opensim-SC_OLD-9985d53681942567c7fef8bba1659aaf3b0eb385.tar.xz |
Added code to gridserver to prevent new region from connecting at X,Y location already used by an existing region.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 240 |
1 files changed, 128 insertions, 112 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 65df708..31500c0 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -228,18 +228,20 @@ namespace OpenSim.Grid.GridServer | |||
228 | response.Value = responseData; | 228 | response.Value = responseData; |
229 | 229 | ||
230 | RegionProfileData TheSim = null; | 230 | RegionProfileData TheSim = null; |
231 | Hashtable requestData = (Hashtable) request.Params[0]; | 231 | RegionProfileData OldSim = null; |
232 | |||
233 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
232 | string myword; | 234 | string myword; |
233 | if (requestData.ContainsKey("UUID")) | 235 | if (requestData.ContainsKey("UUID")) |
234 | { | 236 | { |
235 | TheSim = getRegion(new LLUUID((string) requestData["UUID"])); | 237 | TheSim = getRegion(new LLUUID((string)requestData["UUID"])); |
236 | 238 | ||
237 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID."); | 239 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID."); |
238 | } | 240 | } |
239 | else if (requestData.ContainsKey("region_handle")) | 241 | else if (requestData.ContainsKey("region_handle")) |
240 | { | 242 | { |
241 | // TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); | 243 | // TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); |
242 | // logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle."); | 244 | // logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle."); |
243 | } | 245 | } |
244 | else | 246 | else |
245 | { | 247 | { |
@@ -270,144 +272,158 @@ namespace OpenSim.Grid.GridServer | |||
270 | TheSim.regionUserSendKey = config.UserSendKey; | 272 | TheSim.regionUserSendKey = config.UserSendKey; |
271 | TheSim.regionUserRecvKey = config.UserRecvKey; | 273 | TheSim.regionUserRecvKey = config.UserRecvKey; |
272 | 274 | ||
273 | TheSim.serverIP = (string) requestData["sim_ip"]; | 275 | TheSim.serverIP = (string)requestData["sim_ip"]; |
274 | TheSim.serverPort = Convert.ToUInt32((string) requestData["sim_port"]); | 276 | TheSim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); |
275 | TheSim.httpPort = Convert.ToUInt32((string) requestData["http_port"]); | 277 | TheSim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); |
276 | TheSim.remotingPort = Convert.ToUInt32((string) requestData["remoting_port"]); | 278 | TheSim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); |
277 | TheSim.regionLocX = Convert.ToUInt32((string) requestData["region_locx"]); | 279 | TheSim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); |
278 | TheSim.regionLocY = Convert.ToUInt32((string) requestData["region_locy"]); | 280 | TheSim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); |
279 | TheSim.regionLocZ = 0; | 281 | TheSim.regionLocZ = 0; |
280 | TheSim.regionMapTextureID = new LLUUID((string) requestData["map-image-id"]); | 282 | TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]); |
281 | 283 | ||
282 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); | 284 | TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); |
283 | TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; | 285 | TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; |
284 | Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + | 286 | |
285 | TheSim.serverURI); | ||
286 | TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; | 287 | TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; |
287 | 288 | ||
288 | 289 | ||
289 | TheSim.regionName = (string) requestData["sim_name"]; | 290 | TheSim.regionName = (string)requestData["sim_name"]; |
290 | TheSim.UUID = new LLUUID((string) requestData["UUID"]); | 291 | TheSim.UUID = new LLUUID((string)requestData["UUID"]); |
291 | 292 | ||
292 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 293 | //make sure there is not an existing region at this location |
294 | OldSim = getRegion(TheSim.regionHandle); | ||
295 | if (OldSim == null || OldSim.UUID == TheSim.UUID) | ||
293 | { | 296 | { |
294 | try | 297 | Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + |
298 | TheSim.serverURI); | ||
299 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | ||
295 | { | 300 | { |
296 | DataResponse insertResponse = kvp.Value.AddProfile(TheSim); | 301 | try |
297 | switch (insertResponse) | ||
298 | { | 302 | { |
299 | case DataResponse.RESPONSE_OK: | 303 | DataResponse insertResponse = kvp.Value.AddProfile(TheSim); |
300 | MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); | 304 | switch (insertResponse) |
301 | break; | 305 | { |
302 | case DataResponse.RESPONSE_ERROR: | 306 | case DataResponse.RESPONSE_OK: |
303 | MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); | 307 | MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); |
304 | break; | 308 | break; |
305 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: | 309 | case DataResponse.RESPONSE_ERROR: |
306 | MainLog.Instance.Warn("storage", | 310 | MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); |
307 | "New sim creation failed (Invalid Credentials): " + TheSim.regionName); | 311 | break; |
308 | break; | 312 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: |
309 | case DataResponse.RESPONSE_AUTHREQUIRED: | 313 | MainLog.Instance.Warn("storage", |
310 | MainLog.Instance.Warn("storage", | 314 | "New sim creation failed (Invalid Credentials): " + TheSim.regionName); |
311 | "New sim creation failed (Authentication Required): " + | 315 | break; |
312 | TheSim.regionName); | 316 | case DataResponse.RESPONSE_AUTHREQUIRED: |
313 | break; | 317 | MainLog.Instance.Warn("storage", |
318 | "New sim creation failed (Authentication Required): " + | ||
319 | TheSim.regionName); | ||
320 | break; | ||
321 | } | ||
322 | } | ||
323 | catch (Exception e) | ||
324 | { | ||
325 | MainLog.Instance.Warn("storage", | ||
326 | "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); | ||
327 | MainLog.Instance.Warn("storage", e.ToString()); | ||
314 | } | 328 | } |
315 | } | ||
316 | catch (Exception e) | ||
317 | { | ||
318 | MainLog.Instance.Warn("storage", | ||
319 | "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); | ||
320 | MainLog.Instance.Warn("storage", e.ToString()); | ||
321 | } | ||
322 | 329 | ||
323 | 330 | ||
324 | if (getRegion(TheSim.regionHandle) == null) | 331 | if (getRegion(TheSim.regionHandle) == null) |
325 | { | 332 | { |
326 | responseData["error"] = "Unable to add new region"; | 333 | responseData["error"] = "Unable to add new region"; |
327 | return response; | 334 | return response; |
335 | } | ||
328 | } | 336 | } |
329 | } | ||
330 | 337 | ||
331 | 338 | ||
332 | ArrayList SimNeighboursData = new ArrayList(); | ||
333 | 339 | ||
334 | RegionProfileData neighbour; | 340 | ArrayList SimNeighboursData = new ArrayList(); |
335 | Hashtable NeighbourBlock; | ||
336 | 341 | ||
337 | bool fastMode = false; // Only compatible with MySQL right now | 342 | RegionProfileData neighbour; |
343 | Hashtable NeighbourBlock; | ||
338 | 344 | ||
339 | if (fastMode) | 345 | bool fastMode = false; // Only compatible with MySQL right now |
340 | { | ||
341 | Dictionary<ulong, RegionProfileData> neighbours = | ||
342 | getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, | ||
343 | TheSim.regionLocY + 1); | ||
344 | 346 | ||
345 | foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) | 347 | if (fastMode) |
346 | { | 348 | { |
347 | NeighbourBlock = new Hashtable(); | 349 | Dictionary<ulong, RegionProfileData> neighbours = |
348 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString(); | 350 | getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, |
349 | NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); | 351 | TheSim.regionLocY + 1); |
350 | NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); | 352 | |
351 | NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); | 353 | foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) |
352 | NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); | ||
353 | NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString(); | ||
354 | |||
355 | if (aSim.Value.UUID != TheSim.UUID) | ||
356 | SimNeighboursData.Add(NeighbourBlock); | ||
357 | } | ||
358 | } | ||
359 | else | ||
360 | { | ||
361 | for (int x = -1; x < 2; x++) | ||
362 | for (int y = -1; y < 2; y++) | ||
363 | { | 354 | { |
364 | if ( | 355 | NeighbourBlock = new Hashtable(); |
365 | getRegion( | 356 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString(); |
366 | Helpers.UIntsToLong((uint) ((TheSim.regionLocX + x)*256), | 357 | NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); |
367 | (uint) (TheSim.regionLocY + y)*256)) != null) | 358 | NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); |
359 | NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); | ||
360 | NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); | ||
361 | NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString(); | ||
362 | |||
363 | if (aSim.Value.UUID != TheSim.UUID) | ||
364 | SimNeighboursData.Add(NeighbourBlock); | ||
365 | } | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | for (int x = -1; x < 2; x++) | ||
370 | for (int y = -1; y < 2; y++) | ||
368 | { | 371 | { |
369 | neighbour = | 372 | if ( |
370 | getRegion( | 373 | getRegion( |
371 | Helpers.UIntsToLong((uint) ((TheSim.regionLocX + x)*256), | 374 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), |
372 | (uint) (TheSim.regionLocY + y)*256)); | 375 | (uint)(TheSim.regionLocY + y) * 256)) != null) |
373 | 376 | { | |
374 | NeighbourBlock = new Hashtable(); | 377 | neighbour = |
375 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); | 378 | getRegion( |
376 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | 379 | Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), |
377 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); | 380 | (uint)(TheSim.regionLocY + y) * 256)); |
378 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | 381 | |
379 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | 382 | NeighbourBlock = new Hashtable(); |
380 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); | 383 | NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); |
381 | 384 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | |
382 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | 385 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); |
386 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | ||
387 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | ||
388 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); | ||
389 | |||
390 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | ||
391 | } | ||
383 | } | 392 | } |
384 | } | 393 | } |
385 | } | ||
386 | 394 | ||
387 | responseData["UUID"] = TheSim.UUID.ToString(); | 395 | responseData["UUID"] = TheSim.UUID.ToString(); |
388 | responseData["region_locx"] = TheSim.regionLocX.ToString(); | 396 | responseData["region_locx"] = TheSim.regionLocX.ToString(); |
389 | responseData["region_locy"] = TheSim.regionLocY.ToString(); | 397 | responseData["region_locy"] = TheSim.regionLocY.ToString(); |
390 | responseData["regionname"] = TheSim.regionName; | 398 | responseData["regionname"] = TheSim.regionName; |
391 | responseData["estate_id"] = "1"; | 399 | responseData["estate_id"] = "1"; |
392 | responseData["neighbours"] = SimNeighboursData; | 400 | responseData["neighbours"] = SimNeighboursData; |
393 | 401 | ||
394 | responseData["sim_ip"] = TheSim.serverIP; | 402 | responseData["sim_ip"] = TheSim.serverIP; |
395 | responseData["sim_port"] = TheSim.serverPort.ToString(); | 403 | responseData["sim_port"] = TheSim.serverPort.ToString(); |
396 | responseData["asset_url"] = TheSim.regionAssetURI; | 404 | responseData["asset_url"] = TheSim.regionAssetURI; |
397 | responseData["asset_sendkey"] = TheSim.regionAssetSendKey; | 405 | responseData["asset_sendkey"] = TheSim.regionAssetSendKey; |
398 | responseData["asset_recvkey"] = TheSim.regionAssetRecvKey; | 406 | responseData["asset_recvkey"] = TheSim.regionAssetRecvKey; |
399 | responseData["user_url"] = TheSim.regionUserURI; | 407 | responseData["user_url"] = TheSim.regionUserURI; |
400 | responseData["user_sendkey"] = TheSim.regionUserSendKey; | 408 | responseData["user_sendkey"] = TheSim.regionUserSendKey; |
401 | responseData["user_recvkey"] = TheSim.regionUserRecvKey; | 409 | responseData["user_recvkey"] = TheSim.regionUserRecvKey; |
402 | responseData["authkey"] = TheSim.regionSecret; | 410 | responseData["authkey"] = TheSim.regionSecret; |
403 | 411 | ||
404 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) | 412 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) |
405 | responseData["data_uri"] = TheSim.regionDataURI; | 413 | responseData["data_uri"] = TheSim.regionDataURI; |
406 | 414 | ||
407 | responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines; | 415 | responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines; |
408 | 416 | ||
409 | 417 | ||
410 | return response; | 418 | return response; |
419 | |||
420 | } | ||
421 | else | ||
422 | { | ||
423 | MainLog.Instance.Warn("grid", "Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); | ||
424 | responseData["error"] = "Another region already exists at that location. Try another"; | ||
425 | return response; | ||
426 | } | ||
411 | } | 427 | } |
412 | 428 | ||
413 | public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) | 429 | public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) |