aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
authorMW2007-03-29 11:08:42 +0000
committerMW2007-03-29 11:08:42 +0000
commit17b00785ee10a71d290cbcddca9b0152fdf60c8f (patch)
tree88a78c0b9a0357af823e4ecdad25e09a64569f79 /OpenSim.RegionServer
parentDoh! need to return the response (diff)
downloadopensim-SC-17b00785ee10a71d290cbcddca9b0152fdf60c8f.zip
opensim-SC-17b00785ee10a71d290cbcddca9b0152fdf60c8f.tar.gz
opensim-SC-17b00785ee10a71d290cbcddca9b0152fdf60c8f.tar.bz2
opensim-SC-17b00785ee10a71d290cbcddca9b0152fdf60c8f.tar.xz
Added lbsa71's http server changes.
So it now has a single http listener that passes incoming requests to the correct handler. This means that logins (in sandbox mode) now go through this listener, which for now is listening on the port you set in startup (default 9000). (This needs changing so that the http listener and udp server are not using the same port)
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs11
-rw-r--r--OpenSim.RegionServer/CAPS/SimHttp.cs241
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.csproj7
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.dll.build3
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs86
-rw-r--r--OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs2
-rw-r--r--OpenSim.RegionServer/UserServer/LoginServer.cs303
-rw-r--r--Servers/IRestHandler.cs (renamed from OpenSim.RegionServer/CAPS/IRestHandler.cs)0
8 files changed, 225 insertions, 428 deletions
diff --git a/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs b/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs
deleted file mode 100644
index c3cbbcc..0000000
--- a/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs
+++ /dev/null
@@ -1,11 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.CAPS
6{
7 public interface IXmlRPCHandler
8 {
9 string HandleRPC(string requestBody);
10 }
11}
diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs
deleted file mode 100644
index bfba635..0000000
--- a/OpenSim.RegionServer/CAPS/SimHttp.cs
+++ /dev/null
@@ -1,241 +0,0 @@
1/*
2Copyright (c) OpenSimCAPS project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Threading;
34using System.Text.RegularExpressions;
35using System.Net;
36using System.IO;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using OpenSim.Framework.Console;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Servers;
43
44namespace OpenSim.CAPS
45{
46 // Dummy HTTP server, does nothing useful for now
47
48 public class SimCAPSHTTPServer : BaseHttpServer
49 {
50 private Thread m_workerThread;
51 private HttpListener m_httpListener;
52 private Dictionary<string, IRestHandler> m_restHandlers = new Dictionary<string, IRestHandler>();
53 private Dictionary<string, IXmlRPCHandler> RPCHandlers = new Dictionary<string, IXmlRPCHandler>();
54 private IGridServer m_gridServer;
55 private int m_port;
56
57 public SimCAPSHTTPServer(IGridServer gridServer, int port)
58 {
59 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server");
60 m_workerThread = new Thread(new ThreadStart(StartHTTP));
61 m_workerThread.Start();
62 m_gridServer = gridServer;
63 m_port = port;
64 }
65
66 public void StartHTTP()
67 {
68 try
69 {
70 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK");
71 m_httpListener = new HttpListener();
72
73 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
74 m_httpListener.Start();
75
76 HttpListenerContext context;
77 while (true)
78 {
79 context = m_httpListener.GetContext();
80 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
81 }
82 }
83 catch (Exception e)
84 {
85 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.Message);
86 }
87 }
88
89 public bool AddRestHandler(string path, IRestHandler handler)
90 {
91 if (!this.m_restHandlers.ContainsKey(path))
92 {
93 this.m_restHandlers.Add(path, handler);
94 return true;
95 }
96
97 //must already have a handler for that path so return false
98 return false;
99 }
100
101 public bool AddXmlRPCHandler(string method, IXmlRPCHandler handler)
102 {
103 if (!this.RPCHandlers.ContainsKey(method))
104 {
105 this.RPCHandlers.Add(method, handler);
106 return true;
107 }
108
109 //must already have a handler for that path so return false
110 return false;
111 }
112
113 protected virtual string ParseXMLRPC(string requestBody)
114 {
115 string responseString = "";
116 try
117 {
118 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
119
120 Hashtable requestData = (Hashtable)request.Params[0];
121 switch (request.MethodName)
122 {
123 case "expect_user":
124 AgentCircuitData agent_data = new AgentCircuitData();
125 agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
126 agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
127 agent_data.firstname = (string)requestData["firstname"];
128 agent_data.lastname = (string)requestData["lastname"];
129 agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
130 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
131 if (m_gridServer.GetName() == "Remote")
132 {
133 ((RemoteGridBase) m_gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
134 }
135 responseString = "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>";
136 break;
137 default:
138 if (this.RPCHandlers.ContainsKey(request.MethodName))
139 {
140 //responseString = this.RPCHandlers[request.MethodName]
141 }
142 break;
143 }
144 }
145 catch (Exception e)
146 {
147 Console.WriteLine(e.ToString());
148 }
149 return responseString;
150 }
151
152 protected virtual string ParseREST(string requestBody, string requestURL, string requestMethod)
153 {
154 string[] path;
155 string pathDelimStr = "/";
156 char[] pathDelimiter = pathDelimStr.ToCharArray();
157 path = requestURL.Split(pathDelimiter);
158
159 string responseString = "";
160
161 //path[0] should be empty so we are interested in path[1]
162 if (path.Length > 1)
163 {
164 if ((path[1] != "") && (this.m_restHandlers.ContainsKey(path[1])))
165 {
166 responseString = this.m_restHandlers[path[1]].HandleREST(requestBody, requestURL, requestMethod);
167 }
168 }
169
170 return responseString;
171 }
172
173 protected virtual string ParseLLSDXML(string requestBody)
174 {
175 // dummy function for now - IMPLEMENT ME!
176 return "";
177 }
178
179 public virtual void HandleRequest(Object stateinfo)
180 {
181 // Console.WriteLine("new http incoming");
182 HttpListenerContext context = (HttpListenerContext)stateinfo;
183
184 HttpListenerRequest request = context.Request;
185 HttpListenerResponse response = context.Response;
186
187 response.KeepAlive = false;
188 response.SendChunked = false;
189
190 System.IO.Stream body = request.InputStream;
191 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
192 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
193
194 string requestBody = reader.ReadToEnd();
195 body.Close();
196 reader.Close();
197
198 //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
199 //Console.WriteLine(requestBody);
200
201 string responseString = "";
202 switch (request.ContentType)
203 {
204 case "text/xml":
205 // must be XML-RPC, so pass to the XML-RPC parser
206
207 responseString = ParseXMLRPC(requestBody);
208 response.AddHeader("Content-type", "text/xml");
209 break;
210
211 case "application/xml":
212 // probably LLSD we hope, otherwise it should be ignored by the parser
213 responseString = ParseLLSDXML(requestBody);
214 response.AddHeader("Content-type", "application/xml");
215 break;
216
217 case "application/x-www-form-urlencoded":
218 // a form data POST so send to the REST parser
219 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
220 response.AddHeader("Content-type", "text/html");
221 break;
222
223 case null:
224 // must be REST or invalid crap, so pass to the REST parser
225 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
226 response.AddHeader("Content-type", "text/html");
227 break;
228
229 }
230
231 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
232 System.IO.Stream output = response.OutputStream;
233 response.SendChunked = false;
234 response.ContentLength64 = buffer.Length;
235 output.Write(buffer, 0, buffer.Length);
236 output.Close();
237 }
238 }
239
240
241}
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index d9d5f1a..13b9767 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -117,7 +117,6 @@
117 <Compile Include="AgentAssetUpload.cs"> 117 <Compile Include="AgentAssetUpload.cs">
118 <SubType>Code</SubType> 118 <SubType>Code</SubType>
119 </Compile> 119 </Compile>
120 <Compile Include="CAPS\IXmlRPCHandler.cs" />
121 <Compile Include="ConsoleCmds.cs"> 120 <Compile Include="ConsoleCmds.cs">
122 <SubType>Code</SubType> 121 <SubType>Code</SubType>
123 </Compile> 122 </Compile>
@@ -151,12 +150,6 @@
151 <Compile Include="CAPS\AdminWebFront.cs"> 150 <Compile Include="CAPS\AdminWebFront.cs">
152 <SubType>Code</SubType> 151 <SubType>Code</SubType>
153 </Compile> 152 </Compile>
154 <Compile Include="CAPS\IRestHandler.cs">
155 <SubType>Code</SubType>
156 </Compile>
157 <Compile Include="CAPS\SimHttp.cs">
158 <SubType>Code</SubType>
159 </Compile>
160 <Compile Include="types\Mesh.cs"> 153 <Compile Include="types\Mesh.cs">
161 <SubType>Code</SubType> 154 <SubType>Code</SubType>
162 </Compile> 155 </Compile>
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index ef7dce9..0cb9bf6 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -23,9 +23,6 @@
23 <include name="Assets/AssetCache.cs" /> 23 <include name="Assets/AssetCache.cs" />
24 <include name="Assets/InventoryCache.cs" /> 24 <include name="Assets/InventoryCache.cs" />
25 <include name="CAPS/AdminWebFront.cs" /> 25 <include name="CAPS/AdminWebFront.cs" />
26 <include name="CAPS/IRestHandler.cs" />
27 <include name="CAPS/IXmlRPCHandler.cs" />
28 <include name="CAPS/SimHttp.cs" />
29 <include name="types/Mesh.cs" /> 26 <include name="types/Mesh.cs" />
30 <include name="types/Triangle.cs" /> 27 <include name="types/Triangle.cs" />
31 <include name="UserServer/LocalUserProfileManager.cs" /> 28 <include name="UserServer/LocalUserProfileManager.cs" />
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 07a2d6d..651c0c6 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -45,6 +45,8 @@ using OpenSim.Assets;
45using OpenSim.CAPS; 45using OpenSim.CAPS;
46using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
47using OpenSim.Physics.Manager; 47using OpenSim.Physics.Manager;
48using Nwc.XmlRpc;
49using OpenSim.Servers;
48 50
49namespace OpenSim 51namespace OpenSim
50{ 52{
@@ -54,7 +56,8 @@ namespace OpenSim
54 private World LocalWorld; 56 private World LocalWorld;
55 private Grid GridServers; 57 private Grid GridServers;
56 private SimConfig Cfg; 58 private SimConfig Cfg;
57 private SimCAPSHTTPServer HttpServer; 59 //private SimCAPSHTTPServer HttpServer;
60 private BaseHttpServer HttpServer;
58 private AssetCache AssetCache; 61 private AssetCache AssetCache;
59 private InventoryCache InventoryCache; 62 private InventoryCache InventoryCache;
60 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>(); 63 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>();
@@ -78,13 +81,13 @@ namespace OpenSim
78 public bool user_accounts = false; 81 public bool user_accounts = false;
79 82
80 protected ConsoleBase m_console; 83 protected ConsoleBase m_console;
81 84
82 public OpenSimMain( bool sandBoxMode, bool startLoginServer, string physicsEngine ) 85 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine)
83 { 86 {
84 m_sandbox = sandBoxMode; 87 m_sandbox = sandBoxMode;
85 m_loginserver = startLoginServer; 88 m_loginserver = startLoginServer;
86 m_physicsEngine = physicsEngine; 89 m_physicsEngine = physicsEngine;
87 90
88 m_console = new ConsoleBase("region-console.log", "Region", this); 91 m_console = new ConsoleBase("region-console.log", "Region", this);
89 OpenSim.Framework.Console.MainConsole.Instance = m_console; 92 OpenSim.Framework.Console.MainConsole.Instance = m_console;
90 } 93 }
@@ -92,11 +95,11 @@ namespace OpenSim
92 public virtual void StartUp() 95 public virtual void StartUp()
93 { 96 {
94 GridServers = new Grid(); 97 GridServers = new Grid();
95 if ( m_sandbox ) 98 if (m_sandbox)
96 { 99 {
97 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; 100 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
98 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; 101 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
99 102
100 m_console.WriteLine("Starting in Sandbox mode"); 103 m_console.WriteLine("Starting in Sandbox mode");
101 } 104 }
102 else 105 else
@@ -108,7 +111,7 @@ namespace OpenSim
108 } 111 }
109 112
110 GridServers.Initialise(); 113 GridServers.Initialise();
111 114
112 startuptime = DateTime.Now; 115 startuptime = DateTime.Now;
113 116
114 AssetCache = new AssetCache(GridServers.AssetServer); 117 AssetCache = new AssetCache(GridServers.AssetServer);
@@ -134,36 +137,74 @@ namespace OpenSim
134 LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); 137 LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap);
135 138
136 GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); 139 GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey);
137 GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); 140 //GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey);
141 IGridServer gridServer = GridServers.GridServer;
142 gridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey);
138 143
139 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. 144 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
140 LocalWorld.LoadPrimsFromStorage(); 145 LocalWorld.LoadPrimsFromStorage();
141 146
142 if ( m_sandbox) 147 if (m_sandbox)
143 { 148 {
144 AssetCache.LoadDefaultTextureSet(); 149 AssetCache.LoadDefaultTextureSet();
145 } 150 }
146 151
147 m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); 152 m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
148 HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); 153 // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
154 HttpServer = new BaseHttpServer(Cfg.IPListenPort);
155
156 if (gridServer.GetName() == "Remote")
157 {
158 //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
159 HttpServer.AddXmlRPCHandler("expect_user",
160 delegate(XmlRpcRequest request)
161 {
162 Hashtable requestData = (Hashtable)request.Params[0];
163 AgentCircuitData agent_data = new AgentCircuitData();
164 agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
165 agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
166 agent_data.firstname = (string)requestData["firstname"];
167 agent_data.lastname = (string)requestData["lastname"];
168 agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
169 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
170
171 ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
172
173 return new XmlRpcResponse();
174 });
175 }
176
149 177
150 LoginServer loginServer = null; 178 LoginServer loginServer = null;
151 if (m_loginserver && m_sandbox) 179 if (m_loginserver && m_sandbox)
152 { 180 {
153 loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); 181 loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts);
154 loginServer.Startup(); 182 loginServer.Startup();
155 183
156 } 184 }
157 if((m_loginserver) && (m_sandbox) && (user_accounts)) 185
186 if ((m_loginserver) && (m_sandbox) && (user_accounts))
158 { 187 {
188 //sandbox mode with loginserver using accounts
159 this.GridServers.UserServer = loginServer; 189 this.GridServers.UserServer = loginServer;
160 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); 190 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer));
191 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
161 } 192 }
162 else 193 else if ((m_loginserver) && (m_sandbox))
194 {
195 //sandbox mode with loginserver not using accounts
196 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null));
197 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
198 }
199 else
163 { 200 {
201 //not in sandbox mode so no loginserver, so we don't handle login attempts
164 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); 202 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null));
165 } 203 }
166 204
205 m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
206 HttpServer.Start();
207
167 MainServerListener(); 208 MainServerListener();
168 209
169 timer1.Enabled = true; 210 timer1.Enabled = true;
@@ -207,12 +248,12 @@ namespace OpenSim
207 int numBytes = Server.EndReceiveFrom(result, ref epSender); 248 int numBytes = Server.EndReceiveFrom(result, ref epSender);
208 int packetEnd = numBytes - 1; 249 int packetEnd = numBytes - 1;
209 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 250 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
210 251
211 // This is either a new client or a packet to send to an old one 252 // This is either a new client or a packet to send to an old one
212 // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) 253 // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender))
213 254
214 // do we already have a circuit for this endpoint 255 // do we already have a circuit for this endpoint
215 if(this.clientCircuits.ContainsKey(epSender)) 256 if (this.clientCircuits.ContainsKey(epSender))
216 { 257 {
217 ClientThreads[this.clientCircuits[epSender]].InPacket(packet); 258 ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
218 } 259 }
@@ -223,7 +264,6 @@ namespace OpenSim
223 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); 264 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
224 if ((this.GridServers.UserServer != null) && (user_accounts)) 265 if ((this.GridServers.UserServer != null) && (user_accounts))
225 { 266 {
226 Console.WriteLine("setting userserver");
227 newuser.UserServer = this.GridServers.UserServer; 267 newuser.UserServer = this.GridServers.UserServer;
228 } 268 }
229 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); 269 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
@@ -256,11 +296,11 @@ namespace OpenSim
256 296
257 } 297 }
258 298
259 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) 299 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
260 { 300 {
261 // find the endpoint for this circuit 301 // find the endpoint for this circuit
262 EndPoint sendto = null; 302 EndPoint sendto = null;
263 foreach(KeyValuePair<EndPoint, uint> p in this.clientCircuits) 303 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
264 { 304 {
265 if (p.Value == circuitcode) 305 if (p.Value == circuitcode)
266 { 306 {
@@ -304,7 +344,7 @@ namespace OpenSim
304 { 344 {
305 LocalWorld.Update(); 345 LocalWorld.Update();
306 } 346 }
307 347
308 public void RunCmd(string command, string[] cmdparams) 348 public void RunCmd(string command, string[] cmdparams)
309 { 349 {
310 switch (command) 350 switch (command)
@@ -353,5 +393,5 @@ namespace OpenSim
353 } 393 }
354 } 394 }
355 395
356 396
357} 397}
diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs
index b31feda..3ae7878 100644
--- a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs
+++ b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs
@@ -10,7 +10,7 @@ using libsecondlife;
10 10
11namespace OpenSim.UserServer 11namespace OpenSim.UserServer
12{ 12{
13 class LocalUserProfileManager : UserProfileManager 13 public class LocalUserProfileManager : UserProfileManager
14 { 14 {
15 private IGridServer m_gridServer; 15 private IGridServer m_gridServer;
16 private int m_port; 16 private int m_port;
diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs
index 7b4c1f0..a68e013 100644
--- a/OpenSim.RegionServer/UserServer/LoginServer.cs
+++ b/OpenSim.RegionServer/UserServer/LoginServer.cs
@@ -50,7 +50,7 @@ namespace OpenSim.UserServer
50 /// <summary> 50 /// <summary>
51 /// When running in local (default) mode , handles client logins. 51 /// When running in local (default) mode , handles client logins.
52 /// </summary> 52 /// </summary>
53 public class LoginServer : LoginService , IUserServer 53 public class LoginServer : LoginService, IUserServer
54 { 54 {
55 private IGridServer m_gridServer; 55 private IGridServer m_gridServer;
56 private ushort _loginPort = 8080; 56 private ushort _loginPort = 8080;
@@ -66,7 +66,15 @@ namespace OpenSim.UserServer
66 private int m_simPort; 66 private int m_simPort;
67 private string m_simAddr; 67 private string m_simAddr;
68 68
69 public LoginServer(IGridServer gridServer, string simAddr, int simPort , bool useAccounts) 69 public LocalUserProfileManager LocalUserManager
70 {
71 get
72 {
73 return userManager;
74 }
75 }
76
77 public LoginServer(IGridServer gridServer, string simAddr, int simPort, bool useAccounts)
70 { 78 {
71 m_gridServer = gridServer; 79 m_gridServer = gridServer;
72 m_simPort = simPort; 80 m_simPort = simPort;
@@ -74,6 +82,14 @@ namespace OpenSim.UserServer
74 this.userAccounts = useAccounts; 82 this.userAccounts = useAccounts;
75 } 83 }
76 84
85 public void Startup()
86 {
87 this.InitializeLogin();
88 //Thread runLoginProxy = new Thread(new ThreadStart(RunLogin));
89 //runLoginProxy.IsBackground = true;
90 //runLoginProxy.Start();
91 }
92
77 // InitializeLogin: initialize the login 93 // InitializeLogin: initialize the login
78 private void InitializeLogin() 94 private void InitializeLogin()
79 { 95 {
@@ -94,129 +110,124 @@ namespace OpenSim.UserServer
94 SR.Close(); 110 SR.Close();
95 this._mpasswd = EncodePassword("testpass"); 111 this._mpasswd = EncodePassword("testpass");
96 112
97 userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr ); 113 userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr);
98 userManager.InitUserProfiles(); 114 userManager.InitUserProfiles();
99 userManager.SetKeys("", "", "", "Welcome to OpenSim"); 115 userManager.SetKeys("", "", "", "Welcome to OpenSim");
100 116
101 loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 117 //loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
102 loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); 118 // loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort));
103 loginServer.Listen(1); 119 //loginServer.Listen(1);
104 }
105
106 public void Startup()
107 {
108 this.InitializeLogin();
109 Thread runLoginProxy = new Thread(new ThreadStart(RunLogin));
110 runLoginProxy.IsBackground = true;
111 runLoginProxy.Start();
112 }
113
114 private void RunLogin()
115 {
116 Console.WriteLine("Starting Login Server");
117 try
118 {
119 for (; ; )
120 {
121 Socket client = loginServer.Accept();
122 IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint;
123
124
125 NetworkStream networkStream = new NetworkStream(client);
126 StreamReader networkReader = new StreamReader(networkStream);
127 StreamWriter networkWriter = new StreamWriter(networkStream);
128
129 try
130 {
131 LoginRequest(networkReader, networkWriter);
132 }
133 catch (Exception e)
134 {
135 Console.WriteLine(e.Message);
136 }
137
138 networkWriter.Close();
139 networkReader.Close();
140 networkStream.Close();
141
142 client.Close();
143
144 // send any packets queued for injection
145
146 }
147 }
148 catch (Exception e)
149 {
150 Console.WriteLine(e.Message);
151 Console.WriteLine(e.StackTrace);
152 }
153 }
154
155 // ProxyLogin: proxy a login request
156 private void LoginRequest(StreamReader reader, StreamWriter writer)
157 {
158 lock (this)
159 {
160 string line;
161 int contentLength = 0;
162 // read HTTP header
163 do
164 {
165 // read one line of the header
166 line = reader.ReadLine();
167
168 // check for premature EOF
169 if (line == null)
170 throw new Exception("EOF in client HTTP header");
171
172 // look for Content-Length
173 Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line);
174 if (match.Success)
175 contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString());
176 } while (line != "");
177
178 // read the HTTP body into a buffer
179 char[] content = new char[contentLength];
180 reader.Read(content, 0, contentLength);
181
182 if (this.userAccounts)
183 {
184 //ask the UserProfile Manager to process the request
185 string reply = this.userManager.ParseXMLRPC(new String(content));
186 // forward the XML-RPC response to the client
187 writer.WriteLine("HTTP/1.0 200 OK");
188 writer.WriteLine("Content-type: text/xml");
189 writer.WriteLine();
190 writer.WriteLine(reply);
191 }
192 else
193 {
194 //handle ourselves
195 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
196 if (request.MethodName == "login_to_simulator")
197 {
198 this.ProcessXmlRequest(request, writer);
199 }
200 else
201 {
202 XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
203 Hashtable PresenceErrorRespData = new Hashtable();
204 PresenceErrorRespData["reason"] = "XmlRequest"; ;
205 PresenceErrorRespData["message"] = "Unknown Rpc request";
206 PresenceErrorRespData["login"] = "false";
207 PresenceErrorResp.Value = PresenceErrorRespData;
208 string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "");
209 writer.WriteLine("HTTP/1.0 200 OK");
210 writer.WriteLine("Content-type: text/xml");
211 writer.WriteLine();
212 writer.WriteLine(reply);
213 }
214 }
215 }
216 } 120 }
217 121
218 public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) 122 /* private void RunLogin()
123 {
124 Console.WriteLine("Starting Login Server");
125 try
126 {
127 for (; ; )
128 {
129 Socket client = loginServer.Accept();
130 IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint;
131
132
133 NetworkStream networkStream = new NetworkStream(client);
134 StreamReader networkReader = new StreamReader(networkStream);
135 StreamWriter networkWriter = new StreamWriter(networkStream);
136
137 try
138 {
139 LoginRequest(networkReader, networkWriter);
140 }
141 catch (Exception e)
142 {
143 Console.WriteLine(e.Message);
144 }
145
146 networkWriter.Close();
147 networkReader.Close();
148 networkStream.Close();
149
150 client.Close();
151
152 // send any packets queued for injection
153
154 }
155 }
156 catch (Exception e)
157 {
158 Console.WriteLine(e.Message);
159 Console.WriteLine(e.StackTrace);
160 }
161 }
162
163 // ProxyLogin: proxy a login request
164 private void LoginRequest(StreamReader reader, StreamWriter writer)
165 {
166 lock (this)
167 {
168 string line;
169 int contentLength = 0;
170 // read HTTP header
171 do
172 {
173 // read one line of the header
174 line = reader.ReadLine();
175
176 // check for premature EOF
177 if (line == null)
178 throw new Exception("EOF in client HTTP header");
179
180 // look for Content-Length
181 Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line);
182 if (match.Success)
183 contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString());
184 } while (line != "");
185
186 // read the HTTP body into a buffer
187 char[] content = new char[contentLength];
188 reader.Read(content, 0, contentLength);
189
190 if (this.userAccounts)
191 {
192 //ask the UserProfile Manager to process the request
193 string reply = this.userManager.ParseXMLRPC(new String(content));
194 // forward the XML-RPC response to the client
195 writer.WriteLine("HTTP/1.0 200 OK");
196 writer.WriteLine("Content-type: text/xml");
197 writer.WriteLine();
198 writer.WriteLine(reply);
199 }
200 else
201 {
202 //handle ourselves
203 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
204 if (request.MethodName == "login_to_simulator")
205 {
206 this.ProcessXmlRequest(request, writer);
207 }
208 else
209 {
210 XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
211 Hashtable PresenceErrorRespData = new Hashtable();
212 PresenceErrorRespData["reason"] = "XmlRequest"; ;
213 PresenceErrorRespData["message"] = "Unknown Rpc request";
214 PresenceErrorRespData["login"] = "false";
215 PresenceErrorResp.Value = PresenceErrorRespData;
216 string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "");
217 writer.WriteLine("HTTP/1.0 200 OK");
218 writer.WriteLine("Content-type: text/xml");
219 writer.WriteLine();
220 writer.WriteLine(reply);
221 }
222 }
223 }
224 }
225 */
226 //public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer)
227
228 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
219 { 229 {
230 Console.WriteLine("login attempt");
220 Hashtable requestData = (Hashtable)request.Params[0]; 231 Hashtable requestData = (Hashtable)request.Params[0];
221 string first; 232 string first;
222 string last; 233 string last;
@@ -224,6 +235,8 @@ namespace OpenSim.UserServer
224 LLUUID Agent; 235 LLUUID Agent;
225 LLUUID Session; 236 LLUUID Session;
226 237
238 XmlRpcResponse response = new XmlRpcResponse();
239
227 //get login name 240 //get login name
228 if (requestData.Contains("first")) 241 if (requestData.Contains("first"))
229 { 242 {
@@ -254,18 +267,24 @@ namespace OpenSim.UserServer
254 267
255 if (!Authenticate(first, last, passwd)) 268 if (!Authenticate(first, last, passwd))
256 { 269 {
257 XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); 270 /* XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
258 Hashtable PresenceErrorRespData = new Hashtable(); 271 Hashtable PresenceErrorRespData = new Hashtable();
259 PresenceErrorRespData["reason"] = "key"; ; 272 PresenceErrorRespData["reason"] = "key"; ;
260 PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; 273 PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
261 PresenceErrorRespData["login"] = "false"; 274 PresenceErrorRespData["login"] = "false";
262 PresenceErrorResp.Value = PresenceErrorRespData; 275 PresenceErrorResp.Value = PresenceErrorRespData;
263 string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); 276 string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "");
264 writer.WriteLine("HTTP/1.0 200 OK"); 277 writer.WriteLine("HTTP/1.0 200 OK");
265 writer.WriteLine("Content-type: text/xml"); 278 writer.WriteLine("Content-type: text/xml");
266 writer.WriteLine(); 279 writer.WriteLine();
267 writer.WriteLine(reply); 280 writer.WriteLine(reply);
268 return false; 281 return false;*/
282
283 Hashtable loginError = new Hashtable();
284 loginError["reason"] = "key"; ;
285 loginError["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
286 loginError["login"] = "false";
287 response.Value = loginError;
269 } 288 }
270 289
271 NumClients++; 290 NumClients++;
@@ -291,15 +310,15 @@ namespace OpenSim.UserServer
291 ArrayList GlobalTextures = new ArrayList(); 310 ArrayList GlobalTextures = new ArrayList();
292 GlobalTextures.Add(GlobalT); 311 GlobalTextures.Add(GlobalT);
293 312
294 XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); 313 response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
295 Hashtable responseData = (Hashtable)response.Value; 314 Hashtable responseData = (Hashtable)response.Value;
296 315
297 responseData["sim_port"] = m_simPort; 316 responseData["sim_port"] = m_simPort;
298 responseData["sim_ip"] = m_simAddr; 317 responseData["sim_ip"] = m_simAddr;
299 responseData["agent_id"] = Agent.ToStringHyphenated(); 318 responseData["agent_id"] = Agent.ToStringHyphenated();
300 responseData["session_id"] = Session.ToStringHyphenated(); 319 responseData["session_id"] = Session.ToStringHyphenated();
301 responseData["secure_session_id"]= secureSess.ToStringHyphenated(); 320 responseData["secure_session_id"] = secureSess.ToStringHyphenated();
302 responseData["circuit_code"] = (Int32)(Util.RandomClass.Next()); 321 responseData["circuit_code"] = (Int32)(Util.RandomClass.Next());
303 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 322 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
304 responseData["login-flags"] = LoginFlags; 323 responseData["login-flags"] = LoginFlags;
305 responseData["global-textures"] = GlobalTextures; 324 responseData["global-textures"] = GlobalTextures;
@@ -337,16 +356,16 @@ namespace OpenSim.UserServer
337 ((LocalGridBase)m_gridServer).AddNewSession(_login); 356 ((LocalGridBase)m_gridServer).AddNewSession(_login);
338 } 357 }
339 358
340 // forward the XML-RPC response to the client 359 /* // forward the XML-RPC response to the client
341 writer.WriteLine("HTTP/1.0 200 OK"); 360 writer.WriteLine("HTTP/1.0 200 OK");
342 writer.WriteLine("Content-type: text/xml"); 361 writer.WriteLine("Content-type: text/xml");
343 writer.WriteLine(); 362 writer.WriteLine();
344 363
345 XmlTextWriter responseWriter = new XmlTextWriter(writer); 364 XmlTextWriter responseWriter = new XmlTextWriter(writer);
346 XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); 365 XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
347 responseWriter.Close(); 366 responseWriter.Close();*/
348 367
349 return true; 368 return response;
350 } 369 }
351 370
352 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last) 371 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
diff --git a/OpenSim.RegionServer/CAPS/IRestHandler.cs b/Servers/IRestHandler.cs
index f269600..f269600 100644
--- a/OpenSim.RegionServer/CAPS/IRestHandler.cs
+++ b/Servers/IRestHandler.cs