diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 211 |
1 files changed, 195 insertions, 16 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 354f587..5453420 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -73,6 +73,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
73 | 73 | ||
74 | private string m_name = "RemoteAdminPlugin"; | 74 | private string m_name = "RemoteAdminPlugin"; |
75 | private string m_version = "0.0"; | 75 | private string m_version = "0.0"; |
76 | private string m_openSimVersion; | ||
76 | 77 | ||
77 | public string Version | 78 | public string Version |
78 | { | 79 | { |
@@ -92,6 +93,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
92 | 93 | ||
93 | public void Initialise(OpenSimBase openSim) | 94 | public void Initialise(OpenSimBase openSim) |
94 | { | 95 | { |
96 | m_openSimVersion = openSim.GetVersionText(); | ||
97 | |||
95 | m_configSource = openSim.ConfigSource.Source; | 98 | m_configSource = openSim.ConfigSource.Source; |
96 | try | 99 | try |
97 | { | 100 | { |
@@ -134,6 +137,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
134 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); | 137 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); |
135 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); | 138 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); |
136 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); | 139 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); |
140 | availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod); | ||
137 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); | 141 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); |
138 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); | 142 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); |
139 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); | 143 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); |
@@ -162,6 +166,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
162 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); | 166 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); |
163 | availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload); | 167 | availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload); |
164 | 168 | ||
169 | // Misc | ||
170 | availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch); | ||
171 | availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion); | ||
172 | |||
165 | // Either enable full remote functionality or just selected features | 173 | // Either enable full remote functionality or just selected features |
166 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 174 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
167 | 175 | ||
@@ -263,23 +271,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
263 | { | 271 | { |
264 | m_log.Info("[RADMIN]: Request to restart Region."); | 272 | m_log.Info("[RADMIN]: Request to restart Region."); |
265 | 273 | ||
266 | CheckRegionParams(requestData, responseData); | ||
267 | |||
268 | Scene rebootedScene = null; | 274 | Scene rebootedScene = null; |
269 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | 275 | bool restartAll = false; |
276 | |||
277 | IConfig startupConfig = m_configSource.Configs["Startup"]; | ||
278 | if (startupConfig != null) | ||
279 | { | ||
280 | if (startupConfig.GetBoolean("InworldRestartShutsDown", false)) | ||
281 | { | ||
282 | rebootedScene = m_application.SceneManager.CurrentOrFirstScene; | ||
283 | restartAll = true; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | if (rebootedScene == null) | ||
288 | { | ||
289 | CheckRegionParams(requestData, responseData); | ||
290 | |||
291 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | ||
292 | } | ||
293 | |||
294 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | ||
270 | 295 | ||
271 | responseData["success"] = false; | 296 | responseData["success"] = false; |
272 | responseData["accepted"] = true; | 297 | responseData["accepted"] = true; |
273 | responseData["rebooting"] = true; | 298 | responseData["rebooting"] = true; |
274 | 299 | ||
275 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 300 | string message; |
276 | if (restartModule != null) | 301 | List<int> times = new List<int>(); |
302 | |||
303 | if (requestData.ContainsKey("alerts")) | ||
277 | { | 304 | { |
278 | List<int> times = new List<int> { 30, 15 }; | 305 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); |
306 | if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1) | ||
307 | { | ||
308 | if (restartModule != null) | ||
309 | { | ||
310 | message = "Restart has been cancelled"; | ||
279 | 311 | ||
280 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 312 | if (requestData.ContainsKey("message")) |
281 | responseData["success"] = true; | 313 | message = requestData["message"].ToString(); |
314 | |||
315 | restartModule.AbortRestart(message); | ||
316 | |||
317 | responseData["success"] = true; | ||
318 | responseData["rebooting"] = false; | ||
319 | |||
320 | return; | ||
321 | } | ||
322 | } | ||
323 | foreach (string a in alertTimes) | ||
324 | times.Add(Convert.ToInt32(a)); | ||
282 | } | 325 | } |
326 | else | ||
327 | { | ||
328 | int timeout = 30; | ||
329 | if (requestData.ContainsKey("milliseconds")) | ||
330 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
331 | while (timeout > 0) | ||
332 | { | ||
333 | times.Add(timeout); | ||
334 | if (timeout > 300) | ||
335 | timeout -= 120; | ||
336 | else if (timeout > 30) | ||
337 | timeout -= 30; | ||
338 | else | ||
339 | timeout -= 15; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
344 | |||
345 | if (requestData.ContainsKey("message")) | ||
346 | message = requestData["message"].ToString(); | ||
347 | |||
348 | bool notice = true; | ||
349 | if (requestData.ContainsKey("noticetype") | ||
350 | && ((string)requestData["noticetype"] == "dialog")) | ||
351 | { | ||
352 | notice = false; | ||
353 | } | ||
354 | |||
355 | List<Scene> restartList; | ||
356 | |||
357 | if (restartAll) | ||
358 | restartList = m_application.SceneManager.Scenes; | ||
359 | else | ||
360 | restartList = new List<Scene>() { rebootedScene }; | ||
361 | |||
362 | foreach (Scene s in m_application.SceneManager.Scenes) | ||
363 | { | ||
364 | restartModule = s.RequestModuleInterface<IRestartModule>(); | ||
365 | if (restartModule != null) | ||
366 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); | ||
367 | } | ||
368 | responseData["success"] = true; | ||
283 | } | 369 | } |
284 | catch (Exception e) | 370 | catch (Exception e) |
285 | { | 371 | { |
@@ -316,6 +402,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
316 | m_log.Info("[RADMIN]: Alert request complete"); | 402 | m_log.Info("[RADMIN]: Alert request complete"); |
317 | } | 403 | } |
318 | 404 | ||
405 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
406 | { | ||
407 | Hashtable responseData = (Hashtable)response.Value; | ||
408 | |||
409 | m_log.Info("[RADMIN]: Dialog request started"); | ||
410 | |||
411 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
412 | |||
413 | string message = (string)requestData["message"]; | ||
414 | string fromuuid = (string)requestData["from"]; | ||
415 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
416 | |||
417 | responseData["accepted"] = true; | ||
418 | responseData["success"] = true; | ||
419 | |||
420 | m_application.SceneManager.ForEachScene( | ||
421 | delegate(Scene scene) | ||
422 | { | ||
423 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
424 | if (dialogModule != null) | ||
425 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
426 | }); | ||
427 | |||
428 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
429 | } | ||
430 | |||
319 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 431 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
320 | { | 432 | { |
321 | m_log.Info("[RADMIN]: Load height maps request started"); | 433 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -419,13 +531,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
419 | message = "Region is going down now."; | 531 | message = "Region is going down now."; |
420 | } | 532 | } |
421 | 533 | ||
422 | m_application.SceneManager.ForEachScene( | 534 | if (requestData.ContainsKey("noticetype") |
535 | && ((string) requestData["noticetype"] == "dialog")) | ||
536 | { | ||
537 | m_application.SceneManager.ForEachScene( | ||
538 | |||
423 | delegate(Scene scene) | 539 | delegate(Scene scene) |
540 | { | ||
541 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
542 | if (dialogModule != null) | ||
543 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
544 | }); | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | if (!requestData.ContainsKey("noticetype") | ||
549 | || ((string)requestData["noticetype"] != "none")) | ||
550 | { | ||
551 | m_application.SceneManager.ForEachScene( | ||
552 | delegate(Scene scene) | ||
424 | { | 553 | { |
425 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 554 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
426 | if (dialogModule != null) | 555 | if (dialogModule != null) |
427 | dialogModule.SendGeneralAlert(message); | 556 | dialogModule.SendGeneralAlert(message); |
428 | }); | 557 | }); |
558 | } | ||
559 | } | ||
429 | 560 | ||
430 | // Perform shutdown | 561 | // Perform shutdown |
431 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 562 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1741,21 +1872,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1741 | 1872 | ||
1742 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1873 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1743 | { | 1874 | { |
1744 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1745 | |||
1746 | Hashtable responseData = (Hashtable)response.Value; | 1875 | Hashtable responseData = (Hashtable)response.Value; |
1747 | Hashtable requestData = (Hashtable)request.Params[0]; | 1876 | Hashtable requestData = (Hashtable)request.Params[0]; |
1748 | 1877 | ||
1878 | int flags = 0; | ||
1879 | string text = String.Empty; | ||
1880 | int health = 0; | ||
1881 | responseData["success"] = true; | ||
1882 | |||
1749 | CheckRegionParams(requestData, responseData); | 1883 | CheckRegionParams(requestData, responseData); |
1750 | 1884 | ||
1751 | Scene scene = null; | 1885 | Scene scene = null; |
1752 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1886 | try |
1753 | 1887 | { | |
1754 | int health = scene.GetHealth(); | 1888 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1755 | responseData["health"] = health; | 1889 | health = scene.GetHealth(out flags, out text); |
1890 | } | ||
1891 | catch (Exception e) | ||
1892 | { | ||
1893 | responseData["error"] = null; | ||
1894 | } | ||
1756 | 1895 | ||
1757 | responseData["success"] = true; | 1896 | responseData["success"] = true; |
1758 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1897 | responseData["health"] = health; |
1898 | responseData["flags"] = flags; | ||
1899 | responseData["message"] = text; | ||
1759 | } | 1900 | } |
1760 | 1901 | ||
1761 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1902 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
@@ -2060,6 +2201,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2060 | responseData["success"] = true; | 2201 | responseData["success"] = true; |
2061 | } | 2202 | } |
2062 | 2203 | ||
2204 | private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2205 | { | ||
2206 | m_log.Info("[RADMIN]: Received Refresh Search Request"); | ||
2207 | |||
2208 | Hashtable responseData = (Hashtable)response.Value; | ||
2209 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2210 | |||
2211 | CheckRegionParams(requestData, responseData); | ||
2212 | |||
2213 | Scene scene = null; | ||
2214 | GetSceneFromRegionParams(requestData, responseData, out scene); | ||
2215 | |||
2216 | ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>(); | ||
2217 | if (searchModule != null) | ||
2218 | { | ||
2219 | searchModule.Refresh(); | ||
2220 | responseData["success"] = true; | ||
2221 | } | ||
2222 | else | ||
2223 | { | ||
2224 | responseData["success"] = false; | ||
2225 | } | ||
2226 | |||
2227 | m_log.Info("[RADMIN]: Refresh Search Request complete"); | ||
2228 | } | ||
2229 | |||
2230 | private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2231 | { | ||
2232 | m_log.Info("[RADMIN]: Received Get OpenSim Version Request"); | ||
2233 | |||
2234 | Hashtable responseData = (Hashtable)response.Value; | ||
2235 | |||
2236 | responseData["version"] = m_openSimVersion; | ||
2237 | responseData["success"] = true; | ||
2238 | |||
2239 | m_log.Info("[RADMIN]: Get OpenSim Version Request complete"); | ||
2240 | } | ||
2241 | |||
2063 | /// <summary> | 2242 | /// <summary> |
2064 | /// Parse a float with the given parameter name from a request data hash table. | 2243 | /// Parse a float with the given parameter name from a request data hash table. |
2065 | /// </summary> | 2244 | /// </summary> |