take friends out of basicDOSprot (too little, too late)

0.9.1.0-post-fixes
UbitUmarov 2018-11-14 17:49:05 +00:00
parent 35f5d4449b
commit afb1d6cdd7
2 changed files with 20 additions and 13 deletions

View File

@ -42,22 +42,27 @@ using log4net;
namespace OpenSim.Region.CoreModules.Avatar.Friends
{
public class FriendsRequestHandler : BaseStreamHandlerBasicDOSProtector
// public class FriendsRequestHandler : BaseStreamHandlerBasicDOSProtector
public class FriendsRequestHandler : BaseStreamHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private FriendsModule m_FriendsModule;
/*
public FriendsRequestHandler(FriendsModule fmodule)
: base("POST", "/friends", new BasicDosProtectorOptions()
{
AllowXForwardedFor = true,
ForgetTimeSpan = TimeSpan.FromMinutes(2),
MaxRequestsInTimeframe = 20,
ReportingName = "FRIENDSDOSPROTECTOR",
RequestTimeSpan = TimeSpan.FromSeconds(5),
ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
})
*/
public FriendsRequestHandler(FriendsModule fmodule)
: base("POST", "/friends", new BasicDosProtectorOptions()
{
AllowXForwardedFor = true,
ForgetTimeSpan = TimeSpan.FromMinutes(2),
MaxRequestsInTimeframe = 20,
ReportingName = "FRIENDSDOSPROTECTOR",
RequestTimeSpan = TimeSpan.FromSeconds(5),
ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
})
: base("POST", "/friends")
{
m_FriendsModule = fmodule;
}

View File

@ -170,6 +170,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// we do this only for the root agent
if (m_Friends[agentID].Refcount == 1)
{
IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>();
if(uMan == null)
return true;
// We need to preload the user management cache with the names
// of foreign friends, just like we do with SOPs' creators
foreach (FriendInfo finfo in m_Friends[agentID].Friends)
@ -182,8 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;
if (Util.ParseUniversalUserIdentifier(finfo.Friend, out id, out url, out first, out last, out tmp))
{
IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>();
m_log.DebugFormat("[HGFRIENDS MODULE]: caching {0}", finfo.Friend);
// m_log.DebugFormat("[HGFRIENDS MODULE]: caching {0}", finfo.Friend);
uMan.AddUser(id, url + ";" + first + " " + last);
}
}