From d21e9c755f004d8fe03b11bc57b810dbd401435a Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 19 May 2011 16:54:46 -0700
Subject: HG Friends working to some extent: friendships offered and accepted
correctly handled. Friends list showing correct foreign names. TODO:
GrantRights.
---
.../Services/HypergridService/HGFriendsService.cs | 95 ++++++++++++++++++++++
1 file changed, 95 insertions(+)
create mode 100644 OpenSim/Services/HypergridService/HGFriendsService.cs
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
new file mode 100644
index 0000000..fa4ec5d
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using OpenMetaverse;
+using OpenSim.Framework;
+using System;
+using System.Collections.Generic;
+using OpenSim.Services.Interfaces;
+using OpenSim.Services.Friends;
+using OpenSim.Data;
+using Nini.Config;
+using log4net;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
+
+namespace OpenSim.Services.HypergridService
+{
+ public class HGFriendsService : FriendsService, IFriendsService
+ {
+ public HGFriendsService(IConfigSource config) : base(config)
+ {
+ }
+
+ ///
+ /// Overrides base.
+ /// Storing new friendships from the outside is a tricky, sensitive operation, and it
+ /// needs to be done under certain restrictions.
+ /// First of all, if the friendship already exists, this is a no-op. In other words,
+ /// we cannot change just the flags, it needs to be a new friendship.
+ /// Second, we store it as flags=0 always, independent of what the caller sends. The
+ /// owner of the friendship needs to confirm when it gets back home.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override bool StoreFriend(string PrincipalID, string Friend, int flags)
+ {
+ UUID userID;
+ if (UUID.TryParse(PrincipalID, out userID))
+ {
+ FriendsData[] friendsData = m_Database.GetFriends(userID);
+ List fList = new List(friendsData);
+ if (fList.Find(delegate(FriendsData fdata)
+ {
+ return fdata.Friend == Friend;
+ }) != null)
+ return false;
+ }
+
+ FriendsData d = new FriendsData();
+ d.PrincipalID = PrincipalID;
+ d.Friend = Friend;
+ d.Data = new Dictionary();
+ d.Data["Flags"] = "0";
+
+ return m_Database.Store(d);
+ }
+
+ ///
+ /// Overrides base. Cannot delete friendships while away from home.
+ ///
+ ///
+ ///
+ ///
+ public override bool Delete(UUID PrincipalID, string Friend)
+ {
+ return false;
+ }
+
+ }
+}
--
cgit v1.1
From 58c53c41de2cae0bb041a2e8121792e136d1edb2 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 21 May 2011 16:48:00 -0700
Subject: Fixed permissions bug related to friends in PermissionsModule. Added
FriendsData[] GetFriends(string principalID) to IFriendsData and FriendInfo[]
GetFriends(string PrincipalID) to IFriendsService. Refactored some more in
the FriendsModule. Made client get notification of local friends permissions
upon HGLogin. HG Friends object permissions work.
---
OpenSim/Services/HypergridService/HGFriendsService.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index fa4ec5d..3ffe889 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Services.HypergridService
UUID userID;
if (UUID.TryParse(PrincipalID, out userID))
{
- FriendsData[] friendsData = m_Database.GetFriends(userID);
+ FriendsData[] friendsData = m_Database.GetFriends(userID.ToString());
List fList = new List(friendsData);
if (fList.Find(delegate(FriendsData fdata)
{
@@ -70,6 +70,8 @@ namespace OpenSim.Services.HypergridService
}) != null)
return false;
}
+ else
+ return false;
FriendsData d = new FriendsData();
d.PrincipalID = PrincipalID;
--
cgit v1.1
From fed3cc630efd223866ab03b904dc1053c2d28fe2 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sun, 22 May 2011 15:35:40 -0700
Subject: File to be removed
---
OpenSim/Services/HypergridService/HGFriendsService.cs | 11 -----------
1 file changed, 11 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index 3ffe889..1829ae3 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -82,16 +82,5 @@ namespace OpenSim.Services.HypergridService
return m_Database.Store(d);
}
- ///
- /// Overrides base. Cannot delete friendships while away from home.
- ///
- ///
- ///
- ///
- public override bool Delete(UUID PrincipalID, string Friend)
- {
- return false;
- }
-
}
}
--
cgit v1.1
From 336665e03532cf9d7a1ad65d5071e7050bf6ecd0 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sun, 22 May 2011 16:51:03 -0700
Subject: More on HG Friends. Added Delete(string, string) across the board.
Added security to friendship identifiers so that they can safely be deleted
across worlds. Had to change Get(string) to use LIKE because the secret in
the identifier is not always known -- affects only HG visitors. BOTTOM LINE
SO FAR: HG friendships established and deleted safely across grids, local
rights working but not (yet?) being transmitted back.
---
.../Services/HypergridService/HGFriendsService.cs | 86 ----------------------
1 file changed, 86 deletions(-)
delete mode 100644 OpenSim/Services/HypergridService/HGFriendsService.cs
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
deleted file mode 100644
index 1829ae3..0000000
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using OpenMetaverse;
-using OpenSim.Framework;
-using System;
-using System.Collections.Generic;
-using OpenSim.Services.Interfaces;
-using OpenSim.Services.Friends;
-using OpenSim.Data;
-using Nini.Config;
-using log4net;
-using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
-
-namespace OpenSim.Services.HypergridService
-{
- public class HGFriendsService : FriendsService, IFriendsService
- {
- public HGFriendsService(IConfigSource config) : base(config)
- {
- }
-
- ///
- /// Overrides base.
- /// Storing new friendships from the outside is a tricky, sensitive operation, and it
- /// needs to be done under certain restrictions.
- /// First of all, if the friendship already exists, this is a no-op. In other words,
- /// we cannot change just the flags, it needs to be a new friendship.
- /// Second, we store it as flags=0 always, independent of what the caller sends. The
- /// owner of the friendship needs to confirm when it gets back home.
- ///
- ///
- ///
- ///
- ///
- public override bool StoreFriend(string PrincipalID, string Friend, int flags)
- {
- UUID userID;
- if (UUID.TryParse(PrincipalID, out userID))
- {
- FriendsData[] friendsData = m_Database.GetFriends(userID.ToString());
- List fList = new List(friendsData);
- if (fList.Find(delegate(FriendsData fdata)
- {
- return fdata.Friend == Friend;
- }) != null)
- return false;
- }
- else
- return false;
-
- FriendsData d = new FriendsData();
- d.PrincipalID = PrincipalID;
- d.Friend = Friend;
- d.Data = new Dictionary();
- d.Data["Flags"] = "0";
-
- return m_Database.Store(d);
- }
-
- }
-}
--
cgit v1.1
From 24f28d353427d1905ae1a46408841265379e29c3 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Mon, 23 May 2011 19:45:39 -0700
Subject: HG friends: Status notifications working. Also initial logins get the
online friends in other grids.
---
.../Services/HypergridService/UserAgentService.cs | 172 ++++++++++++++++++++-
1 file changed, 169 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 445d45e..0181533 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -31,10 +31,12 @@ using System.Net;
using System.Reflection;
using OpenSim.Framework;
+using OpenSim.Services.Connectors.Friends;
using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenMetaverse;
using log4net;
@@ -63,19 +65,34 @@ namespace OpenSim.Services.HypergridService
protected static IGridService m_GridService;
protected static GatekeeperServiceConnector m_GatekeeperConnector;
protected static IGatekeeperService m_GatekeeperService;
+ protected static IFriendsService m_FriendsService;
+ protected static IPresenceService m_PresenceService;
+ protected static IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule
+ protected static FriendsSimConnector m_FriendsSimConnector; // grid
protected static string m_GridName;
protected static bool m_BypassClientVerification;
- public UserAgentService(IConfigSource config)
+ public UserAgentService(IConfigSource config) : this(config, null)
{
+ }
+
+ public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector)
+ {
+ // Let's set this always, because we don't know the sequence
+ // of instantiations
+ if (friendsConnector != null)
+ m_FriendsLocalSimConnector = friendsConnector;
+
if (!m_Initialized)
{
m_Initialized = true;
m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
-
+
+ m_FriendsSimConnector = new FriendsSimConnector();
+
IConfig serverConfig = config.Configs["UserAgentService"];
if (serverConfig == null)
throw new Exception(String.Format("No section UserAgentService in config file"));
@@ -83,6 +100,8 @@ namespace OpenSim.Services.HypergridService
string gridService = serverConfig.GetString("GridService", String.Empty);
string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty);
+ string friendsService = serverConfig.GetString("FriendsService", String.Empty);
+ string presenceService = serverConfig.GetString("PresenceService", String.Empty);
m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false);
@@ -94,6 +113,8 @@ namespace OpenSim.Services.HypergridService
m_GridUserService = ServerUtils.LoadPlugin(gridUserService, args);
m_GatekeeperConnector = new GatekeeperServiceConnector();
m_GatekeeperService = ServerUtils.LoadPlugin(gatekeeperService, args);
+ m_FriendsService = ServerUtils.LoadPlugin(friendsService, args);
+ m_PresenceService = ServerUtils.LoadPlugin(presenceService, args);
m_GridName = serverConfig.GetString("ExternalName", string.Empty);
if (m_GridName == string.Empty)
@@ -156,11 +177,16 @@ namespace OpenSim.Services.HypergridService
string gridName = gatekeeper.ServerURI;
m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);
-
+
if (m_GridName == gridName)
success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
else
+ {
success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
+ if (success)
+ // Report them as nowhere
+ m_PresenceService.ReportAgent(agentCircuit.SessionID, UUID.Zero);
+ }
if (!success)
{
@@ -179,6 +205,7 @@ namespace OpenSim.Services.HypergridService
if (clientIP != null)
m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
+
return true;
}
@@ -291,6 +318,145 @@ namespace OpenSim.Services.HypergridService
return false;
}
+ public void StatusNotification(List friends, UUID foreignUserID, bool online)
+ {
+ if (m_FriendsService == null || m_PresenceService == null)
+ {
+ m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
+ return;
+ }
+
+ m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
+
+ // First, let's double check that the reported friends are, indeed, friends of that user
+ // And let's check that the secret matches
+ List usersToBeNotified = new List();
+ foreach (string uui in friends)
+ {
+ UUID localUserID;
+ string secret = string.Empty, tmp = string.Empty;
+ if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
+ {
+ FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
+ foreach (FriendInfo finfo in friendInfos)
+ {
+ if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret))
+ {
+ // great!
+ usersToBeNotified.Add(localUserID.ToString());
+ }
+ }
+ }
+ }
+
+ // Now, let's send the notifications
+ m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count);
+
+ // First, let's send notifications to local users who are online in the home grid
+ PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
+ if (friendSessions != null && friendSessions.Length > 0)
+ {
+ PresenceInfo friendSession = null;
+ foreach (PresenceInfo pinfo in friendSessions)
+ if (pinfo.RegionID != UUID.Zero) // let's guard against traveling agents
+ {
+ friendSession = pinfo;
+ break;
+ }
+
+ if (friendSession != null)
+ {
+ ForwardStatusNotificationToSim(friendSession.RegionID, friendSession.UserID, foreignUserID, online);
+ usersToBeNotified.Remove(friendSession.UserID.ToString());
+ }
+ }
+
+ // Lastly, let's notify the rest who may be online somewhere else
+ foreach (string user in usersToBeNotified)
+ {
+ UUID id = new UUID(user);
+ if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName)
+ {
+ string url = m_TravelingAgents[id].GridExternalName;
+ // forward
+ m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
+ }
+ }
+ }
+
+ protected void ForwardStatusNotificationToSim(UUID regionID, string user, UUID foreignUserID, bool online)
+ {
+ UUID userID;
+ if (UUID.TryParse(user, out userID))
+ {
+ if (m_FriendsLocalSimConnector != null)
+ {
+ m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
+ m_FriendsLocalSimConnector.StatusNotify(userID, foreignUserID, online);
+ }
+ else
+ {
+ GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
+ if (region != null)
+ {
+ m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, user, foreignUserID, (online ? "online" : "offline"));
+ m_FriendsSimConnector.StatusNotify(region, userID, foreignUserID, online);
+ }
+ }
+ }
+ }
+
+ public List GetOnlineFriends(UUID foreignUserID, List friends)
+ {
+ List online = new List();
+
+ if (m_FriendsService == null || m_PresenceService == null)
+ {
+ m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing");
+ return online;
+ }
+
+ m_log.DebugFormat("[USER AGENT SERVICE]: Foreign user {0} wants to know status of {1} local friends", foreignUserID, friends.Count);
+
+ // First, let's double check that the reported friends are, indeed, friends of that user
+ // And let's check that the secret matches and the rights
+ List usersToBeNotified = new List();
+ foreach (string uui in friends)
+ {
+ UUID localUserID;
+ string secret = string.Empty, tmp = string.Empty;
+ if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
+ {
+ FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
+ foreach (FriendInfo finfo in friendInfos)
+ {
+ if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) &&
+ (finfo.TheirFlags & (int)FriendRights.CanSeeOnline) != 0 && (finfo.TheirFlags != -1))
+ {
+ // great!
+ usersToBeNotified.Add(localUserID.ToString());
+ }
+ }
+ }
+ }
+
+ // Now, let's find out their status
+ m_log.DebugFormat("[USER AGENT SERVICE]: GetOnlineFriends: user has {0} local friends with status rights", usersToBeNotified.Count);
+
+ // First, let's send notifications to local users who are online in the home grid
+ PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
+ if (friendSessions != null && friendSessions.Length > 0)
+ {
+ foreach (PresenceInfo pi in friendSessions)
+ {
+ UUID presenceID;
+ if (UUID.TryParse(pi.UserID, out presenceID))
+ online.Add(presenceID);
+ }
+ }
+
+ return online;
+ }
}
class TravelingAgentInfo
--
cgit v1.1
From e19031849ec2957f7312d7e2417bd8c8da0efc53 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 24 May 2011 09:38:03 -0700
Subject: Added necessary code to drop inventory on hg friends using the
profile window, but can't test because this mechanism doesn't seem to work
without a profile service.
---
OpenSim/Services/HypergridService/UserAgentService.cs | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 0181533..e63f941 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -67,6 +67,7 @@ namespace OpenSim.Services.HypergridService
protected static IGatekeeperService m_GatekeeperService;
protected static IFriendsService m_FriendsService;
protected static IPresenceService m_PresenceService;
+ protected static IUserAccountService m_UserAccountService;
protected static IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule
protected static FriendsSimConnector m_FriendsSimConnector; // grid
@@ -102,6 +103,7 @@ namespace OpenSim.Services.HypergridService
string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty);
string friendsService = serverConfig.GetString("FriendsService", String.Empty);
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
+ string userAccountService = serverConfig.GetString("UserAccountService", String.Empty);
m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false);
@@ -115,6 +117,7 @@ namespace OpenSim.Services.HypergridService
m_GatekeeperService = ServerUtils.LoadPlugin(gatekeeperService, args);
m_FriendsService = ServerUtils.LoadPlugin(friendsService, args);
m_PresenceService = ServerUtils.LoadPlugin(presenceService, args);
+ m_UserAccountService = ServerUtils.LoadPlugin(userAccountService, args);
m_GridName = serverConfig.GetString("ExternalName", string.Empty);
if (m_GridName == string.Empty)
@@ -457,6 +460,20 @@ namespace OpenSim.Services.HypergridService
return online;
}
+
+ public Dictionary GetServerURLs(UUID userID)
+ {
+ if (m_UserAccountService == null)
+ {
+ m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing");
+ return new Dictionary();
+ }
+ UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero /*!!!*/, userID);
+ if (account != null)
+ return account.ServiceURLs;
+
+ return new Dictionary();
+ }
}
class TravelingAgentInfo
--
cgit v1.1
From 5c2168cae758ae19367f4c2f5a02713e74fc0912 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Wed, 25 May 2011 12:32:21 -0700
Subject: HG: Instant Message working. Tested on HG standalones only. Needs a
lot more testing.
---
.../HypergridService/HGInstantMessageService.cs | 311 +++++++++++++++++++++
.../Services/HypergridService/UserAgentService.cs | 11 +
2 files changed, 322 insertions(+)
create mode 100644 OpenSim/Services/HypergridService/HGInstantMessageService.cs
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
new file mode 100644
index 0000000..6178ca1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Reflection;
+
+using OpenSim.Framework;
+using OpenSim.Services.Connectors.Friends;
+using OpenSim.Services.Connectors.Hypergrid;
+using OpenSim.Services.Interfaces;
+using OpenSim.Services.Connectors.InstantMessage;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using OpenSim.Server.Base;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
+
+using OpenMetaverse;
+using log4net;
+using Nini.Config;
+
+namespace OpenSim.Services.HypergridService
+{
+ ///
+ /// Inter-grid IM
+ ///
+ public class HGInstantMessageService : IInstantMessage
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours
+
+ static bool m_Initialized = false;
+
+ protected static IGridService m_GridService;
+ protected static IPresenceService m_PresenceService;
+ protected static IUserAgentService m_UserAgentService;
+
+ protected static IInstantMessageSimConnector m_IMSimConnector;
+
+ protected Dictionary m_UserLocationMap = new Dictionary();
+ private ExpiringCache m_RegionCache;
+
+ public HGInstantMessageService(IConfigSource config)
+ : this(config, null)
+ {
+ }
+
+ public HGInstantMessageService(IConfigSource config, IInstantMessageSimConnector imConnector)
+ {
+ if (imConnector != null)
+ m_IMSimConnector = imConnector;
+
+ if (!m_Initialized)
+ {
+ m_Initialized = true;
+
+ m_log.DebugFormat("[HG IM SERVICE]: Starting...");
+
+ IConfig serverConfig = config.Configs["HGInstantMessageService"];
+ if (serverConfig == null)
+ throw new Exception(String.Format("No section HGInstantMessageService in config file"));
+
+ string gridService = serverConfig.GetString("GridService", String.Empty);
+ string presenceService = serverConfig.GetString("PresenceService", String.Empty);
+ string userAgentService = serverConfig.GetString("UserAgentService", String.Empty);
+
+ if (gridService == string.Empty || presenceService == string.Empty)
+ throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
+
+ Object[] args = new Object[] { config };
+ m_GridService = ServerUtils.LoadPlugin(gridService, args);
+ m_PresenceService = ServerUtils.LoadPlugin(presenceService, args);
+ m_UserAgentService = ServerUtils.LoadPlugin(userAgentService, args);
+
+ m_RegionCache = new ExpiringCache();
+
+ }
+ }
+
+ public bool IncomingInstantMessage(GridInstantMessage im)
+ {
+ m_log.DebugFormat("[HG IM SERVICE]: Received message {0} from {1} to {2}", im.message, im.fromAgentID, im.toAgentID);
+ UUID toAgentID = new UUID(im.toAgentID);
+
+ if (m_IMSimConnector != null)
+ {
+ m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
+ return m_IMSimConnector.SendInstantMessage(im);
+ }
+ else
+ return TrySendInstantMessage(im, "", true);
+ }
+
+ public bool OutgoingInstantMessage(GridInstantMessage im, string url)
+ {
+ m_log.DebugFormat("[HG IM SERVICE]: Sending message {0} from {1} to {2}@{3}", im.message, im.fromAgentID, im.toAgentID, url);
+ if (url != string.Empty)
+ return TrySendInstantMessage(im, url, true);
+ else
+ {
+ PresenceInfo upd = new PresenceInfo();
+ upd.RegionID = UUID.Zero;
+ return TrySendInstantMessage(im, upd, true);
+ }
+ }
+
+ protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime)
+ {
+ UUID toAgentID = new UUID(im.toAgentID);
+
+ PresenceInfo upd = null;
+ string url = string.Empty;
+
+ bool lookupAgent = false;
+
+ lock (m_UserLocationMap)
+ {
+ if (m_UserLocationMap.ContainsKey(toAgentID))
+ {
+ object o = m_UserLocationMap[toAgentID];
+ if (o is PresenceInfo)
+ upd = (PresenceInfo)o;
+ else if (o is string)
+ url = (string)o;
+
+ // We need to compare the current location with the previous
+ // or the recursive loop will never end because it will never try to lookup the agent again
+ if (!firstTime)
+ {
+ lookupAgent = true;
+ }
+ }
+ else
+ {
+ lookupAgent = true;
+ }
+ }
+
+ m_log.DebugFormat("[XXX] Neeed lookup ? {0}", (lookupAgent ? "yes" : "no"));
+
+ // Are we needing to look-up an agent?
+ if (lookupAgent)
+ {
+ bool isPresent = false;
+ // Non-cached user agent lookup.
+ PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() });
+ if (presences != null && presences.Length > 0)
+ {
+ foreach (PresenceInfo p in presences)
+ {
+ if (p.RegionID != UUID.Zero)
+ {
+ upd = p;
+ break;
+ }
+ else
+ isPresent = true;
+ }
+ }
+
+ if (upd == null && isPresent)
+ {
+ // Let's check with the UAS if the user is elsewhere
+ url = m_UserAgentService.LocateUser(toAgentID);
+ }
+
+ if (upd != null || url != string.Empty)
+ {
+ // check if we've tried this before..
+ // This is one way to end the recursive loop
+ //
+ if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
+ (previousLocation is string && previousLocation.Equals(url))))
+ {
+ // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
+ m_log.DebugFormat("[XXX] Fail 1 {0} {1}", previousLocation, url);
+
+ return false;
+ }
+ }
+ }
+
+ if (upd != null)
+ {
+ // ok, the user is around somewhere. Let's send back the reply with "success"
+ // even though the IM may still fail. Just don't keep the caller waiting for
+ // the entire time we're trying to deliver the IM
+ return SendIMToRegion(upd, im, toAgentID);
+ }
+ else if (url != string.Empty)
+ {
+ // ok, the user is around somewhere. Let's send back the reply with "success"
+ // even though the IM may still fail. Just don't keep the caller waiting for
+ // the entire time we're trying to deliver the IM
+ return ForwardIMToGrid(url, im, toAgentID);
+ }
+ else if (firstTime && previousLocation is string && (string)previousLocation != string.Empty)
+ {
+ return ForwardIMToGrid((string)previousLocation, im, toAgentID);
+ }
+ else
+ m_log.DebugFormat("[HG IM SERVICE]: Unable to locate user {0}", toAgentID);
+ return false;
+ }
+
+ bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID)
+ {
+ bool imresult = false;
+ GridRegion reginfo = null;
+ if (!m_RegionCache.TryGetValue(upd.RegionID, out reginfo))
+ {
+ reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
+ if (reginfo != null)
+ m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, CACHE_EXPIRATION_SECONDS);
+ }
+
+ if (reginfo != null)
+ imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im);
+ else
+ return false;
+
+ if (imresult)
+ {
+ // IM delivery successful, so store the Agent's location in our local cache.
+ lock (m_UserLocationMap)
+ {
+ if (m_UserLocationMap.ContainsKey(toAgentID))
+ {
+ m_UserLocationMap[toAgentID] = upd;
+ }
+ else
+ {
+ m_UserLocationMap.Add(toAgentID, upd);
+ }
+ }
+ return true;
+ }
+ else
+ {
+ // try again, but lookup user this time.
+ // Warning, this must call the Async version
+ // of this method or we'll be making thousands of threads
+ // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
+ // The version that spawns the thread is SendGridInstantMessageViaXMLRPC
+
+ // This is recursive!!!!!
+ return TrySendInstantMessage(im, upd, false);
+ }
+ }
+
+ bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID)
+ {
+ if (InstantMessageServiceConnector.SendInstantMessage(url, im))
+ {
+ // IM delivery successful, so store the Agent's location in our local cache.
+ lock (m_UserLocationMap)
+ {
+ if (m_UserLocationMap.ContainsKey(toAgentID))
+ {
+ m_UserLocationMap[toAgentID] = url;
+ }
+ else
+ {
+ m_UserLocationMap.Add(toAgentID, url);
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ // try again, but lookup user this time.
+ // Warning, this must call the Async version
+ // of this method or we'll be making thousands of threads
+ // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
+ // The version that spawns the thread is SendGridInstantMessageViaXMLRPC
+
+ // This is recursive!!!!!
+ return TrySendInstantMessage(im, url, false);
+ }
+
+ }
+ }
+}
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index e63f941..59ad043 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -474,6 +474,17 @@ namespace OpenSim.Services.HypergridService
return new Dictionary();
}
+
+ public string LocateUser(UUID userID)
+ {
+ foreach (TravelingAgentInfo t in m_TravelingAgents.Values)
+ {
+ if (t.UserID == userID)
+ return t.GridExternalName;
+ }
+
+ return string.Empty;
+ }
}
class TravelingAgentInfo
--
cgit v1.1
From 0c58a9e68074f3593920dc9f2356bbed96416497 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 26 May 2011 10:04:48 -0700
Subject: HG IM in grid mode working fairly well. Unknown target user
references looked back in source user's User Agent service.
---
.../HypergridService/HGInstantMessageService.cs | 22 ++++++++++++--------
.../Services/HypergridService/UserAgentService.cs | 24 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
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
protected static IInstantMessageSimConnector m_IMSimConnector;
- protected Dictionary m_UserLocationMap = new Dictionary();
- private ExpiringCache m_RegionCache;
+ protected static Dictionary m_UserLocationMap = new Dictionary();
+ private static ExpiringCache m_RegionCache;
public HGInstantMessageService(IConfigSource config)
: this(config, null)
@@ -155,6 +155,8 @@ namespace OpenSim.Services.HypergridService
if (!firstTime)
{
lookupAgent = true;
+ upd = null;
+ url = string.Empty;
}
}
else
@@ -168,7 +170,6 @@ namespace OpenSim.Services.HypergridService
// Are we needing to look-up an agent?
if (lookupAgent)
{
- bool isPresent = false;
// Non-cached user agent lookup.
PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() });
if (presences != null && presences.Length > 0)
@@ -177,17 +178,17 @@ namespace OpenSim.Services.HypergridService
{
if (p.RegionID != UUID.Zero)
{
+ m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID);
upd = p;
break;
}
- else
- isPresent = true;
}
}
- if (upd == null && isPresent)
+ if (upd == null)
{
// Let's check with the UAS if the user is elsewhere
+ m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
url = m_UserAgentService.LocateUser(toAgentID);
}
@@ -197,10 +198,10 @@ namespace OpenSim.Services.HypergridService
// This is one way to end the recursive loop
//
if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
- (previousLocation is string && previousLocation.Equals(url))))
+ (previousLocation is string && upd == null && previousLocation.Equals(url))))
{
// m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
- m_log.DebugFormat("[XXX] Fail 1 {0} {1}", previousLocation, url);
+ m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url);
return false;
}
@@ -242,9 +243,14 @@ namespace OpenSim.Services.HypergridService
}
if (reginfo != null)
+ {
imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im);
+ }
else
+ {
+ m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI);
return false;
+ }
if (imresult)
{
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
return string.Empty;
}
+
+ public string GetUUI(UUID userID, UUID targetUserID)
+ {
+ // Let's see if it's a local user
+ UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID);
+ if (account != null)
+ return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ;
+
+ // Let's try the list of friends
+ FriendInfo[] friends = m_FriendsService.GetFriends(userID);
+ if (friends != null && friends.Length > 0)
+ {
+ foreach (FriendInfo f in friends)
+ if (f.Friend.StartsWith(targetUserID.ToString()))
+ {
+ // Let's remove the secret
+ UUID id; string tmp = string.Empty, secret = string.Empty;
+ if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret))
+ return f.Friend.Replace(secret, "0");
+ }
+ }
+
+ return string.Empty;
+ }
}
class TravelingAgentInfo
--
cgit v1.1
From 0d29f7391629defa0ec1463fb24486ee76cca527 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 26 May 2011 19:13:03 -0700
Subject: Commented a few extra debug messages.
---
OpenSim/Services/HypergridService/HGInstantMessageService.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index ca0fd7f..dd5fd71 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -106,12 +106,12 @@ namespace OpenSim.Services.HypergridService
public bool IncomingInstantMessage(GridInstantMessage im)
{
- m_log.DebugFormat("[HG IM SERVICE]: Received message {0} from {1} to {2}", im.message, im.fromAgentID, im.toAgentID);
+ m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
UUID toAgentID = new UUID(im.toAgentID);
if (m_IMSimConnector != null)
{
- m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
+ //m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
return m_IMSimConnector.SendInstantMessage(im);
}
else
@@ -120,7 +120,7 @@ namespace OpenSim.Services.HypergridService
public bool OutgoingInstantMessage(GridInstantMessage im, string url)
{
- m_log.DebugFormat("[HG IM SERVICE]: Sending message {0} from {1} to {2}@{3}", im.message, im.fromAgentID, im.toAgentID, url);
+ m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
if (url != string.Empty)
return TrySendInstantMessage(im, url, true);
else
@@ -165,7 +165,7 @@ namespace OpenSim.Services.HypergridService
}
}
- m_log.DebugFormat("[XXX] Neeed lookup ? {0}", (lookupAgent ? "yes" : "no"));
+ //m_log.DebugFormat("[XXX] Neeed lookup ? {0}", (lookupAgent ? "yes" : "no"));
// Are we needing to look-up an agent?
if (lookupAgent)
@@ -178,7 +178,7 @@ namespace OpenSim.Services.HypergridService
{
if (p.RegionID != UUID.Zero)
{
- m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID);
+ //m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID);
upd = p;
break;
}
--
cgit v1.1
From d60f525baa8697f896b9f756175118828db9ac78 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 27 May 2011 08:19:40 -0700
Subject: HG inventory transfers over the profile working.
---
OpenSim/Services/HypergridService/HGInventoryService.cs | 2 ++
1 file changed, 2 insertions(+)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 9ee1ae4..4eb61ba 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -134,6 +134,7 @@ namespace OpenSim.Services.HypergridService
public override InventoryFolderBase GetRootFolder(UUID principalID)
{
+ //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
// Warp! Root folder for travelers
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "folderName"},
@@ -171,6 +172,7 @@ namespace OpenSim.Services.HypergridService
public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
{
+ //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
return GetRootFolder(principalID);
}
--
cgit v1.1
From 4b9e446c6267a1161263d885699e72c97e8a94eb Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Wed, 1 Jun 2011 16:57:01 -0400
Subject: Use current TravelingAgent if the login failure reason is "Logins
Disabled" to fix NullReferenceException, allowing agent to login to fallback
region when logins are disabled by "StartDisabled = true" or when logins are
disabled by RegionReady
---
OpenSim/Services/HypergridService/UserAgentService.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 387547e..2f2ebfb 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -197,8 +197,11 @@ namespace OpenSim.Services.HypergridService
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
// restore the old travel info
- lock (m_TravelingAgents)
- m_TravelingAgents[agentCircuit.SessionID] = old;
+ if(reason != "Logins Disabled")
+ {
+ lock (m_TravelingAgents)
+ m_TravelingAgents[agentCircuit.SessionID] = old;
+ }
return false;
}
--
cgit v1.1
From 0a430bbffb561a5172220e7617257798c11a66f5 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Wed, 1 Jun 2011 18:10:56 -0400
Subject: Revert "Use current TravelingAgent if the login failure reason is
"Logins Disabled" to fix NullReferenceException, allowing agent to login to
fallback region when logins are disabled by "StartDisabled = true" or when
logins are disabled by RegionReady"
This reverts commit 4b9e446c6267a1161263d885699e72c97e8a94eb.
---
OpenSim/Services/HypergridService/UserAgentService.cs | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 2f2ebfb..387547e 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -197,11 +197,8 @@ namespace OpenSim.Services.HypergridService
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
// restore the old travel info
- if(reason != "Logins Disabled")
- {
- lock (m_TravelingAgents)
- m_TravelingAgents[agentCircuit.SessionID] = old;
- }
+ lock (m_TravelingAgents)
+ m_TravelingAgents[agentCircuit.SessionID] = old;
return false;
}
--
cgit v1.1
From 777f57d9469d4df11ea2bf2bd0704f89cae34b0a Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Wed, 1 Jun 2011 18:47:06 -0400
Subject: Re-Apply Use current TravelingAgent if the the login failure reason
is "Logins Disabled" to fix NullReferenceException, allowing agent to login
to fallback region when logins are disabled by "StartDisabled = true" or when
logins are disabled by RegionReady""
This reverts commit 0a430bbffb561a5172220e7617257798c11a66f5.
---
OpenSim/Services/HypergridService/UserAgentService.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 387547e..2f2ebfb 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -197,8 +197,11 @@ namespace OpenSim.Services.HypergridService
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
// restore the old travel info
- lock (m_TravelingAgents)
- m_TravelingAgents[agentCircuit.SessionID] = old;
+ if(reason != "Logins Disabled")
+ {
+ lock (m_TravelingAgents)
+ m_TravelingAgents[agentCircuit.SessionID] = old;
+ }
return false;
}
--
cgit v1.1
From 4696a9c95eaf87e5cb43cdba008d3f41a949d629 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 2 Jun 2011 08:13:54 -0700
Subject: Bug fix on HG IM.
---
.../HypergridService/HGInstantMessageService.cs | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index dd5fd71..4f68e55 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -115,23 +115,23 @@ namespace OpenSim.Services.HypergridService
return m_IMSimConnector.SendInstantMessage(im);
}
else
- return TrySendInstantMessage(im, "", true);
+ return TrySendInstantMessage(im, "", true, false);
}
- public bool OutgoingInstantMessage(GridInstantMessage im, string url)
+ public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
{
m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
if (url != string.Empty)
- return TrySendInstantMessage(im, url, true);
+ return TrySendInstantMessage(im, url, true, foreigner);
else
{
PresenceInfo upd = new PresenceInfo();
upd.RegionID = UUID.Zero;
- return TrySendInstantMessage(im, upd, true);
+ return TrySendInstantMessage(im, upd, true, foreigner);
}
}
- protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime)
+ protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner)
{
UUID toAgentID = new UUID(im.toAgentID);
@@ -185,7 +185,7 @@ namespace OpenSim.Services.HypergridService
}
}
- if (upd == null)
+ if (upd == null && !foreigner)
{
// Let's check with the UAS if the user is elsewhere
m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
@@ -213,25 +213,25 @@ namespace OpenSim.Services.HypergridService
// ok, the user is around somewhere. Let's send back the reply with "success"
// even though the IM may still fail. Just don't keep the caller waiting for
// the entire time we're trying to deliver the IM
- return SendIMToRegion(upd, im, toAgentID);
+ return SendIMToRegion(upd, im, toAgentID, foreigner);
}
else if (url != string.Empty)
{
// ok, the user is around somewhere. Let's send back the reply with "success"
// even though the IM may still fail. Just don't keep the caller waiting for
// the entire time we're trying to deliver the IM
- return ForwardIMToGrid(url, im, toAgentID);
+ return ForwardIMToGrid(url, im, toAgentID, foreigner);
}
else if (firstTime && previousLocation is string && (string)previousLocation != string.Empty)
{
- return ForwardIMToGrid((string)previousLocation, im, toAgentID);
+ return ForwardIMToGrid((string)previousLocation, im, toAgentID, foreigner);
}
else
m_log.DebugFormat("[HG IM SERVICE]: Unable to locate user {0}", toAgentID);
return false;
}
- bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID)
+ bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
{
bool imresult = false;
GridRegion reginfo = null;
@@ -277,11 +277,11 @@ namespace OpenSim.Services.HypergridService
// The version that spawns the thread is SendGridInstantMessageViaXMLRPC
// This is recursive!!!!!
- return TrySendInstantMessage(im, upd, false);
+ return TrySendInstantMessage(im, upd, false, foreigner);
}
}
- bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID)
+ bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID, bool foreigner)
{
if (InstantMessageServiceConnector.SendInstantMessage(url, im))
{
@@ -309,7 +309,7 @@ namespace OpenSim.Services.HypergridService
// The version that spawns the thread is SendGridInstantMessageViaXMLRPC
// This is recursive!!!!!
- return TrySendInstantMessage(im, url, false);
+ return TrySendInstantMessage(im, url, false, foreigner);
}
}
--
cgit v1.1
From e77ca65e575e4f8f7645aec879b73b87ba505f49 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Mon, 6 Jun 2011 17:46:34 -0700
Subject: This should make offline IMs work again. It should work for incoming
foreign IMs where the local recipient is offline. I can't test any of this,
because I don't run an offline IM server.
---
.../HypergridService/HGInstantMessageService.cs | 51 ++++++++++++++++++++--
1 file changed, 47 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 4f68e55..66cf4de 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -67,6 +67,10 @@ namespace OpenSim.Services.HypergridService
protected static Dictionary m_UserLocationMap = new Dictionary();
private static ExpiringCache m_RegionCache;
+ private static string m_RestURL;
+ private static bool m_ForwardOfflineGroupMessages;
+ private static bool m_InGatekeeper;
+
public HGInstantMessageService(IConfigSource config)
: this(config, null)
{
@@ -81,8 +85,6 @@ namespace OpenSim.Services.HypergridService
{
m_Initialized = true;
- m_log.DebugFormat("[HG IM SERVICE]: Starting...");
-
IConfig serverConfig = config.Configs["HGInstantMessageService"];
if (serverConfig == null)
throw new Exception(String.Format("No section HGInstantMessageService in config file"));
@@ -90,6 +92,9 @@ namespace OpenSim.Services.HypergridService
string gridService = serverConfig.GetString("GridService", String.Empty);
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
string userAgentService = serverConfig.GetString("UserAgentService", String.Empty);
+ m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false);
+ m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper);
+
if (gridService == string.Empty || presenceService == string.Empty)
throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
@@ -101,6 +106,21 @@ namespace OpenSim.Services.HypergridService
m_RegionCache = new ExpiringCache();
+ IConfig cnf = config.Configs["Messaging"];
+ if (cnf == null)
+ {
+ return;
+ }
+
+ m_RestURL = cnf.GetString("OfflineMessageURL", string.Empty);
+ if (m_RestURL == string.Empty)
+ {
+ m_log.Error("[HG IM SERVICE]: Offline IMs enabled, but no URL is given");
+ return;
+ }
+
+ m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", false);
+
}
}
@@ -109,13 +129,21 @@ namespace OpenSim.Services.HypergridService
m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
UUID toAgentID = new UUID(im.toAgentID);
+ bool success = false;
if (m_IMSimConnector != null)
{
//m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
- return m_IMSimConnector.SendInstantMessage(im);
+ success = m_IMSimConnector.SendInstantMessage(im);
}
else
- return TrySendInstantMessage(im, "", true, false);
+ {
+ success = TrySendInstantMessage(im, "", true, false);
+ }
+
+ if (!success && m_InGatekeeper) // we do this only in the Gatekeeper IM service
+ UndeliveredMessage(im);
+
+ return success;
}
public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
@@ -129,6 +157,7 @@ namespace OpenSim.Services.HypergridService
upd.RegionID = UUID.Zero;
return TrySendInstantMessage(im, upd, true, foreigner);
}
+
}
protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner)
@@ -313,5 +342,19 @@ namespace OpenSim.Services.HypergridService
}
}
+
+ private bool UndeliveredMessage(GridInstantMessage im)
+ {
+ if (m_RestURL != string.Empty && (im.offline != 0)
+ && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
+ {
+ return SynchronousRestObjectPoster.BeginPostObject(
+ "POST", m_RestURL + "/SaveMessage/", im);
+
+ }
+
+ else
+ return false;
+ }
}
}
--
cgit v1.1
From f5d82350bb622baa6f49042882e6c5cb49b24cc0 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 7 Jun 2011 10:51:12 -0700
Subject: This fixes the crash reported in
http://opensimulator.org/mantis/view.php?id=5529 related to sending IMs to
foreign friends who are offline. Hopefully.
---
.../HypergridService/HGInstantMessageService.cs | 28 ++++++++++------------
.../Services/HypergridService/UserAgentService.cs | 2 +-
2 files changed, 13 insertions(+), 17 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 66cf4de..90a0bf2 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -185,7 +185,6 @@ namespace OpenSim.Services.HypergridService
{
lookupAgent = true;
upd = null;
- url = string.Empty;
}
}
else
@@ -221,19 +220,16 @@ namespace OpenSim.Services.HypergridService
url = m_UserAgentService.LocateUser(toAgentID);
}
- if (upd != null || url != string.Empty)
+ // check if we've tried this before..
+ // This is one way to end the recursive loop
+ //
+ if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
+ (previousLocation is string && upd == null && previousLocation.Equals(url))))
{
- // check if we've tried this before..
- // This is one way to end the recursive loop
- //
- if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
- (previousLocation is string && upd == null && previousLocation.Equals(url))))
- {
- // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
- m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url);
+ // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
+ m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url);
- return false;
- }
+ return false;
}
}
@@ -332,10 +328,6 @@ namespace OpenSim.Services.HypergridService
else
{
// try again, but lookup user this time.
- // Warning, this must call the Async version
- // of this method or we'll be making thousands of threads
- // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
- // The version that spawns the thread is SendGridInstantMessageViaXMLRPC
// This is recursive!!!!!
return TrySendInstantMessage(im, url, false, foreigner);
@@ -348,13 +340,17 @@ namespace OpenSim.Services.HypergridService
if (m_RestURL != string.Empty && (im.offline != 0)
&& (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
{
+ m_log.DebugFormat("[HG IM SERVICE]: Message saved");
return SynchronousRestObjectPoster.BeginPostObject(
"POST", m_RestURL + "/SaveMessage/", im);
}
else
+ {
+ m_log.DebugFormat("[HG IM SERVICE]: No offline IM service, message not saved");
return false;
+ }
}
}
}
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 2f2ebfb..8d78f97 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -482,7 +482,7 @@ namespace OpenSim.Services.HypergridService
{
foreach (TravelingAgentInfo t in m_TravelingAgents.Values)
{
- if (t.UserID == userID)
+ if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
return t.GridExternalName;
}
--
cgit v1.1
From 41627bdf8a98358829a6a1210cb14ba143fdeee2 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 7 Jun 2011 12:09:32 -0700
Subject: Remove scary error message
---
OpenSim/Services/HypergridService/HGInstantMessageService.cs | 6 ------
1 file changed, 6 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 90a0bf2..09dbc65 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -113,12 +113,6 @@ namespace OpenSim.Services.HypergridService
}
m_RestURL = cnf.GetString("OfflineMessageURL", string.Empty);
- if (m_RestURL == string.Empty)
- {
- m_log.Error("[HG IM SERVICE]: Offline IMs enabled, but no URL is given");
- return;
- }
-
m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", false);
}
--
cgit v1.1
From 3307db5d4aedec5cc31541e9a28a95abdd4999d0 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 7 Jun 2011 19:36:04 -0700
Subject: This hopefully fixes all issues with online/offline notifications
across grids. http://opensimulator.org/mantis/view.php?id=5528
---
.../Services/HypergridService/UserAgentService.cs | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 8d78f97..29d8b3d 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -324,14 +324,16 @@ namespace OpenSim.Services.HypergridService
return false;
}
- public void StatusNotification(List friends, UUID foreignUserID, bool online)
+ public List StatusNotification(List friends, UUID foreignUserID, bool online)
{
if (m_FriendsService == null || m_PresenceService == null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
- return;
+ return new List();
}
+ List localFriendsOnline = new List();
+
m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
// First, let's double check that the reported friends are, indeed, friends of that user
@@ -372,8 +374,12 @@ namespace OpenSim.Services.HypergridService
if (friendSession != null)
{
- ForwardStatusNotificationToSim(friendSession.RegionID, friendSession.UserID, foreignUserID, online);
+ ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online);
usersToBeNotified.Remove(friendSession.UserID.ToString());
+ UUID id;
+ if (UUID.TryParse(friendSession.UserID, out id))
+ localFriendsOnline.Add(id);
+
}
}
@@ -388,9 +394,17 @@ namespace OpenSim.Services.HypergridService
m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
}
}
+
+ // and finally, let's send the online friends
+ if (online)
+ {
+ return localFriendsOnline;
+ }
+ else
+ return new List();
}
- protected void ForwardStatusNotificationToSim(UUID regionID, string user, UUID foreignUserID, bool online)
+ protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online)
{
UUID userID;
if (UUID.TryParse(user, out userID))
@@ -398,15 +412,15 @@ namespace OpenSim.Services.HypergridService
if (m_FriendsLocalSimConnector != null)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
- m_FriendsLocalSimConnector.StatusNotify(userID, foreignUserID, online);
+ m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
}
else
{
GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
if (region != null)
{
- m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, user, foreignUserID, (online ? "online" : "offline"));
- m_FriendsSimConnector.StatusNotify(region, userID, foreignUserID, online);
+ m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
+ m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online);
}
}
}
--
cgit v1.1
From eabfc9ca153b1b9775bada56c2c0120768a77fda Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 7 Jun 2011 20:05:24 -0700
Subject: Added error message to help understand
http://opensimulator.org/mantis/view.php?id=5527
---
OpenSim/Services/HypergridService/UserAgentService.cs | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 29d8b3d..7ed5ea5 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -496,6 +496,11 @@ namespace OpenSim.Services.HypergridService
{
foreach (TravelingAgentInfo t in m_TravelingAgents.Values)
{
+ if (t == null)
+ {
+ m_log.ErrorFormat("[USER AGENT SERVICE]: Oops! Null TravelingAgentInfo. Please report this on mantis");
+ continue;
+ }
if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
return t.GridExternalName;
}
--
cgit v1.1
From 90f657d77d2df4ff0867431a8bcf34cbed13057f Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Wed, 8 Jun 2011 13:45:38 -0700
Subject: Deleted wrong debug message.
---
OpenSim/Services/HypergridService/HGInstantMessageService.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim/Services/HypergridService')
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 09dbc65..ded589d 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -342,7 +342,6 @@ namespace OpenSim.Services.HypergridService
else
{
- m_log.DebugFormat("[HG IM SERVICE]: No offline IM service, message not saved");
return false;
}
}
--
cgit v1.1