From 2111c66f89033b3426ceedba6a3ec6ed8fb3363f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 05:40:23 +0100 Subject: Graft the REST console onto the message server as well. What a dirty hack! Works the same as the others. --- OpenSim/Framework/MessageServerConfig.cs | 16 ++++++- OpenSim/Grid/MessagingServer/Main.cs | 79 ++++++++++++++++++++++++-------- prebuild.xml | 1 + 3 files changed, 75 insertions(+), 21 deletions(-) diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs index d0ceebc..61e5ea7 100644 --- a/OpenSim/Framework/MessageServerConfig.cs +++ b/OpenSim/Framework/MessageServerConfig.cs @@ -46,6 +46,8 @@ namespace OpenSim.Framework public string UserRecvKey = String.Empty; public string UserSendKey = String.Empty; public string UserServerURL = String.Empty; + public string ConsoleUser = String.Empty; + public string ConsolePass = String.Empty; public MessageServerConfig(string description, string filename) { @@ -88,6 +90,12 @@ namespace OpenSim.Framework "Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false); m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "My Published IP Address", "127.0.0.1", false); + m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access user name [Default: disabled]", "0", false); + + m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access password [Default: disabled]", "0", false); + } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -130,9 +138,15 @@ namespace OpenSim.Framework case "published_ip": MessageServerIP = (string) configuration_result; break; + case "console_user": + ConsoleUser = (string)configuration_result; + break; + case "console_pass": + ConsolePass = (string)configuration_result; + break; } return true; } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index dcefeea..654e770 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using log4net; +using Nini.Config; using log4net.Config; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -56,8 +57,22 @@ namespace OpenSim.Grid.MessagingServer // private UUID m_lastCreatedUser = UUID.Random(); + protected static string m_consoleType = "local"; + protected static IConfigSource m_config = null; + public static void Main(string[] args) { + ArgvConfigSource argvSource = new ArgvConfigSource(args); + argvSource.AddSwitch("Startup", "console", "c"); + + IConfig startupConfig = argvSource.Configs["Startup"]; + if (startupConfig != null) + { + m_consoleType = startupConfig.GetString("console", "local"); + } + + m_config = argvSource; + XmlConfigurator.Configure(); m_log.Info("[SERVER]: Launching MessagingServer..."); @@ -70,7 +85,18 @@ namespace OpenSim.Grid.MessagingServer public OpenMessage_Main() { - m_console = new LocalConsole("Messaging"); + switch (m_consoleType) + { + case "rest": + m_console = new RemoteConsole("Messaging"); + break; + case "basic": + m_console = new CommandConsole("Messaging"); + break; + default: + m_console = new LocalConsole("Messaging"); + break; + } MainConsole.Instance = m_console; } @@ -88,20 +114,33 @@ namespace OpenSim.Grid.MessagingServer { if (m_userServerModule.registerWithUserServer()) { - m_log.Info("[SERVER]: Starting HTTP process"); - m_httpServer = new BaseHttpServer(Cfg.HttpPort); - - m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); - m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); - m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); - m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); - m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); - m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); - - m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); - m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); - - m_httpServer.Start(); + if (m_httpServer == null) + { + m_log.Info("[SERVER]: Starting HTTP process"); + m_httpServer = new BaseHttpServer(Cfg.HttpPort); + + if (m_console is RemoteConsole) + { + RemoteConsole c = (RemoteConsole)m_console; + c.SetServer(m_httpServer); + IConfig netConfig = m_config.AddConfig("Network"); + netConfig.Set("ConsoleUser", Cfg.ConsoleUser); + netConfig.Set("ConsolePass", Cfg.ConsolePass); + c.ReadConfig(m_config); + } + + m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); + m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); + m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); + m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); + m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); + m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); + + m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); + m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); + + m_httpServer.Start(); + } m_log.Info("[SERVER]: Userserver registration was successful"); } else @@ -114,12 +153,12 @@ namespace OpenSim.Grid.MessagingServer private void deregisterFromUserServer() { m_userServerModule.deregisterWithUserServer(); - if (m_httpServer != null) - { +// if (m_httpServer != null) +// { // try a completely fresh registration, with fresh handlers, too - m_httpServer.Stop(); - m_httpServer = null; - } +// m_httpServer.Stop(); +// m_httpServer = null; +// } m_console.Output("[SERVER]: Deregistered from userserver."); } diff --git a/prebuild.xml b/prebuild.xml index 216a02e..ebe5c62 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1281,6 +1281,7 @@ + -- cgit v1.1