Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-06-14 22:05:27 -04:00
commit ec05e93f85
6 changed files with 92 additions and 110 deletions

View File

@ -1557,6 +1557,9 @@ namespace OpenSim.Framework.Servers.HttpServer
private void StartHTTP() private void StartHTTP()
{ {
m_log.InfoFormat(
"[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port);
try try
{ {
//m_httpListener = new HttpListener(); //m_httpListener = new HttpListener();

View File

@ -30,13 +30,15 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Net; using System.Net;
using log4net; using log4net;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
namespace OpenSim.Framework.Servers namespace OpenSim.Framework.Servers
{ {
public class MainServer public class MainServer
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static BaseHttpServer instance = null; private static BaseHttpServer instance = null;
private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>();
@ -87,6 +89,57 @@ namespace OpenSim.Framework.Servers
} }
} }
/// <summary>
/// Get all the registered servers.
/// </summary>
/// <remarks>
/// Returns a copy of the dictionary so this can be iterated through without locking.
/// </remarks>
/// <value></value>
public static Dictionary<uint, BaseHttpServer> Servers
{
get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
}
public static void RegisterHttpConsoleCommands(ICommandConsole console)
{
console.Commands.AddCommand(
"Comms", false, "debug http", "debug http [<level>]",
"Turn on inbound non-poll http request debugging.",
"If level <= 0, then no extra logging is done.\n"
+ "If level >= 1, then short warnings are logged when receiving bad input data.\n"
+ "If level >= 2, then long warnings are logged when receiving bad input data.\n"
+ "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
+ "If no level is specified then the current level is returned.",
HandleDebugHttpCommand);
}
/// <summary>
/// Turn on some debugging values for OpenSim.
/// </summary>
/// <param name="args"></param>
private static void HandleDebugHttpCommand(string module, string[] args)
{
if (args.Length == 3)
{
int newDebug;
if (int.TryParse(args[2], out newDebug))
{
MainServer.DebugLevel = newDebug;
MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
}
}
else if (args.Length == 2)
{
MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
}
else
{
MainConsole.Instance.Output("Usage: debug http 0..3");
}
}
/// <summary> /// <summary>
/// Register an already started HTTP server to the collection of known servers. /// Register an already started HTTP server to the collection of known servers.
/// </summary> /// </summary>
@ -171,11 +224,10 @@ namespace OpenSim.Framework.Servers
if (ipaddr != null) if (ipaddr != null)
m_Servers[port].ListenIPAddress = ipaddr; m_Servers[port].ListenIPAddress = ipaddr;
m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
m_Servers[port].Start(); m_Servers[port].Start();
}
return m_Servers[port]; return m_Servers[port];
} }
} }
} }
}

View File

