aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2011-05-26 10:04:48 -0700
committerDiva Canto2011-05-26 10:04:48 -0700
commit0c58a9e68074f3593920dc9f2356bbed96416497 (patch)
tree6bccb313c233ab6486195e8a3663cfa1d30c41b9 /OpenSim
parentHG: Renamed, shuffled some interfaces around. Move them all to IHypergridServ... (diff)
downloadopensim-SC_OLD-0c58a9e68074f3593920dc9f2356bbed96416497.zip
opensim-SC_OLD-0c58a9e68074f3593920dc9f2356bbed96416497.tar.gz
opensim-SC_OLD-0c58a9e68074f3593920dc9f2356bbed96416497.tar.bz2
opensim-SC_OLD-0c58a9e68074f3593920dc9f2356bbed96416497.tar.xz
HG IM in grid mode working fairly well. Unknown target user references looked back in source user's User Agent service.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs74
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs4
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs57
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs61
-rw-r--r--OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs1
-rw-r--r--OpenSim/Services/HypergridService/HGInstantMessageService.cs22
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs24
-rw-r--r--OpenSim/Services/Interfaces/IHypergridServices.cs3
8 files changed, 231 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
index 9ba4e49..ed02119 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs
@@ -194,6 +194,22 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
194 Util.FireAndForget(delegate 194 Util.FireAndForget(delegate
195 { 195 {
196 bool success = m_IMService.OutgoingInstantMessage(im, url); 196 bool success = m_IMService.OutgoingInstantMessage(im, url);
197 if (!success && account == null)
198 {
199 // One last chance
200 string recipientUUI = TryGetRecipientUUI(new UUID(im.fromAgentID), toAgentID);
201 m_log.DebugFormat("[HG MESSAGE TRANSFER]: Got UUI {0}", recipientUUI);
202 if (recipientUUI != string.Empty)
203 {
204 UUID id; string u = string.Empty, first = string.Empty, last = string.Empty, secret = string.Empty;
205 if (Util.ParseUniversalUserIdentifier(recipientUUI, out id, out u, out first, out last, out secret))
206 {
207 success = m_IMService.OutgoingInstantMessage(im, u);
208 if (success)
209 UserManagementModule.AddUser(toAgentID, u + ";" + first + " " + last);
210 }
211 }
212 }
197 result(success); 213 result(success);
198 }); 214 });
199 215
@@ -254,6 +270,64 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
254 result(false); 270 result(false);
255 } 271 }
256 272
273 private string TryGetRecipientUUI(UUID fromAgent, UUID toAgent)
274 {
275 // Let's call back the fromAgent's user agent service
276 // Maybe that service knows about the toAgent
277 IClientAPI client = LocateClientObject(fromAgent);
278 if (client != null)
279 {
280 AgentCircuitData circuit = m_Scenes[0].AuthenticateHandler.GetAgentCircuitData(client.AgentId);
281 if (circuit != null)
282 {
283 if (circuit.ServiceURLs.ContainsKey("HomeURI"))
284 {
285 string uasURL = circuit.ServiceURLs["HomeURI"].ToString();
286 m_log.DebugFormat("[HG MESSAGE TRANSFER]: getting UUI of user {0} from {1}", toAgent, uasURL);
287 UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uasURL);
288 return uasConn.GetUUI(fromAgent, toAgent);
289 }
290 }
291 }
292
293 return string.Empty;
294 }
295
296
297 /// <summary>
298 /// Find the scene for an agent
299 /// </summary>
300 private Scene GetClientScene(UUID agentId)
301 {
302 lock (m_Scenes)
303 {
304 foreach (Scene scene in m_Scenes)
305 {
306 ScenePresence presence = scene.GetScenePresence(agentId);
307 if (presence != null && !presence.IsChildAgent)
308 return scene;
309 }
310 }
311
312 return null;
313 }
314
315 /// <summary>
316 /// Find the client for a ID
317 /// </summary>
318 public IClientAPI LocateClientObject(UUID agentID)
319 {
320 Scene scene = GetClientScene(agentID);
321 if (scene != null)
322 {
323 ScenePresence presence = scene.GetScenePresence(agentID);
324 if (presence != null)
325 return presence.ControllingClient;
326 }
327
328 return null;
329 }
330
257 #region IInstantMessageSimConnector 331 #region IInstantMessageSimConnector
258 public bool SendInstantMessage(GridInstantMessage im) 332 public bool SendInstantMessage(GridInstantMessage im)
259 { 333 {
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index f4472c7..6743a2e 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -65,6 +65,10 @@ namespace OpenSim.Server.Base
65 /// <returns></returns> 65 /// <returns></returns>
66 public static T LoadPlugin<T>(string dllName, Object[] args) where T:class 66 public static T LoadPlugin<T>(string dllName, Object[] args) where T:class
67 { 67 {
68 // This is good to debug configuration problems
69 //if (dllName == string.Empty)
70 // Util.PrintCallStack();
71
68 string[] parts = dllName.Split(new char[] {':'}); 72 string[] parts = dllName.Split(new char[] {':'});
69 73
70 dllName = parts[0]; 74 dllName = parts[0];
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
index 942d960..eb184a5 100644
--- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Server.Handlers.Hypergrid
54 private IUserAgentService m_HomeUsersService; 54 private IUserAgentService m_HomeUsersService;
55 private string[] m_AuthorizedCallers; 55 private string[] m_AuthorizedCallers;
56 56
57 private bool m_VerifyCallers = false;
58
57 public UserAgentServerConnector(IConfigSource config, IHttpServer server) : 59 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
58 this(config, server, null) 60 this(config, server, null)
59 { 61 {
@@ -76,6 +78,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
76 string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1"); 78 string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1");
77 bool proxy = gridConfig.GetBoolean("HasProxy", false); 79 bool proxy = gridConfig.GetBoolean("HasProxy", false);
78 80
81 m_VerifyCallers = gridConfig.GetBoolean("VerifyCallers", false);
79 string csv = gridConfig.GetString("AuthorizedCallers", "127.0.0.1"); 82 string csv = gridConfig.GetString("AuthorizedCallers", "127.0.0.1");
80 csv = csv.Replace(" ", ""); 83 csv = csv.Replace(" ", "");
81 m_AuthorizedCallers = csv.Split(','); 84 m_AuthorizedCallers = csv.Split(',');
@@ -91,6 +94,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
91 server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false); 94 server.AddXmlRPCHandler("get_server_urls", GetServerURLs, false);
92 95
93 server.AddXmlRPCHandler("locate_user", LocateUser, false); 96 server.AddXmlRPCHandler("locate_user", LocateUser, false);
97 server.AddXmlRPCHandler("get_uui", GetUUI, false);
94 98
95 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler); 99 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler);
96 } 100 }
@@ -324,13 +328,17 @@ namespace OpenSim.Server.Handlers.Hypergrid
324 { 328 {
325 Hashtable hash = new Hashtable(); 329 Hashtable hash = new Hashtable();
326 330
327 bool authorized = false; 331 bool authorized = true;
328 foreach (string s in m_AuthorizedCallers) 332 if (m_VerifyCallers)
329 if (s == remoteClient.Address.ToString()) 333 {
330 { 334 authorized = false;
331 authorized = true; 335 foreach (string s in m_AuthorizedCallers)
332 break; 336 if (s == remoteClient.Address.ToString())
333 } 337 {
338 authorized = true;
339 break;
340 }
341 }
334 342
335 if (authorized) 343 if (authorized)
336 { 344 {
@@ -354,5 +362,40 @@ namespace OpenSim.Server.Handlers.Hypergrid
354 return response; 362 return response;
355 363
356 } 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
357 } 400 }
358} 401}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 50036b3..1c01563 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -576,6 +576,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
576 XmlRpcResponse response = null; 576 XmlRpcResponse response = null;
577 try 577 try
578 { 578 {
579 m_log.DebugFormat("[XXX]: Calling locate_user on {0}", m_ServerURL);
579 response = request.Send(m_ServerURL, 10000); 580 response = request.Send(m_ServerURL, 10000);
580 } 581 }
581 catch (Exception e) 582 catch (Exception e)
@@ -618,6 +619,66 @@ namespace OpenSim.Services.Connectors.Hypergrid
618 return url; 619 return url;
619 } 620 }
620 621
622 public string GetUUI(UUID userID, UUID targetUserID)
623 {
624 Hashtable hash = new Hashtable();
625 hash["userID"] = userID.ToString();
626 hash["targetUserID"] = targetUserID.ToString();
627
628 IList paramList = new ArrayList();
629 paramList.Add(hash);
630
631 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
632 string reason = string.Empty;
633
634 // Send and get reply
635 string uui = string.Empty;
636 XmlRpcResponse response = null;
637 try
638 {
639 m_log.DebugFormat("[XXX]: Calling get_uuid on {0}", m_ServerURL);
640 response = request.Send(m_ServerURL, 10000);
641 }
642 catch (Exception e)
643 {
644 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
645 reason = "Exception: " + e.Message;
646 return uui;
647 }
648
649 if (response.IsFault)
650 {
651 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
652 reason = "XMLRPC Fault";
653 return uui;
654 }
655
656 hash = (Hashtable)response.Value;
657 //foreach (Object o in hash)
658 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
659 try
660 {
661 if (hash == null)
662 {
663 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
664 reason = "Internal error 1";
665 return uui;
666 }
667
668 // Here's the actual response
669 if (hash.ContainsKey("UUI"))
670 uui = hash["UUI"].ToString();
671
672 }
673 catch (Exception e)
674 {
675 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
676 reason = "Exception: " + e.Message;
677 }
678
679 return uui;
680 }
681
621 private bool GetBoolResponse(XmlRpcRequest request, out string reason) 682 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
622 { 683 {
623 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); 684 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL);
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
index 65ee7c7..2a922de 100644
--- a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
+++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
@@ -80,6 +80,7 @@ namespace OpenSim.Services.Connectors.InstantMessage
80 } 80 }
81 else 81 else
82 { 82 {
83 m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url);
83 return false; 84 return false;
84 } 85 }
85 } 86 }
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 6178ca1..ca0fd7f 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -64,8 +64,8 @@ namespace OpenSim.Services.HypergridService
64 64
65 protected static IInstantMessageSimConnector m_IMSimConnector; 65 protected static IInstantMessageSimConnector m_IMSimConnector;
66 66
67 protected Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>(); 67 protected static Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>();
68 private ExpiringCache<UUID, GridRegion> m_RegionCache; 68 private static ExpiringCache<UUID, GridRegion> m_RegionCache;
69 69
70 public HGInstantMessageService(IConfigSource config) 70 public HGInstantMessageService(IConfigSource config)
71 : this(config, null) 71 : this(config, null)
@@ -155,6 +155,8 @@ namespace OpenSim.Services.HypergridService
155 if (!firstTime) 155 if (!firstTime)
156 { 156 {
157 lookupAgent = true; 157 lookupAgent = true;
158 upd = null;
159 url = string.Empty;
158 } 160 }
159 } 161 }
160 else 162 else
@@ -168,7 +170,6 @@ namespace OpenSim.Services.HypergridService
168 // Are we needing to look-up an agent? 170 // Are we needing to look-up an agent?
169 if (lookupAgent) 171 if (lookupAgent)
170 { 172 {
171 bool isPresent = false;
172 // Non-cached user agent lookup. 173 // Non-cached user agent lookup.
173 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() }); 174 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() });
174 if (presences != null && presences.Length > 0) 175 if (presences != null && presences.Length > 0)
@@ -177,17 +178,17 @@ namespace OpenSim.Services.HypergridService
177 { 178 {
178 if (p.RegionID != UUID.Zero) 179 if (p.RegionID != UUID.Zero)
179 { 180 {
181 m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID);
180 upd = p; 182 upd = p;
181 break; 183 break;
182 } 184 }
183 else
184 isPresent = true;
185 } 185 }
186 } 186 }
187 187
188 if (upd == null && isPresent) 188 if (upd == null)
189 { 189 {
190 // Let's check with the UAS if the user is elsewhere 190 // Let's check with the UAS if the user is elsewhere
191 m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
191 url = m_UserAgentService.LocateUser(toAgentID); 192 url = m_UserAgentService.LocateUser(toAgentID);
192 } 193 }
193 194
@@ -197,10 +198,10 @@ namespace OpenSim.Services.HypergridService
197 // This is one way to end the recursive loop 198 // This is one way to end the recursive loop
198 // 199 //
199 if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) || 200 if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
200 (previousLocation is string && previousLocation.Equals(url)))) 201 (previousLocation is string && upd == null && previousLocation.Equals(url))))
201 { 202 {
202 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 203 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
203 m_log.DebugFormat("[XXX] Fail 1 {0} {1}", previousLocation, url); 204 m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url);
204 205
205 return false; 206 return false;
206 } 207 }
@@ -242,9 +243,14 @@ namespace OpenSim.Services.HypergridService
242 } 243 }
243 244
244 if (reginfo != null) 245 if (reginfo != null)
246 {
245 imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im); 247 imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im);
248 }
246 else 249 else
250 {
251 m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI);
247 return false; 252 return false;
253 }
248 254
249 if (imresult) 255 if (imresult)
250 { 256 {
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 59ad043..387547e 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -485,6 +485,30 @@ namespace OpenSim.Services.HypergridService
485 485
486 return string.Empty; 486 return string.Empty;
487 } 487 }
488
489 public string GetUUI(UUID userID, UUID targetUserID)
490 {
491 // Let's see if it's a local user
492 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID);
493 if (account != null)
494 return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ;
495
496 // Let's try the list of friends
497 FriendInfo[] friends = m_FriendsService.GetFriends(userID);
498 if (friends != null && friends.Length > 0)
499 {
500 foreach (FriendInfo f in friends)
501 if (f.Friend.StartsWith(targetUserID.ToString()))
502 {
503 // Let's remove the secret
504 UUID id; string tmp = string.Empty, secret = string.Empty;
505 if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret))
506 return f.Friend.Replace(secret, "0");
507 }
508 }
509
510 return string.Empty;
511 }
488 } 512 }
489 513
490 class TravelingAgentInfo 514 class TravelingAgentInfo
diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs
index 3ab6d4f..753c205 100644
--- a/OpenSim/Services/Interfaces/IHypergridServices.cs
+++ b/OpenSim/Services/Interfaces/IHypergridServices.cs
@@ -57,6 +57,9 @@ namespace OpenSim.Services.Interfaces
57 Dictionary<string, object> GetServerURLs(UUID userID); 57 Dictionary<string, object> GetServerURLs(UUID userID);
58 58
59 string LocateUser(UUID userID); 59 string LocateUser(UUID userID);
60 // Tries to get the universal user identifier for the targetUserId
61 // on behalf of the userID
62 string GetUUI(UUID userID, UUID targetUserID);
60 63
61 void StatusNotification(List<string> friends, UUID userID, bool online); 64 void StatusNotification(List<string> friends, UUID userID, bool online);
62 List<UUID> GetOnlineFriends(UUID userID, List<string> friends); 65 List<UUID> GetOnlineFriends(UUID userID, List<string> friends);