diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 212 |
1 files changed, 196 insertions, 16 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a75d10d..f19e391 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -50,6 +50,7 @@ using OpenSim.Region.Framework.Scenes; | |||
50 | using OpenSim.Services.Interfaces; | 50 | using OpenSim.Services.Interfaces; |
51 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 51 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
52 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 52 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
53 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
53 | 54 | ||
54 | namespace OpenSim.ApplicationPlugins.RemoteController | 55 | namespace OpenSim.ApplicationPlugins.RemoteController |
55 | { | 56 | { |
@@ -70,6 +71,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
70 | 71 | ||
71 | private string m_name = "RemoteAdminPlugin"; | 72 | private string m_name = "RemoteAdminPlugin"; |
72 | private string m_version = "0.0"; | 73 | private string m_version = "0.0"; |
74 | private string m_openSimVersion; | ||
73 | 75 | ||
74 | public string Version | 76 | public string Version |
75 | { | 77 | { |
@@ -89,6 +91,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
89 | 91 | ||
90 | public void Initialise(OpenSimBase openSim) | 92 | public void Initialise(OpenSimBase openSim) |
91 | { | 93 | { |
94 | m_openSimVersion = openSim.GetVersionText(); | ||
95 | |||
92 | m_configSource = openSim.ConfigSource.Source; | 96 | m_configSource = openSim.ConfigSource.Source; |
93 | try | 97 | try |
94 | { | 98 | { |
@@ -131,6 +135,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
131 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); | 135 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); |
132 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); | 136 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); |
133 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); | 137 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); |
138 | availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod); | ||
134 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); | 139 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); |
135 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); | 140 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); |
136 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); | 141 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); |
@@ -156,6 +161,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
156 | availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); | 161 | availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); |
157 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); | 162 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); |
158 | 163 | ||
164 | // Misc | ||
165 | availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch); | ||
166 | availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion); | ||
167 | |||
159 | // Either enable full remote functionality or just selected features | 168 | // Either enable full remote functionality or just selected features |
160 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 169 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
161 | 170 | ||
@@ -257,23 +266,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
257 | { | 266 | { |
258 | m_log.Info("[RADMIN]: Request to restart Region."); | 267 | m_log.Info("[RADMIN]: Request to restart Region."); |
259 | 268 | ||
260 | CheckRegionParams(requestData, responseData); | ||
261 | |||
262 | Scene rebootedScene = null; | 269 | Scene rebootedScene = null; |
263 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | 270 | bool restartAll = false; |
271 | |||
272 | IConfig startupConfig = m_configSource.Configs["Startup"]; | ||
273 | if (startupConfig != null) | ||
274 | { | ||
275 | if (startupConfig.GetBoolean("InworldRestartShutsDown", false)) | ||
276 | { | ||
277 | rebootedScene = m_application.SceneManager.CurrentOrFirstScene; | ||
278 | restartAll = true; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | if (rebootedScene == null) | ||
283 | { | ||
284 | CheckRegionParams(requestData, responseData); | ||
285 | |||
286 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | ||
287 | } | ||
288 | |||
289 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | ||
264 | 290 | ||
265 | responseData["success"] = false; | 291 | responseData["success"] = false; |
266 | responseData["accepted"] = true; | 292 | responseData["accepted"] = true; |
267 | responseData["rebooting"] = true; | 293 | responseData["rebooting"] = true; |
268 | 294 | ||
269 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 295 | string message; |
270 | if (restartModule != null) | 296 | List<int> times = new List<int>(); |
297 | |||
298 | if (requestData.ContainsKey("alerts")) | ||
271 | { | 299 | { |
272 | List<int> times = new List<int> { 30, 15 }; | 300 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); |
301 | if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1) | ||
302 | { | ||
303 | if (restartModule != null) | ||
304 | { | ||
305 | message = "Restart has been cancelled"; | ||
273 | 306 | ||
274 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 307 | if (requestData.ContainsKey("message")) |
275 | responseData["success"] = true; | 308 | message = requestData["message"].ToString(); |
309 | |||
310 | restartModule.AbortRestart(message); | ||
311 | |||
312 | responseData["success"] = true; | ||
313 | responseData["rebooting"] = false; | ||
314 | |||
315 | return; | ||
316 | } | ||
317 | } | ||
318 | foreach (string a in alertTimes) | ||
319 | times.Add(Convert.ToInt32(a)); | ||
276 | } | 320 | } |
321 | else | ||
322 | { | ||
323 | int timeout = 30; | ||
324 | if (requestData.ContainsKey("milliseconds")) | ||
325 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
326 | while (timeout > 0) | ||
327 | { | ||
328 | times.Add(timeout); | ||
329 | if (timeout > 300) | ||
330 | timeout -= 120; | ||
331 | else if (timeout > 30) | ||
332 | timeout -= 30; | ||
333 | else | ||
334 | timeout -= 15; | ||
335 | } | ||
336 | } | ||
337 | |||
338 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
339 | |||
340 | if (requestData.ContainsKey("message")) | ||
341 | message = requestData["message"].ToString(); | ||
342 | |||
343 | bool notice = true; | ||
344 | if (requestData.ContainsKey("noticetype") | ||
345 | && ((string)requestData["noticetype"] == "dialog")) | ||
346 | { | ||
347 | notice = false; | ||
348 | } | ||
349 | |||
350 | List<Scene> restartList; | ||
351 | |||
352 | if (restartAll) | ||
353 | restartList = m_application.SceneManager.Scenes; | ||
354 | else | ||
355 | restartList = new List<Scene>() { rebootedScene }; | ||
356 | |||
357 | foreach (Scene s in m_application.SceneManager.Scenes) | ||
358 | { | ||
359 | restartModule = s.RequestModuleInterface<IRestartModule>(); | ||
360 | if (restartModule != null) | ||
361 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); | ||
362 | } | ||
363 | responseData["success"] = true; | ||
277 | } | 364 | } |
278 | catch (Exception e) | 365 | catch (Exception e) |
279 | { | 366 | { |
@@ -310,6 +397,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
310 | m_log.Info("[RADMIN]: Alert request complete"); | 397 | m_log.Info("[RADMIN]: Alert request complete"); |
311 | } | 398 | } |
312 | 399 | ||
400 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
401 | { | ||
402 | Hashtable responseData = (Hashtable)response.Value; | ||
403 | |||
404 | m_log.Info("[RADMIN]: Dialog request started"); | ||
405 | |||
406 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
407 | |||
408 | string message = (string)requestData["message"]; | ||
409 | string fromuuid = (string)requestData["from"]; | ||
410 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
411 | |||
412 | responseData["accepted"] = true; | ||
413 | responseData["success"] = true; | ||
414 | |||
415 | m_application.SceneManager.ForEachScene( | ||
416 | delegate(Scene scene) | ||
417 | { | ||
418 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
419 | if (dialogModule != null) | ||
420 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
421 | }); | ||
422 | |||
423 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
424 | } | ||
425 | |||
313 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 426 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
314 | { | 427 | { |
315 | m_log.Info("[RADMIN]: Load height maps request started"); | 428 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -398,13 +511,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
398 | message = "Region is going down now."; | 511 | message = "Region is going down now."; |
399 | } | 512 | } |
400 | 513 | ||
401 | m_application.SceneManager.ForEachScene( | 514 | if (requestData.ContainsKey("noticetype") |
515 | && ((string) requestData["noticetype"] == "dialog")) | ||
516 | { | ||
517 | m_application.SceneManager.ForEachScene( | ||
518 | |||
402 | delegate(Scene scene) | 519 | delegate(Scene scene) |
520 | { | ||
521 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
522 | if (dialogModule != null) | ||
523 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
524 | }); | ||
525 | } | ||
526 | else | ||
527 | { | ||
528 | if (!requestData.ContainsKey("noticetype") | ||
529 | || ((string)requestData["noticetype"] != "none")) | ||
530 | { | ||
531 | m_application.SceneManager.ForEachScene( | ||
532 | delegate(Scene scene) | ||
403 | { | 533 | { |
404 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 534 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
405 | if (dialogModule != null) | 535 | if (dialogModule != null) |
406 | dialogModule.SendGeneralAlert(message); | 536 | dialogModule.SendGeneralAlert(message); |
407 | }); | 537 | }); |
538 | } | ||
539 | } | ||
408 | 540 | ||
409 | // Perform shutdown | 541 | // Perform shutdown |
410 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 542 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1576,21 +1708,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1576 | 1708 | ||
1577 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1709 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1578 | { | 1710 | { |
1579 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1580 | |||
1581 | Hashtable responseData = (Hashtable)response.Value; | 1711 | Hashtable responseData = (Hashtable)response.Value; |
1582 | Hashtable requestData = (Hashtable)request.Params[0]; | 1712 | Hashtable requestData = (Hashtable)request.Params[0]; |
1583 | 1713 | ||
1714 | int flags = 0; | ||
1715 | string text = String.Empty; | ||
1716 | int health = 0; | ||
1717 | responseData["success"] = true; | ||
1718 | |||
1584 | CheckRegionParams(requestData, responseData); | 1719 | CheckRegionParams(requestData, responseData); |
1585 | 1720 | ||
1586 | Scene scene = null; | 1721 | Scene scene = null; |
1587 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1722 | try |
1588 | 1723 | { | |
1589 | int health = scene.GetHealth(); | 1724 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1590 | responseData["health"] = health; | 1725 | health = scene.GetHealth(out flags, out text); |
1726 | } | ||
1727 | catch (Exception e) | ||
1728 | { | ||
1729 | responseData["error"] = null; | ||
1730 | } | ||
1591 | 1731 | ||
1592 | responseData["success"] = true; | 1732 | responseData["success"] = true; |
1593 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1733 | responseData["health"] = health; |
1734 | responseData["flags"] = flags; | ||
1735 | responseData["message"] = text; | ||
1594 | } | 1736 | } |
1595 | 1737 | ||
1596 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1738 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
@@ -1814,6 +1956,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1814 | responseData["success"] = true; | 1956 | responseData["success"] = true; |
1815 | } | 1957 | } |
1816 | 1958 | ||
1959 | private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1960 | { | ||
1961 | m_log.Info("[RADMIN]: Received Refresh Search Request"); | ||
1962 | |||
1963 | Hashtable responseData = (Hashtable)response.Value; | ||
1964 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1965 | |||
1966 | CheckRegionParams(requestData, responseData); | ||
1967 | |||
1968 | Scene scene = null; | ||
1969 | GetSceneFromRegionParams(requestData, responseData, out scene); | ||
1970 | |||
1971 | ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>(); | ||
1972 | if (searchModule != null) | ||
1973 | { | ||
1974 | searchModule.Refresh(); | ||
1975 | responseData["success"] = true; | ||
1976 | } | ||
1977 | else | ||
1978 | { | ||
1979 | responseData["success"] = false; | ||
1980 | } | ||
1981 | |||
1982 | m_log.Info("[RADMIN]: Refresh Search Request complete"); | ||
1983 | } | ||
1984 | |||
1985 | private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1986 | { | ||
1987 | m_log.Info("[RADMIN]: Received Get OpenSim Version Request"); | ||
1988 | |||
1989 | Hashtable responseData = (Hashtable)response.Value; | ||
1990 | |||
1991 | responseData["version"] = m_openSimVersion; | ||
1992 | responseData["success"] = true; | ||
1993 | |||
1994 | m_log.Info("[RADMIN]: Get OpenSim Version Request complete"); | ||
1995 | } | ||
1996 | |||
1817 | /// <summary> | 1997 | /// <summary> |
1818 | /// Parse a float with the given parameter name from a request data hash table. | 1998 | /// Parse a float with the given parameter name from a request data hash table. |
1819 | /// </summary> | 1999 | /// </summary> |