diff options
author | Justin Clark-Casey (justincc) | 2011-12-07 17:31:57 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-12-07 17:31:57 +0000 |
commit | 415b7b7ec4be9f87e7d5b65000e092d3372a4391 (patch) | |
tree | 315ba0fc1f42a542a274b997b0d62a490ef78e73 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |
parent | properly lock CapsHandlers.m_capsHandlers (diff) | |
download | opensim-SC-415b7b7ec4be9f87e7d5b65000e092d3372a4391.zip opensim-SC-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.gz opensim-SC-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.bz2 opensim-SC-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.xz |
Implement XMLRPCAdmin command admin_teleport_agent.
This allows someone with access to this command on the XMLRPCAdmin interface to teleport an avatar to an arbitrary region and/or position.
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a634f1c..1b289a6 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -134,16 +134,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
134 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 134 | availableMethods["admin_restart"] = XmlRpcRestartMethod; |
135 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 135 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; |
136 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; | 136 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; |
137 | |||
138 | // Agent management | ||
139 | availableMethods["admin_teleport_agent"] = XmlRpcTeleportAgentMethod; | ||
140 | |||
137 | // User management | 141 | // User management |
138 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; | 142 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; |
139 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; | 143 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; |
140 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; | 144 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; |
141 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; | 145 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; |
146 | |||
142 | // Region state management | 147 | // Region state management |
143 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; | 148 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; |
144 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; | 149 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; |
145 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; | 150 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; |
146 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; | 151 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; |
152 | |||
147 | // Estate access list management | 153 | // Estate access list management |
148 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; | 154 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; |
149 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; | 155 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; |
@@ -2965,6 +2971,112 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2965 | return response; | 2971 | return response; |
2966 | } | 2972 | } |
2967 | 2973 | ||
2974 | public XmlRpcResponse XmlRpcTeleportAgentMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2975 | { | ||
2976 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2977 | Hashtable responseData = new Hashtable(); | ||
2978 | |||
2979 | try | ||
2980 | { | ||
2981 | responseData["success"] = true; | ||
2982 | |||
2983 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2984 | |||
2985 | CheckStringParameters(request, new string[] {"password"}); | ||
2986 | |||
2987 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2988 | |||
2989 | UUID agentId; | ||
2990 | string regionName = null; | ||
2991 | Vector3 pos, lookAt; | ||
2992 | bool agentSpecified = false; | ||
2993 | ScenePresence sp = null; | ||
2994 | |||
2995 | if (requestData.Contains("agent_first_name") && requestData.Contains("agent_last_name")) | ||
2996 | { | ||
2997 | string firstName = requestData["agent_first_name"].ToString(); | ||
2998 | string lastName = requestData["agent_last_name"].ToString(); | ||
2999 | m_application.SceneManager.TryGetRootScenePresenceByName(firstName, lastName, out sp); | ||
3000 | |||
3001 | if (sp == null) | ||
3002 | throw new Exception( | ||
3003 | string.Format( | ||
3004 | "No agent found with agent_first_name {0} and agent_last_name {1}", firstName, lastName)); | ||
3005 | } | ||
3006 | else if (requestData.Contains("agent_id")) | ||
3007 | { | ||
3008 | string rawAgentId = (string)requestData["agent_id"]; | ||
3009 | |||
3010 | if (!UUID.TryParse(rawAgentId, out agentId)) | ||
3011 | throw new Exception(string.Format("agent_id {0} does not have the correct id format", rawAgentId)); | ||
3012 | |||
3013 | m_application.SceneManager.TryGetRootScenePresence(agentId, out sp); | ||
3014 | |||
3015 | if (sp == null) | ||
3016 | throw new Exception(string.Format("No agent with agent_id {0} found in this simulator", agentId)); | ||
3017 | } | ||
3018 | else | ||
3019 | { | ||
3020 | throw new Exception("No agent_id or agent_first_name and agent_last_name parameters specified"); | ||
3021 | } | ||
3022 | |||
3023 | if (requestData.Contains("region_name")) | ||
3024 | regionName = (string)requestData["region_name"]; | ||
3025 | |||
3026 | pos.X = ParseFloat(requestData, "pos_x", sp.AbsolutePosition.X); | ||
3027 | pos.Y = ParseFloat(requestData, "pos_y", sp.AbsolutePosition.Y); | ||
3028 | pos.Z = ParseFloat(requestData, "pos_z", sp.AbsolutePosition.Z); | ||
3029 | lookAt.X = ParseFloat(requestData, "lookat_x", sp.Lookat.X); | ||
3030 | lookAt.Y = ParseFloat(requestData, "lookat_y", sp.Lookat.Y); | ||
3031 | lookAt.Z = ParseFloat(requestData, "lookat_z", sp.Lookat.Z); | ||
3032 | |||
3033 | sp.Scene.RequestTeleportLocation( | ||
3034 | sp.ControllingClient, regionName, pos, lookAt, (uint)Constants.TeleportFlags.ViaLocation); | ||
3035 | } | ||
3036 | catch (Exception e) | ||
3037 | { | ||
3038 | m_log.ErrorFormat("[RADMIN]: admin_teleport_agent exception: {0}{1}", e.Message, e.StackTrace); | ||
3039 | |||
3040 | responseData["success"] = false; | ||
3041 | responseData["error"] = e.Message; | ||
3042 | } | ||
3043 | finally | ||
3044 | { | ||
3045 | response.Value = responseData; | ||
3046 | } | ||
3047 | |||
3048 | return response; | ||
3049 | } | ||
3050 | |||
3051 | /// <summary> | ||
3052 | /// Parse a float with the given parameter name from a request data hash table. | ||
3053 | /// </summary> | ||
3054 | /// <remarks> | ||
3055 | /// Will throw an exception if parameter is not a float. | ||
3056 | /// Will not throw if parameter is not found, passes back default value instead. | ||
3057 | /// </remarks> | ||
3058 | /// <param name="requestData"></param> | ||
3059 | /// <param name="paramName"></param> | ||
3060 | /// <param name="defaultVal"></param> | ||
3061 | /// <returns></returns> | ||
3062 | private static float ParseFloat(Hashtable requestData, string paramName, float defaultVal) | ||
3063 | { | ||
3064 | if (requestData.Contains(paramName)) | ||
3065 | { | ||
3066 | string rawVal = (string)requestData[paramName]; | ||
3067 | float val; | ||
3068 | |||
3069 | if (!float.TryParse(rawVal, out val)) | ||
3070 | throw new Exception(string.Format("{0} {1} is not a valid float", paramName, rawVal)); | ||
3071 | else | ||
3072 | return val; | ||
3073 | } | ||
3074 | else | ||
3075 | { | ||
3076 | return defaultVal; | ||
3077 | } | ||
3078 | } | ||
3079 | |||
2968 | private static void CheckStringParameters(XmlRpcRequest request, string[] param) | 3080 | private static void CheckStringParameters(XmlRpcRequest request, string[] param) |
2969 | { | 3081 | { |
2970 | Hashtable requestData = (Hashtable) request.Params[0]; | 3082 | Hashtable requestData = (Hashtable) request.Params[0]; |
@@ -3144,6 +3256,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
3144 | return false; | 3256 | return false; |
3145 | } | 3257 | } |
3146 | } | 3258 | } |
3259 | |||
3147 | private bool LoadHeightmap(string file, UUID regionID) | 3260 | private bool LoadHeightmap(string file, UUID regionID) |
3148 | { | 3261 | { |
3149 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); | 3262 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); |