29 using System.Collections.Generic;
30 using System.Threading;
31 using System.Reflection;
32 using OpenSim.Framework;
33 using OpenSim.Framework.Console;
34 using OpenSim.Framework.Servers;
35 using OpenSim.Framework.Servers.HttpServer;
39 namespace OpenSim.Server.Base
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private uint m_consolePort;
55 IConfig networkConfig = Config.Configs[
"Network"];
57 if (networkConfig == null)
59 System.Console.WriteLine(
"ERROR: Section [Network] not found, server can't start");
63 uint port = (uint)networkConfig.GetInt(
"port", 0);
67 System.Console.WriteLine(
"ERROR: No 'port' entry found in [Network]. Server can't start");
71 bool ssl_main = networkConfig.GetBoolean(
"https_main",
false);
72 bool ssl_listener = networkConfig.GetBoolean(
"https_listener",
false);
73 bool ssl_external = networkConfig.GetBoolean(
"https_external",
false);
75 m_consolePort = (uint)networkConfig.GetInt(
"ConsolePort", 0);
94 string cert_path = networkConfig.GetString(
"cert_path",String.Empty);
95 if (cert_path == String.Empty)
97 System.Console.WriteLine(
"ERROR: Path to X509 certificate is missing, server can't start.");
101 string cert_pass = networkConfig.GetString(
"cert_pass",String.Empty);
102 if (cert_pass == String.Empty)
104 System.Console.WriteLine(
"ERROR: Password for X509 certificate is missing, server can't start.");
108 httpServer =
new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
115 if (ssl_listener ==
true)
117 uint https_port = (uint)networkConfig.GetInt(
"https_port", 0);
119 m_log.WarnFormat(
"[SSL]: External flag is {0}", ssl_external);
122 string cert_path = networkConfig.GetString(
"cert_path",String.Empty);
123 if ( cert_path == String.Empty )
125 System.Console.WriteLine(
"Path to X509 certificate is missing, server can't start.");
126 Thread.CurrentThread.Abort();
128 string cert_pass = networkConfig.GetString(
"cert_pass",String.Empty);
129 if ( cert_pass == String.Empty )
131 System.Console.WriteLine(
"Password for X509 certificate is missing, server can't start.");
132 Thread.CurrentThread.Abort();
135 MainServer.AddHttpServer(
new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
139 m_log.WarnFormat(
"[SSL]: SSL port is active but no SSL is used because external SSL was requested.");
150 MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
154 if (m_consolePort == 0)
override void ReadConfig()
override void Initialise()
static IHttpServer GetHttpServer(uint port)
Get the default http server or an http server for a specific port.
static Dictionary< uint, BaseHttpServer > Servers
Get all the registered servers.
static ICommandConsole Instance
HttpServerBase(string prompt, string[] args)