aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base/HttpServerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Base/HttpServerBase.cs')
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs87
1 files changed, 19 insertions, 68 deletions
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index d471559..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,10 +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.Instance = m_HttpServer; 110 MainServer.AddHttpServer(httpServer);
111 MainServer.Instance = httpServer;
142 112
143 // 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...
144 if ( ssl_listener == true ) { 114 if ( ssl_listener == true ) {
@@ -157,43 +127,24 @@ namespace OpenSim.Server.Base
157 System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); 127 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
158 Thread.CurrentThread.Abort(); 128 Thread.CurrentThread.Abort();
159 } 129 }
160 // Add our https_server 130
161 BaseHttpServer server = null; 131 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 } 132 }
171 } 133 }
172 134
173 protected override void Initialise() 135 protected override void Initialise()
174 { 136 {
175 m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port); 137 foreach (BaseHttpServer s in MainServer.Servers.Values)
176 m_HttpServer.Start(); 138 s.Start();
177 139
178 if (m_Servers.Count > 0) 140 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 141
191 if (MainConsole.Instance is RemoteConsole) 142 if (MainConsole.Instance is RemoteConsole)
192 { 143 {
193 if (m_consolePort == 0) 144 if (m_consolePort == 0)
194 ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); 145 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
195 else 146 else
196 ((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort)); 147 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
197 } 148 }
198 } 149 }
199 } 150 }