diff options
author | UbitUmarov | 2012-07-17 00:54:23 +0100 |
---|---|---|
committer | UbitUmarov | 2012-07-17 00:54:23 +0100 |
commit | d5f4fb7b50fb7c594b018f8241399e22f88fc951 (patch) | |
tree | 8f3dab3d170596f02b1d1d836a0bc08a3e6b8ebd /OpenSim/Server/Base/HttpServerBase.cs | |
parent | UbitOde: remove useless water collider from active code. (diff) | |
parent | Merge branch 'avination' into careminster (diff) | |
download | opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.zip opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.gz opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.bz2 opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.xz |
Merge branch 'avination' into ubitwork
Diffstat (limited to 'OpenSim/Server/Base/HttpServerBase.cs')
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 89 |
1 files changed, 19 insertions, 70 deletions
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index d471559..29b1c00 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs | |||
@@ -40,44 +40,9 @@ namespace OpenSim.Server.Base | |||
40 | { | 40 | { |
41 | public class HttpServerBase : ServicesServerBase | 41 | public class HttpServerBase : ServicesServerBase |
42 | { | 42 | { |
43 | // Logger | 43 | // private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | // | ||
45 | private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | // The http server instance | ||
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 | 44 | ||
74 | m_Servers[port] = new BaseHttpServer(port); | 45 | private uint m_consolePort; |
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 | 46 | ||
82 | // Handle all the automagical stuff | 47 | // Handle all the automagical stuff |
83 | // | 48 | // |
@@ -94,19 +59,21 @@ namespace OpenSim.Server.Base | |||
94 | System.Console.WriteLine("Section 'Network' not found, server can't start"); | 59 | System.Console.WriteLine("Section 'Network' not found, server can't start"); |
95 | Thread.CurrentThread.Abort(); | 60 | Thread.CurrentThread.Abort(); |
96 | } | 61 | } |
62 | |||
97 | uint port = (uint)networkConfig.GetInt("port", 0); | 63 | uint port = (uint)networkConfig.GetInt("port", 0); |
98 | 64 | ||
99 | if (port == 0) | 65 | if (port == 0) |
100 | { | 66 | { |
101 | |||
102 | Thread.CurrentThread.Abort(); | 67 | Thread.CurrentThread.Abort(); |
103 | } | 68 | } |
104 | // | 69 | |
105 | bool ssl_main = networkConfig.GetBoolean("https_main",false); | 70 | bool ssl_main = networkConfig.GetBoolean("https_main",false); |
106 | bool ssl_listener = networkConfig.GetBoolean("https_listener",false); | 71 | bool ssl_listener = networkConfig.GetBoolean("https_listener",false); |
107 | 72 | ||
108 | m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); | 73 | m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); |
109 | m_Port = port; | 74 | |
75 | BaseHttpServer httpServer = null; | ||
76 | |||
110 | // | 77 | // |
111 | // This is where to make the servers: | 78 | // This is where to make the servers: |
112 | // | 79 | // |
@@ -118,8 +85,7 @@ namespace OpenSim.Server.Base | |||
118 | // | 85 | // |
119 | if ( !ssl_main ) | 86 | if ( !ssl_main ) |
120 | { | 87 | { |
121 | m_HttpServer = new BaseHttpServer(port); | 88 | httpServer = new BaseHttpServer(port); |
122 | |||
123 | } | 89 | } |
124 | else | 90 | else |
125 | { | 91 | { |
@@ -135,10 +101,12 @@ namespace OpenSim.Server.Base | |||
135 | System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); | 101 | System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); |
136 | Thread.CurrentThread.Abort(); | 102 | Thread.CurrentThread.Abort(); |
137 | } | 103 | } |
138 | m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); | 104 | |
105 | httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); | ||
139 | } | 106 | } |
140 | 107 | ||
141 | MainServer.Instance = m_HttpServer; | 108 | MainServer.AddHttpServer(httpServer); |
109 | MainServer.Instance = httpServer; | ||
142 | 110 | ||
143 | // If https_listener = true, then add an ssl listener on the https_port... | 111 | // If https_listener = true, then add an ssl listener on the https_port... |
144 | if ( ssl_listener == true ) { | 112 | if ( ssl_listener == true ) { |
@@ -157,43 +125,24 @@ namespace OpenSim.Server.Base | |||
157 | System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); | 125 | System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); |
158 | Thread.CurrentThread.Abort(); | 126 | Thread.CurrentThread.Abort(); |
159 | } | 127 | } |
160 | // Add our https_server | 128 | |
161 | BaseHttpServer server = null; | 129 | MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); |
162 | server = new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass); | ||
163 | if (server != null) | ||
164 | { | ||
165 | m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", https_port); | ||
166 | m_Servers.Add(https_port,server); | ||
167 | } | ||
168 | else | ||
169 | System.Console.WriteLine(String.Format("Failed to start HTTPS server on port {0}",https_port)); | ||
170 | } | 130 | } |
171 | } | 131 | } |
172 | 132 | ||
173 | protected override void Initialise() | 133 | protected override void Initialise() |
174 | { | 134 | { |
175 | m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port); | 135 | foreach (BaseHttpServer s in MainServer.Servers.Values) |
176 | m_HttpServer.Start(); | 136 | s.Start(); |
177 | 137 | ||
178 | if (m_Servers.Count > 0) | 138 | MainServer.RegisterHttpConsoleCommands(MainConsole.Instance); |
179 | { | ||
180 | foreach (BaseHttpServer s in m_Servers.Values) | ||
181 | { | ||
182 | if (!s.UseSSL) | ||
183 | m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", s.Port); | ||
184 | else | ||
185 | m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", s.Port); | ||
186 | |||
187 | s.Start(); | ||
188 | } | ||
189 | } | ||
190 | 139 | ||
191 | if (MainConsole.Instance is RemoteConsole) | 140 | if (MainConsole.Instance is RemoteConsole) |
192 | { | 141 | { |
193 | if (m_consolePort == 0) | 142 | if (m_consolePort == 0) |
194 | ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); | 143 | ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance); |
195 | else | 144 | else |
196 | ((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort)); | 145 | ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort)); |
197 | } | 146 | } |
198 | } | 147 | } |
199 | } | 148 | } |