aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
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/Server
parentAdd main instance to internal MainServer.m_Servers list to simplify internal ... (diff)
downloadopensim-SC_OLD-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.zip
opensim-SC_OLD-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.gz
opensim-SC_OLD-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.bz2
opensim-SC_OLD-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/Server')
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs78
-rw-r--r--OpenSim/Server/ServerMain.cs26
2 files changed, 30 insertions, 74 deletions
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