*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,6 +86,13 @@ 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();
if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
{
responseData["accepted"] = "false";
response.Value = responseData;
}
else
{
responseData["accepted"] = "true"; responseData["accepted"] = "true";
response.Value = responseData; response.Value = responseData;
@ -99,6 +107,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
{ {
responseData["rebooting"] = "false"; 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];
Hashtable responseData = new Hashtable();
if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
{
responseData["accepted"] = "false";
response.Value = responseData;
}
else
{
string message = (string)requestData["message"]; string message = (string)requestData["message"];
MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message); MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message);
Hashtable responseData = new Hashtable();
responseData["accepted"] = "true"; responseData["accepted"] = "true";
response.Value = responseData; response.Value = responseData;
m_app.SceneManager.SendGeneralMessage(message); m_app.SceneManager.SendGeneralMessage(message);
}
return response; return response;
} }
@ -125,12 +143,18 @@ 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 (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
{
responseData["accepted"] = "false";
response.Value = responseData;
}
else
{
if ((string)requestData["shutdown"] == "delayed") if ((string)requestData["shutdown"] == "delayed")
{ {
int timeout = (Int32)requestData["milliseconds"]; int timeout = (Int32)requestData["milliseconds"];
Hashtable responseData = new Hashtable();
responseData["accepted"] = "true"; responseData["accepted"] = "true";
response.Value = responseData; response.Value = responseData;
@ -147,7 +171,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
} }
else else
{ {
Hashtable responseData = new Hashtable();
responseData["accepted"] = "true"; responseData["accepted"] = "true";
response.Value = responseData; response.Value = responseData;
@ -162,6 +185,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
return response; return response;
} }
} }
return response;
}
private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
@ -173,7 +198,14 @@ 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();
if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
{
responseData["created"] = "false";
response.Value = responseData;
}
else
{
RegionInfo newRegionData = new RegionInfo(); RegionInfo newRegionData = new RegionInfo();
try try
@ -197,17 +229,16 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
m_app.CreateRegion(newRegionData); m_app.CreateRegion(newRegionData);
Hashtable responseData = new Hashtable();
responseData["created"] = "true"; responseData["created"] = "true";
response.Value = responseData; response.Value = responseData;
} }
catch (Exception e) catch (Exception e)
{ {
Hashtable responseData = new Hashtable();
responseData["created"] = "false"; responseData["created"] = "false";
responseData["error"] = e.ToString(); responseData["error"] = e.ToString();
response.Value = responseData; 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;