aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs205
1 files changed, 204 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
index 0e8ce80..eb184a5 100644
--- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -52,15 +52,24 @@ namespace OpenSim.Server.Handlers.Hypergrid
52// MethodBase.GetCurrentMethod().DeclaringType); 52// MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private IUserAgentService m_HomeUsersService; 54 private IUserAgentService m_HomeUsersService;
55 private string[] m_AuthorizedCallers;
56
57 private bool m_VerifyCallers = false;
55 58
56 public UserAgentServerConnector(IConfigSource config, IHttpServer server) : 59 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
60 this(config, server, null)
61 {
62 }
63
64 public UserAgentServerConnector(IConfigSource config, IHttpServer server, IFriendsSimConnector friendsConnector) :
57 base(config, server, String.Empty) 65 base(config, server, String.Empty)
58 { 66 {
59 IConfig gridConfig = config.Configs["UserAgentService"]; 67 IConfig gridConfig = config.Configs["UserAgentService"];
60 if (gridConfig != null) 68 if (gridConfig != null)
61 { 69 {
62 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); 70 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
63 Object[] args = new Object[] { config }; 71
72 Object[] args = new Object[] { config, friendsConnector };
64 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args); 73 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args);
65 } 74 }
66 if (m_HomeUsersService == null) 75 if (m_HomeUsersService == null)
@@ -69,12 +78,24 @@ namespace OpenSim.Server.Handlers.Hypergrid
69 string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1"); 78 string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1");
70 bool proxy = gridConfig.GetBoolean("HasProxy", false); 79 bool proxy = gridConfig.GetBoolean("HasProxy", false);
71 80
81 m_VerifyCallers = gridConfig.GetBoolean("VerifyCallers", false);
82 string csv = gridConfig.GetString("AuthorizedCallers", "127.0.0.1");
83 csv = csv.Replace(" ", "");
84 m_AuthorizedCallers = csv.Split(',');
85
72 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); 86 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
73 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); 87 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
74 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false); 88 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
75 server.AddXmlRPCHandler("verify_client", VerifyClient, false); 89 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
76 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); 90 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
77 91
92 server.AddXmlRPCHandler("status_notification", StatusNotification, false);
93 server.AddXmlRPCHandler("get_online_friends", GetOnlineFriends, false);
94 server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false);
95
96 server.AddXmlRPCHandler("locate_user", LocateUser, false);
97 server.AddXmlRPCHandler("get_uui", GetUUI, false);
98
78 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler); 99 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler);
79 } 100 }
80 101
@@ -194,5 +215,187 @@ namespace OpenSim.Server.Handlers.Hypergrid
194 215
195 } 216 }
196 217
218 public XmlRpcResponse StatusNotification(XmlRpcRequest request, IPEndPoint remoteClient)
219 {
220 Hashtable hash = new Hashtable();
221 hash["result"] = "false";
222
223 Hashtable requestData = (Hashtable)request.Params[0];
224 //string host = (string)requestData["host"];
225 //string portstr = (string)requestData["port"];
226 if (requestData.ContainsKey("userID") && requestData.ContainsKey("online"))
227 {
228 string userID_str = (string)requestData["userID"];
229 UUID userID = UUID.Zero;
230 UUID.TryParse(userID_str, out userID);
231 List<string> ids = new List<string>();
232 foreach (object key in requestData.Keys)
233 {
234 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
235 ids.Add(requestData[key].ToString());
236 }
237 bool online = false;
238 bool.TryParse(requestData["online"].ToString(), out online);
239
240 hash["result"] = "true";
241
242 // let's spawn a thread for this, because it may take a long time...
243 Util.FireAndForget(delegate { m_HomeUsersService.StatusNotification(ids, userID, online); });
244 }
245
246 XmlRpcResponse response = new XmlRpcResponse();
247 response.Value = hash;
248 return response;
249
250 }
251
252 public XmlRpcResponse GetOnlineFriends(XmlRpcRequest request, IPEndPoint remoteClient)
253 {
254 Hashtable hash = new Hashtable();
255
256 Hashtable requestData = (Hashtable)request.Params[0];
257 //string host = (string)requestData["host"];
258 //string portstr = (string)requestData["port"];
259 if (requestData.ContainsKey("userID"))
260 {
261 string userID_str = (string)requestData["userID"];
262 UUID userID = UUID.Zero;
263 UUID.TryParse(userID_str, out userID);
264 List<string> ids = new List<string>();
265 foreach (object key in requestData.Keys)
266 {
267 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
268 ids.Add(requestData[key].ToString());
269 }
270
271 List<UUID> online = m_HomeUsersService.GetOnlineFriends(userID, ids);
272 if (online.Count > 0)
273 {
274 int i = 0;
275 foreach (UUID id in online)
276 {
277 hash["friend_" + i.ToString()] = id.ToString();
278 i++;
279 }
280 }
281 else
282 hash["result"] = "No Friends Online";
283 }
284
285 XmlRpcResponse response = new XmlRpcResponse();
286 response.Value = hash;
287 return response;
288
289 }
290
291 public XmlRpcResponse GetServerURLs(XmlRpcRequest request, IPEndPoint remoteClient)
292 {
293 Hashtable hash = new Hashtable();
294
295 Hashtable requestData = (Hashtable)request.Params[0];
296 //string host = (string)requestData["host"];
297 //string portstr = (string)requestData["port"];
298 if (requestData.ContainsKey("userID"))
299 {
300 string userID_str = (string)requestData["userID"];
301 UUID userID = UUID.Zero;
302 UUID.TryParse(userID_str, out userID);
303
304 Dictionary<string, object> serverURLs = m_HomeUsersService.GetServerURLs(userID);
305 if (serverURLs.Count > 0)
306 {
307 foreach (KeyValuePair<string, object> kvp in serverURLs)
308 hash["SRV_" + kvp.Key] = kvp.Value.ToString();
309 }
310 else
311 hash["result"] = "No Service URLs";
312 }
313
314 XmlRpcResponse response = new XmlRpcResponse();
315 response.Value = hash;
316 return response;
317
318 }
319
320 /// <summary>
321 /// Locates the user.
322 /// This is a sensitive operation, only authorized IP addresses can perform it.
323 /// </summary>
324 /// <param name="request"></param>
325 /// <param name="remoteClient"></param>
326 /// <returns></returns>
327 public XmlRpcResponse LocateUser(XmlRpcRequest request, IPEndPoint remoteClient)
328 {
329 Hashtable hash = new Hashtable();
330
331 bool authorized = true;
332 if (m_VerifyCallers)
333 {
334 authorized = false;
335 foreach (string s in m_AuthorizedCallers)
336 if (s == remoteClient.Address.ToString())
337 {
338 authorized = true;
339 break;
340 }
341 }
342
343 if (authorized)
344 {
345 Hashtable requestData = (Hashtable)request.Params[0];
346 //string host = (string)requestData["host"];
347 //string portstr = (string)requestData["port"];
348 if (requestData.ContainsKey("userID"))
349 {
350 string userID_str = (string)requestData["userID"];
351 UUID userID = UUID.Zero;
352 UUID.TryParse(userID_str, out userID);
353
354 string url = m_HomeUsersService.LocateUser(userID);
355 if (url != string.Empty)
356 hash["URL"] = url;
357 }
358 }
359
360 XmlRpcResponse response = new XmlRpcResponse();
361 response.Value = hash;
362 return response;
363
364 }
365
366 /// <summary>
367 /// Locates the user.
368 /// This is a sensitive operation, only authorized IP addresses can perform it.
369 /// </summary>
370 /// <param name="request"></param>
371 /// <param name="remoteClient"></param>
372 /// <returns></returns>
373 public XmlRpcResponse GetUUI(XmlRpcRequest request, IPEndPoint remoteClient)
374 {
375 Hashtable hash = new Hashtable();
376
377 Hashtable requestData = (Hashtable)request.Params[0];
378 //string host = (string)requestData["host"];
379 //string portstr = (string)requestData["port"];
380 if (requestData.ContainsKey("userID") && requestData.ContainsKey("targetUserID"))
381 {
382 string userID_str = (string)requestData["userID"];
383 UUID userID = UUID.Zero;
384 UUID.TryParse(userID_str, out userID);
385
386 string tuserID_str = (string)requestData["targetUserID"];
387 UUID targetUserID = UUID.Zero;
388 UUID.TryParse(tuserID_str, out targetUserID);
389 string uui = m_HomeUsersService.GetUUI(userID, targetUserID);
390 if (uui != string.Empty)
391 hash["UUI"] = uui;
392 }
393
394 XmlRpcResponse response = new XmlRpcResponse();
395 response.Value = hash;
396 return response;
397
398 }
399
197 } 400 }
198} 401}