aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/Linden/LLProxyLoginModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Client/Linden/LLProxyLoginModule.cs')
-rw-r--r--OpenSim/Client/Linden/LLProxyLoginModule.cs364
1 files changed, 0 insertions, 364 deletions
diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs
deleted file mode 100644
index 9075f15..0000000
--- a/OpenSim/Client/Linden/LLProxyLoginModule.cs
+++ /dev/null
@@ -1,364 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Net;
34using System.Net.Sockets;
35using System.Reflection;
36using System.Security.Authentication;
37using log4net;
38using Nini.Config;
39using OpenMetaverse;
40using OpenSim.Framework;
41using OpenSim.Framework.Communications;
42using OpenSim.Framework.Servers;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45
46namespace OpenSim.Client.Linden
47{
48 /// <summary>
49 /// Handles login user (expect user) and logoff user messages from the remote LL login server
50 /// </summary>
51 public class LLProxyLoginModule : ISharedRegionModule
52 {
53 private uint m_port = 0;
54
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public LLProxyLoginModule(uint port)
58 {
59 m_log.DebugFormat("[CLIENT]: LLProxyLoginModule port {0}", port);
60 m_port = port;
61 }
62
63 protected bool RegionLoginsEnabled
64 {
65 get
66 {
67 if (m_firstScene != null)
68 {
69 return m_firstScene.SceneGridService.RegionLoginsEnabled;
70 }
71 else
72 {
73 return false;
74 }
75 }
76 }
77
78 protected List<Scene> m_scenes = new List<Scene>();
79 protected Scene m_firstScene;
80
81 protected bool m_enabled = false; // Module is only enabled if running in grid mode
82
83 #region IRegionModule Members
84
85 public void Initialise(IConfigSource source)
86 {
87 IConfig startupConfig = source.Configs["Modules"];
88 if (startupConfig != null)
89 {
90 m_enabled = startupConfig.GetBoolean("LLProxyLoginModule", false);
91 }
92 }
93
94 public void AddRegion(Scene scene)
95 {
96 if (m_firstScene == null)
97 {
98 m_firstScene = scene;
99
100 if (m_enabled)
101 {
102 AddHttpHandlers();
103 }
104 }
105
106 if (m_enabled)
107 {
108 AddScene(scene);
109 }
110
111 }
112
113 public void RemoveRegion(Scene scene)
114 {
115 if (m_enabled)
116 {
117 RemoveScene(scene);
118 }
119 }
120
121 public void PostInitialise()
122 {
123
124 }
125
126 public void Close()
127 {
128
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133
134 }
135
136 public Type ReplaceableInterface
137 {
138 get { return null; }
139 }
140
141 public string Name
142 {
143 get { return "LLProxyLoginModule"; }
144 }
145
146 public bool IsSharedModule
147 {
148 get { return true; }
149 }
150
151 #endregion
152
153 /// <summary>
154 /// Adds "expect_user" and "logoff_user" xmlrpc method handlers
155 /// </summary>
156 protected void AddHttpHandlers()
157 {
158 //we will add our handlers to the first scene we received, as all scenes share a http server. But will this ever change?
159 MainServer.GetHttpServer(m_port).AddXmlRPCHandler("expect_user", ExpectUser, false);
160 MainServer.GetHttpServer(m_port).AddXmlRPCHandler("logoff_user", LogOffUser, false);
161 }
162
163 protected void AddScene(Scene scene)
164 {
165 lock (m_scenes)
166 {
167 if (!m_scenes.Contains(scene))
168 {
169 m_scenes.Add(scene);
170 }
171 }
172 }
173
174 protected void RemoveScene(Scene scene)
175 {
176 lock (m_scenes)
177 {
178 if (m_scenes.Contains(scene))
179 {
180 m_scenes.Remove(scene);
181 }
182 }
183 }
184 /// <summary>
185 /// Received from the user server when a user starts logging in. This call allows
186 /// the region to prepare for direct communication from the client. Sends back an empty
187 /// xmlrpc response on completion.
188 /// </summary>
189 /// <param name="request"></param>
190 /// <returns></returns>
191 public XmlRpcResponse ExpectUser(XmlRpcRequest request, IPEndPoint remoteClient)
192 {
193 XmlRpcResponse resp = new XmlRpcResponse();
194
195 try
196 {
197 ulong regionHandle = 0;
198 Hashtable requestData = (Hashtable)request.Params[0];
199 AgentCircuitData agentData = new AgentCircuitData();
200 if (requestData.ContainsKey("session_id"))
201 agentData.SessionID = new UUID((string)requestData["session_id"]);
202 if (requestData.ContainsKey("secure_session_id"))
203 agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
204 if (requestData.ContainsKey("firstname"))
205 agentData.firstname = (string)requestData["firstname"];
206 if (requestData.ContainsKey("lastname"))
207 agentData.lastname = (string)requestData["lastname"];
208 if (requestData.ContainsKey("agent_id"))
209 agentData.AgentID = new UUID((string)requestData["agent_id"]);
210 if (requestData.ContainsKey("circuit_code"))
211 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
212 if (requestData.ContainsKey("caps_path"))
213 agentData.CapsPath = (string)requestData["caps_path"];
214 if (requestData.ContainsKey("regionhandle"))
215 regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
216 else
217 m_log.Warn("[CLIENT]: request from login server did not contain regionhandle");
218
219 // Appearance
220 if (requestData.ContainsKey("appearance"))
221 agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
222
223 m_log.DebugFormat(
224 "[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
225 agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
226
227 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
228 {
229 //m_log.Debug("[CLIENT]: Child agent detected");
230 agentData.child = true;
231 }
232 else
233 {
234 //m_log.Debug("[CLIENT]: Main agent detected");
235 agentData.startpos =
236 new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
237 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
238 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
239 agentData.child = false;
240 }
241
242 if (!RegionLoginsEnabled)
243 {
244 m_log.InfoFormat(
245 "[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
246 agentData.firstname, agentData.lastname);
247
248 Hashtable respdata = new Hashtable();
249 respdata["success"] = "FALSE";
250 respdata["reason"] = "region login currently disabled";
251 resp.Value = respdata;
252 }
253 else
254 {
255 bool success = false;
256 string denyMess = "";
257
258 Scene scene;
259 if (TryGetRegion(regionHandle, out scene))
260 {
261 if (scene.RegionInfo.EstateSettings.IsBanned(agentData.AgentID))
262 {
263 denyMess = "User is banned from this region";
264 m_log.InfoFormat(
265 "[CLIENT]: Denying access for user {0} {1} because user is banned",
266 agentData.firstname, agentData.lastname);
267 }
268 else
269 {
270 string reason;
271 if (scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
272 {
273 success = true;
274 }
275 else
276 {
277 denyMess = String.Format("Login refused by region: {0}", reason);
278 m_log.InfoFormat(
279 "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region",
280 agentData.firstname, agentData.lastname);
281 }
282 }
283
284 }
285 else
286 {
287 denyMess = "Region not found";
288 }
289
290 if (success)
291 {
292 Hashtable respdata = new Hashtable();
293 respdata["success"] = "TRUE";
294 resp.Value = respdata;
295 }
296 else
297 {
298 Hashtable respdata = new Hashtable();
299 respdata["success"] = "FALSE";
300 respdata["reason"] = denyMess;
301 resp.Value = respdata;
302 }
303 }
304 }
305 catch (Exception e)
306 {
307 m_log.WarnFormat("[CLIENT]: Unable to receive user. Reason: {0} ({1})", e, e.StackTrace);
308 Hashtable respdata = new Hashtable();
309 respdata["success"] = "FALSE";
310 respdata["reason"] = "Exception occurred";
311 resp.Value = respdata;
312 }
313
314 return resp;
315 }
316
317 // Grid Request Processing
318 /// <summary>
319 /// Ooops, our Agent must be dead if we're getting this request!
320 /// </summary>
321 /// <param name="request"></param>
322 /// <returns></returns>
323 public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
324 {
325 m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
326
327 Hashtable requestData = (Hashtable)request.Params[0];
328 string message = (string)requestData["message"];
329 UUID agentID = UUID.Zero;
330 UUID RegionSecret = UUID.Zero;
331 UUID.TryParse((string)requestData["agent_id"], out agentID);
332 UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
333
334 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
335
336 Scene scene;
337 if (TryGetRegion(regionHandle, out scene))
338 {
339 scene.HandleLogOffUserFromGrid(agentID, RegionSecret, message);
340 }
341
342 return new XmlRpcResponse();
343 }
344
345 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
346 {
347 lock (m_scenes)
348 {
349 foreach (Scene nextScene in m_scenes)
350 {
351 if (nextScene.RegionInfo.RegionHandle == regionHandle)
352 {
353 scene = nextScene;
354 return true;
355 }
356 }
357 }
358
359 scene = null;
360 return false;
361 }
362
363 }
364}