clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
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;
36 using log4net;
37 using Nini.Config;
38  
39 namespace OpenSim.Server.Base
40 {
41 public class HttpServerBase : ServicesServerBase
42 {
43 // private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44  
45 private uint m_consolePort;
46  
47 // Handle all the automagical stuff
48 //
49 public HttpServerBase(string prompt, string[] args) : base(prompt, args)
50 {
51 }
52  
53 protected override void ReadConfig()
54 {
55 IConfig networkConfig = Config.Configs["Network"];
56  
57 if (networkConfig == null)
58 {
59 System.Console.WriteLine("Section 'Network' not found, server can't start");
60 Thread.CurrentThread.Abort();
61 }
62  
63 uint port = (uint)networkConfig.GetInt("port", 0);
64  
65 if (port == 0)
66 {
67 Thread.CurrentThread.Abort();
68 }
69  
70 bool ssl_main = networkConfig.GetBoolean("https_main",false);
71 bool ssl_listener = networkConfig.GetBoolean("https_listener",false);
72  
73 m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0);
74  
75 BaseHttpServer httpServer = null;
76  
77 //
78 // This is where to make the servers:
79 //
80 //
81 // Make the base server according to the port, etc.
82 // ADD: Possibility to make main server ssl
83 // Then, check for https settings and ADD a server to
84 // m_Servers
85 //
86 if ( !ssl_main )
87 {
88 httpServer = new BaseHttpServer(port);
89 }
90 else
91 {
92 string cert_path = networkConfig.GetString("cert_path",String.Empty);
93 if ( cert_path == String.Empty )
94 {
95 System.Console.WriteLine("Path to X509 certificate is missing, server can't start.");
96 Thread.CurrentThread.Abort();
97 }
98 string cert_pass = networkConfig.GetString("cert_pass",String.Empty);
99 if ( cert_pass == String.Empty )
100 {
101 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
102 Thread.CurrentThread.Abort();
103 }
104  
105 httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
106 }
107  
108 MainServer.AddHttpServer(httpServer);
109 MainServer.Instance = httpServer;
110  
111 // If https_listener = true, then add an ssl listener on the https_port...
112 if ( ssl_listener == true ) {
113  
114 uint https_port = (uint)networkConfig.GetInt("https_port", 0);
115  
116 string cert_path = networkConfig.GetString("cert_path",String.Empty);
117 if ( cert_path == String.Empty )
118 {
119 System.Console.WriteLine("Path to X509 certificate is missing, server can't start.");
120 Thread.CurrentThread.Abort();
121 }
122 string cert_pass = networkConfig.GetString("cert_pass",String.Empty);
123 if ( cert_pass == String.Empty )
124 {
125 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
126 Thread.CurrentThread.Abort();
127 }
128  
129 MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
130 }
131 }
132  
133 protected override void Initialise()
134 {
135 foreach (BaseHttpServer s in MainServer.Servers.Values)
136 s.Start();
137  
138 MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
139  
140 if (MainConsole.Instance is RemoteConsole)
141 {
142 if (m_consolePort == 0)
143 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
144 else
145 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
146 }
147 }
148 }
149 }