Graft the REST console onto the message server as well. What a dirty hack!

Works the same as the others.
arthursv
Melanie 2009-08-19 05:40:23 +01:00
parent dd0234f500
commit 2111c66f89
3 changed files with 72 additions and 18 deletions

View File

@ -46,6 +46,8 @@ namespace OpenSim.Framework
public string UserRecvKey = String.Empty; public string UserRecvKey = String.Empty;
public string UserSendKey = String.Empty; public string UserSendKey = String.Empty;
public string UserServerURL = String.Empty; public string UserServerURL = String.Empty;
public string ConsoleUser = String.Empty;
public string ConsolePass = String.Empty;
public MessageServerConfig(string description, string filename) public MessageServerConfig(string description, string filename)
{ {
@ -88,6 +90,12 @@ namespace OpenSim.Framework
"Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false); "Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false);
m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING, m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"My Published IP Address", "127.0.0.1", false); "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) public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -130,6 +138,12 @@ namespace OpenSim.Framework
case "published_ip": case "published_ip":
MessageServerIP = (string) configuration_result; MessageServerIP = (string) configuration_result;
break; break;
case "console_user":
ConsoleUser = (string)configuration_result;
break;
case "console_pass":
ConsolePass = (string)configuration_result;
break;
} }
return true; return true;

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
using Nini.Config;
using log4net.Config; using log4net.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
@ -56,8 +57,22 @@ namespace OpenSim.Grid.MessagingServer
// private UUID m_lastCreatedUser = UUID.Random(); // private UUID m_lastCreatedUser = UUID.Random();
protected static string m_consoleType = "local";
protected static IConfigSource m_config = null;
public static void Main(string[] args) 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(); XmlConfigurator.Configure();
m_log.Info("[SERVER]: Launching MessagingServer..."); m_log.Info("[SERVER]: Launching MessagingServer...");
@ -70,7 +85,18 @@ namespace OpenSim.Grid.MessagingServer
public OpenMessage_Main() public OpenMessage_Main()
{ {
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"); m_console = new LocalConsole("Messaging");
break;
}
MainConsole.Instance = m_console; MainConsole.Instance = m_console;
} }
@ -87,10 +113,22 @@ namespace OpenSim.Grid.MessagingServer
private void registerWithUserServer() private void registerWithUserServer()
{ {
if (m_userServerModule.registerWithUserServer()) if (m_userServerModule.registerWithUserServer())
{
if (m_httpServer == null)
{ {
m_log.Info("[SERVER]: Starting HTTP process"); m_log.Info("[SERVER]: Starting HTTP process");
m_httpServer = new BaseHttpServer(Cfg.HttpPort); 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("login_to_simulator", msgsvc.UserLoggedOn);
m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk);
@ -102,6 +140,7 @@ namespace OpenSim.Grid.MessagingServer
m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown);
m_httpServer.Start(); m_httpServer.Start();
}
m_log.Info("[SERVER]: Userserver registration was successful"); m_log.Info("[SERVER]: Userserver registration was successful");
} }
else else
@ -114,12 +153,12 @@ namespace OpenSim.Grid.MessagingServer
private void deregisterFromUserServer() private void deregisterFromUserServer()
{ {
m_userServerModule.deregisterWithUserServer(); m_userServerModule.deregisterWithUserServer();
if (m_httpServer != null) // if (m_httpServer != null)
{ // {
// try a completely fresh registration, with fresh handlers, too // try a completely fresh registration, with fresh handlers, too
m_httpServer.Stop(); // m_httpServer.Stop();
m_httpServer = null; // m_httpServer = null;
} // }
m_console.Output("[SERVER]: Deregistered from userserver."); m_console.Output("[SERVER]: Deregistered from userserver.");
} }

View File

@ -1281,6 +1281,7 @@
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="XMLRPC.dll"/> <Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="Nini.dll"/>
<Files> <Files>
<Match pattern="*.cs" recurse="true"/> <Match pattern="*.cs" recurse="true"/>