*RemoteAdminPlugin can now be password protected. Add the password in the INI under [RemoteAdmin] with the name access_password

*Removed a few more unneeded exceptions in land that has been fixed
afrisby
mingchen 2007-12-21 03:34:51 +00:00
parent 9f3170b49f
commit 169e176f47
2 changed files with 106 additions and 75 deletions

View File

@ -53,7 +53,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
{ {
private OpenSimMain m_app; private OpenSimMain m_app;
private BaseHttpServer m_httpd; private BaseHttpServer m_httpd;
private string requiredPassword = "";
public void Initialise(OpenSimMain openSim) public void Initialise(OpenSimMain openSim)
{ {
try try
@ -61,6 +61,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
if (openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false)) if (openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false))
{ {
MainLog.Instance.Verbose("RADMIN", "Remote Admin Plugin Enabled"); MainLog.Instance.Verbose("RADMIN", "Remote Admin Plugin Enabled");
requiredPassword = openSim.ConfigSource.Configs["RemoteAdmin"].GetString("access_password", "");
m_app = openSim; m_app = openSim;
m_httpd = openSim.HttpServer; m_httpd = openSim.HttpServer;
@ -85,19 +86,27 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
LLUUID regionID = new LLUUID((string)requestData["regionID"]); LLUUID regionID = new LLUUID((string)requestData["regionID"]);
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
responseData["accepted"] = "true"; if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
response.Value = responseData;
OpenSim.Region.Environment.Scenes.Scene RebootedScene;
if (m_app.SceneManager.TryGetScene(regionID, out RebootedScene))
{ {
responseData["rebooting"] = "true"; responseData["accepted"] = "false";
RebootedScene.Restart(30); response.Value = responseData;
} }
else else
{ {
responseData["rebooting"] = "false"; responseData["accepted"] = "true";
response.Value = responseData;
OpenSim.Region.Environment.Scenes.Scene RebootedScene;
if (m_app.SceneManager.TryGetScene(regionID, out RebootedScene))
{
responseData["rebooting"] = "true";
RebootedScene.Restart(30);
}
else
{
responseData["rebooting"] = "false";
}
} }
return response; return response;
@ -108,14 +117,23 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
string message = (string)requestData["message"];
MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message);
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
responseData["accepted"] = "true"; if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
response.Value = responseData; {
responseData["accepted"] = "false";
response.Value = responseData;
}
else
{
string message = (string)requestData["message"];
MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message);
m_app.SceneManager.SendGeneralMessage(message); responseData["accepted"] = "true";
response.Value = responseData;
m_app.SceneManager.SendGeneralMessage(message);
}
return response; return response;
} }
@ -125,42 +143,49 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
MainLog.Instance.Verbose("RADMIN", "Received Shutdown Administrator Request"); MainLog.Instance.Verbose("RADMIN", "Received Shutdown Administrator Request");
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
Hashtable responseData = new Hashtable();
if ((string)requestData["shutdown"] == "delayed") if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
{ {
int timeout = (Int32)requestData["milliseconds"]; responseData["accepted"] = "false";
Hashtable responseData = new Hashtable();
responseData["accepted"] = "true";
response.Value = responseData; response.Value = responseData;
m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() +
" second(s). Please save what you are doing and log out.");
// Perform shutdown
Timer shutdownTimer = new Timer(timeout); // Wait before firing
shutdownTimer.AutoReset = false;
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
shutdownTimer.Start();
return response;
} }
else else
{ {
Hashtable responseData = new Hashtable(); if ((string)requestData["shutdown"] == "delayed")
responseData["accepted"] = "true"; {
response.Value = responseData; int timeout = (Int32)requestData["milliseconds"];
m_app.SceneManager.SendGeneralMessage("Region is going down now."); responseData["accepted"] = "true";
response.Value = responseData;
// Perform shutdown m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() +
Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing " second(s). Please save what you are doing and log out.");
shutdownTimer.AutoReset = false;
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
shutdownTimer.Start();
return response; // Perform shutdown
Timer shutdownTimer = new Timer(timeout); // Wait before firing
shutdownTimer.AutoReset = false;
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
shutdownTimer.Start();
return response;
}
else
{
responseData["accepted"] = "true";
response.Value = responseData;
m_app.SceneManager.SendGeneralMessage("Region is going down now.");
// Perform shutdown
Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing
shutdownTimer.AutoReset = false;
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
shutdownTimer.Start();
return response;
}
} }
return response;
} }
private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e)
@ -173,40 +198,46 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
MainLog.Instance.Verbose("RADMIN", "Received Create Region Administrator Request"); MainLog.Instance.Verbose("RADMIN", "Received Create Region Administrator Request");
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
Hashtable responseData = new Hashtable();
RegionInfo newRegionData = new RegionInfo(); if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
try
{ {
newRegionData.RegionID = (string)requestData["region_id"]; responseData["created"] = "false";
newRegionData.RegionName = (string)requestData["region_name"];
newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]);
newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]);
// Security risk
newRegionData.DataStore = (string)requestData["datastore"];
newRegionData.InternalEndPoint = new IPEndPoint(
IPAddress.Parse((string)requestData["listen_ip"]), 0);
newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"];
newRegionData.ExternalHostName = (string)requestData["external_address"];
newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"];
newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"];
m_app.CreateRegion(newRegionData);
Hashtable responseData = new Hashtable();
responseData["created"] = "true";
response.Value = responseData; response.Value = responseData;
} }
catch (Exception e) else
{ {
Hashtable responseData = new Hashtable(); RegionInfo newRegionData = new RegionInfo();
responseData["created"] = "false";
responseData["error"] = e.ToString(); try
response.Value = responseData; {
newRegionData.RegionID = (string)requestData["region_id"];
newRegionData.RegionName = (string)requestData["region_name"];
newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]);
newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]);
// Security risk
newRegionData.DataStore = (string)requestData["datastore"];
newRegionData.InternalEndPoint = new IPEndPoint(
IPAddress.Parse((string)requestData["listen_ip"]), 0);
newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"];
newRegionData.ExternalHostName = (string)requestData["external_address"];
newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"];
newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"];
m_app.CreateRegion(newRegionData);
responseData["created"] = "true";
response.Value = responseData;
}
catch (Exception e)
{
responseData["created"] = "false";
responseData["error"] = e.ToString();
response.Value = responseData;
}
} }
return response; return response;

View File

@ -472,7 +472,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
{ {
//Throw an exception - The bitmap is not 64x64 //Throw an exception - The bitmap is not 64x64
throw new Exception("Error: Invalid Parcel Bitmap"); //throw new Exception("Error: Invalid Parcel Bitmap");
} }
else else
{ {
@ -584,7 +584,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2)
{ {
//Throw an exception - The bitmap is not 64x64 //Throw an exception - The bitmap is not 64x64
throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()");
} }
int x, y; int x, y;