aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs291
1 files changed, 261 insertions, 30 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 808d9e4..bae1582 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -74,6 +74,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
74 74
75 private string m_name = "RemoteAdminPlugin"; 75 private string m_name = "RemoteAdminPlugin";
76 private string m_version = "0.0"; 76 private string m_version = "0.0";
77 private string m_openSimVersion;
77 78
78 public string Version 79 public string Version
79 { 80 {
@@ -93,6 +94,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
93 94
94 public void Initialise(OpenSimBase openSim) 95 public void Initialise(OpenSimBase openSim)
95 { 96 {
97 m_openSimVersion = openSim.GetVersionText();
98
96 m_configSource = openSim.ConfigSource.Source; 99 m_configSource = openSim.ConfigSource.Source;
97 try 100 try
98 { 101 {
@@ -135,10 +138,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
135 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); 138 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod);
136 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); 139 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod);
137 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); 140 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod);
141 availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod);
138 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); 142 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod);
139 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); 143 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod);
140 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); 144 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
141 145
146 availableMethods["admin_reset_land"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcResetLand);
147
142 // Agent management 148 // Agent management
143 availableMethods["admin_get_agents"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentsMethod); 149 availableMethods["admin_get_agents"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentsMethod);
144 availableMethods["admin_teleport_agent"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcTeleportAgentMethod); 150 availableMethods["admin_teleport_agent"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcTeleportAgentMethod);
@@ -163,8 +169,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
163 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); 169 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
164 availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload); 170 availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload);
165 171
166 // Land management 172 // Misc
167 availableMethods["admin_reset_land"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcResetLand); 173 availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch);
174 availableMethods["admin_refresh_map"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshMap);
175 availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion);
176 availableMethods["admin_get_agent_count"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentCount);
168 177
169 // Either enable full remote functionality or just selected features 178 // Either enable full remote functionality or just selected features
170 string enabledMethods = m_config.GetString("enabled_methods", "all"); 179 string enabledMethods = m_config.GetString("enabled_methods", "all");
@@ -265,25 +274,105 @@ namespace OpenSim.ApplicationPlugins.RemoteController
265 274
266 try 275 try
267 { 276 {
268 m_log.Info("[RADMIN]: Request to restart Region."); 277 Scene rebootedScene = null;
278 bool restartAll = false;
269 279
270 CheckRegionParams(requestData, responseData); 280 IConfig startupConfig = m_configSource.Configs["Startup"];
281 if (startupConfig != null)
282 {
283 if (startupConfig.GetBoolean("InworldRestartShutsDown", false))
284 {
285 rebootedScene = m_application.SceneManager.CurrentOrFirstScene;
286 restartAll = true;
287 }
288 }
271 289
272 Scene rebootedScene = null; 290 if (rebootedScene == null)
273 GetSceneFromRegionParams(requestData, responseData, out rebootedScene); 291 {
292 CheckRegionParams(requestData, responseData);
293
294 GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
295 }
296
297 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
274 298
275 responseData["success"] = false; 299 responseData["success"] = false;
276 responseData["accepted"] = true; 300 responseData["accepted"] = true;
277 responseData["rebooting"] = true; 301 responseData["rebooting"] = true;
278 302
279 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 303 string message;
280 if (restartModule != null) 304 List<int> times = new List<int>();
305
306 if (requestData.ContainsKey("alerts"))
281 { 307 {
282 List<int> times = new List<int> { 30, 15 }; 308 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
309 if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1)
310 {
311 m_log.Info("[RADMIN]: Request to cancel restart.");
283 312
284 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 313 if (restartModule != null)
285 responseData["success"] = true; 314 {
315 message = "Restart has been cancelled";
316
317 if (requestData.ContainsKey("message"))
318 message = requestData["message"].ToString();
319
320 restartModule.AbortRestart(message);
321
322 responseData["success"] = true;
323 responseData["rebooting"] = false;
324
325 return;
326 }
327 }
328 foreach (string a in alertTimes)
329 times.Add(Convert.ToInt32(a));
330 }
331 else
332 {
333 int timeout = 30;
334 if (requestData.ContainsKey("milliseconds"))
335 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
336 while (timeout > 0)
337 {
338 times.Add(timeout);
339 if (timeout > 300)
340 timeout -= 120;
341 else if (timeout > 30)
342 timeout -= 30;
343 else
344 timeout -= 15;
345 }
346 }
347
348 m_log.Info("[RADMIN]: Request to restart Region.");
349
350 message = "Region is restarting in {0}. Please save what you are doing and log out.";
351
352 if (requestData.ContainsKey("message"))
353 message = requestData["message"].ToString();
354
355 bool notice = true;
356 if (requestData.ContainsKey("noticetype")
357 && ((string)requestData["noticetype"] == "dialog"))
358 {
359 notice = false;
286 } 360 }
361
362 List<Scene> restartList;
363
364 if (restartAll)
365 restartList = m_application.SceneManager.Scenes;
366 else
367 restartList = new List<Scene>() { rebootedScene };
368
369 foreach (Scene s in m_application.SceneManager.Scenes)
370 {
371 restartModule = s.RequestModuleInterface<IRestartModule>();
372 if (restartModule != null)
373 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
374 }
375 responseData["success"] = true;
287 } 376 }
288 catch (Exception e) 377 catch (Exception e)
289 { 378 {
@@ -320,6 +409,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
320 m_log.Info("[RADMIN]: Alert request complete"); 409 m_log.Info("[RADMIN]: Alert request complete");
321 } 410 }
322 411
412 public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
413 {
414 Hashtable responseData = (Hashtable)response.Value;
415
416 m_log.Info("[RADMIN]: Dialog request started");
417
418 Hashtable requestData = (Hashtable)request.Params[0];
419
420 string message = (string)requestData["message"];
421 string fromuuid = (string)requestData["from"];
422 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
423
424 responseData["accepted"] = true;
425 responseData["success"] = true;
426
427 m_application.SceneManager.ForEachScene(
428 delegate(Scene scene)
429 {
430 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
431 if (dialogModule != null)
432 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
433 });
434
435 m_log.Info("[RADMIN]: Dialog request complete");
436 }
437
323 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 438 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
324 { 439 {
325 m_log.Info("[RADMIN]: Load height maps request started"); 440 m_log.Info("[RADMIN]: Load height maps request started");
@@ -423,13 +538,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
423 message = "Region is going down now."; 538 message = "Region is going down now.";
424 } 539 }
425 540
426 m_application.SceneManager.ForEachScene( 541 if (requestData.ContainsKey("noticetype")
542 && ((string) requestData["noticetype"] == "dialog"))
543 {
544 m_application.SceneManager.ForEachScene(
545
427 delegate(Scene scene) 546 delegate(Scene scene)
547 {
548 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
549 if (dialogModule != null)
550 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
551 });
552 }
553 else
554 {
555 if (!requestData.ContainsKey("noticetype")
556 || ((string)requestData["noticetype"] != "none"))
557 {
558 m_application.SceneManager.ForEachScene(
559 delegate(Scene scene)
428 { 560 {
429 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 561 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
430 if (dialogModule != null) 562 if (dialogModule != null)
431 dialogModule.SendGeneralAlert(message); 563 dialogModule.SendGeneralAlert(message);
432 }); 564 });
565 }
566 }
433 567
434 // Perform shutdown 568 // Perform shutdown
435 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 569 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -1488,7 +1622,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1488 } 1622 }
1489 1623
1490 IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); 1624 IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
1491 Dictionary<string, object> archiveOptions = new Dictionary<string,object>(); 1625 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
1492 if (mergeOar) archiveOptions.Add("merge", null); 1626 if (mergeOar) archiveOptions.Add("merge", null);
1493 if (skipAssets) archiveOptions.Add("skipAssets", null); 1627 if (skipAssets) archiveOptions.Add("skipAssets", null);
1494 if (archiver != null) 1628 if (archiver != null)
@@ -1748,21 +1882,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1748 1882
1749 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1883 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1750 { 1884 {
1751 m_log.Info("[RADMIN]: Received Query XML Administrator Request");
1752
1753 Hashtable responseData = (Hashtable)response.Value; 1885 Hashtable responseData = (Hashtable)response.Value;
1754 Hashtable requestData = (Hashtable)request.Params[0]; 1886 Hashtable requestData = (Hashtable)request.Params[0];
1755 1887
1888 int flags = 0;
1889 string text = String.Empty;
1890 int health = 0;
1891 responseData["success"] = true;
1892
1756 CheckRegionParams(requestData, responseData); 1893 CheckRegionParams(requestData, responseData);
1757 1894
1758 Scene scene = null; 1895 Scene scene = null;
1759 GetSceneFromRegionParams(requestData, responseData, out scene); 1896 try
1760 1897 {
1761 int health = scene.GetHealth(); 1898 GetSceneFromRegionParams(requestData, responseData, out scene);
1762 responseData["health"] = health; 1899 health = scene.GetHealth(out flags, out text);
1900 }
1901 catch (Exception e)
1902 {
1903 responseData["error"] = null;
1904 }
1763 1905
1764 responseData["success"] = true; 1906 responseData["success"] = true;
1765 m_log.Info("[RADMIN]: Query XML Administrator Request complete"); 1907 responseData["health"] = health;
1908 responseData["flags"] = flags;
1909 responseData["message"] = text;
1766 } 1910 }
1767 1911
1768 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1912 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
@@ -2071,7 +2215,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2071 { 2215 {
2072 Hashtable requestData = (Hashtable)request.Params[0]; 2216 Hashtable requestData = (Hashtable)request.Params[0];
2073 Hashtable responseData = (Hashtable)response.Value; 2217 Hashtable responseData = (Hashtable)response.Value;
2074
2075 string musicURL = string.Empty; 2218 string musicURL = string.Empty;
2076 UUID groupID = UUID.Zero; 2219 UUID groupID = UUID.Zero;
2077 uint flags = 0; 2220 uint flags = 0;
@@ -2081,41 +2224,129 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2081 set_group = UUID.TryParse(requestData["group"].ToString(), out groupID); 2224 set_group = UUID.TryParse(requestData["group"].ToString(), out groupID);
2082 if (requestData.Contains("music") && requestData["music"] != null) 2225 if (requestData.Contains("music") && requestData["music"] != null)
2083 { 2226 {
2227
2084 musicURL = requestData["music"].ToString(); 2228 musicURL = requestData["music"].ToString();
2085 set_music = true; 2229 set_music = true;
2086 } 2230 }
2231
2087 if (requestData.Contains("flags") && requestData["flags"] != null) 2232 if (requestData.Contains("flags") && requestData["flags"] != null)
2088 set_flags = UInt32.TryParse(requestData["flags"].ToString(), out flags); 2233 set_flags = UInt32.TryParse(requestData["flags"].ToString(), out flags);
2089 2234
2090 m_log.InfoFormat("[RADMIN]: Received Reset Land Request group={0} musicURL={1} flags={2}", 2235 m_log.InfoFormat("[RADMIN]: Received Reset Land Request group={0} musicURL={1} flags={2}",
2091 (set_group ? groupID.ToString() : "unchanged"), 2236 (set_group ? groupID.ToString() : "unchanged"),
2092 (set_music ? musicURL : "unchanged"), 2237 (set_music ? musicURL : "unchanged"),
2093 (set_flags ? flags.ToString() : "unchanged")); 2238 (set_flags ? flags.ToString() : "unchanged"));
2094 2239
2095 m_application.SceneManager.ForEachScene(delegate(Scene s) 2240 m_application.SceneManager.ForEachScene(delegate (Scene s)
2096 { 2241 {
2097 List<ILandObject> parcels = s.LandChannel.AllParcels(); 2242 List<ILandObject> parcels = s.LandChannel.AllParcels();
2098 foreach (ILandObject p in parcels) 2243 foreach (ILandObject p in parcels)
2099 { 2244 {
2100 if (set_music) 2245 if (set_music)
2101 p.LandData.MusicURL = musicURL; 2246 p.LandData.MusicURL = musicURL;
2102
2103 if (set_group) 2247 if (set_group)
2104 p.LandData.GroupID = groupID; 2248 p.LandData.GroupID = groupID;
2105
2106 if (set_flags) 2249 if (set_flags)
2107 p.LandData.Flags = flags; 2250 p.LandData.Flags = flags;
2108
2109 s.LandChannel.UpdateLandObject(p.LandData.LocalID, p.LandData); 2251 s.LandChannel.UpdateLandObject(p.LandData.LocalID, p.LandData);
2110 } 2252 }
2111 } 2253 }
2112 ); 2254 );
2255 responseData["success"] = true;
2256 m_log.Info("[RADMIN]: Reset Land Request complete");
2257 }
2258
2259 private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2260 {
2261 m_log.Info("[RADMIN]: Received Refresh Search Request");
2262
2263 Hashtable responseData = (Hashtable)response.Value;
2264 Hashtable requestData = (Hashtable)request.Params[0];
2265
2266 CheckRegionParams(requestData, responseData);
2267
2268 Scene scene = null;
2269 GetSceneFromRegionParams(requestData, responseData, out scene);
2270
2271 ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>();
2272 if (searchModule != null)
2273 {
2274 searchModule.Refresh();
2275 responseData["success"] = true;
2276 }
2277 else
2278 {
2279 responseData["success"] = false;
2280 }
2281
2282 m_log.Info("[RADMIN]: Refresh Search Request complete");
2283 }
2284
2285 private void XmlRpcRefreshMap(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2286 {
2287 m_log.Info("[RADMIN]: Received Refresh Map Request");
2288
2289 Hashtable responseData = (Hashtable)response.Value;
2290 Hashtable requestData = (Hashtable)request.Params[0];
2291
2292 CheckRegionParams(requestData, responseData);
2293
2294 Scene scene = null;
2295 GetSceneFromRegionParams(requestData, responseData, out scene);
2296
2297 IMapImageUploadModule mapTileModule = scene.RequestModuleInterface<IMapImageUploadModule>();
2298 if (mapTileModule != null)
2299 {
2300 Util.FireAndForget((x) =>
2301 {
2302 mapTileModule.UploadMapTile(scene);
2303 });
2304 responseData["success"] = true;
2305 }
2306 else
2307 {
2308 responseData["success"] = false;
2309 }
2310
2311 m_log.Info("[RADMIN]: Refresh Map Request complete");
2312 }
2313
2314 private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2315 {
2316 m_log.Info("[RADMIN]: Received Get OpenSim Version Request");
2317
2318 Hashtable responseData = (Hashtable)response.Value;
2113 2319
2320 responseData["version"] = m_openSimVersion;
2114 responseData["success"] = true; 2321 responseData["success"] = true;
2115 2322
2116 m_log.Info("[RADMIN]: Reset Land Request complete"); 2323 m_log.Info("[RADMIN]: Get OpenSim Version Request complete");
2117 } 2324 }
2118 2325
2326 private void XmlRpcGetAgentCount(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2327 {
2328 m_log.Info("[RADMIN]: Received Get Agent Count Request");
2329
2330 Hashtable responseData = (Hashtable)response.Value;
2331 Hashtable requestData = (Hashtable)request.Params[0];
2332
2333 CheckRegionParams(requestData, responseData);
2334
2335 Scene scene = null;
2336 GetSceneFromRegionParams(requestData, responseData, out scene);
2337
2338 if (scene == null)
2339 {
2340 responseData["success"] = false;
2341 }
2342 else
2343 {
2344 responseData["count"] = scene.GetRootAgentCount();
2345 responseData["success"] = true;
2346 }
2347
2348 m_log.Info("[RADMIN]: Get Agent Count Request complete");
2349 }
2119 2350
2120 /// <summary> 2351 /// <summary>
2121 /// Parse a float with the given parameter name from a request data hash table. 2352 /// Parse a float with the given parameter name from a request data hash table.
@@ -2822,7 +3053,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2822 /// </summary> 3053 /// </summary>
2823 private void ApplyNextOwnerPermissions(InventoryItemBase item) 3054 private void ApplyNextOwnerPermissions(InventoryItemBase item)
2824 { 3055 {
2825 if (item.InvType == (int)InventoryType.Object) 3056 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
2826 { 3057 {
2827 uint perms = item.CurrentPermissions; 3058 uint perms = item.CurrentPermissions;
2828 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); 3059 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);