aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-04-11 15:00:41 +0000
committerJustin Clarke Casey2008-04-11 15:00:41 +0000
commitb3892096f3bbdb3310abd9feb341b3a040bbf081 (patch)
tree37a829ab7b6d87b8b0aa4130be0adfc0ae9dc4a3 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
parentFrom: Kurt Taylor <krtaylor@us.ibm.com> (diff)
downloadopensim-SC_OLD-b3892096f3bbdb3310abd9feb341b3a040bbf081.zip
opensim-SC_OLD-b3892096f3bbdb3310abd9feb341b3a040bbf081.tar.gz
opensim-SC_OLD-b3892096f3bbdb3310abd9feb341b3a040bbf081.tar.bz2
opensim-SC_OLD-b3892096f3bbdb3310abd9feb341b3a040bbf081.tar.xz
* From: Dr Scofield <hud@zurich.ibm.com>
* This patch adds support for saving a dynamically generated region to the filesystem (as a region xml file) * Also adds some error checknig to make sure the dynamically generated region name, id or location are not already taken. * Thanks Dr Scofield
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs97
1 files changed, 64 insertions, 33 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 9d4bfea..f1b3ade 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -282,7 +282,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
282 /// </remarks> 282 /// </remarks>
283 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request) 283 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request)
284 { 284 {
285 m_log.Info("[RADMIN]: Received Create Region Administrator Request"); 285 m_log.Info("[RADMIN]: CreateRegion: new request");
286 XmlRpcResponse response = new XmlRpcResponse(); 286 XmlRpcResponse response = new XmlRpcResponse();
287 Hashtable requestData = (Hashtable) request.Params[0]; 287 Hashtable requestData = (Hashtable) request.Params[0];
288 Hashtable responseData = new Hashtable(); 288 Hashtable responseData = new Hashtable();
@@ -291,7 +291,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
291 // check completeness 291 // check completeness
292 foreach (string p in new string[] { "password", 292 foreach (string p in new string[] { "password",
293 "region_name", "region_x", "region_y", 293 "region_name", "region_x", "region_y",
294 "region_master_first", "region_master_last", 294 "region_master_first", "region_master_last",
295 "region_master_password",
295 "listen_ip", "listen_port", "external_address"}) 296 "listen_ip", "listen_port", "external_address"})
296 { 297 {
297 if (!requestData.Contains(p)) 298 if (!requestData.Contains(p))
@@ -302,51 +303,79 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
302 if (!String.IsNullOrEmpty(requiredPassword) && 303 if (!String.IsNullOrEmpty(requiredPassword) &&
303 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); 304 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
304 305
305 // bool persist = Convert.ToBoolean((string)requestData["persist"]); 306 // extract or generate region ID now
306 RegionInfo region = null; 307 Scene scene = null;
307 // if (!persist) 308 LLUUID regionID = LLUUID.Zero;
308 // {
309 // region = new RegionInfo();
310 // }
311 // else
312 // {
313 // region = new RegionInfo("DEFAULT REGION CONFIG",
314 // Path.Combine(regionConfigPath, "default.xml"), false);
315 // }
316 region = new RegionInfo();
317
318
319 if (requestData.ContainsKey("region_id") && 309 if (requestData.ContainsKey("region_id") &&
320 !String.IsNullOrEmpty((string) requestData["region_id"])) 310 !String.IsNullOrEmpty((string)requestData["region_id"]))
321 { 311 {
322 // FIXME: need to check whether region_id already 312 regionID = (string) requestData["region_id"];
323 // in use 313 if (m_app.SceneManager.TryGetScene(regionID, out scene))
324 region.RegionID = (string) requestData["region_id"]; 314 throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
315 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
316 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
325 } 317 }
326 else 318 else
327 { 319 {
328 region.RegionID = LLUUID.Random(); 320 regionID = LLUUID.Random();
321 m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
329 } 322 }
330 323
331 // FIXME: need to check whether region_name already 324 // create volatile or persistent region info
332 // in use 325 RegionInfo region = new RegionInfo();
326
327 region.RegionID = regionID;
333 region.RegionName = (string) requestData["region_name"]; 328 region.RegionName = (string) requestData["region_name"];
334 region.RegionLocX = Convert.ToUInt32((Int32) requestData["region_x"]); 329 region.RegionLocX = Convert.ToUInt32((Int32) requestData["region_x"]);
335 region.RegionLocY = Convert.ToUInt32((Int32) requestData["region_y"]); 330 region.RegionLocY = Convert.ToUInt32((Int32) requestData["region_y"]);
331
332 // check for collisions: region name, region UUID,
333 // region location
334 if (m_app.SceneManager.TryGetScene(region.RegionName, out scene))
335 throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>",
336 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
337 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
338
339 if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene))
340 throw new Exception(String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>",
341 region.RegionLocX, region.RegionLocY,
342 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
343 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
336 344
337 // Security risk 345 // Security risk [and apparently not used]
338 if (requestData.ContainsKey("datastore")) 346 // if (requestData.ContainsKey("datastore"))
339 region.DataStore = (string) requestData["datastore"]; 347 // region.DataStore = (string) requestData["datastore"];
340 348
341 region.InternalEndPoint = 349 region.InternalEndPoint =
342 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); 350 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);
343 351
344 // FIXME: need to check whether listen_port already in use!
345 region.InternalEndPoint.Port = (Int32) requestData["listen_port"]; 352 region.InternalEndPoint.Port = (Int32) requestData["listen_port"];
353 if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene))
354 throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
355 region.InternalEndPoint.Address,
356 region.InternalEndPoint.Port,
357 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
358 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
359
360
346 region.ExternalHostName = (string) requestData["external_address"]; 361 region.ExternalHostName = (string) requestData["external_address"];
347 362
348 region.MasterAvatarFirstName = (string) requestData["region_master_first"]; 363 region.MasterAvatarFirstName = (string) requestData["region_master_first"];
349 region.MasterAvatarLastName = (string) requestData["region_master_last"]; 364 region.MasterAvatarLastName = (string) requestData["region_master_last"];
365 region.MasterAvatarSandboxPassword = (string) requestData["region_master_password"];
366
367 bool persist = Convert.ToBoolean((string)requestData["persist"]);
368 if (persist)
369 {
370 string regionConfigPath = Path.Combine(Path.Combine(Util.configDir(), "Regions"),
371 String.Format("{0}x{1}-{2}.xml",
372 region.RegionLocX.ToString(),
373 region.RegionLocY.ToString(),
374 regionID.ToString()));
375 m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
376 region.RegionID, regionConfigPath);
377 region.SaveRegionToFile("dynamic region", regionConfigPath);
378 }
350 379
351 m_app.CreateRegion(region, true); 380 m_app.CreateRegion(region, true);
352 381
@@ -358,6 +387,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
358 } 387 }
359 catch (Exception e) 388 catch (Exception e)
360 { 389 {
390 m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message);
391 m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString());
392
361 responseData["success"] = "false"; 393 responseData["success"] = "false";
362 responseData["error"] = e.Message; 394 responseData["error"] = e.Message;
363 395
@@ -405,7 +437,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
405 /// </remarks> 437 /// </remarks>
406 public XmlRpcResponse XmlRpcCreateUserMethod(XmlRpcRequest request) 438 public XmlRpcResponse XmlRpcCreateUserMethod(XmlRpcRequest request)
407 { 439 {
408 m_log.Info("[RADMIN]: Received Create User Administrator Request"); 440 m_log.Info("[RADMIN]: CreateUser: new request");
409 XmlRpcResponse response = new XmlRpcResponse(); 441 XmlRpcResponse response = new XmlRpcResponse();
410 Hashtable requestData = (Hashtable) request.Params[0]; 442 Hashtable requestData = (Hashtable) request.Params[0];
411 Hashtable responseData = new Hashtable(); 443 Hashtable responseData = new Hashtable();
@@ -444,12 +476,12 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
444 476
445 response.Value = responseData; 477 response.Value = responseData;
446 478
447 m_log.InfoFormat("[RADMIN]: User {0} {1} created, UUID {2}", firstname, lastname, userID); 479 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
448 } 480 }
449 catch (Exception e) 481 catch (Exception e)
450 { 482 {
451 m_log.ErrorFormat("[RADMIN] create user: failed: {0}", e.Message); 483 m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
452 m_log.DebugFormat("[RADMIN] create user: failed: {0}", e.ToString()); 484 m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
453 485
454 responseData["success"] = "false"; 486 responseData["success"] = "false";
455 responseData["avatar_uuid"] = LLUUID.Zero.ToString(); 487 responseData["avatar_uuid"] = LLUUID.Zero.ToString();
@@ -471,8 +503,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
471 try 503 try
472 { 504 {
473 // check completeness 505 // check completeness
474 foreach (string p in new string[] { "password", 506 foreach (string p in new string[] { "password", "region_name", "filename" })
475 "region_name", "filename" })
476 { 507 {
477 if (!requestData.Contains(p)) 508 if (!requestData.Contains(p))
478 throw new Exception(String.Format("missing parameter {0}", p)); 509 throw new Exception(String.Format("missing parameter {0}", p));