aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 11:43:07 +0100
committerUbitUmarov2015-09-01 11:43:07 +0100
commitfb78b182520fc9bb0f971afd0322029c70278ea6 (patch)
treeb4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Server/Handlers/Hypergrid
parentlixo (diff)
parentMantis #7713: fixed bug introduced by 1st MOSES patch. (diff)
downloadopensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.zip
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs70
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs89
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendServerConnector.cs77
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs425
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs113
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs137
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs136
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/InstantMessageServerConnector.cs248
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs488
9 files changed, 1783 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs
new file mode 100644
index 0000000..95a0510
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs
@@ -0,0 +1,70 @@
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.IO;
31using System.Reflection;
32using System.Net;
33using System.Text;
34
35using OpenSim.Server.Base;
36using OpenSim.Server.Handlers.Base;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Server.Handlers.Simulation;
42using Utils = OpenSim.Server.Handlers.Simulation.Utils;
43
44using OpenMetaverse;
45using OpenMetaverse.StructuredData;
46using Nini.Config;
47using log4net;
48
49
50namespace OpenSim.Server.Handlers.Hypergrid
51{
52 public class GatekeeperAgentHandler : OpenSim.Server.Handlers.Simulation.AgentPostHandler
53 {
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private IGatekeeperService m_GatekeeperService;
57
58 public GatekeeperAgentHandler(IGatekeeperService gatekeeper, bool proxy) : base("/foreignagent")
59 {
60 m_GatekeeperService = gatekeeper;
61 m_Proxy = proxy;
62 }
63
64 protected override bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination,
65 AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
66 {
67 return m_GatekeeperService.LoginAgent(source, aCircuit, destination, out reason);
68 }
69 }
70}
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
new file mode 100644
index 0000000..ffe2f36
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
@@ -0,0 +1,89 @@
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.Generic;
30using System.Reflection;
31using Nini.Config;
32using OpenSim.Framework;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Server.Handlers.Base;
37
38using log4net;
39
40namespace OpenSim.Server.Handlers.Hypergrid
41{
42 public class GatekeeperServiceInConnector : ServiceConnector
43 {
44// private static readonly ILog m_log =
45// LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType);
47
48 private IGatekeeperService m_GatekeeperService;
49 public IGatekeeperService GateKeeper
50 {
51 get { return m_GatekeeperService; }
52 }
53
54 bool m_Proxy = false;
55
56 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
57 base(config, server, String.Empty)
58 {
59 IConfig gridConfig = config.Configs["GatekeeperService"];
60 if (gridConfig != null)
61 {
62 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
63 Object[] args = new Object[] { config, simService };
64 m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(serviceDll, args);
65
66 }
67 if (m_GatekeeperService == null)
68 throw new Exception("Gatekeeper server connector cannot proceed because of missing service");
69
70 m_Proxy = gridConfig.GetBoolean("HasProxy", false);
71
72 HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
73 server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
74 server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
75
76 server.AddStreamHandler(new GatekeeperAgentHandler(m_GatekeeperService, m_Proxy));
77 }
78
79 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, string configName)
80 : this(config, server, (ISimulationService)null)
81 {
82 }
83
84 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server)
85 : this(config, server, String.Empty)
86 {
87 }
88 }
89}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendServerConnector.cs
new file mode 100644
index 0000000..6c79c60
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendServerConnector.cs
@@ -0,0 +1,77 @@
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 Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base;
34
35namespace OpenSim.Server.Handlers.Hypergrid
36{
37 public class HGFriendsServerConnector : ServiceConnector
38 {
39 private IUserAgentService m_UserAgentService;
40 private IHGFriendsService m_TheService;
41 private string m_ConfigName = "HGFriendsService";
42
43 // Called from Robust
44 public HGFriendsServerConnector(IConfigSource config, IHttpServer server, string configName) :
45 this(config, server, configName, null)
46 {
47
48 }
49
50 // Called from standalone configurations
51 public HGFriendsServerConnector(IConfigSource config, IHttpServer server, string configName, IFriendsSimConnector localConn)
52 : base(config, server, configName)
53 {
54 if (configName != string.Empty)
55 m_ConfigName = configName;
56
57 Object[] args = new Object[] { config, m_ConfigName, localConn };
58
59 IConfig serverConfig = config.Configs[m_ConfigName];
60 if (serverConfig == null)
61 throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
62
63 string theService = serverConfig.GetString("LocalServiceModule",
64 String.Empty);
65 if (theService == String.Empty)
66 throw new Exception("No LocalServiceModule in config file");
67 m_TheService = ServerUtils.LoadPlugin<IHGFriendsService>(theService, args);
68
69 theService = serverConfig.GetString("UserAgentService", string.Empty);
70 if (theService == String.Empty)
71 throw new Exception("No UserAgentService in " + m_ConfigName);
72 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(theService, new Object[] { config, localConn });
73
74 server.AddStreamHandler(new HGFriendsServerPostHandler(m_TheService, m_UserAgentService, localConn));
75 }
76 }
77}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
new file mode 100644
index 0000000..37b47ed
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -0,0 +1,425 @@
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 Nini.Config;
29using log4net;
30using System;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43using OpenSim.Framework;
44using OpenSim.Framework.Servers.HttpServer;
45using OpenMetaverse;
46
47namespace OpenSim.Server.Handlers.Hypergrid
48{
49 public class HGFriendsServerPostHandler : BaseStreamHandler
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 private IUserAgentService m_UserAgentService;
54 private IFriendsSimConnector m_FriendsLocalSimConnector;
55 private IHGFriendsService m_TheService;
56
57 public HGFriendsServerPostHandler(IHGFriendsService service, IUserAgentService uas, IFriendsSimConnector friendsConn) :
58 base("POST", "/hgfriends")
59 {
60 m_TheService = service;
61 m_UserAgentService = uas;
62 m_FriendsLocalSimConnector = friendsConn;
63
64 m_log.DebugFormat("[HGFRIENDS HANDLER]: HGFriendsServerPostHandler is On ({0})",
65 (m_FriendsLocalSimConnector == null ? "robust" : "standalone"));
66
67 if (m_TheService == null)
68 m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!");
69 }
70
71 protected override byte[] ProcessRequest(string path, Stream requestData,
72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
73 {
74 StreamReader sr = new StreamReader(requestData);
75 string body = sr.ReadToEnd();
76 sr.Close();
77 body = body.Trim();
78
79 //m_log.DebugFormat("[XXX]: query String: {0}", body);
80
81 try
82 {
83 Dictionary<string, object> request =
84 ServerUtils.ParseQueryString(body);
85
86 if (!request.ContainsKey("METHOD"))
87 return FailureResult();
88
89 string method = request["METHOD"].ToString();
90
91 switch (method)
92 {
93 case "getfriendperms":
94 return GetFriendPerms(request);
95
96 case "newfriendship":
97 return NewFriendship(request);
98
99 case "deletefriendship":
100 return DeleteFriendship(request);
101
102 /* Same as inter-sim */
103 case "friendship_offered":
104 return FriendshipOffered(request);
105
106 case "validate_friendship_offered":
107 return ValidateFriendshipOffered(request);
108
109 case "statusnotification":
110 return StatusNotification(request);
111 /*
112 case "friendship_approved":
113 return FriendshipApproved(request);
114
115 case "friendship_denied":
116 return FriendshipDenied(request);
117
118 case "friendship_terminated":
119 return FriendshipTerminated(request);
120
121 case "grant_rights":
122 return GrantRights(request);
123 */
124 }
125
126 m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0}", method);
127 }
128 catch (Exception e)
129 {
130 m_log.DebugFormat("[HGFRIENDS HANDLER]: Exception {0}", e);
131 }
132
133 return FailureResult();
134 }
135
136 #region Method-specific handlers
137
138 byte[] GetFriendPerms(Dictionary<string, object> request)
139 {
140 if (!VerifyServiceKey(request))
141 return FailureResult();
142
143 UUID principalID = UUID.Zero;
144 if (request.ContainsKey("PRINCIPALID"))
145 UUID.TryParse(request["PRINCIPALID"].ToString(), out principalID);
146 else
147 {
148 m_log.WarnFormat("[HGFRIENDS HANDLER]: no principalID in request to get friend perms");
149 return FailureResult();
150 }
151
152 UUID friendID = UUID.Zero;
153 if (request.ContainsKey("FRIENDID"))
154 UUID.TryParse(request["FRIENDID"].ToString(), out friendID);
155 else
156 {
157 m_log.WarnFormat("[HGFRIENDS HANDLER]: no friendID in request to get friend perms");
158 return FailureResult();
159 }
160
161 int perms = m_TheService.GetFriendPerms(principalID, friendID);
162 if (perms < 0)
163 return FailureResult("Friend not found");
164
165 return SuccessResult(perms.ToString());
166 }
167
168 byte[] NewFriendship(Dictionary<string, object> request)
169 {
170 bool verified = VerifyServiceKey(request);
171
172 FriendInfo friend = new FriendInfo(request);
173
174 bool success = m_TheService.NewFriendship(friend, verified);
175
176 if (success)
177 return SuccessResult();
178 else
179 return FailureResult();
180 }
181
182 byte[] DeleteFriendship(Dictionary<string, object> request)
183 {
184 FriendInfo friend = new FriendInfo(request);
185 string secret = string.Empty;
186 if (request.ContainsKey("SECRET"))
187 secret = request["SECRET"].ToString();
188
189 if (secret == string.Empty)
190 return BoolResult(false);
191
192 bool success = m_TheService.DeleteFriendship(friend, secret);
193
194 return BoolResult(success);
195 }
196
197 byte[] FriendshipOffered(Dictionary<string, object> request)
198 {
199 UUID fromID = UUID.Zero;
200 UUID toID = UUID.Zero;
201 string message = string.Empty;
202 string name = string.Empty;
203
204 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
205 return BoolResult(false);
206
207 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
208 return BoolResult(false);
209
210 message = request["Message"].ToString();
211
212 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
213 return BoolResult(false);
214
215 if (request.ContainsKey("FromName"))
216 name = request["FromName"].ToString();
217
218 bool success = m_TheService.FriendshipOffered(fromID, name, toID, message);
219
220 return BoolResult(success);
221 }
222
223 byte[] ValidateFriendshipOffered(Dictionary<string, object> request)
224 {
225 FriendInfo friend = new FriendInfo(request);
226 UUID friendID = UUID.Zero;
227 if (!UUID.TryParse(friend.Friend, out friendID))
228 return BoolResult(false);
229
230 bool success = m_TheService.ValidateFriendshipOffered(friend.PrincipalID, friendID);
231
232 return BoolResult(success);
233 }
234
235 byte[] StatusNotification(Dictionary<string, object> request)
236 {
237 UUID principalID = UUID.Zero;
238 if (request.ContainsKey("userID"))
239 UUID.TryParse(request["userID"].ToString(), out principalID);
240 else
241 {
242 m_log.WarnFormat("[HGFRIENDS HANDLER]: no userID in request to notify");
243 return FailureResult();
244 }
245
246 bool online = true;
247 if (request.ContainsKey("online"))
248 Boolean.TryParse(request["online"].ToString(), out online);
249 else
250 {
251 m_log.WarnFormat("[HGFRIENDS HANDLER]: no online in request to notify");
252 return FailureResult();
253 }
254
255 List<string> friends = new List<string>();
256 int i = 0;
257 foreach (KeyValuePair<string, object> kvp in request)
258 {
259 if (kvp.Key.Equals("friend_" + i.ToString()))
260 {
261 friends.Add(kvp.Value.ToString());
262 i++;
263 }
264 }
265
266 List<UUID> onlineFriends = m_TheService.StatusNotification(friends, principalID, online);
267
268 Dictionary<string, object> result = new Dictionary<string, object>();
269 if ((onlineFriends == null) || ((onlineFriends != null) && (onlineFriends.Count == 0)))
270 result["RESULT"] = "NULL";
271 else
272 {
273 i = 0;
274 foreach (UUID f in onlineFriends)
275 {
276 result["friend_" + i] = f.ToString();
277 i++;
278 }
279 }
280
281 string xmlString = ServerUtils.BuildXmlResponse(result);
282
283 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
284 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
285 }
286
287 #endregion
288
289 #region Misc
290
291 private bool VerifyServiceKey(Dictionary<string, object> request)
292 {
293 if (!request.ContainsKey("KEY") || !request.ContainsKey("SESSIONID"))
294 {
295 m_log.WarnFormat("[HGFRIENDS HANDLER]: ignoring request without Key or SessionID");
296 return false;
297 }
298
299 if (request["KEY"] == null || request["SESSIONID"] == null)
300 return false;
301
302 string serviceKey = request["KEY"].ToString();
303 string sessionStr = request["SESSIONID"].ToString();
304
305 UUID sessionID;
306 if (!UUID.TryParse(sessionStr, out sessionID) || serviceKey == string.Empty)
307 return false;
308
309 if (!m_UserAgentService.VerifyAgent(sessionID, serviceKey))
310 {
311 m_log.WarnFormat("[HGFRIENDS HANDLER]: Key {0} for session {1} did not match existing key. Ignoring request", serviceKey, sessionID);
312 return false;
313 }
314
315 m_log.DebugFormat("[HGFRIENDS HANDLER]: Verification ok");
316 return true;
317 }
318
319 private byte[] SuccessResult()
320 {
321 XmlDocument doc = new XmlDocument();
322
323 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
324 "", "");
325
326 doc.AppendChild(xmlnode);
327
328 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
329 "");
330
331 doc.AppendChild(rootElement);
332
333 XmlElement result = doc.CreateElement("", "Result", "");
334 result.AppendChild(doc.CreateTextNode("Success"));
335
336 rootElement.AppendChild(result);
337
338 return Util.DocToBytes(doc);
339 }
340
341 private byte[] SuccessResult(string value)
342 {
343 XmlDocument doc = new XmlDocument();
344
345 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
346 "", "");
347
348 doc.AppendChild(xmlnode);
349
350 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
351 "");
352
353 doc.AppendChild(rootElement);
354
355 XmlElement result = doc.CreateElement("", "RESULT", "");
356 result.AppendChild(doc.CreateTextNode("Success"));
357
358 rootElement.AppendChild(result);
359
360 XmlElement message = doc.CreateElement("", "Value", "");
361 message.AppendChild(doc.CreateTextNode(value));
362
363 rootElement.AppendChild(message);
364
365 return Util.DocToBytes(doc);
366 }
367
368
369 private byte[] FailureResult()
370 {
371 return FailureResult(String.Empty);
372 }
373
374 private byte[] FailureResult(string msg)
375 {
376 XmlDocument doc = new XmlDocument();
377
378 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
379 "", "");
380
381 doc.AppendChild(xmlnode);
382
383 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
384 "");
385
386 doc.AppendChild(rootElement);
387
388 XmlElement result = doc.CreateElement("", "RESULT", "");
389 result.AppendChild(doc.CreateTextNode("Failure"));
390
391 rootElement.AppendChild(result);
392
393 XmlElement message = doc.CreateElement("", "Message", "");
394 message.AppendChild(doc.CreateTextNode(msg));
395
396 rootElement.AppendChild(message);
397
398 return Util.DocToBytes(doc);
399 }
400
401 private byte[] BoolResult(bool value)
402 {
403 XmlDocument doc = new XmlDocument();
404
405 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
406 "", "");
407
408 doc.AppendChild(xmlnode);
409
410 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
411 "");
412
413 doc.AppendChild(rootElement);
414
415 XmlElement result = doc.CreateElement("", "RESULT", "");
416 result.AppendChild(doc.CreateTextNode(value.ToString()));
417
418 rootElement.AppendChild(result);
419
420 return Util.DocToBytes(doc);
421 }
422
423 #endregion
424 }
425}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs
new file mode 100644
index 0000000..dac4ca8
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs
@@ -0,0 +1,113 @@
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.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using Nini.Config;
34using log4net;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base;
39
40namespace OpenSim.Server.Handlers.Hypergrid
41{
42 public class HeloServiceInConnector : ServiceConnector
43 {
44 public HeloServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
45 base(config, server, configName)
46 {
47#pragma warning disable 0612
48 server.AddStreamHandler(new HeloServerGetHandler("opensim-robust"));
49#pragma warning restore 0612
50 server.AddStreamHandler(new HeloServerHeadHandler("opensim-robust"));
51 }
52 }
53
54 [Obsolete]
55 public class HeloServerGetHandler : BaseStreamHandler
56 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 private string m_HandlersType;
60
61 public HeloServerGetHandler(string handlersType) :
62 base("GET", "/helo")
63 {
64 m_HandlersType = handlersType;
65 }
66
67 public override byte[] Handle(string path, Stream requestData,
68 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
69 {
70 return OKResponse(httpResponse);
71 }
72
73 private byte[] OKResponse(IOSHttpResponse httpResponse)
74 {
75 m_log.Debug("[HELO]: hi, GET was called");
76 httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType);
77 httpResponse.StatusCode = (int)HttpStatusCode.OK;
78 httpResponse.StatusDescription = "OK";
79 return new byte[0];
80 }
81
82 }
83
84 public class HeloServerHeadHandler : BaseStreamHandler
85 {
86 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
87
88 private string m_HandlersType;
89
90 public HeloServerHeadHandler(string handlersType) :
91 base("HEAD", "/helo")
92 {
93 m_HandlersType = handlersType;
94 }
95
96 protected override byte[] ProcessRequest(string path, Stream requestData,
97 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
98 {
99 return OKResponse(httpResponse);
100 }
101
102 private byte[] OKResponse(IOSHttpResponse httpResponse)
103 {
104 m_log.Debug("[HELO]: hi, HEAD was called");
105 httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType);
106 httpResponse.StatusCode = (int)HttpStatusCode.OK;
107 httpResponse.StatusDescription = "OK";
108 return new byte[0];
109 }
110
111 }
112
113}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
new file mode 100644
index 0000000..e787f7c
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
@@ -0,0 +1,137 @@
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.IO;
31using System.Reflection;
32using System.Net;
33using System.Text;
34
35using OpenSim.Server.Base;
36using OpenSim.Server.Handlers.Base;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Server.Handlers.Simulation;
42using Utils = OpenSim.Server.Handlers.Simulation.Utils;
43
44using OpenMetaverse;
45using OpenMetaverse.StructuredData;
46using Nini.Config;
47using log4net;
48
49
50namespace OpenSim.Server.Handlers.Hypergrid
51{
52 public class HomeAgentHandler : AgentPostHandler
53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private IUserAgentService m_UserAgentService;
56
57 private string m_LoginServerIP;
58
59 public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP, bool proxy) :
60 base("/homeagent")
61 {
62 m_UserAgentService = userAgentService;
63 m_LoginServerIP = loginServerIP;
64 m_Proxy = proxy;
65 }
66
67 protected override AgentDestinationData CreateAgentDestinationData()
68 {
69 return new ExtendedAgentDestinationData();
70 }
71
72 protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
73 {
74 base.UnpackData(args, d, request);
75 ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
76 try
77 {
78 if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
79 data.host = args["gatekeeper_host"].AsString();
80 if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
81 Int32.TryParse(args["gatekeeper_port"].AsString(), out data.port);
82 if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null)
83 data.gatekeeperServerURI = args["gatekeeper_serveruri"];
84 if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null)
85 data.destinationServerURI = args["destination_serveruri"];
86
87 }
88 catch (InvalidCastException)
89 {
90 m_log.ErrorFormat("[HOME AGENT HANDLER]: Bad cast in UnpackData");
91 }
92
93 string callerIP = GetCallerIP(request);
94 // Verify if this call came from the login server
95 if (callerIP == m_LoginServerIP)
96 data.fromLogin = true;
97
98 }
99
100 protected override GridRegion ExtractGatekeeper(AgentDestinationData d)
101 {
102 if (d is ExtendedAgentDestinationData)
103 {
104 ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
105 GridRegion gatekeeper = new GridRegion();
106 gatekeeper.ServerURI = data.gatekeeperServerURI;
107 gatekeeper.ExternalHostName = data.host;
108 gatekeeper.HttpPort = (uint)data.port;
109 gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
110
111 return gatekeeper;
112 }
113 else
114 m_log.WarnFormat("[HOME AGENT HANDLER]: Wrong data type");
115
116 return null;
117 }
118
119
120 protected override bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination,
121 AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
122 {
123 return m_UserAgentService.LoginAgentToGrid(source, aCircuit, gatekeeper, destination, fromLogin, out reason);
124 }
125
126 }
127
128 public class ExtendedAgentDestinationData : AgentDestinationData
129 {
130 public string host;
131 public int port;
132 public string gatekeeperServerURI;
133 public string destinationServerURI;
134
135 }
136
137}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
new file mode 100644
index 0000000..c7ac9be
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
@@ -0,0 +1,136 @@
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 */
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32
33using OpenSim.Services.Interfaces;
34using GridRegion = OpenSim.Services.Interfaces.GridRegion;
35
36using log4net;
37using Nwc.XmlRpc;
38using OpenMetaverse;
39
40namespace OpenSim.Server.Handlers.Hypergrid
41{
42 public class HypergridHandlers
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 private IGatekeeperService m_GatekeeperService;
47
48 public HypergridHandlers(IGatekeeperService gatekeeper)
49 {
50 m_GatekeeperService = gatekeeper;
51 m_log.DebugFormat("[HYPERGRID HANDLERS]: Active");
52 }
53
54 /// <summary>
55 /// Someone wants to link to us
56 /// </summary>
57 /// <param name="request"></param>
58 /// <returns></returns>
59 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
60 {
61 Hashtable requestData = (Hashtable)request.Params[0];
62 //string host = (string)requestData["host"];
63 //string portstr = (string)requestData["port"];
64 string name = (string)requestData["region_name"];
65 if (name == null)
66 name = string.Empty;
67
68 UUID regionID = UUID.Zero;
69 string externalName = string.Empty;
70 string imageURL = string.Empty;
71 ulong regionHandle = 0;
72 string reason = string.Empty;
73
74 bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason);
75
76 Hashtable hash = new Hashtable();
77 hash["result"] = success.ToString();
78 hash["uuid"] = regionID.ToString();
79 hash["handle"] = regionHandle.ToString();
80 hash["region_image"] = imageURL;
81 hash["external_name"] = externalName;
82
83 XmlRpcResponse response = new XmlRpcResponse();
84 response.Value = hash;
85 return response;
86 }
87
88 public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
89 {
90 Hashtable requestData = (Hashtable)request.Params[0];
91 //string host = (string)requestData["host"];
92 //string portstr = (string)requestData["port"];
93 string regionID_str = (string)requestData["region_uuid"];
94 UUID regionID = UUID.Zero;
95 UUID.TryParse(regionID_str, out regionID);
96
97 UUID agentID = UUID.Zero;
98 string agentHomeURI = null;
99 if (requestData.ContainsKey("agent_id"))
100 agentID = UUID.Parse((string)requestData["agent_id"]);
101 if (requestData.ContainsKey("agent_home_uri"))
102 agentHomeURI = (string)requestData["agent_home_uri"];
103
104 string message;
105 GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID, agentID, agentHomeURI, out message);
106
107 Hashtable hash = new Hashtable();
108 if (regInfo == null)
109 {
110 hash["result"] = "false";
111 }
112 else
113 {
114 hash["result"] = "true";
115 hash["uuid"] = regInfo.RegionID.ToString();
116 hash["x"] = regInfo.RegionLocX.ToString();
117 hash["y"] = regInfo.RegionLocY.ToString();
118 hash["size_x"] = regInfo.RegionSizeX.ToString();
119 hash["size_y"] = regInfo.RegionSizeY.ToString();
120 hash["region_name"] = regInfo.RegionName;
121 hash["hostname"] = regInfo.ExternalHostName;
122 hash["http_port"] = regInfo.HttpPort.ToString();
123 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
124 }
125
126 if (message != null)
127 hash["message"] = message;
128
129 XmlRpcResponse response = new XmlRpcResponse();
130 response.Value = hash;
131 return response;
132
133 }
134
135 }
136}
diff --git a/OpenSim/Server/Handlers/Hypergrid/InstantMessageServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/InstantMessageServerConnector.cs
new file mode 100644
index 0000000..8145a21
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/InstantMessageServerConnector.cs
@@ -0,0 +1,248 @@
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.Net;
32using System.Reflection;
33
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Server.Handlers.Base;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42using log4net;
43using Nwc.XmlRpc;
44using OpenMetaverse;
45
46namespace OpenSim.Server.Handlers.Hypergrid
47{
48 public class InstantMessageServerConnector : ServiceConnector
49 {
50 private static readonly ILog m_log =
51 LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType);
53
54 private IInstantMessage m_IMService;
55
56 public InstantMessageServerConnector(IConfigSource config, IHttpServer server) :
57 this(config, server, (IInstantMessageSimConnector)null)
58 {
59 }
60
61 public InstantMessageServerConnector(IConfigSource config, IHttpServer server, string configName) :
62 this(config, server)
63 {
64 }
65
66 public InstantMessageServerConnector(IConfigSource config, IHttpServer server, IInstantMessageSimConnector simConnector) :
67 base(config, server, String.Empty)
68 {
69 IConfig gridConfig = config.Configs["HGInstantMessageService"];
70 if (gridConfig != null)
71 {
72 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
73
74 Object[] args = new Object[] { config, simConnector };
75 m_IMService = ServerUtils.LoadPlugin<IInstantMessage>(serviceDll, args);
76 }
77 if (m_IMService == null)
78 throw new Exception("InstantMessage server connector cannot proceed because of missing service");
79
80 server.AddXmlRPCHandler("grid_instant_message", ProcessInstantMessage, false);
81
82 }
83
84 public IInstantMessage GetService()
85 {
86 return m_IMService;
87 }
88
89 protected virtual XmlRpcResponse ProcessInstantMessage(XmlRpcRequest request, IPEndPoint remoteClient)
90 {
91 bool successful = false;
92
93 try
94 {
95 // various rational defaults
96 UUID fromAgentID = UUID.Zero;
97 UUID toAgentID = UUID.Zero;
98 UUID imSessionID = UUID.Zero;
99 uint timestamp = 0;
100 string fromAgentName = "";
101 string message = "";
102 byte dialog = (byte)0;
103 bool fromGroup = false;
104 byte offline = (byte)0;
105 uint ParentEstateID = 0;
106 Vector3 Position = Vector3.Zero;
107 UUID RegionID = UUID.Zero;
108 byte[] binaryBucket = new byte[0];
109
110 float pos_x = 0;
111 float pos_y = 0;
112 float pos_z = 0;
113 //m_log.Info("Processing IM");
114
115
116 Hashtable requestData = (Hashtable)request.Params[0];
117 // Check if it's got all the data
118 if (requestData.ContainsKey("from_agent_id")
119 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id")
120 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name")
121 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog")
122 && requestData.ContainsKey("from_group")
123 && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id")
124 && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y")
125 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
126 && requestData.ContainsKey("binary_bucket"))
127 {
128 // Do the easy way of validating the UUIDs
129 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
130 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
131 UUID.TryParse((string)requestData["im_session_id"], out imSessionID);
132 UUID.TryParse((string)requestData["region_id"], out RegionID);
133 try
134 {
135 timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]);
136 }
137 catch (ArgumentException)
138 {
139 }
140 catch (FormatException)
141 {
142 }
143 catch (OverflowException)
144 {
145 }
146
147 fromAgentName = (string)requestData["from_agent_name"];
148 message = (string)requestData["message"];
149 if (message == null)
150 message = string.Empty;
151
152 // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them.
153 string requestData1 = (string)requestData["dialog"];
154 if (string.IsNullOrEmpty(requestData1))
155 {
156 dialog = 0;
157 }
158 else
159 {
160 byte[] dialogdata = Convert.FromBase64String(requestData1);
161 dialog = dialogdata[0];
162 }
163
164 if ((string)requestData["from_group"] == "TRUE")
165 fromGroup = true;
166
167 string requestData2 = (string)requestData["offline"];
168 if (String.IsNullOrEmpty(requestData2))
169 {
170 offline = 0;
171 }
172 else
173 {
174 byte[] offlinedata = Convert.FromBase64String(requestData2);
175 offline = offlinedata[0];
176 }
177
178 try
179 {
180 ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]);
181 }
182 catch (ArgumentException)
183 {
184 }
185 catch (FormatException)
186 {
187 }
188 catch (OverflowException)
189 {
190 }
191
192 float.TryParse((string)requestData["position_x"], out pos_x);
193 float.TryParse((string)requestData["position_y"], out pos_y);
194 float.TryParse((string)requestData["position_z"], out pos_z);
195
196 Position = new Vector3(pos_x, pos_y, pos_z);
197
198 string requestData3 = (string)requestData["binary_bucket"];
199 if (string.IsNullOrEmpty(requestData3))
200 {
201 binaryBucket = new byte[0];
202 }
203 else
204 {
205 binaryBucket = Convert.FromBase64String(requestData3);
206 }
207
208 // Create a New GridInstantMessageObject the the data
209 GridInstantMessage gim = new GridInstantMessage();
210 gim.fromAgentID = fromAgentID.Guid;
211 gim.fromAgentName = fromAgentName;
212 gim.fromGroup = fromGroup;
213 gim.imSessionID = imSessionID.Guid;
214 gim.RegionID = RegionID.Guid;
215 gim.timestamp = timestamp;
216 gim.toAgentID = toAgentID.Guid;
217 gim.message = message;
218 gim.dialog = dialog;
219 gim.offline = offline;
220 gim.ParentEstateID = ParentEstateID;
221 gim.Position = Position;
222 gim.binaryBucket = binaryBucket;
223
224 successful = m_IMService.IncomingInstantMessage(gim);
225
226 }
227 }
228 catch (Exception e)
229 {
230 m_log.Error("[INSTANT MESSAGE]: Caught unexpected exception:", e);
231 successful = false;
232 }
233
234 //Send response back to region calling if it was successful
235 // calling region uses this to know when to look up a user's location again.
236 XmlRpcResponse resp = new XmlRpcResponse();
237 Hashtable respdata = new Hashtable();
238 if (successful)
239 respdata["success"] = "TRUE";
240 else
241 respdata["success"] = "FALSE";
242 resp.Value = respdata;
243
244 return resp;
245 }
246
247 }
248}
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
new file mode 100644
index 0000000..e112e0e
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -0,0 +1,488 @@
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.Net;
32using System.Reflection;
33
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Server.Handlers.Base;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42using log4net;
43using Nwc.XmlRpc;
44using OpenMetaverse;
45
46namespace OpenSim.Server.Handlers.Hypergrid
47{
48 public class UserAgentServerConnector : ServiceConnector
49 {
50// private static readonly ILog m_log =
51// LogManager.GetLogger(
52// MethodBase.GetCurrentMethod().DeclaringType);
53
54 private IUserAgentService m_HomeUsersService;
55 public IUserAgentService HomeUsersService
56 {
57 get { return m_HomeUsersService; }
58 }
59
60 private string[] m_AuthorizedCallers;
61
62 private bool m_VerifyCallers = false;
63
64 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
65 this(config, server, (IFriendsSimConnector)null)
66 {
67 }
68
69 public UserAgentServerConnector(IConfigSource config, IHttpServer server, string configName) :
70 this(config, server)
71 {
72 }
73
74 public UserAgentServerConnector(IConfigSource config, IHttpServer server, IFriendsSimConnector friendsConnector) :
75 base(config, server, String.Empty)
76 {
77 IConfig gridConfig = config.Configs["UserAgentService"];
78 if (gridConfig != null)
79 {
80 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
81
82 Object[] args = new Object[] { config, friendsConnector };
83 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args);
84 }
85 if (m_HomeUsersService == null)
86 throw new Exception("UserAgent server connector cannot proceed because of missing service");
87
88 string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1");
89 bool proxy = gridConfig.GetBoolean("HasProxy", false);
90
91 m_VerifyCallers = gridConfig.GetBoolean("VerifyCallers", false);
92 string csv = gridConfig.GetString("AuthorizedCallers", "127.0.0.1");
93 csv = csv.Replace(" ", "");
94 m_AuthorizedCallers = csv.Split(',');
95
96 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
97 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
98 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
99 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
100 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
101
102#pragma warning disable 0612
103 server.AddXmlRPCHandler("status_notification", StatusNotification, false);
104 server.AddXmlRPCHandler("get_online_friends", GetOnlineFriends, false);
105#pragma warning restore 0612
106 server.AddXmlRPCHandler("get_user_info", GetUserInfo, false);
107 server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false);
108
109 server.AddXmlRPCHandler("locate_user", LocateUser, false);
110 server.AddXmlRPCHandler("get_uui", GetUUI, false);
111 server.AddXmlRPCHandler("get_uuid", GetUUID, false);
112
113 server.AddStreamHandler(new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy));
114 }
115
116 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
117 {
118 Hashtable requestData = (Hashtable)request.Params[0];
119 //string host = (string)requestData["host"];
120 //string portstr = (string)requestData["port"];
121 string userID_str = (string)requestData["userID"];
122 UUID userID = UUID.Zero;
123 UUID.TryParse(userID_str, out userID);
124
125 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
126 GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt);
127
128 Hashtable hash = new Hashtable();
129 if (regInfo == null)
130 hash["result"] = "false";
131 else
132 {
133 hash["result"] = "true";
134 hash["uuid"] = regInfo.RegionID.ToString();
135 hash["x"] = regInfo.RegionLocX.ToString();
136 hash["y"] = regInfo.RegionLocY.ToString();
137 hash["size_x"] = regInfo.RegionSizeX.ToString();
138 hash["size_y"] = regInfo.RegionSizeY.ToString();
139 hash["region_name"] = regInfo.RegionName;
140 hash["hostname"] = regInfo.ExternalHostName;
141 hash["http_port"] = regInfo.HttpPort.ToString();
142 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
143 hash["position"] = position.ToString();
144 hash["lookAt"] = lookAt.ToString();
145 }
146 XmlRpcResponse response = new XmlRpcResponse();
147 response.Value = hash;
148 return response;
149
150 }
151
152 public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
153 {
154 Hashtable requestData = (Hashtable)request.Params[0];
155 //string host = (string)requestData["host"];
156 //string portstr = (string)requestData["port"];
157 string sessionID_str = (string)requestData["sessionID"];
158 UUID sessionID = UUID.Zero;
159 UUID.TryParse(sessionID_str, out sessionID);
160 string gridName = (string)requestData["externalName"];
161
162 bool success = m_HomeUsersService.IsAgentComingHome(sessionID, gridName);
163
164 Hashtable hash = new Hashtable();
165 hash["result"] = success.ToString();
166 XmlRpcResponse response = new XmlRpcResponse();
167 response.Value = hash;
168 return response;
169
170 }
171
172 public XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient)
173 {
174 Hashtable requestData = (Hashtable)request.Params[0];
175 //string host = (string)requestData["host"];
176 //string portstr = (string)requestData["port"];
177 string sessionID_str = (string)requestData["sessionID"];
178 UUID sessionID = UUID.Zero;
179 UUID.TryParse(sessionID_str, out sessionID);
180 string token = (string)requestData["token"];
181
182 bool success = m_HomeUsersService.VerifyAgent(sessionID, token);
183
184 Hashtable hash = new Hashtable();
185 hash["result"] = success.ToString();
186 XmlRpcResponse response = new XmlRpcResponse();
187 response.Value = hash;
188 return response;
189
190 }
191
192 public XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient)
193 {
194 Hashtable requestData = (Hashtable)request.Params[0];
195 //string host = (string)requestData["host"];
196 //string portstr = (string)requestData["port"];
197 string sessionID_str = (string)requestData["sessionID"];
198 UUID sessionID = UUID.Zero;
199 UUID.TryParse(sessionID_str, out sessionID);
200 string token = (string)requestData["token"];
201
202 bool success = m_HomeUsersService.VerifyClient(sessionID, token);
203
204 Hashtable hash = new Hashtable();
205 hash["result"] = success.ToString();
206 XmlRpcResponse response = new XmlRpcResponse();
207 response.Value = hash;
208 return response;
209
210 }
211
212 public XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient)
213 {
214 Hashtable requestData = (Hashtable)request.Params[0];
215 //string host = (string)requestData["host"];
216 //string portstr = (string)requestData["port"];
217 string sessionID_str = (string)requestData["sessionID"];
218 UUID sessionID = UUID.Zero;
219 UUID.TryParse(sessionID_str, out sessionID);
220 string userID_str = (string)requestData["userID"];
221 UUID userID = UUID.Zero;
222 UUID.TryParse(userID_str, out userID);
223
224 m_HomeUsersService.LogoutAgent(userID, sessionID);
225
226 Hashtable hash = new Hashtable();
227 hash["result"] = "true";
228 XmlRpcResponse response = new XmlRpcResponse();
229 response.Value = hash;
230 return response;
231
232 }
233
234 [Obsolete]
235 public XmlRpcResponse StatusNotification(XmlRpcRequest request, IPEndPoint remoteClient)
236 {
237 Hashtable hash = new Hashtable();
238 hash["result"] = "false";
239
240 Hashtable requestData = (Hashtable)request.Params[0];
241 //string host = (string)requestData["host"];
242 //string portstr = (string)requestData["port"];
243 if (requestData.ContainsKey("userID") && requestData.ContainsKey("online"))
244 {
245 string userID_str = (string)requestData["userID"];
246 UUID userID = UUID.Zero;
247 UUID.TryParse(userID_str, out userID);
248 List<string> ids = new List<string>();
249 foreach (object key in requestData.Keys)
250 {
251 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
252 ids.Add(requestData[key].ToString());
253 }
254 bool online = false;
255 bool.TryParse(requestData["online"].ToString(), out online);
256
257 // let's spawn a thread for this, because it may take a long time...
258 List<UUID> friendsOnline = m_HomeUsersService.StatusNotification(ids, userID, online);
259 if (friendsOnline.Count > 0)
260 {
261 int i = 0;
262 foreach (UUID id in friendsOnline)
263 {
264 hash["friend_" + i.ToString()] = id.ToString();
265 i++;
266 }
267 }
268 else
269 hash["result"] = "No Friends Online";
270
271 }
272
273 XmlRpcResponse response = new XmlRpcResponse();
274 response.Value = hash;
275 return response;
276
277 }
278
279 [Obsolete]
280 public XmlRpcResponse GetOnlineFriends(XmlRpcRequest request, IPEndPoint remoteClient)
281 {
282 Hashtable hash = new Hashtable();
283
284 Hashtable requestData = (Hashtable)request.Params[0];
285 //string host = (string)requestData["host"];
286 //string portstr = (string)requestData["port"];
287 if (requestData.ContainsKey("userID"))
288 {
289 string userID_str = (string)requestData["userID"];
290 UUID userID = UUID.Zero;
291 UUID.TryParse(userID_str, out userID);
292 List<string> ids = new List<string>();
293 foreach (object key in requestData.Keys)
294 {
295 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
296 ids.Add(requestData[key].ToString());
297 }
298
299 //List<UUID> online = m_HomeUsersService.GetOnlineFriends(userID, ids);
300 //if (online.Count > 0)
301 //{
302 // int i = 0;
303 // foreach (UUID id in online)
304 // {
305 // hash["friend_" + i.ToString()] = id.ToString();
306 // i++;
307 // }
308 //}
309 //else
310 // hash["result"] = "No Friends Online";
311 }
312
313 XmlRpcResponse response = new XmlRpcResponse();
314 response.Value = hash;
315 return response;
316
317 }
318
319 public XmlRpcResponse GetUserInfo(XmlRpcRequest request, IPEndPoint remoteClient)
320 {
321 Hashtable hash = new Hashtable();
322 Hashtable requestData = (Hashtable)request.Params[0];
323
324 // This needs checking!
325 if (requestData.ContainsKey("userID"))
326 {
327 string userID_str = (string)requestData["userID"];
328 UUID userID = UUID.Zero;
329 UUID.TryParse(userID_str, out userID);
330
331 //int userFlags = m_HomeUsersService.GetUserFlags(userID);
332 Dictionary<string,object> userInfo = m_HomeUsersService.GetUserInfo(userID);
333 if (userInfo.Count > 0)
334 {
335 foreach (KeyValuePair<string, object> kvp in userInfo)
336 {
337 hash[kvp.Key] = kvp.Value;
338 }
339 }
340 else
341 {
342 hash["result"] = "failure";
343 }
344 }
345
346 XmlRpcResponse response = new XmlRpcResponse();
347 response.Value = hash;
348 return response;
349 }
350
351 public XmlRpcResponse GetServerURLs(XmlRpcRequest request, IPEndPoint remoteClient)
352 {
353 Hashtable hash = new Hashtable();
354
355 Hashtable requestData = (Hashtable)request.Params[0];
356 //string host = (string)requestData["host"];
357 //string portstr = (string)requestData["port"];
358 if (requestData.ContainsKey("userID"))
359 {
360 string userID_str = (string)requestData["userID"];
361 UUID userID = UUID.Zero;
362 UUID.TryParse(userID_str, out userID);
363
364 Dictionary<string, object> serverURLs = m_HomeUsersService.GetServerURLs(userID);
365 if (serverURLs.Count > 0)
366 {
367 foreach (KeyValuePair<string, object> kvp in serverURLs)
368 hash["SRV_" + kvp.Key] = kvp.Value.ToString();
369 }
370 else
371 hash["result"] = "No Service URLs";
372 }
373
374 XmlRpcResponse response = new XmlRpcResponse();
375 response.Value = hash;
376 return response;
377
378 }
379
380 /// <summary>
381 /// Locates the user.
382 /// This is a sensitive operation, only authorized IP addresses can perform it.
383 /// </summary>
384 /// <param name="request"></param>
385 /// <param name="remoteClient"></param>
386 /// <returns></returns>
387 public XmlRpcResponse LocateUser(XmlRpcRequest request, IPEndPoint remoteClient)
388 {
389 Hashtable hash = new Hashtable();
390
391 bool authorized = true;
392 if (m_VerifyCallers)
393 {
394 authorized = false;
395 foreach (string s in m_AuthorizedCallers)
396 if (s == remoteClient.Address.ToString())
397 {
398 authorized = true;
399 break;
400 }
401 }
402
403 if (authorized)
404 {
405 Hashtable requestData = (Hashtable)request.Params[0];
406 //string host = (string)requestData["host"];
407 //string portstr = (string)requestData["port"];
408 if (requestData.ContainsKey("userID"))
409 {
410 string userID_str = (string)requestData["userID"];
411 UUID userID = UUID.Zero;
412 UUID.TryParse(userID_str, out userID);
413
414 string url = m_HomeUsersService.LocateUser(userID);
415 if (url != string.Empty)
416 hash["URL"] = url;
417 else
418 hash["result"] = "Unable to locate user";
419 }
420 }
421
422 XmlRpcResponse response = new XmlRpcResponse();
423 response.Value = hash;
424 return response;
425
426 }
427
428 /// <summary>
429 /// Returns the UUI of a user given a UUID.
430 /// </summary>
431 /// <param name="request"></param>
432 /// <param name="remoteClient"></param>
433 /// <returns></returns>
434 public XmlRpcResponse GetUUI(XmlRpcRequest request, IPEndPoint remoteClient)
435 {
436 Hashtable hash = new Hashtable();
437
438 Hashtable requestData = (Hashtable)request.Params[0];
439 //string host = (string)requestData["host"];
440 //string portstr = (string)requestData["port"];
441 if (requestData.ContainsKey("userID") && requestData.ContainsKey("targetUserID"))
442 {
443 string userID_str = (string)requestData["userID"];
444 UUID userID = UUID.Zero;
445 UUID.TryParse(userID_str, out userID);
446
447 string tuserID_str = (string)requestData["targetUserID"];
448 UUID targetUserID = UUID.Zero;
449 UUID.TryParse(tuserID_str, out targetUserID);
450 string uui = m_HomeUsersService.GetUUI(userID, targetUserID);
451 if (uui != string.Empty)
452 hash["UUI"] = uui;
453 else
454 hash["result"] = "User unknown";
455 }
456
457 XmlRpcResponse response = new XmlRpcResponse();
458 response.Value = hash;
459 return response;
460 }
461
462 /// <summary>
463 /// Gets the UUID of a user given First name, Last name.
464 /// </summary>
465 /// <param name="request"></param>
466 /// <param name="remoteClient"></param>
467 /// <returns></returns>
468 public XmlRpcResponse GetUUID(XmlRpcRequest request, IPEndPoint remoteClient)
469 {
470 Hashtable hash = new Hashtable();
471
472 Hashtable requestData = (Hashtable)request.Params[0];
473 //string host = (string)requestData["host"];
474 //string portstr = (string)requestData["port"];
475 if (requestData.ContainsKey("first") && requestData.ContainsKey("last"))
476 {
477 string first = (string)requestData["first"];
478 string last = (string)requestData["last"];
479 UUID uuid = m_HomeUsersService.GetUUID(first, last);
480 hash["UUID"] = uuid.ToString();
481 }
482
483 XmlRpcResponse response = new XmlRpcResponse();
484 response.Value = hash;
485 return response;
486 }
487 }
488} \ No newline at end of file