*Added CommandIntentions that is used to describe a console commands hazard. HAZARDOUS if it modifies the simulator, NON_HAZARDOUS if it does a command that doesn't modify the simulator but does a background command such as a forced backup, and STATISTICAL if it returns debug or more information.

*This is useful for implementing a protection system from unwanted script execution or for application modules needing to know what a command does.
0.6.0-stable
mingchen 2008-07-25 02:30:07 +00:00
parent c1e239dedc
commit f2742fb604
7 changed files with 36 additions and 18 deletions

View File

@ -29,12 +29,21 @@ using System.Collections.Generic;
namespace OpenSim.Region.Environment.Interfaces namespace OpenSim.Region.Environment.Interfaces
{ {
public enum CommandIntentions
{
COMMAND_STATISTICAL,
COMMAND_NON_HAZARDOUS,
COMMAND_HAZARDOUS
};
public interface ICommand public interface ICommand
{ {
void AddArgument(string name, string helptext, string type); void AddArgument(string name, string helptext, string type);
Dictionary<string, string> Arguments { get; } Dictionary<string, string> Arguments { get; }
string Help { get; } string Help { get; }
string Name { get; } string Name { get; }
CommandIntentions Intentions { get; }
void Run(object[] args); void Run(object[] args);
void ShowConsoleHelp(); void ShowConsoleHelp();
} }

View File

@ -27,6 +27,8 @@
namespace OpenSim.Region.Environment.Interfaces namespace OpenSim.Region.Environment.Interfaces
{ {
public interface ICommander public interface ICommander
{ {
void ProcessConsoleCommand(string function, string[] args); void ProcessConsoleCommand(string function, string[] args);

View File

@ -47,12 +47,14 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
private Action<object[]> m_command; private Action<object[]> m_command;
private string m_help; private string m_help;
private string m_name; private string m_name;
private CommandIntentions m_intentions; //A permission type system could implement this and know what a command intends on doing.
public Command(string name, Action<Object[]> command, string help) public Command(string name, CommandIntentions intention, Action<Object[]> command, string help)
{ {
m_name = name; m_name = name;
m_command = command; m_command = command;
m_help = help; m_help = help;
m_intentions = intention;
} }
#region ICommand Members #region ICommand Members
@ -67,6 +69,11 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
get { return m_name; } get { return m_name; }
} }
public CommandIntentions Intentions
{
get { return m_intentions; }
}
public string Help public string Help
{ {
get { return m_help; } get { return m_help; }

View File

@ -56,7 +56,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
public void PostInitialise() public void PostInitialise()
{ {
Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); Command testCommand = new Command("hello", CommandIntentions.COMMAND_STATISTICAL, InterfaceHelloWorld, "Says a simple debugging test string");
testCommand.AddArgument("world", "Write world here", "string"); testCommand.AddArgument("world", "Write world here", "string");
m_commander.RegisterCommand("hello", testCommand); m_commander.RegisterCommand("hello", testCommand);

View File

@ -182,13 +182,13 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
//Register Debug Commands //Register Debug Commands
Command bypassCommand = new Command("bypass", InterfaceBypassPermissions, "Force the permissions a specific way to test permissions"); Command bypassCommand = new Command("bypass", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBypassPermissions, "Force the permissions a specific way to test permissions");
bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean"); bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean");
bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean"); bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean");
m_commander.RegisterCommand("bypass", bypassCommand); m_commander.RegisterCommand("bypass", bypassCommand);
Command debugCommand = new Command("debug", InterfaceDebugPermissions, "Force the permissions a specific way to test permissions"); Command debugCommand = new Command("debug", CommandIntentions.COMMAND_STATISTICAL, InterfaceDebugPermissions, "Force the permissions a specific way to test permissions");
debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean"); debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
m_commander.RegisterCommand("debug", debugCommand); m_commander.RegisterCommand("debug", debugCommand);

View File

@ -199,10 +199,10 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
private void LoadCommanderCommands() private void LoadCommanderCommands()
{ {
Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); Command serialiseSceneCommand = new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveRegion, "Saves the named region into the exports directory.");
serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String");
Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); Command serialiseAllScenesCommand = new Command("save-all",CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveAllRegions, "Saves all regions into the exports directory.");
m_commander.RegisterCommand("save", serialiseSceneCommand); m_commander.RegisterCommand("save", serialiseSceneCommand);
m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);

View File

@ -804,19 +804,19 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")";
Command loadFromFileCommand = Command loadFromFileCommand =
new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file.");
loadFromFileCommand.AddArgument("filename", loadFromFileCommand.AddArgument("filename",
"The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String"); supportedFileExtensions, "String");
Command saveToFileCommand = Command saveToFileCommand =
new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveFile, "Saves the current heightmap to a specified file.");
saveToFileCommand.AddArgument("filename", saveToFileCommand.AddArgument("filename",
"The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " +
supportedFileExtensions, "String"); supportedFileExtensions, "String");
Command loadFromTileCommand = Command loadFromTileCommand =
new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); new Command("load-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
loadFromTileCommand.AddArgument("filename", loadFromTileCommand.AddArgument("filename",
"The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String"); supportedFileExtensions, "String");
@ -829,40 +829,40 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
// Terrain adjustments // Terrain adjustments
Command fillRegionCommand = Command fillRegionCommand =
new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.",
"Double"); "Double");
Command elevateCommand = Command elevateCommand =
new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount.");
elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double");
Command lowerCommand = Command lowerCommand =
new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount.");
lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double");
Command multiplyCommand = Command multiplyCommand =
new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified.");
multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
Command bakeRegionCommand = Command bakeRegionCommand =
new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions revert map.");
Command revertRegionCommand = Command revertRegionCommand =
new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap.");
// Debug // Debug
Command showDebugStatsCommand = Command showDebugStatsCommand =
new Command("stats", InterfaceShowDebugStats, new Command("stats", CommandIntentions.COMMAND_STATISTICAL, InterfaceShowDebugStats,
"Shows some information about the regions heightmap for debugging purposes."); "Shows some information about the regions heightmap for debugging purposes.");
Command experimentalBrushesCommand = Command experimentalBrushesCommand =
new Command("newbrushes", InterfaceEnableExperimentalBrushes, new Command("newbrushes", CommandIntentions.COMMAND_HAZARDOUS, InterfaceEnableExperimentalBrushes,
"Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
//Plugins //Plugins
Command pluginRunCommand = Command pluginRunCommand =
new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); new Command("effect", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRunPluginEffect, "Runs a specified plugin effect");
pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
m_commander.RegisterCommand("load", loadFromFileCommand); m_commander.RegisterCommand("load", loadFromFileCommand);