diff options
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 89 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 11 |
2 files changed, 26 insertions, 74 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 | } |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 8effdd2..42c82cf 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -117,7 +117,10 @@ namespace OpenSim.Server.Base | |||
117 | catch (Exception e) | 117 | catch (Exception e) |
118 | { | 118 | { |
119 | if (!(e is System.MissingMethodException)) | 119 | if (!(e is System.MissingMethodException)) |
120 | m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); | 120 | { |
121 | m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}", | ||
122 | interfaceName, dllName, e.InnerException == null ? e.Message : e.InnerException.Message); | ||
123 | } | ||
121 | return null; | 124 | return null; |
122 | } | 125 | } |
123 | 126 | ||
@@ -265,7 +268,7 @@ namespace OpenSim.Server.Base | |||
265 | continue; | 268 | continue; |
266 | 269 | ||
267 | XmlElement elem = parent.OwnerDocument.CreateElement("", | 270 | XmlElement elem = parent.OwnerDocument.CreateElement("", |
268 | kvp.Key, ""); | 271 | XmlConvert.EncodeLocalName(kvp.Key), ""); |
269 | 272 | ||
270 | if (kvp.Value is Dictionary<string, object>) | 273 | if (kvp.Value is Dictionary<string, object>) |
271 | { | 274 | { |
@@ -320,11 +323,11 @@ namespace OpenSim.Server.Base | |||
320 | XmlNode type = part.Attributes.GetNamedItem("type"); | 323 | XmlNode type = part.Attributes.GetNamedItem("type"); |
321 | if (type == null || type.Value != "List") | 324 | if (type == null || type.Value != "List") |
322 | { | 325 | { |
323 | ret[part.Name] = part.InnerText; | 326 | ret[XmlConvert.DecodeName(part.Name)] = part.InnerText; |
324 | } | 327 | } |
325 | else | 328 | else |
326 | { | 329 | { |
327 | ret[part.Name] = ParseElement(part); | 330 | ret[XmlConvert.DecodeName(part.Name)] = ParseElement(part); |
328 | } | 331 | } |
329 | } | 332 | } |
330 | 333 | ||