From 5fb7b485b211bbf19f4531a051b78dde92da4ba3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 19 Sep 2008 17:41:21 +0000 Subject: * Only allow logins on standalone when the sim has completed it's initial startup (script startup doesn't count here) * There was a small window where region logins were allowed before modules were loaded - avatars logins that hit this window could have caused bad things to happen. * A similar change will follow for grid mode sometime soon --- .../Communications/Local/CommunicationsLocal.cs | 4 +- .../Communications/Local/LocalBackEndServices.cs | 13 +++-- .../Communications/Local/LocalLoginService.cs | 64 ++++++++++++++-------- .../Communications/OGS1/CommunicationsOGS1.cs | 6 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 15 ++++- 5 files changed, 68 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/Communications') diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index c79979c..71c44e5 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -42,8 +42,8 @@ namespace OpenSim.Region.Communications.Local IUserServiceAdmin userServiceAdmin, LocalInventoryService inventoryService, IInterRegionCommunications interRegionService, - IGridServices gridService, bool dumpAssetsToFile) - : base(serversInfo, httpServer, assetCache, dumpAssetsToFile) + IGridServices gridService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) + : base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder) { AddInventoryService(inventoryService); m_defaultInventoryHost = inventoryService.Host; diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index aabddc6..a861ceb 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -39,7 +39,7 @@ namespace OpenSim.Region.Communications.Local public class LocalBackEndServices : IGridServices, IInterRegionCommunications { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + protected Dictionary m_regions = new Dictionary(); protected Dictionary m_regionListeners = @@ -50,6 +50,13 @@ namespace OpenSim.Region.Communications.Local private Dictionary m_queuedGridSettings = new Dictionary(); public string _gdebugRegionName = String.Empty; + + public bool RegionLoginsEnabled + { + get { return m_regionLoginsEnabled; } + set { m_regionLoginsEnabled = value; } + } + private bool m_regionLoginsEnabled; public bool CheckRegion(string address, uint port) { @@ -70,10 +77,6 @@ namespace OpenSim.Region.Communications.Local set { _rdebugRegionName = value; } } - public LocalBackEndServices() - { - } - /// /// Register a region method with the BackEnd Services. /// diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 41093c1..ded2d56 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -34,6 +34,7 @@ using OpenMetaverse; using log4net; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; namespace OpenSim.Region.Communications.Local { @@ -43,27 +44,41 @@ namespace OpenSim.Region.Communications.Local { protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected CommunicationsLocal m_Parent; - protected NetworkServersInfo serversInfo; protected uint defaultHomeX; protected uint defaultHomeY; protected bool authUsers = false; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_interServiceInventoryService; + + /// + /// Used to make requests to the local regions. + /// + protected IGridServices m_gridService; public event LoginToRegionEvent OnLoginToRegion; protected LoginToRegionEvent handlerLoginToRegion = null; // OnLoginToRegion; - public LocalLoginService(UserManagerBase userManager, string welcomeMess, - CommunicationsLocal parent, NetworkServersInfo serversInfo, - bool authenticate) - : base(userManager, parent.UserProfileCacheService.libraryRoot, welcomeMess) + public LocalLoginService( + UserManagerBase userManager, string welcomeMess, + IInterServiceInventoryServices interServiceInventoryService, LocalBackEndServices gridService, + NetworkServersInfo serversInfo, + bool authenticate, LibraryRootFolder libraryRootFolder) + : base(userManager, libraryRootFolder, welcomeMess) { - m_Parent = parent; this.serversInfo = serversInfo; defaultHomeX = this.serversInfo.DefaultHomeLocX; defaultHomeY = this.serversInfo.DefaultHomeLocY; authUsers = authenticate; + + m_interServiceInventoryService = interServiceInventoryService; + m_gridService = gridService; + + OnLoginToRegion += gridService.AddNewSession; } public override UserProfileData GetTheUser(string firstname, string lastname) @@ -84,7 +99,7 @@ namespace OpenSim.Region.Communications.Local profile = m_userManager.GetUserProfile(firstname, lastname); if (profile != null) { - m_Parent.InterServiceInventoryService.CreateNewUserInventory(profile.ID); + m_interServiceInventoryService.CreateNewUserInventory(profile.ID); } return profile; @@ -129,11 +144,12 @@ namespace OpenSim.Region.Communications.Local { // HomeLocation RegionInfo homeInfo = null; + // use the homeRegionID if it is stored already. If not, use the regionHandle as before if (theUser.HomeRegionID != UUID.Zero) - homeInfo = m_Parent.GridService.RequestNeighbourInfo(theUser.HomeRegionID); + homeInfo = m_gridService.RequestNeighbourInfo(theUser.HomeRegionID); else - homeInfo = m_Parent.GridService.RequestNeighbourInfo(theUser.HomeRegion); + homeInfo = m_gridService.RequestNeighbourInfo(theUser.HomeRegion); if (homeInfo != null) { response.Home = @@ -172,7 +188,7 @@ namespace OpenSim.Region.Communications.Local } else if (startLocationRequest == "last") { - regionInfo = m_Parent.GridService.RequestNeighbourInfo(theUser.CurrentAgent.Region); + regionInfo = m_gridService.RequestNeighbourInfo(theUser.CurrentAgent.Region); response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; } else @@ -186,7 +202,7 @@ namespace OpenSim.Region.Communications.Local else { string region = uriMatch.Groups["region"].ToString(); - regionInfo = m_Parent.GridService.RequestClosestRegion(region); + regionInfo = m_gridService.RequestClosestRegion(region); if (regionInfo == null) { m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); @@ -208,7 +224,7 @@ namespace OpenSim.Region.Communications.Local } // StartLocation not available, send him to a nearby region instead - // regionInfo = m_Parent.GridService.RequestClosestRegion(""); + // regionInfo = m_gridService.RequestClosestRegion(""); //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); // Send him to default region instead @@ -222,7 +238,7 @@ namespace OpenSim.Region.Communications.Local } m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = m_Parent.GridService.RequestNeighbourInfo(defaultHandle); + regionInfo = m_gridService.RequestNeighbourInfo(defaultHandle); // Customise the response //response.Home = @@ -274,24 +290,26 @@ namespace OpenSim.Region.Communications.Local loginParams.StartPos = user.CurrentAgent.Position; loginParams.CapsPath = capsPath; - handlerLoginToRegion = OnLoginToRegion; - if (handlerLoginToRegion == null) - return false; - - handlerLoginToRegion(user.CurrentAgent.Handle, loginParams); - return true; + if (m_gridService.RegionLoginsEnabled) + { + handlerLoginToRegion = OnLoginToRegion; + handlerLoginToRegion(user.CurrentAgent.Handle, loginParams); + return true; + } + + return false; } // See LoginService protected override InventoryData GetInventorySkeleton(UUID userID) { - List folders = m_Parent.InterServiceInventoryService.GetInventorySkeleton(userID); + List folders = m_interServiceInventoryService.GetInventorySkeleton(userID); // If we have user auth but no inventory folders for some reason, create a new set of folders. if (null == folders || 0 == folders.Count) { - m_Parent.InterServiceInventoryService.CreateNewUserInventory(userID); - folders = m_Parent.InterServiceInventoryService.GetInventorySkeleton(userID); + m_interServiceInventoryService.CreateNewUserInventory(userID); + folders = m_interServiceInventoryService.GetInventorySkeleton(userID); } UUID rootID = UUID.Zero; diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index 1926e79..d76f076 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -34,8 +34,10 @@ namespace OpenSim.Region.Communications.OGS1 { public class CommunicationsOGS1 : CommunicationsManager { - public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) - : base(serversInfo, httpServer, assetCache, false) + public CommunicationsOGS1( + NetworkServersInfo serversInfo, BaseHttpServer httpServer, + AssetCache assetCache, LibraryRootFolder libraryRootFolder) + : base(serversInfo, httpServer, assetCache, false, libraryRootFolder) { OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); m_gridService = gridInterComms; diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 3bd57cd..2e91157 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -51,15 +51,16 @@ namespace OpenSim.Region.Communications.OGS1 { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // FIXME: LocalBackEndServices should to be refactored into a separate common parent class rather than + // encapsulated. private LocalBackEndServices m_localBackend = new LocalBackEndServices(); + private Dictionary m_remoteRegionInfoCache = new Dictionary(); // private List m_knownRegions = new List(); private Dictionary m_deadRegionCache = new Dictionary(); private Dictionary m_queuedGridSettings = new Dictionary(); private List m_regionsOnInstance = new List(); - - public BaseHttpServer httpListener; public NetworkServersInfo serversInfo; public BaseHttpServer httpServer; @@ -79,6 +80,16 @@ namespace OpenSim.Region.Communications.OGS1 get { return _rdebugRegionName; } set { _rdebugRegionName = value; } } + + /// + /// Doesn't have any effect yet! + /// + public bool RegionLoginsEnabled + { + get { return m_regionLoginsEnabled; } + set { m_regionLoginsEnabled = value; } + } + private bool m_regionLoginsEnabled; /// /// Contructor. Adds "expect_user" and "check" xmlrpc method handlers -- cgit v1.1