aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-15 02:51:52 +0100
committerJustin Clark-Casey (justincc)2012-06-15 02:51:52 +0100
commit94517c8d5c63f9e8a1ea9a83b04db956f27aa25d (patch)
treeb38f309e24df668dc9b422daf69ce9273e09dee7 /OpenSim
parentAdd main instance to internal MainServer.m_Servers list to simplify internal ... (diff)
downloadopensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.zip
opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.gz
opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.bz2
opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.xz
Make the "debug http" command available for robust as well as the simulator. This allows one to see incoming requests as they happen.
This required making everything use the common MainServer class for registering and retrieving http servers, rather than duplicate structures.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs3
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs60
-rw-r--r--OpenSim/Region/Application/OpenSim.cs34
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs78
-rw-r--r--OpenSim/Server/ServerMain.cs26
5 files changed, 91 insertions, 110 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 0db1329..3de7f9c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1557,6 +1557,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1557 1557
1558 private void StartHTTP() 1558 private void StartHTTP()
1559 { 1559 {
1560 m_log.InfoFormat(
1561 "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port);
1562
1560 try 1563 try
1561 { 1564 {
1562 //m_httpListener = new HttpListener(); 1565 //m_httpListener = new HttpListener();
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index becbbc2..07ff60c 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -30,13 +30,15 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Net; 31using System.Net;
32using log4net; 32using log4net;
33using OpenSim.Framework;
34using OpenSim.Framework.Console;
33using OpenSim.Framework.Servers.HttpServer; 35using OpenSim.Framework.Servers.HttpServer;
34 36
35namespace OpenSim.Framework.Servers 37namespace OpenSim.Framework.Servers
36{ 38{
37 public class MainServer 39 public class MainServer
38 { 40 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 42
41 private static BaseHttpServer instance = null; 43 private static BaseHttpServer instance = null;
42 private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); 44 private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>();
@@ -88,6 +90,57 @@ namespace OpenSim.Framework.Servers
88 } 90 }
89 91
90 /// <summary> 92 /// <summary>
93 /// Get all the registered servers.
94 /// </summary>
95 /// <remarks>
96 /// Returns a copy of the dictionary so this can be iterated through without locking.
97 /// </remarks>
98 /// <value></value>
99 public static Dictionary<uint, BaseHttpServer> Servers
100 {
101 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
102 }
103
104
105 public static void RegisterHttpConsoleCommands(ICommandConsole console)
106 {
107 console.Commands.AddCommand(
108 "Comms", false, "debug http", "debug http [<level>]",
109 "Turn on inbound non-poll http request debugging.",
110 "If level <= 0, then no extra logging is done.\n"
111 + "If level >= 1, then short warnings are logged when receiving bad input data.\n"
112 + "If level >= 2, then long warnings are logged when receiving bad input data.\n"
113 + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
114 + "If no level is specified then the current level is returned.",
115 HandleDebugHttpCommand);
116 }
117
118 /// <summary>
119 /// Turn on some debugging values for OpenSim.
120 /// </summary>
121 /// <param name="args"></param>
122 private static void HandleDebugHttpCommand(string module, string[] args)
123 {
124 if (args.Length == 3)
125 {
126 int newDebug;
127 if (int.TryParse(args[2], out newDebug))
128 {
129 MainServer.DebugLevel = newDebug;
130 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
131 }
132 }
133 else if (args.Length == 2)
134 {
135 MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
136 }
137 else
138 {
139 MainConsole.Instance.Output("Usage: debug http 0..3");
140 }
141 }
142
143 /// <summary>
91 /// Register an already started HTTP server to the collection of known servers. 144 /// Register an already started HTTP server to the collection of known servers.
92 /// </summary> 145 /// </summary>
93 /// <param name='server'></param> 146 /// <param name='server'></param>
@@ -171,11 +224,10 @@ namespace OpenSim.Framework.Servers
171 if (ipaddr != null) 224 if (ipaddr != null)
172 m_Servers[port].ListenIPAddress = ipaddr; 225 m_Servers[port].ListenIPAddress = ipaddr;
173 226
174 m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
175 m_Servers[port].Start(); 227 m_Servers[port].Start();
176 }
177 228
178 return m_Servers[port]; 229 return m_Servers[port];
230 }
179 } 231 }
180 } 232 }
181} \ No newline at end of file 233} \ No newline at end of file
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index abb30a9..faa9e09 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -231,6 +231,8 @@ namespace OpenSim
231 /// </summary> 231 /// </summary>
232 private void RegisterConsoleCommands() 232 private void RegisterConsoleCommands()
233 { 233 {
234 MainServer.RegisterHttpConsoleCommands(m_console);
235
234 m_console.Commands.AddCommand("Objects", false, "force update", 236 m_console.Commands.AddCommand("Objects", false, "force update",
235 "force update", 237 "force update",
236 "Force the update of all objects on clients", 238 "Force the update of all objects on clients",
@@ -248,16 +250,6 @@ namespace OpenSim
248 + "If an avatar name is given then only packets from that avatar are logged", 250 + "If an avatar name is given then only packets from that avatar are logged",
249 Debug); 251 Debug);
250 252
251 m_console.Commands.AddCommand("Comms", false, "debug http",
252 "debug http [<level>]",
253 "Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
254 "If level <= 0, then no extra logging is done.\n"
255 + "If level >= 1, then short warnings are logged when receiving bad input data.\n"
256 + "If level >= 2, then long warnings are logged when receiving bad input data.\n"
257 + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
258 + "If no level is specified then the current level is returned.",
259 Debug);
260
261 m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); 253 m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
262 254
263 m_console.Commands.AddCommand("Regions", false, "debug scene", 255 m_console.Commands.AddCommand("Regions", false, "debug scene",
@@ -916,28 +908,6 @@ namespace OpenSim
916 908
917 break; 909 break;
918 910
919 case "http":
920 if (args.Length == 3)
921 {
922 int newDebug;
923 if (int.TryParse(args[2], out newDebug))
924 {
925 MainServer.DebugLevel = newDebug;
926 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
927 break;
928 }
929 }
930 else if (args.Length == 2)
931 {
932 MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
933 }
934 else
935 {
936 MainConsole.Instance.Output("Usage: debug http 0..3");
937 }
938
939 break;
940
941 case "scene": 911 case "scene":
942 if (args.Length == 4) 912 if (args.Length == 4)
943 { 913 {
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 7014303..7ba0ca8 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -42,42 +42,9 @@ namespace OpenSim.Server.Base
42 { 42 {
43 // Logger 43 // Logger
44 // 44 //
45 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 // The http server instance 47 private uint m_consolePort;
48 //
49 protected BaseHttpServer m_HttpServer = null;
50 protected uint m_Port = 0;
51 protected Dictionary<uint, BaseHttpServer> m_Servers =
52 new Dictionary<uint, BaseHttpServer>();
53 protected uint m_consolePort = 0;
54
55 public IHttpServer HttpServer
56 {
57 get { return m_HttpServer; }
58 }
59
60 public uint DefaultPort
61 {
62 get { return m_Port; }
63 }
64
65 public IHttpServer GetHttpServer(uint port)
66 {
67 m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
68 if (port == m_Port)
69 return HttpServer;
70
71 if (m_Servers.ContainsKey(port))
72 return m_Servers[port];
73
74 m_Servers[port] = new BaseHttpServer(port);
75
76 m_Log.InfoFormat("[SERVER]: Starting new HTTP server on port {0}", port);
77 m_Servers[port].Start();
78
79 return m_Servers[port];
80 }
81 48
82 // Handle all the automagical stuff 49 // Handle all the automagical stuff
83 // 50 //
@@ -94,19 +61,21 @@ namespace OpenSim.Server.Base
94 System.Console.WriteLine("Section 'Network' not found, server can't start"); 61 System.Console.WriteLine("Section 'Network' not found, server can't start");
95 Thread.CurrentThread.Abort(); 62 Thread.CurrentThread.Abort();
96 } 63 }
64
97 uint port = (uint)networkConfig.GetInt("port", 0); 65 uint port = (uint)networkConfig.GetInt("port", 0);
98 66
99 if (port == 0) 67 if (port == 0)
100 { 68 {
101
102 Thread.CurrentThread.Abort(); 69 Thread.CurrentThread.Abort();
103 } 70 }
104 // 71
105 bool ssl_main = networkConfig.GetBoolean("https_main",false); 72 bool ssl_main = networkConfig.GetBoolean("https_main",false);
106 bool ssl_listener = networkConfig.GetBoolean("https_listener",false); 73 bool ssl_listener = networkConfig.GetBoolean("https_listener",false);
107 74
108 m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); 75 m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0);
109 m_Port = port; 76
77 BaseHttpServer httpServer = null;
78
110 // 79 //
111 // This is where to make the servers: 80 // This is where to make the servers:
112 // 81 //
@@ -118,8 +87,7 @@ namespace OpenSim.Server.Base
118 // 87 //
119 if ( !ssl_main ) 88 if ( !ssl_main )
120 { 89 {
121 m_HttpServer = new BaseHttpServer(port); 90 httpServer = new BaseHttpServer(port);
122
123 } 91 }
124 else 92 else
125 { 93 {
@@ -135,11 +103,12 @@ namespace OpenSim.Server.Base
135 System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); 103 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
136 Thread.CurrentThread.Abort(); 104 Thread.CurrentThread.Abort();
137 } 105 }
138 m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); 106
107 httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
139 } 108 }
140 109
141 MainServer.AddHttpServer(m_HttpServer); 110 MainServer.AddHttpServer(httpServer);
142 MainServer.Instance = m_HttpServer; 111 MainServer.Instance = httpServer;
143 112
144 // If https_listener = true, then add an ssl listener on the https_port... 113 // If https_listener = true, then add an ssl listener on the https_port...
145 if ( ssl_listener == true ) { 114 if ( ssl_listener == true ) {
@@ -159,34 +128,23 @@ namespace OpenSim.Server.Base
159 Thread.CurrentThread.Abort(); 128 Thread.CurrentThread.Abort();
160 } 129 }
161 130
162 m_Servers.Add(https_port, new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); 131 MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
163 } 132 }
164 } 133 }
165 134
166 protected override void Initialise() 135 protected override void Initialise()
167 { 136 {
168 m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port); 137 foreach (BaseHttpServer s in MainServer.Servers.Values)
169 m_HttpServer.Start(); 138 s.Start();
170
171 if (m_Servers.Count > 0)
172 {
173 foreach (BaseHttpServer s in m_Servers.Values)
174 {
175 if (!s.UseSSL)
176 m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", s.Port);
177 else
178 m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", s.Port);
179 139
180 s.Start(); 140 MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
181 }
182 }
183 141
184 if (MainConsole.Instance is RemoteConsole) 142 if (MainConsole.Instance is RemoteConsole)
185 { 143 {
186 if (m_consolePort == 0) 144 if (m_consolePort == 0)
187 ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); 145 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
188 else 146 else
189 ((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort)); 147 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
190 } 148 }
191 } 149 }
192 } 150 }
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index 9503c4c..21fb678 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -30,6 +30,7 @@ using log4net;
30using System.Reflection; 30using System.Reflection;
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework.Servers;
33using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Server.Handlers.Base; 36using OpenSim.Server.Handlers.Base;
@@ -92,27 +93,24 @@ namespace OpenSim.Server
92 if (parts.Length > 1) 93 if (parts.Length > 1)
93 friendlyName = parts[1]; 94 friendlyName = parts[1];
94 95
95 IHttpServer server = m_Server.HttpServer; 96 IHttpServer server;
96 if (port != 0)
97 server = m_Server.GetHttpServer(port);
98 97
99 if (port != m_Server.DefaultPort && port != 0) 98 if (port != 0)
100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port); 99 server = MainServer.GetHttpServer(port);
101 else 100 else
102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); 101 server = MainServer.Instance;
102
103 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port);
103 104
104 IServiceConnector connector = null; 105 IServiceConnector connector = null;
105 106
106 Object[] modargs = new Object[] { m_Server.Config, server, 107 Object[] modargs = new Object[] { m_Server.Config, server, configName };
107 configName }; 108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, 109
109 modargs);
110 if (connector == null) 110 if (connector == null)
111 { 111 {
112 modargs = new Object[] { m_Server.Config, server }; 112 modargs = new Object[] { m_Server.Config, server };
113 connector = 113 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
114 ServerUtils.LoadPlugin<IServiceConnector>(conn,
115 modargs);
116 } 114 }
117 115
118 if (connector != null) 116 if (connector != null)
@@ -132,4 +130,4 @@ namespace OpenSim.Server
132 return 0; 130 return 0;
133 } 131 }
134 } 132 }
135} 133} \ No newline at end of file