@ -231,6 +231,8 @@ namespace OpenSim
/// </summary> /// </summary>
private void RegisterConsoleCommands() private void RegisterConsoleCommands()
{ {
MainServer.RegisterHttpConsoleCommands(m_console);
m_console.Commands.AddCommand("Objects", false, "force update", m_console.Commands.AddCommand("Objects", false, "force update",
"force update", "force update",
"Force the update of all objects on clients", "Force the update of all objects on clients",
@ -248,16 +250,6 @@ namespace OpenSim
+ "If an avatar name is given then only packets from that avatar are logged", + "If an avatar name is given then only packets from that avatar are logged",
Debug); Debug);
m_console.Commands.AddCommand("Comms", false, "debug http",
"debug http [<level>]",
"Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
"If level <= 0, then no extra logging is done.\n"
+ "If level >= 1, then short warnings are logged when receiving bad input data.\n"
+ "If level >= 2, then long warnings are logged when receiving bad input data.\n"
+ "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
+ "If no level is specified then the current level is returned.",
Debug);
m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
m_console.Commands.AddCommand("Regions", false, "debug scene", m_console.Commands.AddCommand("Regions", false, "debug scene",
@ -916,28 +908,6 @@ namespace OpenSim
break; break;
case "http":
if (args.Length == 3)
{
int newDebug;
if (int.TryParse(args[2], out newDebug))
{
MainServer.DebugLevel = newDebug;
MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
break;
}
}
else if (args.Length == 2)
{
MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
}
else
{
MainConsole.Instance.Output("Usage: debug http 0..3");
}
break;
case "scene": case "scene":
if (args.Length == 4) if (args.Length == 4)
{ {

View File

@ -44,40 +44,7 @@ namespace OpenSim.Server.Base
// //
private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// The http server instance private uint m_consolePort;
//
protected BaseHttpServer m_HttpServer = null;
protected uint m_Port = 0;
protected Dictionary<uint, BaseHttpServer> m_Servers =
new Dictionary<uint, BaseHttpServer>();
protected uint m_consolePort = 0;
public IHttpServer HttpServer
{
get { return m_HttpServer; }
}
public uint DefaultPort
{
get { return m_Port; }
}
public IHttpServer GetHttpServer(uint port)
{
m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
if (port == m_Port)
return HttpServer;
if (m_Servers.ContainsKey(port))
return m_Servers[port];
m_Servers[port] = new BaseHttpServer(port);
m_Log.InfoFormat("[SERVER]: Starting new HTTP server on port {0}", port);
m_Servers[port].Start();
return m_Servers[port];
}
// Handle all the automagical stuff // Handle all the automagical stuff
// //
@ -94,19 +61,21 @@ namespace OpenSim.Server.Base
System.Console.WriteLine("Section 'Network' not found, server can't start"); System.Console.WriteLine("Section 'Network' not found, server can't start");
Thread.CurrentThread.Abort(); Thread.CurrentThread.Abort();
} }
uint port = (uint)networkConfig.GetInt("port", 0); uint port = (uint)networkConfig.GetInt("port", 0);
if (port == 0) if (port == 0)
{ {
Thread.CurrentThread.Abort(); Thread.CurrentThread.Abort();
} }
//
bool ssl_main = networkConfig.GetBoolean("https_main",false); bool ssl_main = networkConfig.GetBoolean("https_main",false);
bool ssl_listener = networkConfig.GetBoolean("https_listener",false); bool ssl_listener = networkConfig.GetBoolean("https_listener",false);
m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0);
m_Port = port;
BaseHttpServer httpServer = null;
// //
// This is where to make the servers: // This is where to make the servers:
// //
@ -118,8 +87,7 @@ namespace OpenSim.Server.Base
// //
if ( !ssl_main ) if ( !ssl_main )
{ {
m_HttpServer = new BaseHttpServer(port); httpServer = new BaseHttpServer(port);
} }
else else
{ {
@ -135,11 +103,12 @@ namespace OpenSim.Server.Base
System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
Thread.CurrentThread.Abort(); Thread.CurrentThread.Abort();
} }
m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
} }
MainServer.AddHttpServer(m_HttpServer); MainServer.AddHttpServer(httpServer);
MainServer.Instance = m_HttpServer; MainServer.Instance = httpServer;
// If https_listener = true, then add an ssl listener on the https_port... // If https_listener = true, then add an ssl listener on the https_port...
if ( ssl_listener == true ) { if ( ssl_listener == true ) {
@ -159,34 +128,23 @@ namespace OpenSim.Server.Base
Thread.CurrentThread.Abort(); Thread.CurrentThread.Abort();
} }
m_Servers.Add(https_port, new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
} }
} }
protected override void Initialise() protected override void Initialise()
{ {
m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port); foreach (BaseHttpServer s in MainServer.Servers.Values)
m_HttpServer.Start();
if (m_Servers.Count > 0)
{
foreach (BaseHttpServer s in m_Servers.Values)
{
if (!s.UseSSL)
m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", s.Port);
else
m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", s.Port);
s.Start(); s.Start();
}
} MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
if (MainConsole.Instance is RemoteConsole) if (MainConsole.Instance is RemoteConsole)
{ {
if (m_consolePort == 0) if (m_consolePort == 0)
((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
else else
((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort)); ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
} }
} }
} }

View File

@ -30,6 +30,7 @@ using log4net;
using System.Reflection; using System.Reflection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Base;
@ -92,27 +93,24 @@ namespace OpenSim.Server
if (parts.Length > 1) if (parts.Length > 1)
friendlyName = parts[1]; friendlyName = parts[1];
IHttpServer server = m_Server.HttpServer; IHttpServer server;
if (port != 0)
server = m_Server.GetHttpServer(port);
if (port != m_Server.DefaultPort && port != 0) if (port != 0)
m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port); server = MainServer.GetHttpServer(port);
else else
m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); server = MainServer.Instance;
m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port);
IServiceConnector connector = null; IServiceConnector connector = null;
Object[] modargs = new Object[] { m_Server.Config, server, Object[] modargs = new Object[] { m_Server.Config, server, configName };
configName }; connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
connector = ServerUtils.LoadPlugin<IServiceConnector>(conn,
modargs);
if (connector == null) if (connector == null)
{ {
modargs = new Object[] { m_Server.Config, server }; modargs = new Object[] { m_Server.Config, server };
connector = connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
ServerUtils.LoadPlugin<IServiceConnector>(conn,
modargs);
} }
if (connector != null) if (connector != null)

View File

@ -1424,6 +1424,7 @@
<Reference name="OpenMetaverse.StructuredData" path="../../bin/"/> <Reference name="OpenMetaverse.StructuredData" path="../../bin/"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Server.Base"/> <Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Server.Handlers"/> <Reference name="OpenSim.Server.Handlers"/>