diff options
author | Justin Clark-Casey (justincc) | 2012-06-15 02:51:52 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-06-15 02:51:52 +0100 |
commit | 94517c8d5c63f9e8a1ea9a83b04db956f27aa25d (patch) | |
tree | b38f309e24df668dc9b422daf69ce9273e09dee7 /OpenSim/Server/Base | |
parent | Add main instance to internal MainServer.m_Servers list to simplify internal ... (diff) | |
download | opensim-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/Base')
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 78 |
1 files changed, 18 insertions, 60 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 | } |