From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Services/AssetService/AssetService.cs | 11 +- .../AssetService/Properties/AssemblyInfo.cs | 10 +- OpenSim/Services/AssetService/XAssetService.cs | 10 +- .../AuthenticationServiceBase.cs | 15 +- .../PasswordAuthenticationService.cs | 94 ++++- .../Properties/AssemblyInfo.cs | 10 +- .../WebkeyAuthenticationService.cs | 15 +- .../WebkeyOrPasswordAuthenticationService.cs | 23 +- .../Properties/AssemblyInfo.cs | 10 +- OpenSim/Services/AvatarService/AvatarService.cs | 4 +- .../Services/AvatarService/AvatarServiceBase.cs | 2 +- .../AvatarService/Properties/AssemblyInfo.cs | 10 +- OpenSim/Services/Base/Properties/AssemblyInfo.cs | 10 +- OpenSim/Services/Base/ServiceBase.cs | 11 +- .../AgentPreferences/AgentPreferencesConnector.cs | 4 +- .../Connectors/Asset/AssetServicesConnector.cs | 458 +++++++++++++++++---- .../AuthenticationServicesConnector.cs | 7 + .../AuthorizationServicesConnector.cs | 16 +- .../Connectors/Avatar/AvatarServicesConnector.cs | 4 +- .../Connectors/Estate/EstateDataConnector.cs | 8 +- .../Connectors/Friends/FriendsServicesConnector.cs | 2 +- .../Connectors/Friends/FriendsSimConnector.cs | 68 +-- .../Connectors/Grid/GridServicesConnector.cs | 17 +- .../Hypergrid/GatekeeperServiceConnector.cs | 23 +- .../Hypergrid/HGFriendsServicesConnector.cs | 5 +- .../Connectors/Hypergrid/HeloServicesConnector.cs | 2 +- .../Hypergrid/UserAgentServiceConnector.cs | 30 +- .../Inventory/XInventoryServicesConnector.cs | 62 ++- .../Connectors/Land/LandServicesConnector.cs | 29 +- .../MapImage/MapImageServicesConnector.cs | 66 ++- .../MuteList/MuteListServicesConnector.cs | 183 ++++++++ .../Neighbour/NeighbourServicesConnector.cs | 8 +- .../Presence/PresenceServicesConnector.cs | 15 +- .../Services/Connectors/Properties/AssemblyInfo.cs | 10 +- .../SimianGrid/SimianAssetServiceConnector.cs | 52 ++- .../SimianAuthenticationServiceConnector.cs | 6 + .../SimianGrid/SimianAvatarServiceConnector.cs | 11 +- .../SimianGrid/SimianExternalCapsModule.cs | 16 +- .../Services/Connectors/SimianGrid/SimianGrid.cs | 18 +- .../SimianGrid/SimianGridMaptileModule.cs | 16 +- .../SimianGrid/SimianGridServiceConnector.cs | 21 +- .../SimianGrid/SimianInventoryServiceConnector.cs | 37 +- .../SimianGrid/SimianPresenceServiceConnector.cs | 10 +- .../Connectors/SimianGrid/SimianProfiles.cs | 14 +- .../SimianUserAccountServiceConnector.cs | 16 +- .../Simulation/SimulationServiceConnector.cs | 71 ++-- .../UserAccounts/UserAccountServicesConnector.cs | 99 ++++- .../Services/EstateService/EstateDataService.cs | 8 +- OpenSim/Services/FSAssetService/FSAssetService.cs | 199 ++++++--- .../FreeswitchService/FreeswitchService.cs | 58 +-- .../FreeswitchService/Properties/AssemblyInfo.cs | 10 +- .../Services/Friends/Properties/AssemblyInfo.cs | 10 +- OpenSim/Services/GridService/GridService.cs | 294 ++++++------- OpenSim/Services/GridService/GridServiceBase.cs | 2 +- OpenSim/Services/GridService/HypergridLinker.cs | 189 +++++---- .../GridService/Properties/AssemblyInfo.cs | 10 +- .../Services/HypergridService/GatekeeperService.cs | 151 +++++-- .../Services/HypergridService/HGAssetService.cs | 2 +- .../Services/HypergridService/HGFSAssetService.cs | 2 +- .../Services/HypergridService/HGFriendsService.cs | 2 +- .../HypergridService/HGInstantMessageService.cs | 2 +- .../HypergridService/HGInventoryService.cs | 12 +- .../HypergridService/HGRemoteAssetService.cs | 240 +++++++++++ .../HypergridService/HGSuitcaseInventoryService.cs | 20 +- .../HypergridService/Properties/AssemblyInfo.cs | 10 +- .../Services/HypergridService/UserAccountCache.cs | 12 +- .../Services/HypergridService/UserAgentService.cs | 25 +- .../Interfaces/IAgentPreferencesService.cs | 4 +- OpenSim/Services/Interfaces/IAssetService.cs | 6 +- OpenSim/Services/Interfaces/IAttachmentsService.cs | 38 ++ .../Services/Interfaces/IAuthenticationService.cs | 3 +- .../Services/Interfaces/IAuthorizationService.cs | 24 +- OpenSim/Services/Interfaces/IAvatarService.cs | 15 +- OpenSim/Services/Interfaces/IEstateDataService.cs | 34 +- OpenSim/Services/Interfaces/IGridService.cs | 102 ++--- OpenSim/Services/Interfaces/IGridUserService.cs | 14 +- OpenSim/Services/Interfaces/IHypergridServices.cs | 8 +- OpenSim/Services/Interfaces/IInventoryService.cs | 10 +- OpenSim/Services/Interfaces/ILoginService.cs | 4 +- OpenSim/Services/Interfaces/IMapImageService.cs | 6 +- OpenSim/Services/Interfaces/IMuteLIstService.cs | 41 ++ OpenSim/Services/Interfaces/IOfflineIMService.cs | 4 +- OpenSim/Services/Interfaces/ISimulationService.cs | 21 +- OpenSim/Services/Interfaces/IUserAccountService.cs | 6 + OpenSim/Services/Interfaces/IUserManagement.cs | 3 +- .../Services/Interfaces/IUserProfilesService.cs | 8 +- OpenSim/Services/Interfaces/OpenProfileClient.cs | 4 +- .../Services/Interfaces/Properties/AssemblyInfo.cs | 10 +- .../InventoryService/Properties/AssemblyInfo.cs | 10 +- .../Tests/XInventoryServiceTests.cs | 54 ++- .../Services/InventoryService/XInventoryService.cs | 62 ++- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 39 +- OpenSim/Services/LLLoginService/LLLoginService.cs | 211 +++++++--- .../LLLoginService/Properties/AssemblyInfo.cs | 10 +- .../Services/MapImageService/MapImageService.cs | 127 +++--- .../MapImageService/Properties/AssemblyInfo.cs | 10 +- .../Services/MuteListService/MuteListService.cs | 127 ++++++ .../Services/PresenceService/PresenceService.cs | 10 +- .../PresenceService/PresenceServiceBase.cs | 2 +- .../PresenceService/Properties/AssemblyInfo.cs | 10 +- .../SimulationService/SimulationDataService.cs | 15 + .../UserAccountService/AgentPreferencesService.cs | 4 +- .../Services/UserAccountService/GridUserService.cs | 4 +- .../UserAccountService/GridUserServiceBase.cs | 2 +- .../UserAccountService/Properties/AssemblyInfo.cs | 10 +- .../UserAccountService/UserAccountService.cs | 383 +++++++++++++++-- .../UserProfilesService/UserProfilesService.cs | 44 +- .../UserProfilesService/UserProfilesServiceBase.cs | 4 +- 108 files changed, 3156 insertions(+), 1244 deletions(-) create mode 100644 OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs create mode 100644 OpenSim/Services/HypergridService/HGRemoteAssetService.cs create mode 100644 OpenSim/Services/Interfaces/IAttachmentsService.cs create mode 100644 OpenSim/Services/Interfaces/IMuteLIstService.cs create mode 100644 OpenSim/Services/MuteListService/MuteListService.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 0aefa16..5c37c33 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -95,7 +95,7 @@ namespace OpenSim.Services.AssetService public virtual AssetBase Get(string id) { // m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id); - + UUID assetID; if (!UUID.TryParse(id, out assetID)) @@ -166,7 +166,7 @@ namespace OpenSim.Services.AssetService return new bool[ids.Length]; } } - + public virtual string Store(AssetBase asset) { bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; @@ -174,12 +174,15 @@ namespace OpenSim.Services.AssetService { // m_log.DebugFormat( // "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); - m_Database.StoreAsset(asset); + if (!m_Database.StoreAsset(asset)) + { + return UUID.Zero.ToString(); + } } // else // { // m_log.DebugFormat( -// "[ASSET SERVICE]: Not storing asset {0} {1}, bytes {2} as it already exists", asset.Name, asset.FullID, asset.Data.Length); +// "[ASSET SERVICE]: Not storing asset {0} {1}, bytes {2} as it already exists", asset.Name, asset.FullID, asset.Data.Length); // } return asset.ID; diff --git a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs index 63654a6..8da7100 100644 --- a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.AssetService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs index b1e5184..9490d55 100644 --- a/OpenSim/Services/AssetService/XAssetService.cs +++ b/OpenSim/Services/AssetService/XAssetService.cs @@ -94,7 +94,7 @@ namespace OpenSim.Services.AssetService public virtual AssetBase Get(string id) { // m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id); - + UUID assetID; if (!UUID.TryParse(id, out assetID)) @@ -162,7 +162,7 @@ namespace OpenSim.Services.AssetService public virtual bool Get(string id, Object sender, AssetRetrieved handler) { //m_log.DebugFormat("[XASSET SERVICE]: Get asset async {0}", id); - + UUID assetID; if (!UUID.TryParse(id, out assetID)) @@ -171,7 +171,7 @@ namespace OpenSim.Services.AssetService AssetBase asset = Get(id); //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); - + handler(id, sender, asset); return true; @@ -182,7 +182,7 @@ namespace OpenSim.Services.AssetService UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id)); return m_Database.AssetsExist(uuid); } - + public virtual string Store(AssetBase asset) { bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; @@ -222,7 +222,7 @@ namespace OpenSim.Services.AssetService private void MigrateFromChainedService(AssetBase asset) { - Store(asset); + Store(asset); m_ChainedAssetService.Delete(asset.ID); } } diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 229f557..f66b4e2 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -30,17 +30,18 @@ using OpenMetaverse; using log4net; using Nini.Config; using System.Reflection; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Services.Base; -using OpenSim.Services.Interfaces; namespace OpenSim.Services.AuthenticationService { // Generic Authentication service used for identifying // and authenticating principals. // Principals may be clients acting on users' behalf, - // or any other components that need + // or any other components that need // verifiable identification. // public class AuthenticationServiceBase : ServiceBase @@ -48,8 +49,14 @@ namespace OpenSim.Services.AuthenticationService private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - + protected IAuthenticationData m_Database; + protected IUserAccountService m_UserAccountService = null; + + public AuthenticationServiceBase(IConfigSource config, IUserAccountService acct) : this(config) + { + m_UserAccountService = acct; + } public AuthenticationServiceBase(IConfigSource config) : base(config) { @@ -171,7 +178,7 @@ namespace OpenSim.Services.AuthenticationService m_log.DebugFormat("[AUTHENTICATION DB]: Set authentication info for principalID {0}", info.PrincipalID); return true; } - + protected string GetToken(UUID principalID, int lifetime) { UUID token = UUID.Random(); diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 5f1bde1..0204699 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -41,7 +41,7 @@ namespace OpenSim.Services.AuthenticationService // Generic Authentication service used for identifying // and authenticating principals. // Principals may be clients acting on users' behalf, - // or any other components that need + // or any other components that need // verifiable identification. // public class PasswordAuthenticationService : @@ -50,7 +50,13 @@ namespace OpenSim.Services.AuthenticationService private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - + + public PasswordAuthenticationService(IConfigSource config, IUserAccountService userService) : + base(config, userService) + { + m_log.Debug("[AUTH SERVICE]: Started with User Account access"); + } + public PasswordAuthenticationService(IConfigSource config) : base(config) { @@ -58,42 +64,90 @@ namespace OpenSim.Services.AuthenticationService public string Authenticate(UUID principalID, string password, int lifetime) { + UUID realID; + return Authenticate(principalID, password, lifetime, out realID); + } + + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + + m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null); AuthenticationData data = m_Database.Get(principalID); + UserAccount user = null; + if (m_UserAccountService != null) + user = m_UserAccountService.GetUserAccount(UUID.Zero, principalID); - if (data == null) + if (data == null || data.Data == null) { - m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} not found", principalID); + m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); return String.Empty; } - else if (data.Data == null) + + if (!data.Data.ContainsKey("passwordHash") || + !data.Data.ContainsKey("passwordSalt")) { - m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} data not found", principalID); return String.Empty; } - else if (!data.Data.ContainsKey("passwordHash") || !data.Data.ContainsKey("passwordSalt")) + + string hashed = Util.Md5Hash(password + ":" + + data.Data["passwordSalt"].ToString()); + +// m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); + + if (data.Data["passwordHash"].ToString() == hashed) + { + return GetToken(principalID, lifetime); + } + + if (user == null) { - m_log.DebugFormat( - "[AUTH SERVICE]: PrincipalID {0} data didn't contain either passwordHash or passwordSalt", principalID); + m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID); return String.Empty; } - else + + int impersonateFlag = 1 << 6; + + if ((user.UserFlags & impersonateFlag) == 0) + return String.Empty; + + m_log.DebugFormat("[PASS AUTH]: Attempting impersonation"); + + List accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200"); + if (accounts == null || accounts.Count == 0) + return String.Empty; + + foreach (UserAccount a in accounts) { - string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); + data = m_Database.Get(a.PrincipalID); + if (data == null || data.Data == null || + !data.Data.ContainsKey("passwordHash") || + !data.Data.ContainsKey("passwordSalt")) + { + continue; + } + +// m_log.DebugFormat("[PASS AUTH]: Trying {0}", data.PrincipalID); - m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); + hashed = Util.Md5Hash(password + ":" + + data.Data["passwordSalt"].ToString()); if (data.Data["passwordHash"].ToString() == hashed) { + m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID); + realID = a.PrincipalID; return GetToken(principalID, lifetime); } - else - { - m_log.DebugFormat( - "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", - hashed, data.Data["passwordHash"], principalID); - return String.Empty; - } +// else +// { +// m_log.DebugFormat( +// "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", +// hashed, data.Data["passwordHash"], data.PrincipalID); +// } } + + m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID); + return String.Empty; } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs index f25accc..c946b04 100644 --- a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.AuthenticationService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 2344c0e..0bd5b1f 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -40,7 +40,7 @@ namespace OpenSim.Services.AuthenticationService // Generic Authentication service used for identifying // and authenticating principals. // Principals may be clients acting on users' behalf, - // or any other components that need + // or any other components that need // verifiable identification. // public class WebkeyAuthenticationService : @@ -50,11 +50,22 @@ namespace OpenSim.Services.AuthenticationService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + public WebkeyAuthenticationService(IConfigSource config, IUserAccountService userService) : + base(config, userService) + { + } + public WebkeyAuthenticationService(IConfigSource config) : base(config) { } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { if (new UUID(password) == UUID.Zero) @@ -68,7 +79,7 @@ namespace OpenSim.Services.AuthenticationService { if (data.Data.ContainsKey("webLoginKey")) { - string key = data.Data["webLoginKey"].ToString(); + string key = data.Data["webLoginKey"].ToString(); if (key == password) { data.Data["webLoginKey"] = UUID.Zero.ToString(); diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 2c6cebd..4203c7b 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Dictionary m_svcChecks + private Dictionary m_svcChecks = new Dictionary(); - + public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { @@ -55,14 +55,22 @@ namespace OpenSim.Services.AuthenticationService public string Authenticate(UUID principalID, string password, int lifetime) { + UUID realID; + + return Authenticate(principalID, password, lifetime, out realID); + } + + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { AuthenticationData data = m_Database.Get(principalID); string result = String.Empty; + realID = UUID.Zero; if (data != null && data.Data != null) { if (data.Data.ContainsKey("webLoginKey")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); - result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime, out realID); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); @@ -71,12 +79,15 @@ namespace OpenSim.Services.AuthenticationService if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); - result = m_svcChecks["password"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["password"].Authenticate(principalID, password, lifetime, out realID); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); } } + + + if (result == string.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID); @@ -86,7 +97,9 @@ namespace OpenSim.Services.AuthenticationService { m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); } + + return result; } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs index 47d47ab..f87095a 100644 --- a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.AuthorizationService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index 423c781..222944c 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -56,7 +56,7 @@ namespace OpenSim.Services.AvatarService AvatarData avatar = GetAvatar(principalID); return avatar.ToAvatarAppearance(); } - + public bool SetAppearance(UUID principalID, AvatarAppearance appearance) { AvatarData avatar = new AvatarData(appearance); @@ -136,7 +136,7 @@ namespace OpenSim.Services.AvatarService { av.Data["Value"] = kvp.Value; } - + if (!m_Database.Store(av)) { m_Database.Delete("PrincipalID", principalID.ToString()); diff --git a/OpenSim/Services/AvatarService/AvatarServiceBase.cs b/OpenSim/Services/AvatarService/AvatarServiceBase.cs index ab9d7cd..c1c4fb7 100644 --- a/OpenSim/Services/AvatarService/AvatarServiceBase.cs +++ b/OpenSim/Services/AvatarService/AvatarServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.AvatarService connString = presenceConfig.GetString("ConnectionString", connString); realm = presenceConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs index a233d8a..816ab0b 100644 --- a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.AvatarService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/Base/Properties/AssemblyInfo.cs b/OpenSim/Services/Base/Properties/AssemblyInfo.cs index b113c42..90c14d7 100644 --- a/OpenSim/Services/Base/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/Base/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.Base")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs index a7eb2be..2017f50 100644 --- a/OpenSim/Services/Base/ServiceBase.cs +++ b/OpenSim/Services/Base/ServiceBase.cs @@ -26,8 +26,8 @@ */ using System; -using System.Collections.Generic; using System.IO; +using System.Collections.Generic; using System.Reflection; using log4net; using Nini.Config; @@ -38,7 +38,7 @@ namespace OpenSim.Services.Base public class ServiceBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + public T LoadPlugin(string dllName) where T:class { return LoadPlugin(dllName, new Object[0]); @@ -54,6 +54,7 @@ namespace OpenSim.Services.Base string noRoot = dllName.Substring(pathRoot.Length); string[] parts = noRoot.Split(new char[] {':'}); + dllName = pathRoot + parts[0]; string className = String.Empty; @@ -104,12 +105,12 @@ namespace OpenSim.Services.Base List strArgs = new List(); foreach (Object arg in args) strArgs.Add(arg.ToString()); - + m_log.Error( string.Format( - "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}", + "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}", interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e); - + return null; } } diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs index 1dbc0c8..bd342fa 100644 --- a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs +++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs @@ -62,7 +62,7 @@ namespace OpenSim.Services.Connectors Initialise(source); } - public virtual void Initialise(IConfigSource source) + public void Initialise(IConfigSource source) { IConfig gridConfig = source.Configs["AgentPreferencesService"]; if (gridConfig == null) @@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors { m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message); } - + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); if (replyData != null) { diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index bd43552..7e81be7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -27,12 +27,14 @@ using log4net; using System; +using System.Threading; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Timers; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -44,15 +46,27 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + const int MAXSENDRETRIESLEN = 30; + private string m_ServerURI = String.Empty; - private IImprovedAssetCache m_Cache = null; + private IAssetCache m_Cache = null; + private int m_retryCounter; + private bool m_inRetries; + private List[] m_sendRetries = new List[MAXSENDRETRIESLEN]; + private System.Timers.Timer m_retryTimer; private int m_maxAssetRequestConcurrency = 30; - + private delegate void AssetRetrievedEx(AssetBase asset); // Keeps track of concurrent requests for the same asset, so that it's only loaded once. // Maps: Asset ID -> Handlers which will be called when the asset has been loaded - private Dictionary m_AssetHandlers = new Dictionary(); +// private Dictionary m_AssetHandlers = new Dictionary(); + + private Dictionary> m_AssetHandlers = new Dictionary>(); + + private Dictionary m_UriMap = new Dictionary(); + + private Thread[] m_fetchThreads; public int MaxAssetRequestConcurrency { @@ -91,31 +105,155 @@ namespace OpenSim.Services.Connectors string serviceURI = assetConfig.GetString("AssetServerURI", String.Empty); + m_ServerURI = serviceURI; + if (serviceURI == String.Empty) { m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); throw new Exception("Asset connector init error"); } - m_ServerURI = serviceURI; + m_retryTimer = new System.Timers.Timer(); + m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); + m_retryTimer.AutoReset = true; + m_retryTimer.Interval = 60000; + + Uri serverUri = new Uri(m_ServerURI); + + string groupHost = serverUri.Host; + + for (int i = 0 ; i < 256 ; i++) + { + string prefix = i.ToString("x2"); + groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost); + + m_UriMap[prefix] = groupHost; + //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix); + } + + m_fetchThreads = new Thread[2]; + + for (int i = 0 ; i < 2 ; i++) + { + m_fetchThreads[i] = WorkManager.StartThread(AssetRequestProcessor, + String.Format("GetTextureWorker{0}", i), + ThreadPriority.Normal, + true, + false); + } + } + + private string MapServer(string id) + { + if (m_UriMap.Count == 0) + return m_ServerURI; + + UriBuilder serverUri = new UriBuilder(m_ServerURI); + + string prefix = id.Substring(0, 2).ToLower(); + + string host; + + // HG URLs will not be valid UUIDS + if (m_UriMap.ContainsKey(prefix)) + host = m_UriMap[prefix]; + else + host = m_UriMap["00"]; + + serverUri.Host = host; + + // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix); + + string ret = serverUri.Uri.AbsoluteUri; + if (ret.EndsWith("/")) + ret = ret.Substring(0, ret.Length - 1); + return ret; } - protected void SetCache(IImprovedAssetCache cache) + protected void retryCheck(object source, ElapsedEventArgs e) + { + lock(m_sendRetries) + { + if(m_inRetries) + return; + m_inRetries = true; + } + + m_retryCounter++; + if(m_retryCounter >= 61 ) // avoid overflow 60 is max in use below + m_retryCounter = 1; + + int inUse = 0; + int nextlevel; + int timefactor; + List retrylist; + // we need to go down + for(int i = MAXSENDRETRIESLEN - 1; i >= 0; i--) + { + lock(m_sendRetries) + retrylist = m_sendRetries[i]; + + if(retrylist == null) + continue; + + inUse++; + nextlevel = i + 1; + + //We exponentially fall back on frequency until we reach one attempt per hour + //The net result is that we end up in the queue for roughly 24 hours.. + //24 hours worth of assets could be a lot, so the hope is that the region admin + //will have gotten the asset connector back online quickly! + if(i == 0) + timefactor = 1; + else + { + timefactor = 1 << nextlevel; + if (timefactor > 60) + timefactor = 60; + } + + if(m_retryCounter < timefactor) + continue; // to update inUse; + + if (m_retryCounter % timefactor != 0) + continue; + + // a list to retry + lock(m_sendRetries) + m_sendRetries[i] = null; + + // we are the only ones with a copy of this retrylist now + foreach(AssetBase ass in retrylist) + retryStore(ass, nextlevel); + } + + lock(m_sendRetries) + { + if(inUse == 0 ) + m_retryTimer.Stop(); + + m_inRetries = false; + } + } + + protected void SetCache(IAssetCache cache) { m_Cache = cache; } public AssetBase Get(string id) { -// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); - - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; AssetBase asset = null; + if (m_Cache != null) - asset = m_Cache.Get(id); + { + if (!m_Cache.Get(id, out asset)) + return null; + } - if (asset == null) + if (asset == null || asset.Data == null || asset.Data.Length == 0) { // XXX: Commented out for now since this has either never been properly operational or not for some time // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option. @@ -128,8 +266,14 @@ namespace OpenSim.Services.Connectors asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); + if (m_Cache != null) - m_Cache.Cache(asset); + { + if (asset != null) + m_Cache.Cache(asset); + else + m_Cache.CacheNegative(id); + } } return asset; } @@ -138,23 +282,28 @@ namespace OpenSim.Services.Connectors { // m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id); + AssetBase asset = null; if (m_Cache != null) - return m_Cache.Get(id); + { + m_Cache.Get(id, out asset); + } - return null; + return asset; } public AssetMetadata GetMetadata(string id) { if (m_Cache != null) { - AssetBase fullAsset = m_Cache.Get(id); + AssetBase fullAsset; + if (!m_Cache.Get(id, out fullAsset)) + return null; if (fullAsset != null) return fullAsset.Metadata; } - string uri = m_ServerURI + "/assets/" + id + "/metadata"; + string uri = MapServer(id) + "/assets/" + id + "/metadata"; AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); return asset; @@ -164,13 +313,15 @@ namespace OpenSim.Services.Connectors { if (m_Cache != null) { - AssetBase fullAsset = m_Cache.Get(id); + AssetBase fullAsset; + if (!m_Cache.Get(id, out fullAsset)) + return null; if (fullAsset != null) return fullAsset.Data; } - using (RestClient rc = new RestClient(m_ServerURI)) + using (RestClient rc = new RestClient(MapServer(id))) { rc.AddResourcePath("assets"); rc.AddResourcePath(id); @@ -178,81 +329,110 @@ namespace OpenSim.Services.Connectors rc.RequestMethod = "GET"; - Stream s = rc.Request(m_Auth); + using (Stream s = rc.Request(m_Auth)) + { + if (s == null) + return null; - if (s == null) - return null; + if (s.Length > 0) + { + byte[] ret = new byte[s.Length]; + s.Read(ret, 0, (int)s.Length); + + return ret; + } + } + return null; + } + } - if (s.Length > 0) + private class QueuedAssetRequest + { + public string uri; + public string id; + } + + private OpenSim.Framework.BlockingQueue m_requestQueue = + new OpenSim.Framework.BlockingQueue(); + + private void AssetRequestProcessor() + { + QueuedAssetRequest r; + + while (true) + { + r = m_requestQueue.Dequeue(4500); + Watchdog.UpdateThread(); + if(r== null) + continue; + string uri = r.uri; + string id = r.id; + + try { - byte[] ret = new byte[s.Length]; - s.Read(ret, 0, (int)s.Length); + AssetBase a = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, 30000, m_Auth); - return ret; - } + if (a != null && m_Cache != null) + m_Cache.Cache(a); - return null; + List handlers; + lock (m_AssetHandlers) + { + handlers = m_AssetHandlers[id]; + m_AssetHandlers.Remove(id); + } + + if(handlers != null) + { + Util.FireAndForget(x => + { + foreach (AssetRetrievedEx h in handlers) + { + try { h.Invoke(a); } + catch { } + } + handlers.Clear(); + }); + } + } + catch { } } } public bool Get(string id, Object sender, AssetRetrieved handler) { -// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); - - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; AssetBase asset = null; if (m_Cache != null) - asset = m_Cache.Get(id); + { + if (!m_Cache.Get(id, out asset)) + return false; + } - if (asset == null) + if (asset == null || asset.Data == null || asset.Data.Length == 0) { lock (m_AssetHandlers) { AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); }); - AssetRetrievedEx handlers; + List handlers; if (m_AssetHandlers.TryGetValue(id, out handlers)) { // Someone else is already loading this asset. It will notify our handler when done. - handlers += handlerEx; + handlers.Add(handlerEx); return true; } - // Load the asset ourselves - handlers += handlerEx; - m_AssetHandlers.Add(id, handlers); - } + handlers = new List(); + handlers.Add(handlerEx); - bool success = false; - try - { - AsynchronousRestObjectRequester.MakeRequest("GET", uri, 0, - delegate(AssetBase a) - { - if (a != null && m_Cache != null) - m_Cache.Cache(a); + m_AssetHandlers.Add(id, handlers); - AssetRetrievedEx handlers; - lock (m_AssetHandlers) - { - handlers = m_AssetHandlers[id]; - m_AssetHandlers.Remove(id); - } - handlers.Invoke(a); - }, m_maxAssetRequestConcurrency, m_Auth); - - success = true; - } - finally - { - if (!success) - { - lock (m_AssetHandlers) - { - m_AssetHandlers.Remove(id); - } - } + QueuedAssetRequest request = new QueuedAssetRequest(); + request.id = id; + request.uri = uri; + m_requestQueue.Enqueue(request); } } else @@ -277,52 +457,151 @@ namespace OpenSim.Services.Connectors // This is most likely to happen because the server doesn't support this function, // so just silently return "doesn't exist" for all the assets. } - + if (exist == null) exist = new bool[ids.Length]; return exist; } + string stringUUIDZero = UUID.Zero.ToString(); + public string Store(AssetBase asset) { - if (asset.Local) + // Have to assign the asset ID here. This isn't likely to + // trigger since current callers don't pass emtpy IDs + // We need the asset ID to route the request to the proper + // cluster member, so we can't have the server assign one. + if (asset.ID == string.Empty || asset.ID == stringUUIDZero) { - if (m_Cache != null) - m_Cache.Cache(asset); + if (asset.FullID == UUID.Zero) + { + asset.FullID = UUID.Random(); + } + m_log.WarnFormat("[Assets] Zero ID: {0}",asset.Name); + asset.ID = asset.FullID.ToString(); + } + + if (asset.FullID == UUID.Zero) + { + UUID uuid = UUID.Zero; + if (UUID.TryParse(asset.ID, out uuid)) + { + asset.FullID = uuid; + } + if(asset.FullID == UUID.Zero) + { + m_log.WarnFormat("[Assets] Zero IDs: {0}",asset.Name); + asset.FullID = UUID.Random(); + asset.ID = asset.FullID.ToString(); + } + } + + if (m_Cache != null) + m_Cache.Cache(asset); + if (asset.Temporary || asset.Local) + { return asset.ID; } - string uri = m_ServerURI + "/assets/"; + string uri = MapServer(asset.FullID.ToString()) + "/assets/"; - string newID; + string newID = null; try { - newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth); + newID = SynchronousRestObjectRequester. + MakeRequest("POST", uri, asset, 100000, m_Auth); } - catch (Exception e) + catch { - m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e); - return string.Empty; + newID = null; } - // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets - if (newID == null) + if (newID == null || newID == String.Empty || newID == stringUUIDZero) { - m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID); - return asset.ID; + //The asset upload failed, try later + lock(m_sendRetries) + { + if (m_sendRetries[0] == null) + m_sendRetries[0] = new List(); + List m_queue = m_sendRetries[0]; + m_queue.Add(asset); + m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later", + asset.ID.ToString(), asset.Type.ToString()); + m_retryTimer.Start(); + } } + else + { + if (newID != asset.ID) + { + // Placing this here, so that this work with old asset servers that don't send any reply back + // SynchronousRestObjectRequester returns somethins that is not an empty string - if (string.IsNullOrEmpty(newID)) - return string.Empty; + asset.ID = newID; - asset.ID = newID; + if (m_Cache != null) + m_Cache.Cache(asset); + } + } + return asset.ID; + } - if (m_Cache != null) - m_Cache.Cache(asset); + public void retryStore(AssetBase asset, int nextRetryLevel) + { +/* this may be bad, so excluding + if (m_Cache != null && !m_Cache.Check(asset.ID)) + { + m_log.WarnFormat("[Assets] Upload giveup asset bc no longer in local cache: {0}", + asset.ID.ToString(); + return; // if no longer in cache, it was deleted or expired + } +*/ + string uri = MapServer(asset.FullID.ToString()) + "/assets/"; - return newID; + string newID = null; + try + { + newID = SynchronousRestObjectRequester. + MakeRequest("POST", uri, asset, 100000, m_Auth); + } + catch + { + newID = null; + } + + if (newID == null || newID == String.Empty || newID == stringUUIDZero) + { + if(nextRetryLevel >= MAXSENDRETRIESLEN) + m_log.WarnFormat("[Assets] Upload giveup after several retries id: {0} type {1}", + asset.ID.ToString(), asset.Type.ToString()); + else + { + lock(m_sendRetries) + { + if (m_sendRetries[nextRetryLevel] == null) + { + m_sendRetries[nextRetryLevel] = new List(); + } + List m_queue = m_sendRetries[nextRetryLevel]; + m_queue.Add(asset); + m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later", + asset.ID.ToString(), asset.Type.ToString()); + } + } + } + else + { + m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), nextRetryLevel.ToString()); + if (newID != asset.ID) + { + asset.ID = newID; + + if (m_Cache != null) + m_Cache.Cache(asset); + } + } } public bool UpdateContent(string id, byte[] data) @@ -330,7 +609,7 @@ namespace OpenSim.Services.Connectors AssetBase asset = null; if (m_Cache != null) - asset = m_Cache.Get(id); + m_Cache.Get(id, out asset); if (asset == null) { @@ -343,7 +622,7 @@ namespace OpenSim.Services.Connectors } asset.Data = data; - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth)) { @@ -355,9 +634,10 @@ namespace OpenSim.Services.Connectors return false; } + public bool Delete(string id) { - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0, m_Auth)) { diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index c8a4912..0443f5a 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -84,6 +84,13 @@ namespace OpenSim.Services.Connectors base.Initialise(source, "AuthenticationService"); } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs index d2da85f..a130f71 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs @@ -37,7 +37,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AuthorizationServicesConnector + public class AuthorizationServicesConnector { private static readonly ILog m_log = LogManager.GetLogger( @@ -45,7 +45,7 @@ namespace OpenSim.Services.Connectors private string m_ServerURI = String.Empty; private bool m_ResponseOnFailure = true; - + public AuthorizationServicesConnector() { } @@ -78,11 +78,11 @@ namespace OpenSim.Services.Connectors throw new Exception("Authorization connector init error"); } m_ServerURI = serviceURI; - + // this dictates what happens if the remote service fails, if the service fails and the value is true // the user is authorized for the region. bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true); - + m_ResponseOnFailure = responseOnFailure; m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized"); } @@ -91,11 +91,11 @@ namespace OpenSim.Services.Connectors { // do a remote call to the authorization server specified in the AuthorizationServerURI m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI); - + string uri = m_ServerURI; - + AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID); - + AuthorizationResponse response; try { @@ -114,7 +114,7 @@ namespace OpenSim.Services.Connectors } m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message); message = response.Message; - + return response.IsAuthorized; } diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs index 3f44efa..424e95a 100644 --- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs +++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs @@ -94,13 +94,13 @@ namespace OpenSim.Services.Connectors AvatarData avatar = GetAvatar(userID); return avatar.ToAvatarAppearance(); } - + public bool SetAppearance(UUID userID, AvatarAppearance appearance) { AvatarData avatar = new AvatarData(appearance); return SetAvatar(userID,avatar); } - + public AvatarData GetAvatar(UUID userID) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs index 6412bcd..b9a6281 100644 --- a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs +++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs @@ -120,7 +120,7 @@ namespace OpenSim.Services.Connectors // If we don't have them, load them from the server List estates = null; if (!m_EstateCache.TryGetValue("estates", out estates)) - LoadEstateSettingsAll(); + estates = LoadEstateSettingsAll(); foreach (EstateSettings es in estates) eids.Add((int)es.EstateID); @@ -133,7 +133,7 @@ namespace OpenSim.Services.Connectors // If we don't have them, load them from the server List estates = null; if (!m_EstateCache.TryGetValue("estates", out estates)) - LoadEstateSettingsAll(); + estates = LoadEstateSettingsAll(); List eids = new List(); foreach (EstateSettings es in estates) @@ -148,7 +148,7 @@ namespace OpenSim.Services.Connectors // If we don't have them, load them from the server List estates = null; if (!m_EstateCache.TryGetValue("estates", out estates)) - LoadEstateSettingsAll(); + estates = LoadEstateSettingsAll(); List eids = new List(); foreach (EstateSettings es in estates) @@ -323,7 +323,7 @@ namespace OpenSim.Services.Connectors } else m_log.Error(string.Format( - "[ESTATE CONNECTOR]: WebException for {0} {1} {2} ", + "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}", verb, uri, formdata, e)); } } diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs index b7702a8..873b554 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs @@ -86,7 +86,7 @@ namespace OpenSim.Services.Connectors.Friends #region IFriendsService - + public FriendInfo[] GetFriends(UUID PrincipalID) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs index 6d5ce4b..74cd703 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs @@ -144,44 +144,48 @@ namespace OpenSim.Services.Connectors.Friends private bool Call(GridRegion region, Dictionary sendData) { - string reqString = ServerUtils.BuildQueryString(sendData); - //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); - if (region == null) - return false; - - string path = ServicePath(); - if (!region.ServerURI.EndsWith("/")) - path = "/" + path; - string uri = region.ServerURI + path; -// m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); - - try - { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); - if (reply != string.Empty) + Util.FireAndForget(x => { + string reqString = ServerUtils.BuildQueryString(sendData); + //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); + if (region == null) + return; + + string path = ServicePath(); + if (!region.ServerURI.EndsWith("/")) + path = "/" + path; + string uri = region.ServerURI + path; + // m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); + + try { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("RESULT")) + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, 15, null, false); + if (reply != string.Empty) { - if (replyData["RESULT"].ToString().ToLower() == "true") - return true; + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("RESULT")) + { +// if (replyData["RESULT"].ToString().ToLower() == "true") +// return; +// else + return; + } else - return false; + m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); + } else - m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); - + m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message); } - else - m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); - } - catch (Exception e) - { - m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message); - } - - return false; + + return; + }); + + return true; } } } diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs index 596f867..ded7806 100644 --- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs @@ -49,6 +49,9 @@ namespace OpenSim.Services.Connectors private string m_ServerURI = String.Empty; + private ExpiringCache m_regionCache = + new ExpiringCache(); + public GridServicesConnector() { } @@ -275,6 +278,13 @@ namespace OpenSim.Services.Connectors public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { + GridRegion rinfo = null; + ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y); + + // this cache includes NULL regions + if (m_regionCache.TryGetValue(regionHandle, out rinfo)) + return rinfo; + Dictionary sendData = new Dictionary(); sendData["SCOPEID"] = scopeID.ToString(); @@ -296,7 +306,6 @@ namespace OpenSim.Services.Connectors return null; } - GridRegion rinfo = null; if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -316,6 +325,8 @@ namespace OpenSim.Services.Connectors else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); + m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600)); + return rinfo; } @@ -672,7 +683,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - + public int GetRegionFlags(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -744,7 +755,7 @@ namespace OpenSim.Services.Connectors if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - + if ((replyData != null) && replyData.Count > 0) { foreach (string key in replyData.Keys) diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index b1663ee..e814c45 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -73,13 +73,15 @@ namespace OpenSim.Services.Connectors.Hypergrid return "foreignobject/"; } - public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason) + public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY) { regionID = UUID.Zero; imageURL = string.Empty; realHandle = 0; externalName = string.Empty; reason = string.Empty; + sizeX = (int)Constants.RegionSize; + sizeY = (int)Constants.RegionSize; Hashtable hash = new Hashtable(); hash["region_name"] = info.RegionName; @@ -134,8 +136,15 @@ namespace OpenSim.Services.Connectors.Hypergrid externalName = (string)hash["external_name"]; //m_log.Debug(">> HERE, externalName: " + externalName); } + if (hash["size_x"] != null) + { + Int32.TryParse((string)hash["size_x"], out sizeX); + } + if (hash["size_y"] != null) + { + Int32.TryParse((string)hash["size_y"], out sizeY); + } } - } catch (Exception e) { @@ -160,14 +169,15 @@ namespace OpenSim.Services.Connectors.Hypergrid try { - WebClient c = new WebClient(); + //m_log.Debug("JPEG: " + imageURL); string name = regionID.ToString(); filename = Path.Combine(storagePath, name + ".jpg"); m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); if (!File.Exists(filename)) { m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading..."); - c.DownloadFile(imageURL, filename); + using(WebClient c = new WebClient()) + c.DownloadFile(imageURL, filename); } else { @@ -189,11 +199,10 @@ namespace OpenSim.Services.Connectors.Hypergrid ass.Data = imageData; - mapTile = ass.FullID; - - // finally m_AssetService.Store(ass); + // finally + mapTile = ass.FullID; } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs index 622d4e1..8b31fa2 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs @@ -277,7 +277,10 @@ namespace OpenSim.Services.Connectors.Hypergrid { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData), 15); + ServerUtils.BuildQueryString(sendData), + 15, + null, + false); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs index b5e6d69..91e1740 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs @@ -33,7 +33,7 @@ using Nini.Config; namespace OpenSim.Services.Connectors { - public class HeloServicesConnector + public class HeloServicesConnector { private static readonly ILog m_log = LogManager.GetLogger( diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 8abd046..f2bb52a 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -70,9 +70,14 @@ namespace OpenSim.Services.Connectors.Hypergrid { Uri m_Uri = new Uri(m_ServerURL); IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); - m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); - if (!m_ServerURL.EndsWith("/")) - m_ServerURL += "/"; + if(ip != null) + { + m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); + if (!m_ServerURL.EndsWith("/")) + m_ServerURL += "/"; + } + else + m_log.DebugFormat("[USER AGENT CONNECTOR]: Failed to resolv address of {0}", url); } catch (Exception e) { @@ -113,7 +118,7 @@ namespace OpenSim.Services.Connectors.Hypergrid return "homeagent/"; } - // The Login service calls this interface with fromLogin=true + // The Login service calls this interface with fromLogin=true // Sims call it with fromLogin=false // Either way, this is verified by the handler public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason) @@ -138,7 +143,8 @@ namespace OpenSim.Services.Connectors.Hypergrid Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI); uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome; - return CreateAgent(source, home, aCircuit, flags, out reason); + EntityTransferContext ctx = new EntityTransferContext(); + return CreateAgent(source, home, aCircuit, flags, ctx, out reason); } @@ -158,7 +164,7 @@ namespace OpenSim.Services.Connectors.Hypergrid } public void SetClientToken(UUID sessionID, string token) - { + { // no-op } @@ -415,7 +421,7 @@ namespace OpenSim.Services.Connectors.Hypergrid XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); // string reason = string.Empty; - + // Send and get reply List online = new List(); XmlRpcResponse response = null; @@ -496,7 +502,7 @@ namespace OpenSim.Services.Connectors.Hypergrid hash["userID"] = userID.ToString(); hash = CallServer("get_server_urls", hash); - + Dictionary serverURLs = new Dictionary(); foreach (object key in hash.Keys) { @@ -515,7 +521,7 @@ namespace OpenSim.Services.Connectors.Hypergrid Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); - hash = CallServer("locate_user", hash); + hash = CallServer("locate_user", hash); string url = string.Empty; @@ -571,7 +577,11 @@ namespace OpenSim.Services.Connectors.Hypergrid XmlRpcResponse response = null; try { - response = request.Send(m_ServerURL, 10000); + // We can not use m_ServerURL here anymore because it causes + // the HTTP request to be built without a host name. This messes + // with OSGrid's NGINX and can make OSGrid avatars unable to TP + // to other grids running recent mono. + response = request.Send(m_ServerURLHost, 10000); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 7cecd93..dcf25ad 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs @@ -54,6 +54,8 @@ namespace OpenSim.Services.Connectors private string m_ServerURI = String.Empty; + private int m_maxRetries = 0; + /// /// Timeout for remote requests. /// @@ -61,6 +63,7 @@ namespace OpenSim.Services.Connectors /// In this case, -1 is default timeout (100 seconds), not infinite. /// private int m_requestTimeoutSecs = -1; + private string m_configName = "InventoryService"; private const double CACHE_EXPIRATION_SECONDS = 20.0; private static ExpiringCache m_ItemCache = new ExpiringCache(); @@ -74,6 +77,13 @@ namespace OpenSim.Services.Connectors m_ServerURI = serverURI.TrimEnd('/'); } + public XInventoryServicesConnector(IConfigSource source, string configName) + : base(source, configName) + { + m_configName = configName; + Initialise(source); + } + public XInventoryServicesConnector(IConfigSource source) : base(source, "InventoryService") { @@ -82,10 +92,10 @@ namespace OpenSim.Services.Connectors public virtual void Initialise(IConfigSource source) { - IConfig config = source.Configs["InventoryService"]; + IConfig config = source.Configs[m_configName]; if (config == null) { - m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); + m_log.ErrorFormat("[INVENTORY CONNECTOR]: {0} missing from OpenSim.ini", m_configName); throw new Exception("Inventory connector init error"); } @@ -100,16 +110,17 @@ namespace OpenSim.Services.Connectors m_ServerURI = serviceURI; m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs); + m_maxRetries = config.GetInt("MaxRetries", m_maxRetries); StatsManager.RegisterStat( new Stat( - "RequestsMade", - "Requests made", - "Number of requests made to the remove inventory service", - "requests", - "inventory", - serviceURI, - StatType.Pull, + "RequestsMade", + "Requests made", + "Number of requests made to the remove inventory service", + "requests", + "inventory", + serviceURI, + StatType.Pull, MeasuresOfInterest.AverageChangeOverTime, s => s.Value = RequestsMade, StatVerbosity.Debug)); @@ -240,7 +251,7 @@ namespace OpenSim.Services.Connectors return inventory; } - + public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) { InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length]; @@ -520,10 +531,10 @@ namespace OpenSim.Services.Connectors return CheckReturn(ret); } - public InventoryItemBase GetItem(InventoryItemBase item) + public InventoryItemBase GetItem(UUID principalID, UUID itemID) { InventoryItemBase retrieved = null; - if (m_ItemCache.TryGetValue(item.ID, out retrieved)) + if (m_ItemCache.TryGetValue(itemID, out retrieved)) { return retrieved; } @@ -532,7 +543,8 @@ namespace OpenSim.Services.Connectors { Dictionary ret = MakeRequest("GETITEM", new Dictionary { - { "ID", item.ID.ToString() } + { "ID", itemID.ToString() }, + { "PRINCIPAL", principalID.ToString() } }); if (!CheckReturn(ret)) @@ -545,7 +557,7 @@ namespace OpenSim.Services.Connectors m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e); } - m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); + m_ItemCache.AddOrUpdate(itemID, retrieved, CACHE_EXPIRATION_SECONDS); return retrieved; } @@ -559,6 +571,7 @@ namespace OpenSim.Services.Connectors List pending = new List(); InventoryItemBase item = null; int i = 0; + foreach (UUID id in itemIDs) { if (m_ItemCache.TryGetValue(id, out item)) @@ -612,13 +625,14 @@ namespace OpenSim.Services.Connectors return itemArr; } - public InventoryFolderBase GetFolder(InventoryFolderBase folder) + public InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { try { Dictionary ret = MakeRequest("GETFOLDER", new Dictionary { - { "ID", folder.ID.ToString() } + { "ID", folderID.ToString() }, + { "PRINCIPAL", principalID.ToString() } }); if (!CheckReturn(ret)) @@ -660,7 +674,7 @@ namespace OpenSim.Services.Connectors { "ASSET", assetID.ToString() } }); - // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int + // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int if (ret == null) return 0; @@ -697,11 +711,21 @@ namespace OpenSim.Services.Connectors RequestsMade++; - string reply - = SynchronousRestFormsRequester.MakeRequest( + string reply = String.Empty; + int retries = 0; + + do + { + reply = SynchronousRestFormsRequester.MakeRequest( "POST", m_ServerURI + "/xinventory", ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth); + if (reply != String.Empty) + break; + + retries++; + } while (retries <= m_maxRetries); + Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs index 034c42e..5492e83 100644 --- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs @@ -66,22 +66,31 @@ namespace OpenSim.Services.Connectors public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) { LandData landData = null; - Hashtable hash = new Hashtable(); - hash["region_handle"] = regionHandle.ToString(); - hash["x"] = x.ToString(); - hash["y"] = y.ToString(); IList paramList = new ArrayList(); - paramList.Add(hash); regionAccess = 42; // Default to adult. Better safe... try { uint xpos = 0, ypos = 0; Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos); + GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos); if (info != null) // just to be sure { + string targetHandlestr = info.RegionHandle.ToString(); + if( ypos == 0 ) //HG proxy? + { + // this is real region handle on hg proxies hack + targetHandlestr = info.RegionSecret; + } + + Hashtable hash = new Hashtable(); + hash["region_handle"] = targetHandlestr; + hash["x"] = x.ToString(); + hash["y"] = y.ToString(); + paramList.Add(hash); + XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); XmlRpcResponse response = request.Send(info.ServerURI, 10000); if (response.IsFault) @@ -108,17 +117,19 @@ namespace OpenSim.Services.Connectors landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); if (hash["RegionAccess"] != null) regionAccess = (byte)Convert.ToInt32((string)hash["RegionAccess"]); + if(hash["Dwell"] != null) + landData.Dwell = Convert.ToSingle((string)hash["Dwell"]); m_log.DebugFormat("[LAND CONNECTOR]: Got land data for parcel {0}", landData.Name); } catch (Exception e) { m_log.ErrorFormat( - "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}", + "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}", e.Message, e.StackTrace); } } } - else + else m_log.WarnFormat("[LAND CONNECTOR]: Couldn't find region with handle {0}", regionHandle); } catch (Exception e) @@ -126,8 +137,8 @@ namespace OpenSim.Services.Connectors m_log.ErrorFormat( "[LAND CONNECTOR]: Couldn't contact region {0}: {1} {2}", regionHandle, e.Message, e.StackTrace); } - + return landData; } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index c91ed84..84c4efe 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -149,13 +149,75 @@ namespace OpenSim.Services.Connectors return false; } - public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) + public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) { reason = string.Empty; int tickstart = Util.EnvironmentTickCount(); Dictionary sendData = new Dictionary(); sendData["X"] = x.ToString(); sendData["Y"] = y.ToString(); + sendData["SCOPE"] = scopeID.ToString(); + + string reqString = ServerUtils.BuildQueryString(sendData); + string uri = m_ServerURI + "/removemap"; + + try + { + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success")) + { + return true; + } + else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString()); + reason = replyData["Message"].ToString(); + return false; + } + else if (!replyData.ContainsKey("Result")) + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field"); + } + else + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); + reason = "Unexpected result " + replyData["Result"].ToString(); + } + + } + else + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply"); + } + } + catch (Exception e) + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message); + } + finally + { + // This just dumps a warning for any operation that takes more than 100 ms + int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff); + } + + return false; + } + + public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string reason) + { + reason = string.Empty; + int tickstart = Util.EnvironmentTickCount(); + Dictionary sendData = new Dictionary(); + sendData["X"] = x.ToString(); + sendData["Y"] = y.ToString(); + sendData["SCOPE"] = scopeID.ToString(); sendData["TYPE"] = "image/jpeg"; sendData["DATA"] = Convert.ToBase64String(jpgData); @@ -216,7 +278,7 @@ namespace OpenSim.Services.Connectors } - public byte[] GetMapTile(string fileName, out string format) + public byte[] GetMapTile(string fileName, UUID scopeID, out string format) { format = string.Empty; new Exception("GetMapTile method not Implemented"); diff --git a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs new file mode 100644 index 0000000..e574c1d --- /dev/null +++ b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs @@ -0,0 +1,183 @@ +/* + * 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 log4net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; + +using OpenSim.Framework.ServiceAuth; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Server.Base; +using OpenMetaverse; + +namespace OpenSim.Services.Connectors +{ + public class MuteListServicesConnector : BaseServiceConnector, IMuteListService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ServerURI = String.Empty; + + public MuteListServicesConnector() + { + } + + public MuteListServicesConnector(string serverURI) + { + m_ServerURI = serverURI.TrimEnd('/') + "/mutelist"; + } + + public MuteListServicesConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig gridConfig = source.Configs["MuteListService"]; + if (gridConfig == null) + { + m_log.Error("[MUTELIST CONNECTOR]: MuteListService missing from configuration"); + throw new Exception("MuteList connector init error"); + } + + string serviceURI = gridConfig.GetString("MuteListServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[GRID USER CONNECTOR]: No Server URI named in section GridUserService"); + throw new Exception("GridUser connector init error"); + } + m_ServerURI = serviceURI + "/mutelist";; + base.Initialise(source, "MuteListService"); + } + + #region IMuteListService + public Byte[] MuteListRequest(UUID agentID, uint crc) + { + Dictionary sendData = new Dictionary(); + sendData["METHOD"] = "get"; + sendData["agentid"] = agentID.ToString(); + sendData["mutecrc"] = crc.ToString(); + + try + { + string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, + ServerUtils.BuildQueryString(sendData), m_Auth); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("result")) + { + string datastr = replyData["result"].ToString(); + if(String.IsNullOrWhiteSpace(datastr)) + return null; + return Convert.FromBase64String(datastr); + } + else + m_log.DebugFormat("[MUTELIST CONNECTOR]: get reply data does not contain result field"); + } + else + m_log.DebugFormat("[MUTELIST CONNECTOR]: get received empty reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message); + } + + return null; + } + + public bool UpdateMute(MuteData mute) + { + Dictionary sendData = new Dictionary(); + sendData["METHOD"] = "update"; + sendData["agentid"] = mute.AgentID.ToString(); + sendData["muteid"] = mute.MuteID.ToString(); + if(mute.MuteType != 0) + sendData["mutetype"] = mute.MuteType.ToString(); + if(mute.MuteFlags != 0) + sendData["muteflags"] = mute.MuteFlags.ToString(); + sendData["mutestamp"] = mute.Stamp.ToString(); + if(!String.IsNullOrEmpty(mute.MuteName)) + sendData["mutename"] = mute.MuteName; + + return doSimplePost(ServerUtils.BuildQueryString(sendData), "update"); + } + + public bool RemoveMute(UUID agentID, UUID muteID, string muteName) + { + Dictionary sendData = new Dictionary(); + sendData["METHOD"] = "delete"; + sendData["agentid"] = agentID.ToString(); + sendData["muteid"] = muteID.ToString(); + if(!String.IsNullOrEmpty(muteName)) + sendData["mutename"] = muteName; + + return doSimplePost(ServerUtils.BuildQueryString(sendData), "remove"); + } + + #endregion IMuteListService + + private bool doSimplePost(string reqString, string meth) + { + try + { + string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString, m_Auth); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("result")) + { + if (replyData["result"].ToString().ToLower() == "success") + return true; + else + return false; + } + else + m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} reply data does not contain result field", meth); + } + else + m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} received empty reply", meth); + } + catch (Exception e) + { + m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message); + } + + return false; + } + } +} diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs index 925364a..5f075ac 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs @@ -153,9 +153,9 @@ namespace OpenSim.Services.Connectors } catch (Exception e) { - m_log.Warn(string.Format( - "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ", - thisRegion.RegionName, region.RegionName, uri, e.Message), e); +// m_log.WarnFormat( +// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", +// thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); return false; } @@ -183,8 +183,8 @@ namespace OpenSim.Services.Connectors { using (StreamReader sr = new StreamReader(s)) { + sr.ReadToEnd(); // just try to read //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); } } diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs index b7e95c4..89d64ca 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs @@ -107,7 +107,7 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString, + reqString, m_Auth); if (reply != string.Empty) { @@ -313,6 +313,17 @@ namespace OpenSim.Services.Connectors { pinfo = new PresenceInfo((Dictionary)replyData["result"]); } + else + { + if (replyData["result"].ToString() == "null") + return null; + + m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString()); + } + } + else + { + m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString()); } return pinfo; @@ -355,7 +366,7 @@ namespace OpenSim.Services.Connectors if (replyData != null) { - if (replyData.ContainsKey("result") && + if (replyData.ContainsKey("result") && (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) { return new PresenceInfo[0]; diff --git a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs index c581a59..76d26d6 100644 --- a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.Connectors")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 9ad4a7a..953bc2a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private static string ZeroID = UUID.Zero.ToString(); private string m_serverUrl = String.Empty; - private IImprovedAssetCache m_cache; + private IAssetCache m_cache; private bool m_Enabled = false; #region ISharedRegionModule @@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { if (m_cache == null) { - IImprovedAssetCache cache = scene.RequestModuleInterface(); + IAssetCache cache = scene.RequestModuleInterface(); if (cache is ISharedRegionModule) m_cache = cache; } @@ -77,7 +77,7 @@ namespace OpenSim.Services.Connectors.SimianGrid public string Name { get { return "SimianAssetServiceConnector"; } } public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface(this); } } public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface(this); } } - + #endregion ISharedRegionModule public SimianAssetServiceConnector(IConfigSource source) @@ -136,19 +136,22 @@ namespace OpenSim.Services.Connectors.SimianGrid // Cache fetch if (m_cache != null) { - AssetBase asset = m_cache.Get(id); + AssetBase asset; + if (!m_cache.Get(id, out asset)) + return null; if (asset != null) return asset; } return SimianGetOperation(id); } - + public AssetBase GetCached(string id) { + AssetBase asset; if (m_cache != null) - return m_cache.Get(id); + m_cache.Get(id, out asset); return null; } @@ -169,7 +172,9 @@ namespace OpenSim.Services.Connectors.SimianGrid // Cache fetch if (m_cache != null) { - AssetBase asset = m_cache.Get(id); + AssetBase asset; + if (!m_cache.Get(id, out asset)) + return null; if (asset != null) return asset.Metadata; } @@ -177,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // return GetRemoteMetadata(id); return SimianGetMetadataOperation(id); } - + public byte[] GetData(string id) { if (String.IsNullOrEmpty(m_serverUrl)) @@ -212,7 +217,10 @@ namespace OpenSim.Services.Connectors.SimianGrid // Cache fetch if (m_cache != null) { - AssetBase asset = m_cache.Get(id); + AssetBase asset; + if (!m_cache.Get(id, out asset)) + return false; + if (asset != null) { handler(id, sender, asset); @@ -296,7 +304,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return SimianStoreOperation(asset); } - + /// /// Update an asset's content /// @@ -344,7 +352,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return SimianDeleteOperation(id); } - + #endregion IAssetService #region SimianOperations @@ -369,9 +377,9 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); return false; } - + return true; - + } catch (Exception ex) { @@ -400,7 +408,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { "Temporary", asset.Temporary ? "1" : "0" }, { "Name", asset.Name } }; - + OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); if (! response["Success"].AsBoolean()) { @@ -410,13 +418,13 @@ namespace OpenSim.Services.Connectors.SimianGrid // asset.ID is always set before calling this function return asset.ID; - + } catch (Exception ex) { m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); } - + return null; } @@ -427,12 +435,12 @@ namespace OpenSim.Services.Connectors.SimianGrid /// private AssetBase SimianGetOperation(string id) { - try + try { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xGetAsset" }, - { "ID", id } + { "ID", id } }; OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); @@ -441,7 +449,7 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); return null; } - + AssetBase asset = new AssetBase(); asset.ID = id; @@ -475,7 +483,7 @@ namespace OpenSim.Services.Connectors.SimianGrid NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xGetAssetMetadata" }, - { "ID", id } + { "ID", id } }; OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); @@ -485,7 +493,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); return null; } - + AssetMetadata metadata = new AssetMetadata(); metadata.ID = id; metadata.ContentType = response["ContentType"].AsString(); @@ -620,7 +628,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // } // string errorMessage = null; - + // // Build the remote storage request // List postParameters = new List() // { diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index 3bd11d9..c402907 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs @@ -102,6 +102,12 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector"); } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { NameValueCollection requestArgs = new NameValueCollection diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs index a397740..34bb274 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs @@ -146,13 +146,14 @@ namespace OpenSim.Services.Connectors.SimianGrid userID,response["Message"].AsString()); return null; } - + // // // public bool SetAppearance(UUID userID, AvatarAppearance appearance) { - OSDMap map = appearance.Pack(); + EntityTransferContext ctx = new EntityTransferContext(); + OSDMap map = appearance.Pack(ctx); if (map == null) { m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID); @@ -177,7 +178,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return success; } - + // // // @@ -218,7 +219,7 @@ namespace OpenSim.Services.Connectors.SimianGrid appearance.AvatarHeight = (float)map["Height"].AsReal(); AvatarData avatar = new AvatarData(appearance); - + // Get attachments map = null; try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; } @@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors.SimianGrid foreach (KeyValuePair kvp in map) avatar.Data[kvp.Key] = kvp.Value.AsString(); } - + return avatar; } else diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs index 764e71f..49bd9a4 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private bool m_enabled = true; private Scene m_scene; private String m_simianURL; - + #region IRegionModule Members public string Name @@ -65,10 +65,10 @@ namespace OpenSim.Services.Connectors.SimianGrid public void Initialise(IConfigSource config) { - try + try { IConfig m_config; - + if ((m_config = config.Configs["SimianExternalCaps"]) != null) { m_enabled = m_config.GetBoolean("Enabled", m_enabled); @@ -97,10 +97,10 @@ namespace OpenSim.Services.Connectors.SimianGrid public void Close() { } public void AddRegion(Scene scene) - { + { if (! m_enabled) return; - + m_scene = scene; m_scene.RegisterModuleInterface(this); } @@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid subs["%USR%"] = agentID.ToString(); subs["%CAP%"] = cap.ToString(); subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString(); - + caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs)); return true; } @@ -168,12 +168,12 @@ namespace OpenSim.Services.Connectors.SimianGrid private String ExpandSkeletonURL(String urlSkel, Dictionary subs) { String result = urlSkel; - + foreach (KeyValuePair kvp in subs) { result = result.Replace(kvp.Key,kvp.Value); } - + return result; } } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs index a35d749..b29adb3 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs @@ -52,20 +52,20 @@ namespace OpenSim.Services.Connectors.SimianGrid private IConfig m_config = null; private String m_simianURL; - + #region IRegionModule Members public string Name { get { return this.GetType().Name; } } - + public void Initialise(IConfigSource config) { - try + try { m_config = config.Configs["SimianGrid"]; - + if (m_config != null) { m_simianURL = m_config.GetString("SimianServiceURL"); @@ -74,7 +74,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // m_log.DebugFormat("[SimianGrid] service URL is not defined"); return; } - + InitialiseSimCap(); SimulatorCapability = SimulatorCapability.Trim(); m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability); @@ -100,7 +100,7 @@ namespace OpenSim.Services.Connectors.SimianGrid /// /// Try a variety of methods for finding the simian simulator capability; first check the - /// configuration itself, then look for a file that contains the cap, then finally look + /// configuration itself, then look for a file that contains the cap, then finally look /// for an environment variable that contains it. /// private void InitialiseSimCap() @@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors.SimianGrid SimulatorCapability = m_config.GetString("SimulatorCapability"); return; } - + if (m_config.Contains("SimulatorCapabilityFile")) { String filename = m_config.GetString("SimulatorCapabilityFile"); @@ -120,7 +120,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return; } } - + if (m_config.Contains("SimulatorCapabilityVariable")) { String envname = m_config.GetString("SimulatorCapabilityVariable"); @@ -134,7 +134,7 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability"); } - + #endregion public static String SimulatorCapability = UUID.Zero.ToString(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs index 8375c95..4896d09 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs @@ -65,14 +65,14 @@ namespace OpenSim.Services.Connectors.SimianGrid private int m_refreshtime = 0; private int m_lastrefresh = 0; private System.Timers.Timer m_refreshTimer = new System.Timers.Timer(); - + #region ISharedRegionModule - + public Type ReplaceableInterface { get { return null; } } - public string Name { get { return "SimianGridMaptile"; } } + public string Name { get { return "SimianGridMaptile"; } } public void RegionLoaded(Scene scene) { } public void Close() { } - + /// /// /// @@ -81,7 +81,7 @@ namespace OpenSim.Services.Connectors.SimianGrid IConfig config = source.Configs["SimianGridMaptiles"]; if (config == null) return; - + if (! config.GetBoolean("Enabled", false)) return; @@ -218,7 +218,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize); uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize); - + ConvertAndUploadMaptile(subMapTile, locX, locY); } } @@ -232,7 +232,7 @@ namespace OpenSim.Services.Connectors.SimianGrid } } - + /// /// /// @@ -255,7 +255,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { "ContentType", "image/png" }, { "EncodedData", System.Convert.ToBase64String(pngData) } }; - + OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); if (! response["Success"].AsBoolean()) { diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index b031f21..f8eebbe 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Net; using System.Reflection; @@ -89,7 +91,7 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService"); throw new Exception("Grid connector init error"); } - + if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) serviceUrl = serviceUrl + '/'; m_ServerURI = serviceUrl; @@ -100,6 +102,15 @@ namespace OpenSim.Services.Connectors.SimianGrid public string RegisterRegion(UUID scopeID, GridRegion regionInfo) { + IPEndPoint ext = regionInfo.ExternalEndPoint; + if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint"; + // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service +// Scene scene; +// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) +// UploadMapTile(scene); +// else +// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); + Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight); @@ -108,7 +119,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, - { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, + { "ExternalAddress", OSD.FromString(ext.Address.ToString()) }, { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, { "Access", OSD.FromInteger(regionInfo.Access) }, @@ -219,7 +230,7 @@ namespace OpenSim.Services.Connectors.SimianGrid }; // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); - + OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { @@ -297,7 +308,7 @@ namespace OpenSim.Services.Connectors.SimianGrid }; //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); - + OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) @@ -402,7 +413,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return -1; } } - + public Dictionary GetExtraFeatures() { /// See SimulatorFeaturesModule - Need to get map, search and destination guide diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index e793420..9eefd16 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs @@ -277,17 +277,17 @@ namespace OpenSim.Services.Connectors.SimianGrid /// /// /// - public InventoryItemBase GetItem(InventoryItemBase item) + public InventoryItemBase GetItem(UUID principalID, UUID itemID) { InventoryItemBase retrieved = null; - if (m_ItemCache.TryGetValue(item.ID, out retrieved)) + if (m_ItemCache.TryGetValue(itemID, out retrieved)) return retrieved; NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetInventoryNode" }, - { "ItemID", item.ID.ToString() }, - { "OwnerID", item.Owner.ToString() }, + { "ItemID", itemID.ToString() }, + { "OwnerID", principalID.ToString() }, { "IncludeFolders", "1" }, { "IncludeItems", "1" }, { "ChildrenOnly", "1" } @@ -303,17 +303,17 @@ namespace OpenSim.Services.Connectors.SimianGrid // and sanity check just in case for (int i = 0; i < items.Count; i++) { - if (items[i].ID == item.ID) + if (items[i].ID == itemID) { retrieved = items[i]; - m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); + m_ItemCache.AddOrUpdate(itemID, retrieved, CACHE_EXPIRATION_SECONDS); return retrieved; } } } } - m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + item.ID + " owned by " + item.Owner + " not found"); + m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + itemID + " owned by " + principalID + " not found"); return null; } @@ -321,13 +321,8 @@ namespace OpenSim.Services.Connectors.SimianGrid { InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length]; int i = 0; - InventoryItemBase item = new InventoryItemBase(); - item.Owner = principalID; foreach (UUID id in itemIDs) - { - item.ID = id; - result[i++] = GetItem(item); - } + result[i++] = GetItem(principalID, id); return result; } @@ -337,13 +332,13 @@ namespace OpenSim.Services.Connectors.SimianGrid /// /// /// - public InventoryFolderBase GetFolder(InventoryFolderBase folder) + public InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetInventoryNode" }, - { "ItemID", folder.ID.ToString() }, - { "OwnerID", folder.Owner.ToString() }, + { "ItemID", folderID.ToString() }, + { "OwnerID", principalID.ToString() }, { "IncludeFolders", "1" }, { "IncludeItems", "0" }, { "ChildrenOnly", "1" } @@ -353,7 +348,7 @@ namespace OpenSim.Services.Connectors.SimianGrid if (response["Success"].AsBoolean() && response["Items"] is OSDArray) { OSDArray items = (OSDArray)response["Items"]; - List folders = GetFoldersFromResponse(items, folder.ID, true); + List folders = GetFoldersFromResponse(items, folderID, true); if (folders.Count > 0) return folders[0]; @@ -540,7 +535,7 @@ namespace OpenSim.Services.Connectors.SimianGrid allSuccess = false; } } - + return allSuccess; } @@ -732,11 +727,11 @@ namespace OpenSim.Services.Connectors.SimianGrid /// /// Get the union of permissions of all inventory items - /// that hold the given assetID. + /// that hold the given assetID. /// /// /// - /// The permissions or 0 if no such asset is found in + /// The permissions or 0 if no such asset is found in /// the user's inventory public int GetAssetPermissions(UUID userID, UUID assetID) { @@ -792,7 +787,7 @@ namespace OpenSim.Services.Connectors.SimianGrid if (item != null && item["Type"].AsString() == "Item") { InventoryItemBase invItem = new InventoryItemBase(); - + invItem.AssetID = item["AssetID"].AsUUID(); invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString()); invItem.CreationDate = item["CreationDate"].AsInteger(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 211b775..08efefb 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -121,7 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) serviceUrl = serviceUrl + '/'; m_serverUrl = serviceUrl; - m_activityDetector = new SimianActivityDetector(this); + m_activityDetector = new SimianActivityDetector(this); m_Enabled = true; } } @@ -210,7 +210,7 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString()); return null; } - + UUID userID = sessionResponse["UserID"].AsUUID(); OSDMap userResponse = GetUserData(userID); if (userResponse == null) @@ -238,7 +238,7 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString()); return null; } - + OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray; for (int i = 0; i < sessionList.Count; i++) { @@ -311,7 +311,7 @@ namespace OpenSim.Services.Connectors.SimianGrid public GridUserInfo GetGridUserInfo(string user) { - // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); + // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); UUID userID = new UUID(user); OSDMap userResponse = GetUserData(userID); @@ -421,7 +421,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return null; } - + private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) { return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index 8fc766d..a388bcc 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs @@ -70,7 +70,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private bool m_Enabled = false; #region INonSharedRegionModule - + public Type ReplaceableInterface { get { return null; } } public void RegionLoaded(Scene scene) { } public void Close() { } @@ -284,7 +284,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private void RequestAvatarPropertiesHandler(IClientAPI client, UUID avatarID) { m_log.DebugFormat("[SIMIAN PROFILES]: Request avatar properties for {0}",avatarID); - + OSDMap user = FetchUserData(avatarID); ProfileFlags flags = ProfileFlags.AllowPublish | ProfileFlags.MaturePublish; @@ -308,11 +308,11 @@ namespace OpenSim.Services.Connectors.SimianGrid about = new OSDMap(0); // Check if this user is a grid operator - byte[] charterMember; + byte[] membershipType; if (user["AccessLevel"].AsInteger() >= 200) - charterMember = Utils.StringToBytes("Operator"); + membershipType = Utils.StringToBytes("Operator"); else - charterMember = Utils.EmptyBytes; + membershipType = Utils.EmptyBytes; // Check if the user is online if (client.Scene is Scene) @@ -327,7 +327,7 @@ namespace OpenSim.Services.Connectors.SimianGrid flags |= ProfileFlags.Identified; client.SendAvatarProperties(avatarID, about["About"].AsString(), user["CreationDate"].AsDate().ToString("M/d/yyyy", - System.Globalization.CultureInfo.InvariantCulture), charterMember, about["FLAbout"].AsString(), (uint)flags, + System.Globalization.CultureInfo.InvariantCulture), membershipType, about["FLAbout"].AsString(), (uint)flags, about["FLImage"].AsUUID(), about["Image"].AsUUID(), about["URL"].AsString(), user["Partner"].AsUUID()); OSDMap interests = null; @@ -455,7 +455,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private OSDMap FetchUserData(UUID userID) { m_log.DebugFormat("[SIMIAN PROFILES]: Fetch information about {0}",userID); - + NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 698c4c0..115ae36 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -42,7 +42,7 @@ using OpenMetaverse.StructuredData; namespace OpenSim.Services.Connectors.SimianGrid { /// - /// Connects user account data (creating new users, looking up existing + /// Connects user account data (creating new users, looking up existing /// users) to the SimianGrid backend /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianUserAccountServiceConnector")] @@ -196,6 +196,16 @@ namespace OpenSim.Services.Connectors.SimianGrid m_accountCache.Remove(userID); } + public List GetUserAccountsWhere(UUID scopeID, string query) + { + return null; + } + + public List GetUserAccounts(UUID scopeID, List IDs) + { + return null; + } + public bool StoreUserAccount(UserAccount data) { // m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); @@ -210,7 +220,7 @@ namespace OpenSim.Services.Connectors.SimianGrid }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); - + if (response["Success"].AsBoolean()) { m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account data for " + data.Name); @@ -295,7 +305,7 @@ namespace OpenSim.Services.Connectors.SimianGrid account.LocalToGrid = true; if (response.ContainsKey("LocalToGrid")) account.LocalToGrid = (response["LocalToGrid"].AsString() == "true" ? true : false); - + GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName); // Cache the user account info diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index cea870b..a4ca2d3 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -50,7 +50,7 @@ namespace OpenSim.Services.Connectors.Simulation // we use this dictionary to track the pending updateagent requests, maps URI --> position update private Dictionary m_updateAgentQueue = new Dictionary(); - + //private GridRegion m_Region; public SimulationServiceConnector() @@ -98,29 +98,32 @@ namespace OpenSim.Services.Connectors.Simulation args["teleport_flags"] = OSD.FromString(flags.ToString()); } - public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) + public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason) { string tmp = String.Empty; - return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason); + return CreateAgent(source, destination, aCircuit, flags, ctx, out tmp, out reason); } - public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) + public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason) { - m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); reason = String.Empty; myipaddress = String.Empty; if (destination == null) { - m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); + reason = "Destination not found"; + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Create agent destination is null"); return false; } + m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); + string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; - + try { - OSDMap args = aCircuit.PackAgentCircuitData(); + OSDMap args = aCircuit.PackAgentCircuitData(ctx); + args["context"] = ctx.Pack(); PackData(args, source, aCircuit, destination, flags); OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); @@ -134,7 +137,7 @@ namespace OpenSim.Services.Connectors.Simulation myipaddress = data["your_ip"].AsString(); return success; } - + // Try the old version, uncompressed result = WebUtil.PostToService(uri, args, 30000, false); @@ -152,10 +155,10 @@ namespace OpenSim.Services.Connectors.Simulation return success; } } - + m_log.WarnFormat( - "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", - aCircuit.firstname, aCircuit.lastname, destination.RegionName); + "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", + aCircuit.firstname, aCircuit.lastname, destination.RegionName); reason = result["Message"] != null ? result["Message"].AsString() : "error"; return false; } @@ -171,9 +174,9 @@ namespace OpenSim.Services.Connectors.Simulation /// /// Send complete data about an agent in this region to a neighbor /// - public bool UpdateAgent(GridRegion destination, AgentData data) + public bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx) { - return UpdateAgent(destination, (IAgentData)data, 200000); // yes, 200 seconds + return UpdateAgent(destination, (IAgentData)data, ctx, 200000); // yes, 200 seconds } private ExpiringCache _failedSims = new ExpiringCache(); @@ -199,8 +202,8 @@ namespace OpenSim.Services.Connectors.Simulation { if (m_updateAgentQueue.ContainsKey(uri)) { - // Another thread is already handling - // updates for this simulator, just update + // Another thread is already handling + // updates for this simulator, just update // the position and return, overwrites are // not a problem since we only care about the // last update anyway @@ -234,7 +237,8 @@ namespace OpenSim.Services.Connectors.Simulation } } - success = UpdateAgent(destination, (IAgentData)pos, 10000); + EntityTransferContext ctx = new EntityTransferContext(); // Dummy, not needed for position + success = UpdateAgent(destination, (IAgentData)pos, ctx, 10000); } // we get here iff success == false // blacklist sim for 2 minutes @@ -249,7 +253,7 @@ namespace OpenSim.Services.Connectors.Simulation /// /// This is the worker function to send AgentData to a neighbor region /// - private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) + private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, EntityTransferContext ctx, int timeout) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); @@ -258,12 +262,13 @@ namespace OpenSim.Services.Connectors.Simulation try { - OSDMap args = cAgentData.Pack(); + OSDMap args = cAgentData.Pack(ctx); args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + args["context"] = ctx.Pack(); OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout); if (result["Success"].AsBoolean()) @@ -284,20 +289,19 @@ namespace OpenSim.Services.Connectors.Simulation public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List featuresAvailable, EntityTransferContext ctx, out string reason) { + Culture.SetCurrentCulture(); + reason = "Failed to contact destination"; // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); - IPEndPoint ext = destination.ExternalEndPoint; - if (ext == null) return false; - // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); - // To those who still understad this field, we're telling them + // To those who still understad this field, we're telling them // the lowest version just to be safe request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin))); // New simulation service negotiation @@ -306,6 +310,8 @@ namespace OpenSim.Services.Connectors.Simulation request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); + request.Add("context", ctx.Pack()); + OSDArray features = new OSDArray(); foreach (UUID feature in featuresAvailable) features.Add(OSD.FromString(feature.ToString())); @@ -325,7 +331,7 @@ namespace OpenSim.Services.Connectors.Simulation // FIXME: If there is a _Result map then it's the success key here that indicates the true success // or failure, not the sibling result node. - success = data["success"]; + success = data["success"].AsBoolean(); reason = data["reason"].AsString(); // We will need to plumb this and start sing the outbound version as well @@ -345,8 +351,6 @@ namespace OpenSim.Services.Connectors.Simulation ctx.OutboundVersion = float.Parse(parts[1]); } } - if (data.ContainsKey("variable_wearables_count_supported")) - ctx.VariableWearablesSupported = true; m_log.DebugFormat( "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", @@ -367,7 +371,7 @@ namespace OpenSim.Services.Connectors.Simulation m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); return true; } - + reason = result["Message"]; } else @@ -379,7 +383,6 @@ namespace OpenSim.Services.Connectors.Simulation return false; } - featuresAvailable.Clear(); if (result.ContainsKey("features")) @@ -390,13 +393,21 @@ namespace OpenSim.Services.Connectors.Simulation featuresAvailable.Add(new UUID(o.AsString())); } + // Version stuff + if (ctx.OutboundVersion < 0.5) + ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; + else if (ctx.OutboundVersion < 0.6) + ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES + 1; + else + ctx.WearablesCount = -1; // send all (just in case..) + return success; } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}",e.ToString()); } - + return false; } @@ -414,7 +425,7 @@ namespace OpenSim.Services.Connectors.Simulation { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] ReleaseAgent failed with exception; {0}",e.ToString()); } - + return true; } diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index c21db54..68ae7bb 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -191,10 +191,107 @@ namespace OpenSim.Services.Connectors return accounts; } + public virtual List GetUserAccounts(UUID scopeID, List IDs) + { + List accs = new List(); + bool multisuported = true; + accs = doGetMultiUserAccounts(scopeID, IDs, out multisuported); + if(multisuported) + return accs; + + // service does not do multi accounts so need to do it one by one + + UUID uuid = UUID.Zero; + foreach(string id in IDs) + { + if(UUID.TryParse(id, out uuid) && uuid != UUID.Zero) + accs.Add(GetUserAccount(scopeID,uuid)); + } + + return accs; + } + + private List doGetMultiUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = true; + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "getmultiaccounts"; + + sendData["ScopeID"] = scopeID.ToString(); + sendData["IDS"] = new List(IDs); + + string reply = string.Empty; + string reqString = ServerUtils.BuildQueryString(sendData); + string uri = m_ServerURI + "/accounts"; + // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + reqString, + m_Auth); + if (reply == null || (reply != null && reply == string.Empty)) + { + m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received null or empty reply"); + return null; + } + } + catch (Exception e) + { + m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message); + } + + List accounts = new List(); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) + { + if (replyData.ContainsKey("result")) + { + if(replyData["result"].ToString() == "null") + return accounts; + + if(replyData["result"].ToString() == "Failure") + { + suported = false; + return accounts; + } + } + + Dictionary.ValueCollection accountList = replyData.Values; + //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); + foreach (object acc in accountList) + { + if (acc is Dictionary) + { + UserAccount pinfo = new UserAccount((Dictionary)acc); + accounts.Add(pinfo); + } + else + m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received invalid response type {0}", + acc.GetType()); + } + } + else + m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetMultiUserAccounts received null response"); + + return accounts; + } + + public void InvalidateCache(UUID userID) { } + public List GetUserAccountsWhere(UUID scopeID, string where) + { + return null; // Not implemented for regions + } + public virtual bool StoreUserAccount(UserAccount data) { Dictionary sendData = new Dictionary(); @@ -247,7 +344,7 @@ namespace OpenSim.Services.Connectors return SendAndGetReply(sendData); } - + private UserAccount SendAndGetReply(Dictionary sendData) { string reply = string.Empty; diff --git a/OpenSim/Services/EstateService/EstateDataService.cs b/OpenSim/Services/EstateService/EstateDataService.cs index f6a8654..f051ffb 100644 --- a/OpenSim/Services/EstateService/EstateDataService.cs +++ b/OpenSim/Services/EstateService/EstateDataService.cs @@ -92,11 +92,11 @@ namespace OpenSim.Services.EstateService { return m_database.CreateNewEstate(); } - + public List LoadEstateSettingsAll() { - return m_database.LoadEstateSettingsAll(); - } + return m_database.LoadEstateSettingsAll(); + } public void StoreEstateSettings(EstateSettings es) { @@ -107,7 +107,7 @@ namespace OpenSim.Services.EstateService { return m_database.GetEstates(search); } - + public List GetEstatesAll() { return m_database.GetEstatesAll(); diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index aba8b33..ca2f459 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs @@ -76,6 +76,8 @@ namespace OpenSim.Services.FSAssetService protected int m_missingAssets = 0; protected int m_missingAssetsFS = 0; protected string m_FSBase; + protected bool m_useOsgridFormat = false; + protected bool m_showStats = true; private static bool m_Initialized; private bool m_MainInstance; @@ -113,34 +115,34 @@ namespace OpenSim.Services.FSAssetService } IConfig assetConfig = config.Configs[configName]; - + if (assetConfig == null) throw new Exception("No AssetService configuration"); // Get Database Connector from Asset Config (If present) string dllName = assetConfig.GetString("StorageProvider", string.Empty); - string m_ConnectionString = assetConfig.GetString("ConnectionString", string.Empty); - string m_Realm = assetConfig.GetString("Realm", "fsassets"); + string connectionString = assetConfig.GetString("ConnectionString", string.Empty); + string realm = assetConfig.GetString("Realm", "fsassets"); int SkipAccessTimeDays = assetConfig.GetInt("DaysBetweenAccessTimeUpdates", 0); // If not found above, fallback to Database defaults IConfig dbConfig = config.Configs["DatabaseService"]; - + if (dbConfig != null) { if (dllName == String.Empty) dllName = dbConfig.GetString("StorageProvider", String.Empty); - - if (m_ConnectionString == String.Empty) - m_ConnectionString = dbConfig.GetString("ConnectionString", String.Empty); + + if (connectionString == String.Empty) + connectionString = dbConfig.GetString("ConnectionString", String.Empty); } // No databse connection found in either config if (dllName.Equals(String.Empty)) throw new Exception("No StorageProvider configured"); - if (m_ConnectionString.Equals(String.Empty)) + if (connectionString.Equals(String.Empty)) throw new Exception("Missing database connection string"); // Create Storage Provider @@ -150,11 +152,11 @@ namespace OpenSim.Services.FSAssetService throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName)); // Initialize DB And perform any migrations required - m_DataConnector.Initialise(m_ConnectionString, m_Realm, SkipAccessTimeDays); + m_DataConnector.Initialise(connectionString, realm, SkipAccessTimeDays); // Setup Fallback Service string str = assetConfig.GetString("FallbackService", string.Empty); - + if (str != string.Empty) { object[] args = new object[] { config }; @@ -183,6 +185,11 @@ namespace OpenSim.Services.FSAssetService throw new Exception("Configuration error"); } + m_useOsgridFormat = assetConfig.GetBoolean("UseOsgridFormat", m_useOsgridFormat); + + // Default is to show stats to retain original behaviour + m_showStats = assetConfig.GetBoolean("ShowConsoleStats", m_showStats); + if (m_MainInstance) { string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty); @@ -197,13 +204,17 @@ namespace OpenSim.Services.FSAssetService Store(a, false); }); } - + m_WriterThread = new Thread(Writer); m_WriterThread.Start(); - m_StatsThread = new Thread(Stats); - m_StatsThread.Start(); + + if (m_showStats) + { + m_StatsThread = new Thread(Stats); + m_StatsThread.Start(); + } } - + m_log.Info("[FSASSETS]: FS asset service enabled"); } @@ -212,7 +223,7 @@ namespace OpenSim.Services.FSAssetService while (true) { Thread.Sleep(60000); - + lock (m_statsLock) { if (m_readCount > 0) @@ -220,6 +231,7 @@ namespace OpenSim.Services.FSAssetService double avg = (double)m_readTicks / (double)m_readCount; // if (avg > 10000) // Environment.Exit(0); + m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS); } m_readCount = 0; m_readTicks = 0; @@ -231,7 +243,7 @@ namespace OpenSim.Services.FSAssetService private void Writer() { - m_log.Info("[FSASSETS]: Writer started"); + m_log.Info("[ASSET]: Writer started"); while (true) { @@ -245,33 +257,98 @@ namespace OpenSim.Services.FSAssetService string hash = Path.GetFileNameWithoutExtension(files[i]); string s = HashToFile(hash); string diskFile = Path.Combine(m_FSBase, s); + bool pathOk = false; - Directory.CreateDirectory(Path.GetDirectoryName(diskFile)); - try + // The cure for chicken bones! + while(true) { - byte[] data = File.ReadAllBytes(files[i]); - - using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress)) + try { - gz.Write(data, 0, data.Length); - gz.Close(); + // Try to make the directory we need for this file + Directory.CreateDirectory(Path.GetDirectoryName(diskFile)); + pathOk = true; + break; } - File.Delete(files[i]); - - //File.Move(files[i], diskFile); + catch (System.IO.IOException) + { + // Creating the directory failed. This can't happen unless + // a part of the path already exists as a file. Sadly the + // SRAS data contains such files. + string d = Path.GetDirectoryName(diskFile); + + // Test each path component in turn. If we can successfully + // make a directory, the level below must be the chicken bone. + while (d.Length > 0) + { + Console.WriteLine(d); + try + { + Directory.CreateDirectory(Path.GetDirectoryName(d)); + } + catch (System.IO.IOException) + { + d = Path.GetDirectoryName(d); + + // We failed making the directory and need to + // go up a bit more + continue; + } + + // We succeeded in making the directory and (d) is + // the chicken bone + break; + } + + // Is the chicken alive? + if (d.Length > 0) + { + Console.WriteLine(d); + + FileAttributes attr = File.GetAttributes(d); + + if ((attr & FileAttributes.Directory) == 0) + { + // The chicken bone should be resolved. + // Return to writing the file. + File.Delete(d); + continue; + } + } + } + // Could not resolve, skipping + m_log.ErrorFormat("[ASSET]: Could not resolve path creation error for {0}", diskFile); + break; } - catch(System.IO.IOException e) + + if (pathOk) { - if (e.Message.StartsWith("Win32 IO returned ERROR_ALREADY_EXISTS")) + try + { + byte[] data = File.ReadAllBytes(files[i]); + + using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress)) + { + gz.Write(data, 0, data.Length); + gz.Close(); + } File.Delete(files[i]); - else - throw; + + //File.Move(files[i], diskFile); + } + catch(System.IO.IOException e) + { + if (e.Message.StartsWith("Win32 IO returned ERROR_ALREADY_EXISTS")) + File.Delete(files[i]); + else + throw; + } } } + int totalTicks = System.Environment.TickCount - tickCount; if (totalTicks > 0) // Wrap? { - m_log.InfoFormat("[FSASSETS]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length); + m_log.InfoFormat("[ASSET]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length); } } @@ -291,20 +368,27 @@ namespace OpenSim.Services.FSAssetService if (hash == null || hash.Length < 10) return "junkyard"; - return Path.Combine(hash.Substring(0, 3), - Path.Combine(hash.Substring(3, 3))); - /* - * The below is what core would normally use. - * This is modified to work in OSGrid, as seen - * above, because the SRAS data is structured - * that way. - */ - /* - return Path.Combine(hash.Substring(0, 2), - Path.Combine(hash.Substring(2, 2), - Path.Combine(hash.Substring(4, 2), - hash.Substring(6, 4)))); - */ + if (m_useOsgridFormat) + { + /* + * The code below is the OSGrid code. + */ + return Path.Combine(hash.Substring(0, 3), + Path.Combine(hash.Substring(3, 3))); + } + else + { + /* + * The below is what core would normally use. + * This is modified to work in OSGrid, as seen + * above, because the SRAS data is structured + * that way. + */ + return Path.Combine(hash.Substring(0, 2), + Path.Combine(hash.Substring(2, 2), + Path.Combine(hash.Substring(4, 2), + hash.Substring(6, 4)))); + } } private bool AssetExists(string hash) @@ -365,7 +449,7 @@ namespace OpenSim.Services.FSAssetService Store(asset); } } - if (asset == null) + if (asset == null && m_showStats) { // m_log.InfoFormat("[FSASSETS]: Asset {0} not found", id); m_missingAssets++; @@ -393,8 +477,11 @@ namespace OpenSim.Services.FSAssetService } } if (asset == null) - m_missingAssetsFS++; - // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash); + { + if (m_showStats) + m_missingAssetsFS++; + // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash); + } else { // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) @@ -408,10 +495,13 @@ namespace OpenSim.Services.FSAssetService } } - lock (m_statsLock) + if (m_showStats) { - m_readTicks += Environment.TickCount - startTime; - m_readCount++; + lock (m_statsLock) + { + m_readTicks += Environment.TickCount - startTime; + m_readCount++; + } } // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) @@ -578,6 +668,9 @@ namespace OpenSim.Services.FSAssetService if (!m_DataConnector.Store(asset.Metadata, hash)) { + if (asset.Metadata.Type == -2) + return asset.ID; + return UUID.Zero.ToString(); } else @@ -630,7 +723,7 @@ namespace OpenSim.Services.FSAssetService AssetBase asset = Get(args[2], out hash); if (asset == null || asset.Data.Length == 0) - { + { MainConsole.Instance.Output("Asset not found"); return; } @@ -672,7 +765,7 @@ namespace OpenSim.Services.FSAssetService AssetBase asset = Get(args[2]); if (asset == null || asset.Data.Length == 0) - { + { MainConsole.Instance.Output("Asset not found"); return; } diff --git a/OpenSim/Services/FreeswitchService/FreeswitchService.cs b/OpenSim/Services/FreeswitchService/FreeswitchService.cs index 201e72f..970d682 100644 --- a/OpenSim/Services/FreeswitchService/FreeswitchService.cs +++ b/OpenSim/Services/FreeswitchService/FreeswitchService.cs @@ -74,7 +74,7 @@ namespace OpenSim.Services.FreeswitchService response["str_response_string"] = String.Format(@"
- " + + " + /* @@ -116,21 +116,21 @@ namespace OpenSim.Services.FreeswitchService { Hashtable response = new Hashtable(); string domain = (string) request["domain"]; - if (domain != m_freeSwitchRealm) + if (domain != m_freeSwitchRealm) { response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; response["str_response_string"] = ""; - } - else + } + else { // m_log.DebugFormat("[FreeSwitchDirectory]: HandleDirectoryRequest called with {0}",request.ToString()); - + // information in the request we might be interested in - + // Request 1 sip_auth for users account - + //Event-Calling-Function=sofia_reg_parse_auth //Event-Calling-Line-Number=1494 //action=sip_auth @@ -145,10 +145,10 @@ namespace OpenSim.Services.FreeswitchService //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D //domain=9.20.151.43 //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup - + // foreach (DictionaryEntry item in request) // m_log.DebugFormat("[FreeSwitchDirectory]: requestBody item {0} {1}", item.Key, item.Value); - + string eventCallingFunction = (string) request["Event-Calling-Function"]; if (eventCallingFunction == null) { @@ -159,15 +159,15 @@ namespace OpenSim.Services.FreeswitchService { eventCallingFunction = "sofia_reg_parse_auth"; } - + if (eventCallingFunction == "sofia_reg_parse_auth") { string sipAuthMethod = (string)request["sip_auth_method"]; - + if (sipAuthMethod == "REGISTER") { response = HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request); - } + } else if (sipAuthMethod == "INVITE") { response = HandleInvite(m_freeSwitchContext, m_freeSwitchRealm, request); @@ -215,16 +215,16 @@ namespace OpenSim.Services.FreeswitchService } return response; } - + private Hashtable HandleRegister(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory]: HandleRegister called"); - + // TODO the password we return needs to match that sent in the request, this is hard coded for now string password = "1234"; string domain = (string) request["domain"]; string user = (string) request["user"]; - + Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; @@ -249,20 +249,20 @@ namespace OpenSim.Services.FreeswitchService "
\r\n" + "
\r\n", domain , user, password, Context); - + return response; } - + private Hashtable HandleInvite(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory]: HandleInvite called"); - + // TODO the password we return needs to match that sent in the request, this is hard coded for now string password = "1234"; string domain = (string) request["domain"]; string user = (string) request["user"]; string sipRequestUser = (string) request["sip_request_user"]; - + Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; @@ -296,18 +296,18 @@ namespace OpenSim.Services.FreeswitchService "\r\n" + "\r\n", domain , user, password,sipRequestUser, Context); - + return response; } private Hashtable HandleLocateUser(String Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory]: HandleLocateUser called"); - + // TODO the password we return needs to match that sent in the request, this is hard coded for now string domain = (string) request["domain"]; string user = (string) request["user"]; - + Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; @@ -330,17 +330,17 @@ namespace OpenSim.Services.FreeswitchService "\r\n" + "\r\n", domain , user); - + return response; } - + private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory]: HandleConfigSofia called."); - + // TODO the password we return needs to match that sent in the request, this is hard coded for now string domain = (string) request["domain"]; - + Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; @@ -381,9 +381,9 @@ namespace OpenSim.Services.FreeswitchService "\r\n"+ "\r\n" + "\r\n" + - "\r\n", - domain, Context); - + "\r\n", + domain, Context); + return response; } diff --git a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs index 1e3560b..bfeb388d 100644 --- a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.FreeswitchService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs index 87fb6a9..3e6447a 100644 --- a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.FriendsService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 0c502a2..a5c7d34 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -57,8 +57,6 @@ namespace OpenSim.Services.GridService protected bool m_AllowDuplicateNames = false; protected bool m_AllowHypergridMapSearch = false; - protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; - private static Dictionary m_ExtraFeatures = new Dictionary(); public GridService(IConfigSource config) @@ -74,7 +72,7 @@ namespace OpenSim.Services.GridService if (gridConfig != null) { m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); - + string authService = gridConfig.GetString("AuthenticationService", String.Empty); if (authService != String.Empty) @@ -85,8 +83,6 @@ namespace OpenSim.Services.GridService m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); - m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration); - // This service is also used locally by a simulator running in grid mode. This switches prevents // inappropriate console commands from being registered suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); @@ -155,9 +151,9 @@ namespace OpenSim.Services.GridService if (loginConfig == null || gridConfig == null) return; - + string configVal; - + configVal = loginConfig.GetString("SearchURL", string.Empty); if (!string.IsNullOrEmpty(configVal)) m_ExtraFeatures["search-server-url"] = configVal; @@ -201,15 +197,28 @@ namespace OpenSim.Services.GridService if (regionInfos.RegionID == UUID.Zero) return "Invalid RegionID - cannot be zero UUID"; + if (regionInfos.RegionLocY <= Constants.MaximumRegionSize) + return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString(); + String reason = "Region overlaps another region"; - RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); - // If there is a conflicting region, if it has the same ID and same coordinates - // then it is a region re-registering (permissions and ownership checked later). - if ((region != null) - && ( (region.coordX != regionInfos.RegionCoordX) - || (region.coordY != regionInfos.RegionCoordY) - || (region.RegionID != regionInfos.RegionID) ) - ) + + List rdatas = m_Database.Get( + regionInfos.RegionLocX, + regionInfos.RegionLocY, + regionInfos.RegionLocX + regionInfos.RegionSizeX - 1, + regionInfos.RegionLocY + regionInfos.RegionSizeY - 1 , + scopeID); + + RegionData region = null; + if(rdatas.Count > 1) + { + m_log.WarnFormat("{0} Register region overlaps with {1} regions", LogHeader, scopeID, rdatas.Count); + return reason; + } + else if(rdatas.Count == 1) + region = rdatas[0]; + + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { // If not same ID and same coordinates, this new region has conflicts and can't be registered. m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); @@ -263,7 +272,7 @@ namespace OpenSim.Services.GridService { if (d.RegionID != regionInfos.RegionID) { - m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", + m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID); return "Duplicate region name"; } @@ -273,7 +282,7 @@ namespace OpenSim.Services.GridService // If there is an old record for us, delete it if it is elsewhere. region = m_Database.Get(regionInfos.RegionID, scopeID); - if ((region != null) && (region.RegionID == regionInfos.RegionID) && + if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) @@ -284,7 +293,7 @@ namespace OpenSim.Services.GridService // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); try { @@ -299,7 +308,7 @@ namespace OpenSim.Services.GridService // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; - + if (region != null) { int oldFlags = Convert.ToInt32(region.Data["flags"]); @@ -336,107 +345,15 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } - m_log.InfoFormat - ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, - regionInfos.RegionCoordX, regionInfos.RegionCoordY, + m_log.DebugFormat + ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, + regionInfos.RegionCoordX, regionInfos.RegionCoordY, (OpenSim.Framework.RegionFlags)flags); return String.Empty; } - /// - /// Search the region map for regions conflicting with this region. - /// The region to be added is passed and we look for any existing regions that are - /// in the requested location, that are large varregions that overlap this region, or - /// are previously defined regions that would lie under this new region. - /// - /// Information on region requested to be added to the world map - /// Grid id for region - /// The reason the returned region conflicts with passed region - /// - private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason) - { - reason = "Reregistration"; - // First see if there is an existing region right where this region is trying to go - // (We keep this result so it can be returned if suppressing errors) - RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - RegionData region = noErrorRegion; - if (region != null - && region.RegionID == regionInfos.RegionID - && region.sizeX == regionInfos.RegionSizeX - && region.sizeY == regionInfos.RegionSizeY) - { - // If this seems to be exactly the same region, return this as it could be - // a re-registration (permissions checked by calling routine). - m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}", - LogHeader, RegionString(regionInfos)); - return region; - } - - // No region exactly there or we're resizing an existing region. - // Fetch regions that could be varregions overlapping requested location. - int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10; - int xmax = regionInfos.RegionLocX; - int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10; - int ymax = regionInfos.RegionLocY; - List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); - foreach (RegionData rdata in rdatas) - { - // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) ); - if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX) - && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) ) - { - region = rdata; - m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}", - LogHeader, RegionString(regionInfos), RegionString(region)); - reason = String.Format("Region location is overlapped by existing varregion {0}", - RegionString(region)); - - if (m_SuppressVarregionOverlapCheckOnRegistration) - region = noErrorRegion; - return region; - } - } - - // There isn't a region that overlaps this potential region. - // See if this potential region overlaps an existing region. - // First, a shortcut of not looking for overlap if new region is legacy region sized - // and connot overlap anything. - if (regionInfos.RegionSizeX != Constants.RegionSize - || regionInfos.RegionSizeY != Constants.RegionSize) - { - // trim range looked for so we don't pick up neighbor regions just off the edges - xmin = regionInfos.RegionLocX; - xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10; - ymin = regionInfos.RegionLocY; - ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10; - rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); - - // If the region is being resized, the found region could be ourself. - foreach (RegionData rdata in rdatas) - { - // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) ); - if (region == null || region.RegionID != regionInfos.RegionID) - { - region = rdata; - m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}", - LogHeader, RegionString(regionInfos), RegionString(region)); - reason = String.Format("Region {0} would overlap existing region {1}", - RegionString(regionInfos), RegionString(region)); - - if (m_SuppressVarregionOverlapCheckOnRegistration) - region = noErrorRegion; - return region; - } - } - } - - // If we get here, region is either null (nothing found here) or - // is the non-conflicting region found at the location being requested. - return region; - } - // String describing name and region location of passed region private String RegionString(RegionData reg) { @@ -463,7 +380,7 @@ namespace OpenSim.Services.GridService int flags = Convert.ToInt32(region.Data["flags"]); - if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) + if ((!m_DeleteOnUnregister) || ((flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0)) { flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; region.Data["flags"] = flags.ToString(); @@ -478,7 +395,6 @@ namespace OpenSim.Services.GridService } return true; - } return m_Database.Delete(regionID); @@ -488,13 +404,11 @@ namespace OpenSim.Services.GridService { List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); - + if (region != null) { - // Not really? Maybe? - // The adjacent regions are presumed to be the same size as the current region List rdatas = m_Database.Get( - region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, + region.posX - 1, region.posY - 1, region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); foreach (RegionData rdata in rdatas) @@ -516,10 +430,10 @@ namespace OpenSim.Services.GridService else { m_log.WarnFormat( - "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", + "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", scopeID, regionID); } - + return rinfos; } @@ -537,6 +451,7 @@ namespace OpenSim.Services.GridService // be the base coordinate of the region. // The snapping is technically unnecessary but is harmless because regions are always // multiples of the legacy region size (256). + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { uint regionX = Util.WorldToRegionLoc((uint)x); @@ -553,8 +468,8 @@ namespace OpenSim.Services.GridService } else { - m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", - LogHeader, regionX, regionY); +// m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", +// LogHeader, regionX, regionY); return null; } } @@ -584,7 +499,78 @@ namespace OpenSim.Services.GridService int count = 0; List rinfos = new List(); - if (rdatas != null) + if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains(".")) + { + string regionURI = ""; + string regionName = ""; + if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) + return null; + + string mapname; + bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); + if(localGrid) + mapname = regionName; + else + mapname = regionURI + regionName; + + bool haveMatch = false; + + if (rdatas != null && (rdatas.Count > 0)) + { +// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); + foreach (RegionData rdata in rdatas) + { + if (count++ < maxNumber) + rinfos.Add(RegionData2RegionInfo(rdata)); + if(rdata.RegionName == mapname) + { + haveMatch = true; + if(count == maxNumber) + { + rinfos.RemoveAt(count - 1); + rinfos.Add(RegionData2RegionInfo(rdata)); + } + } + } + if(haveMatch) + return rinfos; + } + + rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID); + if (rdatas != null && (rdatas.Count > 0)) + { +// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); + foreach (RegionData rdata in rdatas) + { + if (count++ < maxNumber) + rinfos.Add(RegionData2RegionInfo(rdata)); + if(rdata.RegionName == mapname) + { + haveMatch = true; + if(count == maxNumber) + { + rinfos.RemoveAt(count - 1); + rinfos.Add(RegionData2RegionInfo(rdata)); + break; + } + } + } + if(haveMatch) + return rinfos; + } + if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) + { + string HGname = regionURI +" "+ regionName; // include space for compatibility + GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); + if (r != null) + { + if( count == maxNumber) + rinfos.RemoveAt(count - 1); + rinfos.Add(r); + } + } + } + else if (rdatas != null && (rdatas.Count > 0)) { // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); foreach (RegionData rdata in rdatas) @@ -594,13 +580,6 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0))) - { - GridRegion r = GetHypergridRegionByName(scopeID, name); - if (r != null) - rinfos.Add(r); - } - return rinfos; } @@ -613,9 +592,30 @@ namespace OpenSim.Services.GridService protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) { if (name.Contains(".")) - return m_HypergridLinker.LinkRegion(scopeID, name); - else - return null; + { + string regionURI = ""; + string regionName = ""; + if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) + return null; + + string mapname; + bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); + if(localGrid) + mapname = regionName; + else + mapname = regionURI + regionName; + + List rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID); + if ((rdatas != null) && (rdatas.Count > 0)) + return RegionData2RegionInfo(rdatas[0]); // get the first + + if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) + { + string HGname = regionURI +" "+ regionName; + return m_HypergridLinker.LinkRegion(scopeID, HGname); + } + } + return null; } public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) @@ -666,7 +666,7 @@ namespace OpenSim.Services.GridService return rinfo; } - #endregion + #endregion public List GetDefaultRegions(UUID scopeID) { @@ -705,7 +705,7 @@ namespace OpenSim.Services.GridService int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline; m_log.DebugFormat( - "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", + "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline); return ret; @@ -742,7 +742,7 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); return ret; } - + public int GetRegionFlags(UUID scopeID, UUID regionID) { RegionData region = m_Database.Get(regionID, scopeID); @@ -804,14 +804,14 @@ namespace OpenSim.Services.GridService return; } - List regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); + List regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero); OutputRegionsToConsoleSummary(regions); } private void HandleShowGridSize(string module, string[] cmd) { - List regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); + List regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero); double size = 0; @@ -872,7 +872,9 @@ namespace OpenSim.Services.GridService return; } + RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); + if (region == null) { MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); @@ -889,7 +891,7 @@ namespace OpenSim.Services.GridService ConsoleDisplayList dispList = new ConsoleDisplayList(); dispList.AddRow("Region Name", r.RegionName); dispList.AddRow("Region ID", r.RegionID); - dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); + dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); dispList.AddRow("URI", r.Data["serverURI"]); dispList.AddRow("Owner ID", r.Data["owner_uuid"]); @@ -907,9 +909,9 @@ namespace OpenSim.Services.GridService private void OutputRegionsToConsoleSummary(List regions) { ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); - dispTable.AddColumn("Name", 44); - dispTable.AddColumn("ID", 36); - dispTable.AddColumn("Position", 11); + dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize); + dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize); + dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize); dispTable.AddColumn("Size", 11); dispTable.AddColumn("Flags", 60); @@ -992,7 +994,7 @@ namespace OpenSim.Services.GridService } /// - /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh + /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh /// parameters in the viewer used to access services like map, search and destination guides. /// see "SimulatorFeaturesModule" /// diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 444f79b..7522e64 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService connString = gridConfig.GetString("ConnectionString", connString); realm = gridConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index aebbf7c..dabfd3b 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -63,6 +63,7 @@ namespace OpenSim.Services.GridService protected GatekeeperServiceConnector m_GatekeeperConnector; protected UUID m_ScopeID = UUID.Zero; +// protected bool m_Check4096 = true; protected string m_MapTileDirectory = string.Empty; protected string m_ThisGatekeeper = string.Empty; protected Uri m_ThisGatekeeperURI = null; @@ -119,8 +120,9 @@ namespace OpenSim.Services.GridService if (scope != string.Empty) UUID.TryParse(scope, out m_ScopeID); -// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. - m_MapTileDirectory = "../caches/" + Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")); +// m_Check4096 = gridConfig.GetBoolean("Check4096", true); + + m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); m_ThisGatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); @@ -135,18 +137,27 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); } + m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri; + if(m_ThisGatekeeperURI.Port == 80) + m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/"; + else if(m_ThisGatekeeperURI.Port == 443) + m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/"; + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); - try - { - Directory.CreateDirectory(m_MapTileDirectory); - } - catch (Exception e) + if (!string.IsNullOrEmpty(m_MapTileDirectory)) { - m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); - m_MapTileDirectory = string.Empty; + try + { + Directory.CreateDirectory(m_MapTileDirectory); + } + catch (Exception e) + { + m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); + m_MapTileDirectory = string.Empty; + } } if (MainConsole.Instance != null) @@ -186,85 +197,29 @@ namespace OpenSim.Services.GridService return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); } + public bool IsLocalGrid(string serverURI) + { + return serverURI == m_ThisGatekeeper; + } + public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) { reason = string.Empty; GridRegion regInfo = null; - mapName = mapName.Trim(); + string serverURI = string.Empty; + string regionName = string.Empty; - if (!mapName.StartsWith("http")) + if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName)) { - // Formats: grid.example.com:8002:region name - // grid.example.com:region name - // grid.example.com:8002 - // grid.example.com - - string host; - uint port = 80; - string regionName = ""; - - string[] parts = mapName.Split(new char[] { ':' }); - - if (parts.Length == 0) - { - reason = "Wrong format for link-region"; - return null; - } - - host = parts[0]; - - if (parts.Length >= 2) - { - // If it's a number then assume it's a port. Otherwise, it's a region name. - if (!UInt32.TryParse(parts[1], out port)) - regionName = parts[1]; - } - - // always take the last one - if (parts.Length >= 3) - { - regionName = parts[2]; - } - - - bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); - if (success) - { - regInfo.RegionName = mapName; - return regInfo; - } + reason = "Wrong URI format for link-region"; + return null; } - else - { - // Formats: http://grid.example.com region name - // http://grid.example.com "region name" - // http://grid.example.com - - string serverURI; - string regionName = ""; - string[] parts = mapName.Split(new char[] { ' ' }); - - if (parts.Length == 0) - { - reason = "Wrong format for link-region"; - return null; - } - - serverURI = parts[0]; - - if (parts.Length >= 2) - { - regionName = mapName.Substring(serverURI.Length); - regionName = regionName.Trim(new char[] { '"', ' ' }); - } - - if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) - { - regInfo.RegionName = mapName; - return regInfo; - } + if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) + { + regInfo.RegionName = serverURI + regionName; + return regInfo; } return null; @@ -285,7 +240,7 @@ namespace OpenSim.Services.GridService private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) { - m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", + m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); @@ -361,7 +316,9 @@ namespace OpenSim.Services.GridService UUID regionID = UUID.Zero; string externalName = string.Empty; string imageURL = string.Empty; - if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) + int sizeX = (int)Constants.RegionSize; + int sizeY = (int)Constants.RegionSize; + if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY)) return false; if (regionID == UUID.Zero) @@ -374,13 +331,27 @@ namespace OpenSim.Services.GridService region = m_GridService.GetRegionByUUID(scopeID, regionID); if (region != null) { - m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", - Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); + m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); regInfo = region; return true; } + // We are now performing this check for each individual teleport in the EntityTransferModule instead. This + // allows us to give better feedback when teleports fail because of the distance reason (which can't be + // done here) and it also hypergrid teleports that are within range (possibly because the source grid + // itself has regions that are very far apart). +// uint x, y; +// if (m_Check4096 && !Check4096(handle, out x, out y)) +// { +// //RemoveHyperlinkRegion(regInfo.RegionID); +// reason = "Region is too far (" + x + ", " + y + ")"; +// m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")"); +// //return false; +// } + regInfo.RegionID = regionID; + regInfo.RegionSizeX = sizeX; + regInfo.RegionSizeY = sizeY; if (externalName == string.Empty) regInfo.RegionName = regInfo.ServerURI; @@ -412,7 +383,7 @@ namespace OpenSim.Services.GridService OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) { - regInfo = new GridRegion(); + regInfo = new GridRegion(); regInfo.RegionID = regions[0].RegionID; regInfo.ScopeID = m_ScopeID; } @@ -430,6 +401,52 @@ namespace OpenSim.Services.GridService } } +// Not currently used +// /// +// /// Cope with this viewer limitation. +// /// +// /// +// /// +// public bool Check4096(ulong realHandle, out uint x, out uint y) +// { +// uint ux = 0, uy = 0; +// Utils.LongToUInts(realHandle, out ux, out uy); +// x = Util.WorldToRegionLoc(ux); +// y = Util.WorldToRegionLoc(uy); +// +// const uint limit = Util.RegionToWorldLoc(4096 - 1); +// uint xmin = ux - limit; +// uint xmax = ux + limit; +// uint ymin = uy - limit; +// uint ymax = uy + limit; +// // World map boundary checks +// if (xmin < 0 || xmin > ux) +// xmin = 0; +// if (xmax > int.MaxValue || xmax < ux) +// xmax = int.MaxValue; +// if (ymin < 0 || ymin > uy) +// ymin = 0; +// if (ymax > int.MaxValue || ymax < uy) +// ymax = int.MaxValue; +// +// // Check for any regions that are within the possible teleport range to the linked region +// List regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); +// if (regions.Count == 0) +// { +// return false; +// } +// else +// { +// // Check for regions which are not linked regions +// List hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); +// IEnumerable availableRegions = regions.Except(hyperlinks); +// if (availableRegions.Count() == 0) +// return false; +// } +// +// return true; +// } + private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) { RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); @@ -474,7 +491,7 @@ namespace OpenSim.Services.GridService { MainConsole.Instance.Output( String.Format("{0}\n{2,-32} {1}\n", - r.RegionName, r.RegionID, + r.RegionName, r.RegionID, String.Format("{0},{1} ({2},{3})", r.posX, r.posY, Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) ) @@ -556,7 +573,7 @@ namespace OpenSim.Services.GridService if (cmdparams[2].StartsWith("http")) { RunLinkRegionCommand(cmdparams); - } + } else if (cmdparams[2].Contains(":")) { // New format diff --git a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs index 0841e5a..69a3c44 100644 --- a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.GridService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 8e10125..5c6abd2 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -35,8 +35,8 @@ using OpenSim.Framework; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; +using OpenSim.Services.Connectors.InstantMessage; using OpenSim.Services.Connectors.Hypergrid; - using OpenMetaverse; using Nini.Config; @@ -71,6 +71,7 @@ namespace OpenSim.Services.HypergridService private static string m_ExternalName; private static Uri m_Uri; private static GridRegion m_DefaultGatewayRegion; + private bool m_allowDuplicatePresences = false; public GatekeeperService(IConfigSource config, ISimulationService simService) { @@ -93,7 +94,7 @@ namespace OpenSim.Services.HypergridService // These are mandatory, the others aren't if (gridService == string.Empty || presenceService == string.Empty) throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); - + string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); UUID.TryParse(scope, out m_ScopeID); //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); @@ -135,7 +136,7 @@ namespace OpenSim.Services.HypergridService m_AllowedClients = Util.GetConfigVarFromSections( config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); m_DeniedClients = Util.GetConfigVarFromSections( - config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); + config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); @@ -144,6 +145,12 @@ namespace OpenSim.Services.HypergridService if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); + IConfig presenceConfig = config.Configs["PresenceService"]; + if (presenceConfig != null) + { + m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); + } + m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); } } @@ -162,10 +169,12 @@ namespace OpenSim.Services.HypergridService exceptions.Add(s.Trim()); } - public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) + public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY) { regionID = UUID.Zero; regionHandle = 0; + sizeX = (int)Constants.RegionSize; + sizeY = (int)Constants.RegionSize; externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); imageURL = string.Empty; reason = string.Empty; @@ -199,6 +208,8 @@ namespace OpenSim.Services.HypergridService regionID = region.RegionID; regionHandle = region.RegionHandle; + sizeX = region.RegionSizeX; + sizeY = region.RegionSizeY; string regionimage = "regionImage" + regionID.ToString(); regionimage = regionimage.Replace("-", ""); @@ -215,11 +226,11 @@ namespace OpenSim.Services.HypergridService { // Don't even check the given regionID m_log.DebugFormat( - "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.", - m_DefaultGatewayRegion.RegionName, + "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.", + m_DefaultGatewayRegion.RegionName, m_DefaultGatewayRegion.RegionID, m_DefaultGatewayRegion.ServerURI, - agentID, + agentID, agentHomeURI == null ? "" : " @ " + agentHomeURI); message = "Teleporting to the default region."; @@ -240,10 +251,10 @@ namespace OpenSim.Services.HypergridService m_log.DebugFormat( "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.", - region.RegionName, + region.RegionName, region.RegionID, region.ServerURI, - agentID, + agentID, agentHomeURI == null ? "" : " @ " + agentHomeURI); return region; @@ -275,6 +286,7 @@ namespace OpenSim.Services.HypergridService if (!am.Success) { + reason = "Login failed: client " + curViewer + " is not allowed"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); return false; } @@ -287,6 +299,7 @@ namespace OpenSim.Services.HypergridService if (dm.Success) { + reason = "Login failed: client " + curViewer + " is denied"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); return false; } @@ -302,7 +315,7 @@ namespace OpenSim.Services.HypergridService return false; } m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); - + // // Check for impersonations // @@ -363,6 +376,38 @@ namespace OpenSim.Services.HypergridService return false; } + UUID agentID = aCircuit.AgentID; + if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e")) + { + // really? + reason = "Invalid account ID"; + return false; + } + + if(m_GridUserService != null) + { + string PrincipalIDstr = agentID.ToString(); + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr); + + if(!m_allowDuplicatePresences) + { + if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) + { + if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo)) + { + if(account != null) + m_log.InfoFormat( + "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in", + account.FirstName, account.LastName); + reason = "You appear to be already logged in on the destination grid " + + "Please wait a a minute or two and retry. " + + "If this takes longer than a few minutes please contact the grid owner."; + return false; + } + } + } + } + m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); bool isFirstLogin = false; @@ -383,26 +428,6 @@ namespace OpenSim.Services.HypergridService return false; } - m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); - - // Also login foreigners with GridUser service - if (m_GridUserService != null && account == null) - { - string userId = aCircuit.AgentID.ToString(); - string first = aCircuit.firstname, last = aCircuit.lastname; - if (last.StartsWith("@")) - { - string[] parts = aCircuit.firstname.Split('.'); - if (parts.Length >= 2) - { - first = parts[0]; - last = parts[1]; - } - } - - userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last; - m_GridUserService.LoggedIn(userId); - } } // @@ -455,11 +480,37 @@ namespace OpenSim.Services.HypergridService EntityTransferContext ctx = new EntityTransferContext(); if (!m_SimulationService.QueryAccess( - destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), + destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), true, aCircuit.startpos, new List(), ctx, out reason)) return false; - return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); + bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason); + + if(didit) + { + m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); + + if(!isFirstLogin && m_GridUserService != null && account == null) + { + // Also login foreigners with GridUser service + string userId = aCircuit.AgentID.ToString(); + string first = aCircuit.firstname, last = aCircuit.lastname; + if (last.StartsWith("@")) + { + string[] parts = aCircuit.firstname.Split('.'); + if (parts.Length >= 2) + { + first = parts[0]; + last = parts[1]; + } + } + + userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last; + m_GridUserService.LoggedIn(userId); + } + } + + return didit; } protected bool Authenticate(AgentCircuitData aCircuit) @@ -489,7 +540,7 @@ namespace OpenSim.Services.HypergridService } else { - IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); + IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); try { @@ -557,6 +608,40 @@ namespace OpenSim.Services.HypergridService return exception; } + private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo) + { + UUID regionID = guinfo.LastRegionID; + GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); + if(regInfo == null) + return false; + + string regURL = regInfo.ServerURI; + if(String.IsNullOrEmpty(regURL)) + return false; + + UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e"); + + GridInstantMessage msg = new GridInstantMessage(); + msg.imSessionID = UUID.Zero.Guid; + msg.fromAgentID = guuid.Guid; + msg.toAgentID = agentID.Guid; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = "GRID"; + msg.message = string.Format("New login detected"); + msg.dialog = 250; // God kick + msg.fromGroup = false; + msg.offline = (byte)0; + msg.ParentEstateID = 0; + msg.Position = Vector3.Zero; + msg.RegionID = scopeID.Guid; + msg.binaryBucket = new byte[1] {0}; + InstantMessageServiceConnector.SendInstantMessage(regURL,msg); + + m_GridUserService.LoggedOut(agentID.ToString(), + UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); + + return true; + } #endregion } } diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index b83fb1e..a66478e 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -164,7 +164,7 @@ namespace OpenSim.Services.HypergridService return false; } - #endregion + #endregion protected void AdjustIdentifiers(AssetMetadata meta) { diff --git a/OpenSim/Services/HypergridService/HGFSAssetService.cs b/OpenSim/Services/HypergridService/HGFSAssetService.cs index 54e8ccb..2b30b3a 100644 --- a/OpenSim/Services/HypergridService/HGFSAssetService.cs +++ b/OpenSim/Services/HypergridService/HGFSAssetService.cs @@ -160,7 +160,7 @@ namespace OpenSim.Services.HypergridService return false; } - #endregion + #endregion protected void AdjustIdentifiers(AssetMetadata meta) { diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs index 6e35a88..d3b4f18 100644 --- a/OpenSim/Services/HypergridService/HGFriendsService.cs +++ b/OpenSim/Services/HypergridService/HGFriendsService.cs @@ -227,7 +227,7 @@ namespace OpenSim.Services.HypergridService List localFriendsOnline = new List(); - m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status", + m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status", foreignUserID, friends.Count, (online ? "online" : "offline")); // First, let's double check that the reported friends are, indeed, friends of that user diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index 32ca09a..d1739cf 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -184,7 +184,7 @@ namespace OpenSim.Services.HypergridService else if (o is string) url = (string)o; - // We need to compare the current location with the previous + // 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) { diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index 9158b41..f14593e 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -70,7 +70,7 @@ namespace OpenSim.Services.HypergridService // IConfig invConfig = config.Configs[m_ConfigName]; if (invConfig != null) - { + { // realm = authConfig.GetString("Realm", realm); string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); if (userAccountsDll == string.Empty) @@ -82,7 +82,7 @@ namespace OpenSim.Services.HypergridService throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", - new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); + new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } @@ -113,7 +113,7 @@ namespace OpenSim.Services.HypergridService if (folders.Length > 0) return ConvertToOpenSim(folders[0]); - + // make one XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)FolderType.Suitcase, "My Suitcase"); return ConvertToOpenSim(suitcase); @@ -160,7 +160,7 @@ namespace OpenSim.Services.HypergridService { return new InventoryCollection[0]; } - + //public List GetFolderItems(UUID principalID, UUID folderID) //{ //} @@ -291,9 +291,9 @@ namespace OpenSim.Services.HypergridService //{ //} - public override InventoryItemBase GetItem(InventoryItemBase item) + public override InventoryItemBase GetItem(UUID principalID, UUID itemID) { - InventoryItemBase it = base.GetItem(item); + InventoryItemBase it = base.GetItem(principalID, itemID); if (it != null) { UserAccount user = m_Cache.GetUser(it.CreatorId); diff --git a/OpenSim/Services/HypergridService/HGRemoteAssetService.cs b/OpenSim/Services/HypergridService/HGRemoteAssetService.cs new file mode 100644 index 0000000..5e98af9 --- /dev/null +++ b/OpenSim/Services/HypergridService/HGRemoteAssetService.cs @@ -0,0 +1,240 @@ +/* + * 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.IO; +using System.Reflection; +using System.Xml; + +using Nini.Config; +using log4net; +using OpenMetaverse; + +using OpenSim.Framework; +using OpenSim.Framework.Serialization.External; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.AssetService; + +namespace OpenSim.Services.HypergridService +{ + /// + /// Hypergrid asset service. It serves the IAssetService interface, + /// but implements it in ways that are appropriate for inter-grid + /// asset exchanges. + /// + public class HGRemoteAssetService : IAssetService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_HomeURL; + private IUserAccountService m_UserAccountService; + private IAssetService m_assetConnector; + + private UserAccountCache m_Cache; + + private AssetPermissions m_AssetPerms; + + public HGRemoteAssetService(IConfigSource config, string configName) + { + m_log.Debug("[HGRemoteAsset Service]: Starting"); + IConfig assetConfig = config.Configs[configName]; + if (assetConfig == null) + throw new Exception("No HGAssetService configuration"); + + Object[] args = new Object[] { config }; + + string assetConnectorDll = assetConfig.GetString("AssetConnector", String.Empty); + if (assetConnectorDll == String.Empty) + throw new Exception("Please specify AssetConnector in HGAssetService configuration"); + + m_assetConnector = ServerUtils.LoadPlugin(assetConnectorDll, args); + if (m_assetConnector == null) + throw new Exception(String.Format("Unable to create AssetConnector from {0}", assetConnectorDll)); + + string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty); + if (userAccountsDll == string.Empty) + throw new Exception("Please specify UserAccountsService in HGAssetService configuration"); + + m_UserAccountService = ServerUtils.LoadPlugin(userAccountsDll, args); + if (m_UserAccountService == null) + throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); + + m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", + new string[] { "Startup", "Hypergrid", configName }, string.Empty); + if (m_HomeURL == string.Empty) + throw new Exception("[HGAssetService] No HomeURI specified"); + + m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); + + // Permissions + m_AssetPerms = new AssetPermissions(assetConfig); + + } + + #region IAssetService overrides + public AssetBase Get(string id) + { + AssetBase asset = m_assetConnector.Get(id); + + if (asset == null) + return null; + + if (!m_AssetPerms.AllowedExport(asset.Type)) + return null; + + if (asset.Metadata.Type == (sbyte)AssetType.Object) + asset.Data = AdjustIdentifiers(asset.Data); + + AdjustIdentifiers(asset.Metadata); + + return asset; + } + + public AssetMetadata GetMetadata(string id) + { + AssetMetadata meta = m_assetConnector.GetMetadata(id); + + if (meta == null) + return null; + + AdjustIdentifiers(meta); + + return meta; + } + + public byte[] GetData(string id) + { + AssetBase asset = Get(id); + + if (asset == null) + return null; + + if (!m_AssetPerms.AllowedExport(asset.Type)) + return null; + + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before sending them elsewhere + if (asset.Type == (int)AssetType.Object && asset.Data != null) + { + string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data)); + asset.Data = Utils.StringToBytes(xml); + } + + return asset.Data; + } + + // public delegate void AssetRetrieved(string id, Object sender, AssetBase asset); + public virtual bool Get(string id, Object sender, AssetRetrieved handler) + { + return m_assetConnector.Get(id, sender, (i, s, asset) => + { + if (asset != null) + { + if (!m_AssetPerms.AllowedExport(asset.Type)) + { + asset = null; + } + else + { + if (asset.Metadata.Type == (sbyte)AssetType.Object) + asset.Data = AdjustIdentifiers(asset.Data); + + AdjustIdentifiers(asset.Metadata); + } + } + + handler(i, s, asset); + }); + } + + public string Store(AssetBase asset) + { + if (!m_AssetPerms.AllowedImport(asset.Type)) + return string.Empty; + + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before storing on this server + if (asset.Type == (int)AssetType.Object && asset.Data != null) + { + string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data)); + asset.Data = Utils.StringToBytes(xml); + } + + return m_assetConnector.Store(asset); + } + + public bool Delete(string id) + { + // NOGO + return false; + } + + #endregion + + protected void AdjustIdentifiers(AssetMetadata meta) + { + if (meta == null || m_Cache == null) + return; + + UserAccount creator = m_Cache.GetUser(meta.CreatorID); + if (creator != null) + meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName; + } + + // Only for Object + protected byte[] AdjustIdentifiers(byte[] data) + { + string xml = Utils.BytesToString(data); + + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before sending them elsewhere + xml = ExternalRepresentationUtils.SanitizeXml(xml); + + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero)); + } + + public AssetBase GetCached(string id) + { + return Get(id); + } + + public bool[] AssetsExist(string[] ids) + { + return m_assetConnector.AssetsExist(ids); + } + + public bool UpdateContent(string id, byte[] data) + { + // SO not happening!! + return false; + } + } + +} diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 40eb6d4..d1f2e70 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -97,7 +97,7 @@ namespace OpenSim.Services.HypergridService throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); // m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", -// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); +// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } @@ -318,7 +318,7 @@ namespace OpenSim.Services.HypergridService m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner); return false; } - + if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) { m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); @@ -383,7 +383,7 @@ namespace OpenSim.Services.HypergridService // Check the items' current folders foreach (InventoryItemBase item in items) { - InventoryItemBase originalItem = base.GetItem(item); + InventoryItemBase originalItem = base.GetItem(item.Owner, item.ID); if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder)) { m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); @@ -401,7 +401,7 @@ namespace OpenSim.Services.HypergridService public new InventoryItemBase GetItem(InventoryItemBase item) { - InventoryItemBase it = base.GetItem(item); + InventoryItemBase it = base.GetItem(item.Owner, item.ID); if (it == null) { m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0} ({1}) in folder {2}", @@ -426,9 +426,9 @@ namespace OpenSim.Services.HypergridService return it; } - public new InventoryFolderBase GetFolder(InventoryFolderBase folder) + public new InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { - InventoryFolderBase f = base.GetFolder(folder); + InventoryFolderBase f = base.GetFolder(principalID, folderID); if (f != null) { @@ -505,11 +505,11 @@ namespace OpenSim.Services.HypergridService // Warp! Root folder for travelers XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "agentID", "type" }, - new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() }); + new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() }); if (folders != null && folders.Length > 0) return folders[0]; - + // check to see if we have the old Suitcase folder folders = m_Database.GetFolders( new string[] { "agentID", "folderName", "parentFolderID" }, @@ -629,7 +629,7 @@ namespace OpenSim.Services.HypergridService { if (a.Wearables[i][j].ItemID == itemID) { - //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID); + //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID); return true; } } @@ -638,7 +638,7 @@ namespace OpenSim.Services.HypergridService // Check attachments if (a.GetAttachmentForItem(itemID) != null) { - //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID); + //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID); return true; } diff --git a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs index 9999237..31b9f4e 100644 --- a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.HypergridService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index fa7dd0b..ae0f7ce 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -16,7 +16,7 @@ namespace OpenSim.Services.HypergridService // private static readonly ILog m_log = // LogManager.GetLogger( // MethodBase.GetCurrentMethod().DeclaringType); - + private ExpiringCache m_UUIDCache; private IUserAccountService m_UserAccountService; @@ -90,11 +90,21 @@ namespace OpenSim.Services.HypergridService return null; } + public List GetUserAccountsWhere(UUID scopeID, string query) + { + return null; + } + public List GetUserAccounts(UUID scopeID, string query) { return null; } + public List GetUserAccounts(UUID scopeID, List IDs) + { + return null; + } + public void InvalidateCache(UUID userID) { m_UUIDCache.Remove(userID); diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index c65122a..6f2cdd5 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -219,7 +219,7 @@ namespace OpenSim.Services.HypergridService public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason) { - m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", + m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI); string gridName = gatekeeper.ServerURI; @@ -254,7 +254,6 @@ namespace OpenSim.Services.HypergridService } } - // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination GridRegion region = new GridRegion(gatekeeper); region.ServerURI = gatekeeper.ServerURI; @@ -269,7 +268,7 @@ namespace OpenSim.Services.HypergridService agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); TravelingAgentInfo old = null; TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old); - + bool success = false; string myExternalIP = string.Empty; @@ -281,12 +280,14 @@ namespace OpenSim.Services.HypergridService } else { - success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); + //TODO: Should there not be a call to QueryAccess here? + EntityTransferContext ctx = new EntityTransferContext(); + success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out myExternalIP, out reason); } if (!success) { - m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", + m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); if (old != null) @@ -299,8 +300,12 @@ namespace OpenSim.Services.HypergridService // Everything is ok - // Update the perceived IP Address of our grid - m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); + if (!fromLogin) + { + // Update the perceived IP Address of our grid + m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); + } + travel.MyIpAddress = myExternalIP; StoreTravelInfo(travel); @@ -370,7 +375,7 @@ namespace OpenSim.Services.HypergridService if (m_BypassClientVerification) return true; - m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", + m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", sessionID, reportedIP); HGTravelingData hgt = m_Database.Get(sessionID); @@ -529,7 +534,7 @@ namespace OpenSim.Services.HypergridService FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); foreach (FriendInfo finfo in friendInfos) { - if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) && + if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) && (finfo.TheirFlags & (int)FriendRights.CanSeeOnline) != 0 && (finfo.TheirFlags != -1)) { // great! @@ -635,7 +640,7 @@ namespace OpenSim.Services.HypergridService foreach (FriendInfo f in friends) if (f.Friend.StartsWith(targetUserID.ToString())) { - // Let's remove the secret + // 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"); diff --git a/OpenSim/Services/Interfaces/IAgentPreferencesService.cs b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs index 3b4fda2..af92326 100644 --- a/OpenSim/Services/Interfaces/IAgentPreferencesService.cs +++ b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs @@ -33,7 +33,7 @@ namespace OpenSim.Services.Interfaces { public class AgentPrefs { - public AgentPrefs(UUID principalID) + public AgentPrefs(UUID principalID) { PrincipalID = principalID; } @@ -101,7 +101,7 @@ namespace OpenSim.Services.Interfaces // DefaultObjectPermMasks public int PermEveryone = 0; public int PermGroup = 0; - public int PermNextOwner = 532480; + public int PermNextOwner = 0; // Illegal value by design } public interface IAgentPreferencesService diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs index 28c3315..170dc97 100644 --- a/OpenSim/Services/Interfaces/IAssetService.cs +++ b/OpenSim/Services/Interfaces/IAssetService.cs @@ -47,7 +47,7 @@ namespace OpenSim.Services.Interfaces /// /// AssetMetadata GetMetadata(string id); - + /// /// Get an asset's data, ignoring the metadata. /// @@ -63,7 +63,7 @@ namespace OpenSim.Services.Interfaces AssetBase GetCached(string id); /// - /// Get an asset synchronously or asynchronously (depending on whether + /// Get an asset synchronously or asynchronously (depending on whether /// it is locally cached) and fire a callback with the fetched asset /// /// The asset id @@ -75,7 +75,7 @@ namespace OpenSim.Services.Interfaces /// /// True if the id was parseable, false otherwise bool Get(string id, Object sender, AssetRetrieved handler); - + /// /// Check if assets exist in the database. /// diff --git a/OpenSim/Services/Interfaces/IAttachmentsService.cs b/OpenSim/Services/Interfaces/IAttachmentsService.cs new file mode 100644 index 0000000..7d33662 --- /dev/null +++ b/OpenSim/Services/Interfaces/IAttachmentsService.cs @@ -0,0 +1,38 @@ +/* + * 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 Nini.Config; + +namespace OpenSim.Services.Interfaces +{ + public interface IAttachmentsService + { + string Get(string id); + void Store(string id, string data); + } +} diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs index cee8bc0..1ff092f 100644 --- a/OpenSim/Services/Interfaces/IAuthenticationService.cs +++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.Interfaces // Generic Authentication service used for identifying // and authenticating principals. // Principals may be clients acting on users' behalf, - // or any other components that need + // or any other components that need // verifiable identification. // public interface IAuthenticationService @@ -67,6 +67,7 @@ namespace OpenSim.Services.Interfaces // various services. // string Authenticate(UUID principalID, string password, int lifetime); + string Authenticate(UUID principalID, string password, int lifetime, out UUID realID); ////////////////////////////////////////////////////// // Verification diff --git a/OpenSim/Services/Interfaces/IAuthorizationService.cs b/OpenSim/Services/Interfaces/IAuthorizationService.cs index e5c68f6..d4c697a 100644 --- a/OpenSim/Services/Interfaces/IAuthorizationService.cs +++ b/OpenSim/Services/Interfaces/IAuthorizationService.cs @@ -31,7 +31,7 @@ using OpenSim.Framework; namespace OpenSim.Services.Interfaces { // Generic Authorization service used for authorizing principals in a particular region - + public interface IAuthorizationService { /// @@ -50,7 +50,7 @@ namespace OpenSim.Services.Interfaces bool IsAuthorizedForRegion( string userID, string firstName, string lastName, string regionID, out string message); } - + public class AuthorizationRequest { private string m_userID; @@ -69,7 +69,7 @@ namespace OpenSim.Services.Interfaces m_userID = ID; m_regionID = RegionID; } - + public AuthorizationRequest( string ID, string FirstName, string SurName, string Email, string RegionName, string RegionID) { @@ -80,44 +80,44 @@ namespace OpenSim.Services.Interfaces m_regionName = RegionName; m_regionID = RegionID; } - + public string ID { get { return m_userID; } set { m_userID = value; } } - + public string FirstName { get { return m_firstname; } set { m_firstname = value; } } - + public string SurName { get { return m_surname; } set { m_surname = value; } } - + public string Email { get { return m_email; } set { m_email = value; } } - + public string RegionName { get { return m_regionName; } set { m_regionName = value; } } - + public string RegionID { get { return m_regionID; } set { m_regionID = value; } } } - + public class AuthorizationResponse { private bool m_isAuthorized; @@ -132,13 +132,13 @@ namespace OpenSim.Services.Interfaces m_isAuthorized = isAuthorized; m_message = message; } - + public bool IsAuthorized { get { return m_isAuthorized; } set { m_isAuthorized = value; } } - + public string Message { get { return m_message; } diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs index 892e0b4..b4dc511 100644 --- a/OpenSim/Services/Interfaces/IAvatarService.cs +++ b/OpenSim/Services/Interfaces/IAvatarService.cs @@ -51,7 +51,7 @@ namespace OpenSim.Services.Interfaces /// /// bool SetAppearance(UUID userID, AvatarAppearance appearance); - + /// /// Called by the login service /// @@ -75,7 +75,7 @@ namespace OpenSim.Services.Interfaces bool ResetAvatar(UUID userID); /// - /// These methods raison d'etre: + /// These methods raison d'etre: /// No need to send the entire avatar data (SetAvatar) for changing attachments /// /// @@ -150,7 +150,8 @@ namespace OpenSim.Services.Interfaces // Wearables Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); - for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++) + // TODO: With COF, is this even needed? + for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++) { for (int j = 0 ; j < appearance.Wearables[i].Count ; j++) { @@ -211,8 +212,8 @@ namespace OpenSim.Services.Interfaces float h = float.Parse(Data["AvatarHeight"]); if( h == 0f) h = 1.9f; - - appearance.AvatarHeight = h; + appearance.SetSize(new Vector3(0.45f, 0.6f, h )); +// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); } // Legacy Wearables @@ -287,12 +288,11 @@ namespace OpenSim.Services.Interfaces //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT]; //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++) - byte[] binary = new byte[vps.Length]; for (int i = 0; i < vps.Length; i++) binary[i] = (byte)Convert.ToInt32(vps[i]); - + appearance.VisualParams = binary; } @@ -357,6 +357,7 @@ namespace OpenSim.Services.Interfaces appearance.Wearables[AvatarWearable.EYES].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.EYES][0]); + } catch { diff --git a/OpenSim/Services/Interfaces/IEstateDataService.cs b/OpenSim/Services/Interfaces/IEstateDataService.cs index 719563d..9b64a39 100644 --- a/OpenSim/Services/Interfaces/IEstateDataService.cs +++ b/OpenSim/Services/Interfaces/IEstateDataService.cs @@ -39,14 +39,14 @@ namespace OpenSim.Services.Interfaces /// /// /// If true, then an estate is created if one is not found. - /// + /// EstateSettings LoadEstateSettings(UUID regionID, bool create); - + /// /// Load estate settings for an estate ID. /// /// - /// + /// EstateSettings LoadEstateSettings(int estateID); /// @@ -56,60 +56,60 @@ namespace OpenSim.Services.Interfaces /// A /// EstateSettings CreateNewEstate(); - + /// /// Load/Get all estate settings. /// /// An empty list if no estates were found. List LoadEstateSettingsAll(); - + /// /// Store estate settings. /// /// /// This is also called by EstateSettings.Save() - /// + /// void StoreEstateSettings(EstateSettings es); - + /// /// Get estate IDs. /// /// Name of estate to search for. This is the exact name, no parttern matching is done. - /// + /// List GetEstates(string search); - + /// /// Get the IDs of all estates owned by the given user. /// /// An empty list if no estates were found. - List GetEstatesByOwner(UUID ownerID); - + List GetEstatesByOwner(UUID ownerID); + /// /// Get the IDs of all estates. /// /// An empty list if no estates were found. List GetEstatesAll(); - + /// /// Link a region to an estate. /// /// /// - /// true if the link succeeded, false otherwise + /// true if the link succeeded, false otherwise bool LinkRegion(UUID regionID, int estateID); - + /// /// Get the UUIDs of all the regions in an estate. /// /// - /// + /// List GetRegions(int estateID); - + /// /// Delete an estate /// /// - /// true if the delete succeeded, false otherwise + /// true if the delete succeeded, false otherwise bool DeleteEstate(int estateID); } } \ No newline at end of file diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index f5f1f75..ead5d3c 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -85,7 +85,7 @@ namespace OpenSim.Services.Interfaces GridRegion GetRegionByName(UUID scopeID, string regionName); /// - /// Get information about regions starting with the provided name. + /// Get information about regions starting with the provided name. /// /// /// The name to match against. @@ -95,7 +95,7 @@ namespace OpenSim.Services.Interfaces /// /// /// A list of s of regions with matching name. If the - /// grid-server couldn't be contacted or returned an error, return null. + /// grid-server couldn't be contacted or returned an error, return null. /// List GetRegionsByName(UUID scopeID, string name, int maxNumber); @@ -139,7 +139,7 @@ namespace OpenSim.Services.Interfaces #pragma warning restore 414 /// - /// The port by which http communication occurs with the region + /// The port by which http communication occurs with the region /// public uint HttpPort { get; set; } @@ -148,7 +148,7 @@ namespace OpenSim.Services.Interfaces /// public string ServerURI { - get { + get { if (!String.IsNullOrEmpty(m_serverURI)) { return m_serverURI; } else { @@ -158,14 +158,25 @@ namespace OpenSim.Services.Interfaces return "http://" + m_externalHostName + ":" + HttpPort + "/"; } } - set { - if (value.EndsWith("/")) { + set { + if ( value == null) + { + m_serverURI = String.Empty; + return; + } + + if ( value.EndsWith("/") ) + { + m_serverURI = value; - } else { + } + else + { m_serverURI = value + '/'; } } } + protected string m_serverURI; /// @@ -260,31 +271,6 @@ namespace OpenSim.Services.Interfaces m_serverURI = string.Empty; } - /* - public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) - { - m_regionLocX = regionLocX; - m_regionLocY = regionLocY; - RegionSizeX = (int)Constants.RegionSize; - RegionSizeY = (int)Constants.RegionSize; - - m_internalEndPoint = internalEndPoint; - m_externalHostName = externalUri; - } - - public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) - { - m_regionLocX = regionLocX; - m_regionLocY = regionLocY; - RegionSizeX = (int)Constants.RegionSize; - RegionSizeY = (int)Constants.RegionSize; - - m_externalHostName = externalUri; - - m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); - } - */ - public GridRegion(uint xcell, uint ycell) { m_regionLocX = (int)Util.RegionToWorldLoc(xcell); @@ -333,7 +319,7 @@ namespace OpenSim.Services.Interfaces RegionSecret = ConvertFrom.RegionSecret; EstateOwner = ConvertFrom.EstateOwner; } - + public GridRegion(Dictionary kvp) { if (kvp.ContainsKey("uuid")) @@ -358,6 +344,13 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("regionName")) RegionName = (string)kvp["regionName"]; + if (kvp.ContainsKey("access")) + { + byte access = Convert.ToByte((string)kvp["access"]); + Access = access; + Maturity = (int)Util.ConvertAccessLevelToMaturity(access); + } + if (kvp.ContainsKey("flags") && kvp["flags"] != null) RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]); @@ -394,9 +387,6 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("parcelMapTexture")) UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage); - if (kvp.ContainsKey("access")) - Access = Byte.Parse((string)kvp["access"]); - if (kvp.ContainsKey("regionSecret")) RegionSecret =(string)kvp["regionSecret"]; @@ -409,7 +399,7 @@ namespace OpenSim.Services.Interfaces // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>", // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY); } - + public Dictionary ToKeyValuePairs() { Dictionary kvp = new Dictionary(); @@ -472,41 +462,7 @@ namespace OpenSim.Services.Interfaces /// public IPEndPoint ExternalEndPoint { - get - { - // Old one defaults to IPv6 - //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); - - IPAddress ia = null; - // If it is already an IP, don't resolve it - just return directly - if (IPAddress.TryParse(m_externalHostName, out ia)) - return new IPEndPoint(ia, m_internalEndPoint.Port); - - // Reset for next check - ia = null; - try - { - foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) - { - if (ia == null) - ia = Adr; - - if (Adr.AddressFamily == AddressFamily.InterNetwork) - { - ia = Adr; - break; - } - } - } - catch (SocketException e) - { - throw new Exception( - "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + - e + "' attached to this exception", e); - } - - return new IPEndPoint(ia, m_internalEndPoint.Port); - } + get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); } } public string ExternalHostName @@ -526,4 +482,4 @@ namespace OpenSim.Services.Interfaces get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs index 2e7237e..6ad0f42 100644 --- a/OpenSim/Services/Interfaces/IGridUserService.cs +++ b/OpenSim/Services/Interfaces/IGridUserService.cs @@ -37,7 +37,7 @@ namespace OpenSim.Services.Interfaces public class GridUserInfo { public string UserID; - + public UUID HomeRegionID; public Vector3 HomePosition; public Vector3 HomeLookAt; @@ -45,13 +45,13 @@ namespace OpenSim.Services.Interfaces public UUID LastRegionID; public Vector3 LastPosition; public Vector3 LastLookAt; - + public bool Online; public DateTime Login; public DateTime Logout; public GridUserInfo() {} - + public GridUserInfo(Dictionary kvp) { if (kvp.ContainsKey("UserID")) @@ -96,11 +96,11 @@ namespace OpenSim.Services.Interfaces result["Online"] = Online.ToString(); result["Login"] = Login.ToString(); result["Logout"] = Logout.ToString(); - + return result; } } - + public interface IGridUserService { GridUserInfo LoggedIn(string userID); @@ -115,7 +115,7 @@ namespace OpenSim.Services.Interfaces /// Last normalized look direction for the user /// True if the logout request was successfully processed, otherwise false bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); - + bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt); /// @@ -128,7 +128,7 @@ namespace OpenSim.Services.Interfaces /// Normalized look direction /// True if the user's last position was successfully updated, otherwise false bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); - + GridUserInfo GetGridUserInfo(string userID); GridUserInfo[] GetGridUserInfo(string[] userID); } diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 5e012fb..e0a63ca 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -36,8 +36,8 @@ namespace OpenSim.Services.Interfaces { public interface IGatekeeperService { - bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason); - + bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY); + /// /// Returns the region a Hypergrid visitor should enter. /// @@ -59,7 +59,7 @@ namespace OpenSim.Services.Interfaces public interface IUserAgentService { bool LoginAgentToGrid(GridRegion source, AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason); - + void LogoutAgent(UUID userID, UUID sessionID); /// @@ -89,7 +89,7 @@ namespace OpenSim.Services.Interfaces /// On success: the user's Server URLs. If the user doesn't exist: "". /// Throws an exception if an error occurs (e.g., can't contact the server). string LocateUser(UUID userID); - + /// /// Returns the Universal User Identifier for 'targetUserID' on behalf of 'userID'. /// diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 4289bba..582ea90 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -84,7 +84,7 @@ namespace OpenSim.Services.Interfaces /// /// Inventory content. InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs); - + /// /// Gets the items inside a folder /// @@ -161,7 +161,7 @@ namespace OpenSim.Services.Interfaces /// /// /// null if no item was found, otherwise the found item - InventoryItemBase GetItem(InventoryItemBase item); + InventoryItemBase GetItem(UUID userID, UUID itemID); /// /// Get multiple items, given by their UUIDs @@ -175,7 +175,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - InventoryFolderBase GetFolder(InventoryFolderBase folder); + InventoryFolderBase GetFolder(UUID userID, UUID folderID); /// /// Does the given user have an inventory structure? @@ -193,11 +193,11 @@ namespace OpenSim.Services.Interfaces /// /// Get the union of permissions of all inventory items - /// that hold the given assetID. + /// that hold the given assetID. /// /// /// - /// The permissions or 0 if no such asset is found in + /// The permissions or 0 if no such asset is found in /// the user's inventory int GetAssetPermissions(UUID userID, UUID assetID); } diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs index ee9b0b1..7c44cd8 100644 --- a/OpenSim/Services/Interfaces/ILoginService.cs +++ b/OpenSim/Services/Interfaces/ILoginService.cs @@ -47,8 +47,8 @@ namespace OpenSim.Services.Interfaces public interface ILoginService { - LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, - string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP); + LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, + string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient); Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP); } diff --git a/OpenSim/Services/Interfaces/IMapImageService.cs b/OpenSim/Services/Interfaces/IMapImageService.cs index 78daa5f..b8d45dd 100644 --- a/OpenSim/Services/Interfaces/IMapImageService.cs +++ b/OpenSim/Services/Interfaces/IMapImageService.cs @@ -34,8 +34,8 @@ namespace OpenSim.Services.Interfaces public interface IMapImageService { //List GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY); - bool AddMapTile(int x, int y, byte[] imageData, out string reason); - bool RemoveMapTile(int x, int y, out string reason); - byte[] GetMapTile(string fileName, out string format); + bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason); + bool RemoveMapTile(int x, int y, UUID scopeID, out string reason); + byte[] GetMapTile(string fileName, UUID scopeID, out string format); } } diff --git a/OpenSim/Services/Interfaces/IMuteLIstService.cs b/OpenSim/Services/Interfaces/IMuteLIstService.cs new file mode 100644 index 0000000..9ffd47f --- /dev/null +++ b/OpenSim/Services/Interfaces/IMuteLIstService.cs @@ -0,0 +1,41 @@ +/* + * 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 OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Services.Interfaces +{ + public interface IMuteListService + { + Byte[] MuteListRequest(UUID agent, uint crc); + bool UpdateMute(MuteData mute); + bool RemoveMute(UUID agentID, UUID muteID, string muteName); + } +} \ No newline at end of file diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs index 588aaaf..db501fd 100644 --- a/OpenSim/Services/Interfaces/IOfflineIMService.cs +++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs @@ -35,9 +35,9 @@ namespace OpenSim.Services.Interfaces public interface IOfflineIMService { List GetMessages(UUID principalID); - + bool StoreMessage(GridInstantMessage im, out string reason); - + /// /// Delete messages to or from this user (or group). /// diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 8a25509..a01897a 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -34,20 +34,6 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Services.Interfaces { - public class EntityTransferContext - { - public EntityTransferContext() - { - InboundVersion = VersionInfo.SimulationServiceVersionAcceptedMax; - OutboundVersion = VersionInfo.SimulationServiceVersionSupportedMax; - VariableWearablesSupported = false; - } - - public float InboundVersion { get; set; } - public float OutboundVersion { get; set; } - public bool VariableWearablesSupported { get; set; } - } - public interface ISimulationService { /// @@ -73,8 +59,8 @@ namespace OpenSim.Services.Interfaces /// /// /// - /// Reason message in the event of a failure. - bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); + /// Reason message in the event of a failure. + bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason); /// /// Full child agent update. @@ -82,7 +68,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - bool UpdateAgent(GridRegion destination, AgentData data); + bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx); /// /// Short child agent update, mostly for position. @@ -100,6 +86,7 @@ namespace OpenSim.Services.Interfaces /// The visitor's Home URI. Will be missing (null) in older OpenSims. /// True: via teleport; False: via cross (walking) /// Position in the region + /// /// Version that the requesting simulator is runing. If null then no version check is carried out. /// diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index 2f7702c..c6f3ef3 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -91,6 +91,7 @@ namespace OpenSim.Services.Interfaces public int UserLevel; public int UserFlags; public string UserTitle; + public string UserCountry; public Boolean LocalToGrid = true; public Dictionary ServiceURLs; @@ -120,6 +121,8 @@ namespace OpenSim.Services.Interfaces UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); if (kvp.ContainsKey("UserTitle")) UserTitle = kvp["UserTitle"].ToString(); + if (kvp.ContainsKey("UserCountry")) + UserCountry = kvp["UserCountry"].ToString(); if (kvp.ContainsKey("LocalToGrid")) Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid); @@ -155,6 +158,7 @@ namespace OpenSim.Services.Interfaces result["UserLevel"] = UserLevel.ToString(); result["UserFlags"] = UserFlags.ToString(); result["UserTitle"] = UserTitle; + result["UserCountry"] = UserCountry; result["LocalToGrid"] = LocalToGrid.ToString(); string str = string.Empty; @@ -182,6 +186,8 @@ namespace OpenSim.Services.Interfaces /// /// List GetUserAccounts(UUID scopeID, string query); + List GetUserAccountsWhere(UUID scopeID, string where); + List GetUserAccounts(UUID scopeID, List IDs); /// /// Store the data given, wich replaces the stored data, therefore must be complete. diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs index 9e560d5..91b344e 100644 --- a/OpenSim/Services/Interfaces/IUserManagement.cs +++ b/OpenSim/Services/Interfaces/IUserManagement.cs @@ -42,6 +42,7 @@ namespace OpenSim.Services.Interfaces string GetUserUUI(UUID uuid); bool GetUserUUI(UUID userID, out string uui); string GetUserServerURL(UUID uuid, string serverType); + Dictionary GetUsersNames(string[] ids); /// /// Get user ID by the given name. @@ -78,7 +79,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - void AddUser(UUID uuid, string firstName, string lastName); + void AddUser(UUID uuid, string first, string last, bool isNPC = false); /// /// Add a user. diff --git a/OpenSim/Services/Interfaces/IUserProfilesService.cs b/OpenSim/Services/Interfaces/IUserProfilesService.cs index 121baa8..867c623 100644 --- a/OpenSim/Services/Interfaces/IUserProfilesService.cs +++ b/OpenSim/Services/Interfaces/IUserProfilesService.cs @@ -40,19 +40,19 @@ namespace OpenSim.Services.Interfaces bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result); bool ClassifiedDelete(UUID recordId); #endregion Classifieds - + #region Picks OSD AvatarPicksRequest(UUID creatorId); bool PickInfoRequest(ref UserProfilePick pick, ref string result); bool PicksUpdate(ref UserProfilePick pick, ref string result); bool PicksDelete(UUID pickId); #endregion Picks - + #region Notes bool AvatarNotesRequest(ref UserProfileNotes note); bool NotesUpdate(ref UserProfileNotes note, ref string result); #endregion Notes - + #region Profile Properties bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result); bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result); @@ -62,7 +62,7 @@ namespace OpenSim.Services.Interfaces bool UserPreferencesRequest(ref UserPreferences pref, ref string result); bool UserPreferencesUpdate(ref UserPreferences pref, ref string result); #endregion User Preferences - + #region Interests bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result); #endregion Interests diff --git a/OpenSim/Services/Interfaces/OpenProfileClient.cs b/OpenSim/Services/Interfaces/OpenProfileClient.cs index bda8151..8c4d14b 100644 --- a/OpenSim/Services/Interfaces/OpenProfileClient.cs +++ b/OpenSim/Services/Interfaces/OpenProfileClient.cs @@ -49,7 +49,7 @@ namespace OpenSim.Services.UserProfilesService public class OpenProfileClient { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private string m_serverURI; /// @@ -60,7 +60,7 @@ namespace OpenSim.Services.UserProfilesService { m_serverURI = serverURI; } - + /// /// Gets an avatar's profile using the OpenProfile protocol. /// diff --git a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs b/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs index 01cafbf..6c683b4 100644 --- a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.Interfaces")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs index ec89097..2e3fb3e 100644 --- a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.InventoryService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs index 9e3fa69..2e4637c 100644 --- a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs +++ b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs @@ -47,7 +47,7 @@ namespace OpenSim.Services.InventoryService.Tests { private IInventoryService CreateXInventoryService() { - IConfigSource config = new IniConfigSource(); + IConfigSource config = new IniConfigSource(); config.AddConfig("InventoryService"); config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); @@ -73,25 +73,24 @@ namespace OpenSim.Services.InventoryService.Tests UUID folderId = TestHelpers.ParseTail(0x30); int invType = (int)InventoryType.Animation; int assetType = (int)AssetType.Animation; - string itemName = "item1"; + string itemName = "item1"; IInventoryService xis = CreateXInventoryService(); - InventoryItemBase itemToStore - = new InventoryItemBase(itemId, ownerId) - { - CreatorIdentification = creatorId.ToString(), - AssetID = assetId, - Name = itemName, - Folder = folderId, - InvType = invType, - AssetType = assetType + InventoryItemBase itemToStore + = new InventoryItemBase(itemId, ownerId) + { + CreatorIdentification = creatorId.ToString(), + AssetID = assetId, + Name = itemName, + Folder = folderId, + InvType = invType, + AssetType = assetType }; Assert.That(xis.AddItem(itemToStore), Is.True); - InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); - itemRetrieved = xis.GetItem(itemRetrieved); + InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); @@ -116,20 +115,20 @@ namespace OpenSim.Services.InventoryService.Tests UUID folderId = TestHelpers.ParseTail(0x30); int invType = (int)InventoryType.Animation; int assetType = (int)AssetType.Animation; - string itemName = "item1"; + string itemName = "item1"; string itemName2 = "item2"; IInventoryService xis = CreateXInventoryService(); - InventoryItemBase itemToStore - = new InventoryItemBase(itemId, ownerId) - { - CreatorIdentification = creatorId.ToString(), - AssetID = assetId, - Name = itemName, - Folder = folderId, - InvType = invType, - AssetType = assetType + InventoryItemBase itemToStore + = new InventoryItemBase(itemId, ownerId) + { + CreatorIdentification = creatorId.ToString(), + AssetID = assetId, + Name = itemName, + Folder = folderId, + InvType = invType, + AssetType = assetType }; Assert.That(xis.AddItem(itemToStore), Is.True); @@ -139,8 +138,7 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(xis.UpdateItem(itemToStore), Is.True); - InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); - itemRetrieved = xis.GetItem(itemRetrieved); + InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); @@ -151,7 +149,7 @@ namespace OpenSim.Services.InventoryService.Tests UUID folderId2 = TestHelpers.ParseTail(0x70); int invType2 = (int)InventoryType.CallingCard; int assetType2 = (int)AssetType.CallingCard; - string itemName3 = "item3"; + string itemName3 = "item3"; itemToStore.CreatorIdentification = creatorId2.ToString(); itemToStore.Owner = ownerId2; @@ -162,7 +160,7 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(xis.UpdateItem(itemToStore), Is.True); - itemRetrieved = xis.GetItem(itemRetrieved); + itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); @@ -174,4 +172,4 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index b75193f..b8ed46c 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -176,7 +176,7 @@ namespace OpenSim.Services.InventoryService protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID) { // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); - + XInventoryFolder[] allFolders = m_Database.GetFolders( new string[] { "agentID", "parentFolderID" }, new string[] { principalID.ToString(), rootID.ToString() }); @@ -192,7 +192,7 @@ namespace OpenSim.Services.InventoryService // m_log.DebugFormat( // "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID); - + return sysFolders; } @@ -234,7 +234,7 @@ namespace OpenSim.Services.InventoryService break; } } - + if (root == null) // oops root = folders[0]; @@ -255,7 +255,7 @@ namespace OpenSim.Services.InventoryService return null; } - + return GetSystemFolderForType(rootFolder, type); } @@ -315,8 +315,7 @@ namespace OpenSim.Services.InventoryService inventory.Items.Add(ConvertToOpenSim(i)); } - InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); - f = GetFolder(f); + InventoryFolderBase f = GetFolder(principalID, folderID); if (f != null) { inventory.Version = f.Version; @@ -336,11 +335,11 @@ namespace OpenSim.Services.InventoryService return multiple; } - + public virtual List GetFolderItems(UUID principalID, UUID folderID) { // m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID); - + // Since we probably don't get a valid principal here, either ... // List invItems = new List(); @@ -359,7 +358,7 @@ namespace OpenSim.Services.InventoryService { // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); - InventoryFolderBase check = GetFolder(folder); + InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); if (check != null) return false; @@ -387,7 +386,7 @@ namespace OpenSim.Services.InventoryService m_log.WarnFormat( "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}", folder.Type, folder.Name, folder.ParentID, folder.Owner); - + return false; } } @@ -402,7 +401,7 @@ namespace OpenSim.Services.InventoryService // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); XInventoryFolder xFolder = ConvertFromOpenSim(folder); - InventoryFolderBase check = GetFolder(folder); + InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); if (check == null) return AddFolder(folder); @@ -499,7 +498,7 @@ namespace OpenSim.Services.InventoryService { // m_log.DebugFormat( // "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner); - + return m_Database.StoreItem(ConvertFromOpenSim(item)); } @@ -512,32 +511,32 @@ namespace OpenSim.Services.InventoryService // m_log.InfoFormat( // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - InventoryItemBase retrievedItem = GetItem(item); + InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID); if (retrievedItem == null) { m_log.WarnFormat( - "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.", + "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.", item.Name, item.ID, item.Owner); return false; } // Do not allow invariants to change. Changes to folder ID occur in MoveItems() - if (retrievedItem.InvType != item.InvType + if (retrievedItem.InvType != item.InvType || retrievedItem.AssetType != item.AssetType - || retrievedItem.Folder != item.Folder - || retrievedItem.CreatorIdentification != item.CreatorIdentification + || retrievedItem.Folder != item.Folder + || retrievedItem.CreatorIdentification != item.CreatorIdentification || retrievedItem.Owner != item.Owner) { m_log.WarnFormat( "[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})", - retrievedItem.Name, - retrievedItem.ID, - retrievedItem.InvType, - retrievedItem.AssetType, - retrievedItem.Folder, - retrievedItem.CreatorIdentification, + retrievedItem.Name, + retrievedItem.ID, + retrievedItem.InvType, + retrievedItem.AssetType, + retrievedItem.Folder, + retrievedItem.CreatorIdentification, retrievedItem.Owner, item.InvType, item.AssetType, @@ -598,11 +597,11 @@ namespace OpenSim.Services.InventoryService return true; } - public virtual InventoryItemBase GetItem(InventoryItemBase item) + public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) { XInventoryItem[] items = m_Database.GetItems( new string[] { "inventoryID" }, - new string[] { item.ID.ToString() }); + new string[] { itemID.ToString() }); if (items.Length == 0) return null; @@ -614,22 +613,17 @@ namespace OpenSim.Services.InventoryService { InventoryItemBase[] items = new InventoryItemBase[ids.Length]; int i = 0; - InventoryItemBase item = new InventoryItemBase(); - item.Owner = userID; foreach (UUID id in ids) - { - item.ID = id; - items[i++] = GetItem(item); - } + items[i++] = GetItem(userID, id); return items; } - public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) + public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "folderID"}, - new string[] { folder.ID.ToString() }); + new string[] { folderID.ToString() }); if (folders.Length == 0) return null; @@ -645,7 +639,7 @@ namespace OpenSim.Services.InventoryService return new List(); List ret = new List(); - + foreach (XInventoryItem x in items) ret.Add(ConvertToOpenSim(x)); diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index c3756d0..823fd36 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -55,12 +55,13 @@ namespace OpenSim.Services.LLLoginService public static LLFailedLoginResponse InventoryProblem; public static LLFailedLoginResponse DeadRegionProblem; public static LLFailedLoginResponse LoginBlockedProblem; + public static LLFailedLoginResponse UnverifiedAccountProblem; public static LLFailedLoginResponse AlreadyLoggedInProblem; public static LLFailedLoginResponse InternalError; static LLFailedLoginResponse() { - UserProblem = new LLFailedLoginResponse("key", + UserProblem = new LLFailedLoginResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"); GridProblem = new LLFailedLoginResponse("key", @@ -75,11 +76,14 @@ namespace OpenSim.Services.LLLoginService LoginBlockedProblem = new LLFailedLoginResponse("presence", "Logins are currently restricted. Please try again later.", "false"); + UnverifiedAccountProblem = new LLFailedLoginResponse("presence", + "Your account has not yet been verified. Please check " + + "your email and click the provided link.", + "false"); AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", + "Please wait a a minute or two and retry. " + + "If this takes longer than a few minutes please contact the grid owner. ", "false"); InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); } @@ -145,6 +149,7 @@ namespace OpenSim.Services.LLLoginService private UUID agentID; private UUID sessionID; private UUID secureSessionID; + private UUID realID; // Login Flags private string dst; @@ -228,8 +233,9 @@ namespace OpenSim.Services.LLLoginService public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, GridRegion destination, List invSkel, FriendInfo[] friendsList, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List gestures, string message, - GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL, string currency, - string DSTZone, string destinationsURL, string avatarsURL, string classifiedFee, int maxAgentGroups) + + GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency, + string DSTZone, string destinationsURL, string avatarsURL, UUID realID, string classifiedFee,int maxAgentGroups) : this() { FillOutInventoryData(invSkel, libService); @@ -242,6 +248,7 @@ namespace OpenSim.Services.LLLoginService AgentID = account.PrincipalID; SessionID = aCircuit.SessionID; SecureSessionID = aCircuit.SecureSessionID; + RealID = realID; Message = message; BuddList = ConvertFriendListItem(friendsList); StartLocation = where; @@ -299,7 +306,7 @@ namespace OpenSim.Services.LLLoginService { DST = dstTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; } - + break; } } @@ -383,6 +390,7 @@ namespace OpenSim.Services.LLLoginService private void FillOutRegionData(GridRegion destination) { IPEndPoint endPoint = destination.ExternalEndPoint; + if (endPoint == null) return; SimAddress = endPoint.Address.ToString(); SimPort = (uint)endPoint.Port; RegionX = (uint)destination.RegionLocX; @@ -408,7 +416,7 @@ namespace OpenSim.Services.LLLoginService // try // { // // First try to fetch DST from Pacific Standard Time, because this is -// // the one expected by the viewer. "US/Pacific" is the string to search +// // the one expected by the viewer. "US/Pacific" is the string to search // // on linux and mac, and should work also on Windows (to confirm) // gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific"); // } @@ -438,7 +446,7 @@ namespace OpenSim.Services.LLLoginService ErrorReason = "key"; welcomeMessage = "Welcome to OpenSim!"; seedCapability = String.Empty; - home = "{'region_handle':[" + home = "{'region_handle':[" + "r" + Util.RegionToWorldLoc(1000).ToString() + "," + "r" + Util.RegionToWorldLoc(1000).ToString() @@ -473,6 +481,7 @@ namespace OpenSim.Services.LLLoginService SessionID = UUID.Random(); SecureSessionID = UUID.Random(); AgentID = UUID.Random(); + RealID = UUID.Zero; Hashtable InitialOutfitHash = new Hashtable(); InitialOutfitHash["folder_name"] = "Nightclub Female"; @@ -518,6 +527,7 @@ namespace OpenSim.Services.LLLoginService responseData["http_port"] = (Int32)SimHttpPort; responseData["agent_id"] = AgentID.ToString(); + responseData["real_id"] = RealID.ToString(); responseData["session_id"] = SessionID.ToString(); responseData["secure_session_id"] = SecureSessionID.ToString(); responseData["circuit_code"] = CircuitCode; @@ -582,7 +592,7 @@ namespace OpenSim.Services.LLLoginService // responseData["real_currency"] = currency; responseData["currency"] = currency; } - + if (ClassifiedFee != String.Empty) responseData["classified_fee"] = ClassifiedFee; @@ -613,6 +623,7 @@ namespace OpenSim.Services.LLLoginService map["sim_ip"] = OSD.FromString(SimAddress); map["agent_id"] = OSD.FromUUID(AgentID); + map["real_id"] = OSD.FromUUID(RealID); map["session_id"] = OSD.FromUUID(SessionID); map["secure_session_id"] = OSD.FromUUID(SecureSessionID); map["circuit_code"] = OSD.FromInteger(CircuitCode); @@ -924,6 +935,12 @@ namespace OpenSim.Services.LLLoginService set { secureSessionID = value; } } + public UUID RealID + { + get { return realID; } + set { realID = value; } + } + public Int32 CircuitCode { get { return circuitCode; } @@ -1052,7 +1069,7 @@ namespace OpenSim.Services.LLLoginService get { return activeGestures; } set { activeGestures = value; } } - + public string Home { get { return home; } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 0b38738..3ccdc9c 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -40,6 +40,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Server.Base; +using OpenSim.Services.Connectors.InstantMessage; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; @@ -77,16 +78,19 @@ namespace OpenSim.Services.LLLoginService protected string m_GatekeeperURL; protected bool m_AllowRemoteSetLoginLevel; protected string m_MapTileURL; + protected string m_ProfileURL; + protected string m_OpenIDURL; protected string m_SearchURL; protected string m_Currency; protected string m_ClassifiedFee; - protected int m_MaxAgentGroups; + protected int m_MaxAgentGroups = 42; protected string m_DestinationGuide; protected string m_AvatarPicker; protected string m_AllowedClients; protected string m_DeniedClients; protected string m_MessageUrl; protected string m_DSTZone; + protected bool m_allowDuplicatePresences = false; IConfig m_LoginServerConfig; // IConfig m_ClientsConfig; @@ -117,6 +121,8 @@ namespace OpenSim.Services.LLLoginService m_GatekeeperURL = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty); m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); + m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); + m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty); m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty); @@ -127,7 +133,7 @@ namespace OpenSim.Services.LLLoginService m_AllowedClients = Util.GetConfigVarFromSections( config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); m_DeniedClients = Util.GetConfigVarFromSections( - config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); + config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty); m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); @@ -136,6 +142,11 @@ namespace OpenSim.Services.LLLoginService if (groupConfig != null) m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); + IConfig presenceConfig = config.Configs["PresenceService"]; + if (presenceConfig != null) + { + m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); + } // Clean up some of these vars if (m_MapTileURL != String.Empty) @@ -155,7 +166,8 @@ namespace OpenSim.Services.LLLoginService Object[] args = new Object[] { config }; m_UserAccountService = ServerUtils.LoadPlugin(accountService, args); m_GridUserService = ServerUtils.LoadPlugin(gridUserService, args); - m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); + Object[] authArgs = new Object[] { config, m_UserAccountService }; + m_AuthenticationService = ServerUtils.LoadPlugin(authService, authArgs); m_InventoryService = ServerUtils.LoadPlugin(invService, args); if (gridService != string.Empty) @@ -175,9 +187,14 @@ namespace OpenSim.Services.LLLoginService string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty); if (hgInvServicePlugin != string.Empty) { + // TODO: Remove HGInventoryServiceConstructorArg after 0.9 release string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty); - Object[] args2 = new Object[] { config, hgInvServiceArg }; - m_HGInventoryService = ServerUtils.LoadPlugin(hgInvServicePlugin, args2); + if (hgInvServiceArg != String.Empty) + { + m_log.Warn("[LLOGIN SERVICE]: You are using HGInventoryServiceConstructorArg, which is deprecated. See example file for correct syntax."); + hgInvServicePlugin = hgInvServiceArg + "@" + hgInvServicePlugin; + } + m_HGInventoryService = ServerUtils.LoadPlugin(hgInvServicePlugin, args); } // @@ -260,16 +277,20 @@ namespace OpenSim.Services.LLLoginService return response; } - public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, - string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) + public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, + string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient) { bool success = false; UUID session = UUID.Random(); + string processedMessage; - m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}", - firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0); - + if (clientVersion.Contains("Radegast")) + LibOMVclient = false; + + m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}, Possible LibOMVGridProxy: {8} ", + firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString()); + try { // @@ -345,7 +366,8 @@ namespace OpenSim.Services.LLLoginService if (!passwd.StartsWith("$1$")) passwd = "$1$" + Util.Md5Hash(passwd); passwd = passwd.Remove(0, 3); //remove $1$ - string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); + UUID realID; + string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID); UUID secureSession = UUID.Zero; if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) { @@ -355,6 +377,29 @@ namespace OpenSim.Services.LLLoginService return LLFailedLoginResponse.UserProblem; } + if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e")) + { + // really? + return LLFailedLoginResponse.UserProblem; + } + + string PrincipalIDstr = account.PrincipalID.ToString(); + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr); + + if(!m_allowDuplicatePresences) + { + if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) + { + if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo)) + { + m_log.InfoFormat( + "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in", + firstName, lastName); + return LLFailedLoginResponse.AlreadyLoggedInProblem; + } + } + } + // // Get the user's inventory // @@ -391,7 +436,7 @@ namespace OpenSim.Services.LLLoginService // if (m_PresenceService != null) { - success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); + success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession); if (!success) { @@ -406,7 +451,6 @@ namespace OpenSim.Services.LLLoginService // Change Online status and get the home region // GridRegion home = null; - GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString()); // We are only going to complain about no home if the user actually tries to login there, to avoid // spamming the console. @@ -437,7 +481,7 @@ namespace OpenSim.Services.LLLoginService guinfo = new GridUserInfo(); guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); } - + // // Find the destination region/grid // @@ -479,7 +523,7 @@ namespace OpenSim.Services.LLLoginService // string reason = string.Empty; GridRegion dest; - AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, + AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest); destination = dest; if (aCircuit == null) @@ -489,7 +533,11 @@ namespace OpenSim.Services.LLLoginService return new LLFailedLoginResponse("key", reason, "false"); } - // Get Friends list + + // only now we can assume a login + guinfo = m_GridUserService.LoggedIn(PrincipalIDstr); + + // Get Friends list FriendInfo[] friendsList = new FriendInfo[0]; if (m_FriendsService != null) { @@ -502,8 +550,8 @@ namespace OpenSim.Services.LLLoginService // if (m_MessageUrl != String.Empty) { - WebClient client = new WebClient(); - processedMessage = client.DownloadString(m_MessageUrl); + using(WebClient client = new WebClient()) + processedMessage = client.DownloadString(m_MessageUrl); } else { @@ -512,11 +560,11 @@ namespace OpenSim.Services.LLLoginService processedMessage = processedMessage.Replace("\\n", "\n").Replace("", firstName + " " + lastName); LLLoginResponse response - = new LLLoginResponse( - account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, - where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, - m_MapTileURL, m_SearchURL, m_Currency, m_DSTZone, - m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee, m_MaxAgentGroups); + = new LLLoginResponse( + account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, + where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, + m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone, + m_DestinationGuide, m_AvatarPicker, realID, m_ClassifiedFee,m_MaxAgentGroups); m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); @@ -572,12 +620,13 @@ namespace OpenSim.Services.LLLoginService lookAt = pinfo.HomeLookAt; flags |= TeleportFlags.ViaHome; } - + if (tryDefaults) { List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { + flags |= TeleportFlags.ViaRegionID; region = defaults[0]; where = "safe"; } @@ -587,7 +636,10 @@ namespace OpenSim.Services.LLLoginService account.FirstName, account.LastName); region = FindAlternativeRegion(scopeID); if (region != null) + { + flags |= TeleportFlags.ViaRegionID; where = "safe"; + } } } @@ -608,6 +660,7 @@ namespace OpenSim.Services.LLLoginService List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { + flags |= TeleportFlags.ViaRegionID; region = defaults[0]; where = "safe"; } @@ -616,7 +669,10 @@ namespace OpenSim.Services.LLLoginService m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); region = FindAlternativeRegion(scopeID); if (region != null) + { + flags |= TeleportFlags.ViaRegionID; where = "safe"; + } } } @@ -625,7 +681,7 @@ namespace OpenSim.Services.LLLoginService position = pinfo.LastPosition; lookAt = pinfo.LastLookAt; } - + return region; } else @@ -661,7 +717,7 @@ namespace OpenSim.Services.LLLoginService regions = m_GridService.GetDefaultRegions(scopeID); if (regions != null && regions.Count > 0) { - where = "safe"; + where = "safe"; return regions[0]; } else @@ -696,7 +752,7 @@ namespace OpenSim.Services.LLLoginService return null; } // Valid specification of a remote grid - + regionName = parts[0]; string domainLocator = parts[1]; parts = domainLocator.Split(new char[] {':'}); @@ -714,7 +770,7 @@ namespace OpenSim.Services.LLLoginService List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { - where = "safe"; + where = "safe"; return defaults[0]; } else @@ -767,12 +823,15 @@ namespace OpenSim.Services.LLLoginService ulong handle; string imageURL = string.Empty, reason = string.Empty; string message; - if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) + int sizeX = (int)Constants.RegionSize; + int sizeY = (int)Constants.RegionSize; + + if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason, out sizeX, out sizeY)) { string homeURI = null; if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI")) homeURI = (string)account.ServiceURLs["HomeURI"]; - + GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message); return destination; } @@ -806,6 +865,9 @@ namespace OpenSim.Services.LLLoginService reason = string.Empty; uint circuitCode = 0; AgentCircuitData aCircuit = null; + dest = null; + + bool success = false; if (m_UserAgentService == null) { @@ -816,28 +878,14 @@ namespace OpenSim.Services.LLLoginService simConnector = m_LocalSimulationService; else if (m_RemoteSimulationService != null) simConnector = m_RemoteSimulationService; - } - else // User Agent Service is on - { - if (gatekeeper == null) // login to local grid - { - if (hostName == string.Empty) - SetHostAndPort(m_GatekeeperURL); - - gatekeeper = new GridRegion(destination); - gatekeeper.ExternalHostName = hostName; - gatekeeper.HttpPort = (uint)port; - gatekeeper.ServerURI = m_GatekeeperURL; - } - m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL); - } - bool success = false; + if(simConnector == null) + return null; - if (m_UserAgentService == null && simConnector != null) - { circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, + clientIP.Address.ToString(), viewer, channel, mac, id0); + success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); if (!success && m_GridService != null) { @@ -859,10 +907,22 @@ namespace OpenSim.Services.LLLoginService } } - if (m_UserAgentService != null) + else { + if (gatekeeper == null) // login to local grid + { + if (hostName == string.Empty) + SetHostAndPort(m_GatekeeperURL); + + gatekeeper = new GridRegion(destination); + gatekeeper.ExternalHostName = hostName; + gatekeeper.HttpPort = (uint)port; + gatekeeper.ServerURI = m_GatekeeperURL; + } circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, + clientIP.Address.ToString(), viewer, channel, mac, id0); + aCircuit.teleportFlags |= (uint)flags; success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); if (!success && m_GridService != null) @@ -891,8 +951,8 @@ namespace OpenSim.Services.LLLoginService return null; } - private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, - AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, + private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, + AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, string ipaddress, string viewer, string channel, string mac, string id0) { AgentCircuitData aCircuit = new AgentCircuitData(); @@ -930,7 +990,7 @@ namespace OpenSim.Services.LLLoginService if (account.ServiceURLs == null) return; - // Old style: get the service keys from the DB + // Old style: get the service keys from the DB foreach (KeyValuePair kvp in account.ServiceURLs) { if (kvp.Value != null) @@ -989,7 +1049,7 @@ namespace OpenSim.Services.LLLoginService region, aCircuit.AgentID, null, true, aCircuit.startpos, new List(), ctx, out reason)) return false; - return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, out reason); + return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, ctx, out reason); } private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) @@ -1027,7 +1087,7 @@ namespace OpenSim.Services.LLLoginService switch (subcommand) { case "level": - // Set the minimum level to allow login + // Set the minimum level to allow login // Useful to allow grid update without worrying about users. // or fixing critical issues // @@ -1040,8 +1100,8 @@ namespace OpenSim.Services.LLLoginService } break; - case "reset": - m_MinLoginLevel = 0; + case "reset": + m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel); break; @@ -1054,6 +1114,41 @@ namespace OpenSim.Services.LLLoginService break; } } + + private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo) + { + UUID regionID = guinfo.LastRegionID; + GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); + if(regInfo == null) + return false; + + string regURL = regInfo.ServerURI; + if(String.IsNullOrEmpty(regURL)) + return false; + + UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e"); + + GridInstantMessage msg = new GridInstantMessage(); + msg.imSessionID = UUID.Zero.Guid; + msg.fromAgentID = guuid.Guid; + msg.toAgentID = agentID.Guid; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = "GRID"; + msg.message = string.Format("New login detected"); + msg.dialog = 250; // God kick + msg.fromGroup = false; + msg.offline = (byte)0; + msg.ParentEstateID = 0; + msg.Position = Vector3.Zero; + msg.RegionID = scopeID.Guid; + msg.binaryBucket = new byte[1] {0}; + InstantMessageServiceConnector.SendInstantMessage(regURL,msg); + + m_GridUserService.LoggedOut(agentID.ToString(), + UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); + + return true; + } } #endregion diff --git a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs b/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs index 5c150e3..005ddd8 100644 --- a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.LLLoginService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index 6b4a91a..c90f5bd 100644 --- a/OpenSim/Services/MapImageService/MapImageService.cs +++ b/OpenSim/Services/MapImageService/MapImageService.cs @@ -23,8 +23,8 @@ * 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. - * - * The design of this map service is based on SimianGrid's PHP-based + * + * The design of this map service is based on SimianGrid's PHP-based * map service. See this URL for the original PHP version: * https://github.com/openmetaversefoundation/simiangrid/ */ @@ -69,6 +69,8 @@ namespace OpenSim.Services.MapImageService private static bool m_Initialized = false; private static string m_WaterTileFile = string.Empty; private static Color m_Watercolor = Color.FromArgb(29, 71, 95); + private static Bitmap m_WaterBitmap = null; + private static byte[] m_WaterBytes = null; public MapImageService(IConfigSource config) { @@ -80,7 +82,7 @@ namespace OpenSim.Services.MapImageService IConfig serviceConfig = config.Configs["MapImageService"]; if (serviceConfig != null) { - m_TilesStoragePath = "../caches/" + serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath); + m_TilesStoragePath = serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath); if (!Directory.Exists(m_TilesStoragePath)) Directory.CreateDirectory(m_TilesStoragePath); @@ -91,6 +93,18 @@ namespace OpenSim.Services.MapImageService Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH); FillImage(waterTile, m_Watercolor); waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg); + m_WaterBitmap = waterTile; + } + + if (File.Exists(m_WaterTileFile)) + { + m_WaterBitmap = new Bitmap(m_WaterTileFile); + using (MemoryStream ms = new MemoryStream()) + { + m_WaterBitmap.Save(ms,ImageFormat.Jpeg); + ms.Seek(0, SeekOrigin.Begin); + m_WaterBytes = ms.ToArray(); + } } } } @@ -98,10 +112,10 @@ namespace OpenSim.Services.MapImageService #region IMapImageService - public bool AddMapTile(int x, int y, byte[] imageData, out string reason) + public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason) { reason = string.Empty; - string fileName = GetFileName(1, x, y); + string fileName = GetFileName(1, x, y, scopeID); lock (m_Sync) { @@ -118,13 +132,13 @@ namespace OpenSim.Services.MapImageService } } - return UpdateMultiResolutionFilesAsync(x, y, out reason); + return UpdateMultiResolutionFiles(x, y, scopeID, out reason); } - public bool RemoveMapTile(int x, int y, out string reason) + public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) { reason = String.Empty; - string fileName = GetFileName(1, x, y); + string fileName = GetFileName(1, x, y, scopeID); lock (m_Sync) { @@ -134,15 +148,16 @@ namespace OpenSim.Services.MapImageService } catch (Exception e) { + m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e); reason = e.Message; return false; } } - - return UpdateMultiResolutionFilesAsync(x, y, out reason); + return UpdateMultiResolutionFiles(x, y, scopeID, out reason); } + // When large varregions start up, they can send piles of new map tiles. This causes // this multi-resolution routine to be called a zillion times an causes much CPU // time to be spent creating multi-resolution tiles that will be replaced when @@ -151,23 +166,27 @@ namespace OpenSim.Services.MapImageService { public int xx; public int yy; - public mapToMultiRez(int pX, int pY) + public UUID scopeID; + public mapToMultiRez(int pX, int pY, UUID pscopeID) { xx = pX; yy = pY; + scopeID = pscopeID; } }; private Queue multiRezToBuild = new Queue(); - private bool UpdateMultiResolutionFilesAsync(int x, int y, out string reason) + + private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID, out string reason) { reason = String.Empty; + lock (multiRezToBuild) { // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y); - multiRezToBuild.Enqueue(new mapToMultiRez(x, y)); + multiRezToBuild.Enqueue(new mapToMultiRez(x, y, scopeID)); if (multiRezToBuild.Count == 1) Util.FireAndForget( - DoUpdateMultiResolutionFilesAsync, null, "MapImageService.DoUpdateMultiResolutionFilesAsync"); + DoUpdateMultiResolutionFilesAsync); } return true; @@ -175,10 +194,8 @@ namespace OpenSim.Services.MapImageService private void DoUpdateMultiResolutionFilesAsync(object o) { - // This sleep causes the FireAndForget thread to be different than the invocation thread. - // It also allows other tiles to be uploaded so the multi-rez images are more likely - // to be correct. - Thread.Sleep(1 * 1000); + // let acumulate large region tiles + Thread.Sleep(60 * 1000); // large regions take time to upload tiles while (multiRezToBuild.Count > 0) { @@ -192,20 +209,23 @@ namespace OpenSim.Services.MapImageService { int x = toMultiRez.xx; int y = toMultiRez.yy; + UUID scopeID = toMultiRez.scopeID; // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y); + int width = 1; + // Stitch seven more aggregate tiles together for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++) { // Calculate the width (in full resolution tiles) and bottom-left // corner of the current zoom level - int width = (int)Math.Pow(2, (double)(zoomLevel - 1)); + width *= 2; int x1 = x - (x % width); int y1 = y - (y % width); lock (m_Sync) // must lock the reading and writing of the maptile files { - if (!CreateTile(zoomLevel, x1, y1)) + if (!CreateTile(zoomLevel, x1, y1, scopeID)) { m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); return; @@ -214,25 +234,25 @@ namespace OpenSim.Services.MapImageService } } } - return; } - public byte[] GetMapTile(string fileName, out string format) + public byte[] GetMapTile(string fileName, UUID scopeID, out string format) { // m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName); format = ".jpg"; - string fullName = Path.Combine(m_TilesStoragePath, fileName); + string fullName = Path.Combine(m_TilesStoragePath, scopeID.ToString()); + fullName = Path.Combine(fullName, fileName); if (File.Exists(fullName)) { format = Path.GetExtension(fileName).ToLower(); //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); return File.ReadAllBytes(fullName); } - else if (File.Exists(m_WaterTileFile)) + else if (m_WaterBytes != null) { - return File.ReadAllBytes(m_WaterTileFile); + return (byte[])m_WaterBytes.Clone(); } else { @@ -244,10 +264,12 @@ namespace OpenSim.Services.MapImageService #endregion - private string GetFileName(uint zoomLevel, int x, int y) + private string GetFileName(uint zoomLevel, int x, int y, UUID scopeID) { string extension = "jpg"; - return Path.Combine(m_TilesStoragePath, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); + string path = Path.Combine(m_TilesStoragePath, scopeID.ToString()); + Directory.CreateDirectory(path); + return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); } private Bitmap GetInputTileImage(string fileName) @@ -269,14 +291,14 @@ namespace OpenSim.Services.MapImageService { try { - if (File.Exists(fileName)) + if (File.Exists(fileName)) return new Bitmap(fileName); else { // Create a new output tile with a transparent background Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); - bm.MakeTransparent(); + //bm.MakeTransparent(); // 24bpp does not have transparency, this would make it 32bpp return bm; } } @@ -288,7 +310,7 @@ namespace OpenSim.Services.MapImageService return null; } - private bool CreateTile(uint zoomLevel, int x, int y) + private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID) { // m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); @@ -303,55 +325,60 @@ namespace OpenSim.Services.MapImageService int yOut = y - (y % thisWidth); // Try to open the four input tiles from the previous zoom level - Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn)); - Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn)); - Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth)); - Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth)); + Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn, scopeID)); + Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn, scopeID)); + Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth, scopeID)); + Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth, scopeID)); // Open the output tile (current zoom level) - string outputFile = GetFileName(zoomLevel, xOut, yOut); - Bitmap output = GetOutputTileImage(outputFile); - if (output == null) - return false; - FillImage(output, m_Watercolor); + string outputFile = GetFileName(zoomLevel, xOut, yOut, scopeID); + + int ntiles = 0; + Bitmap output = (Bitmap)m_WaterBitmap.Clone(); if (inputBL != null) { ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0); inputBL.Dispose(); + ntiles++; } if (inputBR != null) { ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0); inputBR.Dispose(); + ntiles++; } if (inputTL != null) { ImageCopyResampled(output, inputTL, 0, 0, 0, 0); inputTL.Dispose(); + ntiles++; } if (inputTR != null) { ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0); inputTR.Dispose(); + ntiles++; } // Write the modified output - try + if (ntiles == 0) + File.Delete(outputFile); + + else { - using (Bitmap final = new Bitmap(output)) + + try { - output.Dispose(); - final.Save(outputFile, ImageFormat.Jpeg); + output.Save(outputFile, ImageFormat.Jpeg); } - } - catch (Exception e) - { - m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e); - } - - // Save also as png? + catch (Exception e) + { + m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e); + } + } // Save also as png? + output.Dispose(); return true; } diff --git a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs b/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs index e779238..8f4b9b9 100644 --- a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.MapImageService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/MuteListService/MuteListService.cs b/OpenSim/Services/MuteListService/MuteListService.cs new file mode 100644 index 0000000..7e5ded1 --- /dev/null +++ b/OpenSim/Services/MuteListService/MuteListService.cs @@ -0,0 +1,127 @@ +/* + * 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.Text; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Services.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Data; +using OpenSim.Framework; + +namespace OpenSim.Services.EstateService +{ + public class MuteListService : ServiceBase, IMuteListService + { +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); + + protected IMuteListData m_database; + + public MuteListService(IConfigSource config) + : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + + // Try reading the [DatabaseService] section, if it exists + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + dllName = dbConfig.GetString("StorageProvider", String.Empty); + connString = dbConfig.GetString("ConnectionString", String.Empty); + connString = dbConfig.GetString("MuteConnectionString", connString); + } + + // Try reading the [MuteListStore] section, if it exists + IConfig muteConfig = config.Configs["MuteListStore"]; + if (muteConfig != null) + { + dllName = muteConfig.GetString("StorageProvider", dllName); + connString = muteConfig.GetString("ConnectionString", connString); + } + + // We tried, but this doesn't exist. We can't proceed + if (dllName == String.Empty) + throw new Exception("No StorageProvider configured"); + + m_database = LoadPlugin(dllName, new Object[] { connString }); + if (m_database == null) + throw new Exception("Could not find a storage interface in the given module"); + } + + public Byte[] MuteListRequest(UUID agentID, uint crc) + { + if(m_database == null) + return null; + + MuteData[] data = m_database.Get(agentID); + if (data == null || data.Length == 0) + return new Byte[0]; + + StringBuilder sb = new StringBuilder(16384); + foreach (MuteData d in data) + sb.AppendFormat("{0} {1} {2}|{3}\n", + d.MuteType, + d.MuteID.ToString(), + d.MuteName, + d.MuteFlags); + + Byte[] filedata = Util.UTF8.GetBytes(sb.ToString()); + + uint dataCrc = Crc32.Compute(filedata); + + if (dataCrc == crc) + { + if(crc == 0) + return new Byte[0]; + + Byte[] ret = new Byte[1] {1}; + return ret; + } + + return filedata; + } + + public bool UpdateMute(MuteData mute) + { + if(m_database == null) + return false; + return m_database.Store(mute); + } + + public bool RemoveMute(UUID agentID, UUID muteID, string muteName) + { + if(m_database == null) + return false; + return m_database.Delete(agentID, muteID, muteName); + } + } +} diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index b5ca4d5..ae92919 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -71,7 +71,7 @@ namespace OpenSim.Services.PresenceService data.SessionID = sessionID; data.Data = new Dictionary(); data.Data["SecureSessionID"] = secureSessionID.ToString(); - + m_Database.Store(data); string prevUserStr = ""; @@ -80,7 +80,7 @@ namespace OpenSim.Services.PresenceService m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}", data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr); - + return true; } @@ -88,11 +88,11 @@ namespace OpenSim.Services.PresenceService { PresenceInfo presence = GetAgent(sessionID); - m_log.InfoFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}", + m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}", sessionID, (presence == null) ? null : presence.UserID, (presence == null) ? null : presence.RegionID.ToString()); - + return m_Database.Delete("SessionID", sessionID.ToString()); } @@ -144,7 +144,7 @@ namespace OpenSim.Services.PresenceService public PresenceInfo GetAgent(UUID sessionID) { PresenceInfo ret = new PresenceInfo(); - + PresenceData data = m_Database.Get(sessionID); if (data == null) return null; diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs index a4adb2f..7647865 100644 --- a/OpenSim/Services/PresenceService/PresenceServiceBase.cs +++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.PresenceService connString = presenceConfig.GetString("ConnectionString", connString); realm = presenceConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs b/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs index 4fd21a8..a79bc9f 100644 --- a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.PresenceService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs index d9684c4..eef958a 100644 --- a/OpenSim/Services/SimulationService/SimulationDataService.cs +++ b/OpenSim/Services/SimulationService/SimulationDataService.cs @@ -104,6 +104,11 @@ namespace OpenSim.Services.SimulationService m_database.StoreTerrain(terrain, regionID); } + public void StoreBakedTerrain(TerrainData terrain, UUID regionID) + { + m_database.StoreBakedTerrain(terrain, regionID); + } + public void StoreTerrain(double[,] terrain, UUID regionID) { m_database.StoreTerrain(terrain, regionID); @@ -119,6 +124,11 @@ namespace OpenSim.Services.SimulationService return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); } + public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) + { + return m_database.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ); + } + public void StoreLandObject(ILandObject Parcel) { m_database.StoreLandObject(Parcel); @@ -173,6 +183,11 @@ namespace OpenSim.Services.SimulationService m_database.RemoveRegionEnvironmentSettings(regionUUID); } + public UUID[] GetObjectIDs(UUID regionID) + { + return m_database.GetObjectIDs(regionID); + } + public void SaveExtra(UUID regionID, string name, string val) { m_database.SaveExtra(regionID, name, val); diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs index 1808ee5..c473d4a 100644 --- a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs +++ b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs @@ -41,7 +41,7 @@ namespace OpenSim.Services.UserAccountService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public AgentPreferencesService(IConfigSource config) : base(config) + public AgentPreferencesService(IConfigSource config) : base(config) { m_log.Debug("[AGENT PREFERENCES SERVICE]: Starting agent preferences service"); } @@ -49,7 +49,7 @@ namespace OpenSim.Services.UserAccountService public AgentPrefs GetAgentPreferences(UUID principalID) { AgentPreferencesData d = m_Database.GetPrefs(principalID); - AgentPrefs prefs = (d == null) ? new AgentPrefs(principalID) : new AgentPrefs(d.Data); + AgentPrefs prefs = (d == null) ? null : new AgentPrefs(d.Data); return prefs; } diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index 80a9d9d..3cb672e 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -45,7 +45,7 @@ namespace OpenSim.Services.UserAccountService private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static bool m_Initialized; - public GridUserService(IConfigSource config) : base(config) + public GridUserService(IConfigSource config) : base(config) { m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); @@ -207,7 +207,7 @@ namespace OpenSim.Services.UserAccountService public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { - m_log.InfoFormat("[GRID USER SERVICE]: User {0} is offline", userID); + m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); GridUserData d = GetGridUserData(userID); diff --git a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs index 8c5f5df..f9a7260 100644 --- a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs +++ b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs @@ -67,7 +67,7 @@ namespace OpenSim.Services.UserAccountService connString = usersConfig.GetString("ConnectionString", connString); realm = usersConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs index 6ca07a6..0c1464d 100644 --- a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Services.UserAccountService")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 2e19ece..48929ee 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -43,6 +43,7 @@ namespace OpenSim.Services.UserAccountService public class UserAccountService : UserAccountServiceBase, IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly UUID UUID_GRID_GOD = new UUID("6571e388-6218-4574-87db-f9379718315e"); private static UserAccountService m_RootInstance; /// @@ -85,38 +86,63 @@ namespace OpenSim.Services.UserAccountService m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); - // In case there are several instances of this class in the same process, - // the console commands are only registered for the root instance - if (m_RootInstance == null && MainConsole.Instance != null) + // create a system grid god account + UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD); + if(ggod == null) + { + UserAccountData d = new UserAccountData(); + + d.FirstName = "GRID"; + d.LastName = "SERVICES"; + d.PrincipalID = UUID_GRID_GOD; + d.ScopeID = UUID.Zero; + d.Data = new Dictionary(); + d.Data["Email"] = string.Empty; + d.Data["Created"] = Util.UnixTimeSinceEpoch().ToString(); + d.Data["UserLevel"] = "240"; + d.Data["UserFlags"] = "0"; + d.Data["ServiceURLs"] = string.Empty; + + m_Database.Store(d); + } + + if (m_RootInstance == null) { m_RootInstance = this; - MainConsole.Instance.Commands.AddCommand("Users", false, - "create user", - "create user [ [ [ [ []]]]]", - "Create a new user", HandleCreateUser); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "reset user password", - "reset user password [ [ []]]", - "Reset a user password", HandleResetUserPassword); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "reset user email", - "reset user email [ [ []]]", - "Reset a user email address", HandleResetUserEmail); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "set user level", - "set user level [ [ []]]", - "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " - + "this account will be treated as god-moded. " - + "It will also affect the 'login level' command. ", - HandleSetUserLevel); - - MainConsole.Instance.Commands.AddCommand("Users", false, - "show account", - "show account ", - "Show account details for the given user", HandleShowAccount); + + // In case there are several instances of this class in the same process, + // the console commands are only registered for the root instance + if (MainConsole.Instance != null) + { + + MainConsole.Instance.Commands.AddCommand("Users", false, + "create user", + "create user [ [ [ [ [ []]]]]]", + "Create a new user", HandleCreateUser); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "reset user password", + "reset user password [ [ []]]", + "Reset a user password", HandleResetUserPassword); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "reset user email", + "reset user email [ [ []]]", + "Reset a user email address", HandleResetUserEmail); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "set user level", + "set user level [ [ []]]", + "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " + + "this account will be treated as god-moded. " + + "It will also affect the 'login level' command. ", + HandleSetUserLevel); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "show account", + "show account ", + "Show account details for the given user", HandleShowAccount); + } } } @@ -176,6 +202,10 @@ namespace OpenSim.Services.UserAccountService Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); + if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null) + u.UserCountry = d.Data["UserCountry"].ToString(); + else + u.UserCountry = string.Empty; if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) { @@ -261,6 +291,19 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } + public List GetUserAccounts(UUID scopeID, List IDs) + { + // do it one at a time db access should be fast, so no need to break its api + List accs = new List(); + UUID uuid = UUID.Zero; + foreach(string id in IDs) + { + if (UUID.TryParse(id, out uuid) && uuid != UUID.Zero) + accs.Add(GetUserAccount(scopeID, uuid)); + } + return accs; + } + public void InvalidateCache(UUID userID) { } @@ -301,7 +344,22 @@ namespace OpenSim.Services.UserAccountService public List GetUserAccounts(UUID scopeID, string query) { - UserAccountData[] d = m_Database.GetUsers(scopeID, query); + UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim()); + + if (d == null) + return new List(); + + List ret = new List(); + + foreach (UserAccountData data in d) + ret.Add(MakeUserAccount(data)); + + return ret; + } + + public List GetUserAccountsWhere(UUID scopeID, string where) + { + UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where); if (d == null) return new List(); @@ -321,7 +379,7 @@ namespace OpenSim.Services.UserAccountService /// /// Handle the create user command from the console. /// - /// string array with parameters: firstname, lastname, password, locationX, locationY, email + /// string array with parameters: firstname, lastname, password, locationX, locationY, email, userID, model name protected void HandleCreateUser(string module, string[] cmdparams) { string firstName; @@ -329,6 +387,7 @@ namespace OpenSim.Services.UserAccountService string password; string email; string rawPrincipalId; + string model; List excluded = new List(new char[]{' '}); @@ -353,11 +412,16 @@ namespace OpenSim.Services.UserAccountService else rawPrincipalId = cmdparams[6]; + if (cmdparams.Length < 8) + model = MainConsole.Instance.CmdPrompt("Model name",""); + else + model = cmdparams[7]; + UUID principalId = UUID.Zero; if (!UUID.TryParse(rawPrincipalId, out principalId)) throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId)); - CreateUser(UUID.Zero, principalId, firstName, lastName, password, email); + CreateUser(UUID.Zero, principalId, firstName, lastName, password, email, model); } protected void HandleShowAccount(string module, string[] cmdparams) @@ -512,7 +576,8 @@ namespace OpenSim.Services.UserAccountService /// /// /// - public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email) + /// + public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email, string model = "") { UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); if (null == account) @@ -571,7 +636,12 @@ namespace OpenSim.Services.UserAccountService } if (m_CreateDefaultAvatarEntries) - CreateDefaultAppearanceEntries(account.PrincipalID); + { + if (String.IsNullOrEmpty(model)) + CreateDefaultAppearanceEntries(account.PrincipalID); + else + EstablishAppearance(account.PrincipalID, model); + } } m_log.InfoFormat( @@ -596,9 +666,11 @@ namespace OpenSim.Services.UserAccountService m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart); + // Get Current Outfit folder + InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(principalID, FolderType.CurrentOutfit); InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); - eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); + eyes.AssetID = AvatarWearable.DEFAULT_EYES_ASSET; eyes.Name = "Default Eyes"; eyes.CreatorId = principalID.ToString(); eyes.AssetType = (int)AssetType.Bodypart; @@ -611,6 +683,7 @@ namespace OpenSim.Services.UserAccountService eyes.NextPermissions = (uint)PermissionMask.All; eyes.Flags = (uint)WearableType.Eyes; m_InventoryService.AddItem(eyes); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Eyes, eyes.Name, eyes.ID, principalID, currentOutfitFolder.ID); InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; @@ -626,6 +699,7 @@ namespace OpenSim.Services.UserAccountService shape.NextPermissions = (uint)PermissionMask.All; shape.Flags = (uint)WearableType.Shape; m_InventoryService.AddItem(shape); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shape, shape.Name, shape.ID, principalID, currentOutfitFolder.ID); InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; @@ -641,6 +715,7 @@ namespace OpenSim.Services.UserAccountService skin.NextPermissions = (uint)PermissionMask.All; skin.Flags = (uint)WearableType.Skin; m_InventoryService.AddItem(skin); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Skin, skin.Name, skin.ID, principalID, currentOutfitFolder.ID); InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; @@ -656,6 +731,7 @@ namespace OpenSim.Services.UserAccountService hair.NextPermissions = (uint)PermissionMask.All; hair.Flags = (uint)WearableType.Hair; m_InventoryService.AddItem(hair); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Hair, hair.Name, hair.ID, principalID, currentOutfitFolder.ID); InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing); @@ -673,6 +749,7 @@ namespace OpenSim.Services.UserAccountService shirt.NextPermissions = (uint)PermissionMask.All; shirt.Flags = (uint)WearableType.Shirt; m_InventoryService.AddItem(shirt); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shirt, shirt.Name, shirt.ID, principalID, currentOutfitFolder.ID); InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; @@ -688,6 +765,7 @@ namespace OpenSim.Services.UserAccountService pants.NextPermissions = (uint)PermissionMask.All; pants.Flags = (uint)WearableType.Pants; m_InventoryService.AddItem(pants); + CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Pants, pants.Name, pants.ID, principalID, currentOutfitFolder.ID); if (m_AvatarService != null) { @@ -702,6 +780,7 @@ namespace OpenSim.Services.UserAccountService wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID); AvatarAppearance ap = new AvatarAppearance(); + // this loop works, but is questionable for (int i = 0; i < 6; i++) { ap.SetWearable(i, wearables[i]); @@ -710,5 +789,237 @@ namespace OpenSim.Services.UserAccountService m_AvatarService.SetAppearance(principalID, ap); } } + + protected void EstablishAppearance(UUID destinationAgent, string model) + { + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Establishing new appearance for {0} - {1}", + destinationAgent.ToString(), model); + + string[] modelSpecifiers = model.Split(); + if (modelSpecifiers.Length != 2) + { + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Invalid model name \'{0}\'. Falling back to Ruth for {1}", + model, destinationAgent); + CreateDefaultAppearanceEntries(destinationAgent); + return; + } + + // Does the source model exist? + UserAccount modelAccount = GetUserAccount(UUID.Zero, modelSpecifiers[0], modelSpecifiers[1]); + if (modelAccount == null) + { + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Requested model \'{0}\' not found. Falling back to Ruth for {1}", + model, destinationAgent); + CreateDefaultAppearanceEntries(destinationAgent); + return; + } + + // Does the source model have an established appearance herself? + AvatarAppearance modelAppearance = m_AvatarService.GetAppearance(modelAccount.PrincipalID); + if (modelAppearance == null) + { + m_log.WarnFormat("USER ACCOUNT SERVICE]: Requested model \'{0}\' does not have an established appearance. Falling back to Ruth for {1}", + model, destinationAgent); + CreateDefaultAppearanceEntries(destinationAgent); + return; + } + + try + { + CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance); + + m_AvatarService.SetAppearance(destinationAgent, modelAppearance); + } + catch (Exception e) + { + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring appearance for {0} : {1}", + destinationAgent, e.Message); + } + + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Finished establishing appearance for {0}", + destinationAgent.ToString()); + } + + /// + /// This method is called by EstablishAppearance to do a copy all inventory items + /// worn or attached to the Clothing inventory folder of the receiving avatar. + /// In parallel the avatar wearables and attachments are updated. + /// + private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) + { + // Get Clothing folder of receiver + InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing); + // Get Current Outfit folder + InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit); + + if (destinationFolder == null) + throw new Exception("Cannot locate folder(s)"); + + // Missing destination folder? This should *never* be the case + if (destinationFolder.Type != (short)FolderType.Clothing) + { + destinationFolder = new InventoryFolderBase(); + + destinationFolder.ID = UUID.Random(); + destinationFolder.Name = "Clothing"; + destinationFolder.Owner = destination; + destinationFolder.Type = (short)AssetType.Clothing; + destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID; + destinationFolder.Version = 1; + m_InventoryService.AddFolder(destinationFolder); // store base record + m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source); + } + + // Wearables + AvatarWearable[] wearables = avatarAppearance.Wearables; + AvatarWearable wearable; + + for (int i = 0; i < wearables.Length; i++) + { + wearable = wearables[i]; + m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable[0].ItemID, source); + if (wearable[0].ItemID != UUID.Zero) + { + // Get inventory item and copy it + InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID); + + if (item != null) + { + InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); + destinationItem.Name = item.Name; + destinationItem.Owner = destination; + destinationItem.Description = item.Description; + destinationItem.InvType = item.InvType; + destinationItem.CreatorId = item.CreatorId; + destinationItem.CreatorData = item.CreatorData; + destinationItem.NextPermissions = item.NextPermissions; + destinationItem.CurrentPermissions = item.CurrentPermissions; + destinationItem.BasePermissions = item.BasePermissions; + destinationItem.EveryOnePermissions = item.EveryOnePermissions; + destinationItem.GroupPermissions = item.GroupPermissions; + destinationItem.AssetType = item.AssetType; + destinationItem.AssetID = item.AssetID; + destinationItem.GroupID = item.GroupID; + destinationItem.GroupOwned = item.GroupOwned; + destinationItem.SalePrice = item.SalePrice; + destinationItem.SaleType = item.SaleType; + destinationItem.Flags = item.Flags; + destinationItem.CreationDate = item.CreationDate; + destinationItem.Folder = destinationFolder.ID; + ApplyNextOwnerPermissions(destinationItem); + + m_InventoryService.AddItem(destinationItem); + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); + + // Wear item + AvatarWearable newWearable = new AvatarWearable(); + newWearable.Wear(destinationItem.ID, wearable[0].AssetID); + avatarAppearance.SetWearable(i, newWearable); + + // Add to Current Outfit + CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID); + } + else + { + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID); + } + } + } + + // Attachments + List attachments = avatarAppearance.GetAttachments(); + + foreach (AvatarAttachment attachment in attachments) + { + int attachpoint = attachment.AttachPoint; + UUID itemID = attachment.ItemID; + + if (itemID != UUID.Zero) + { + // Get inventory item and copy it + InventoryItemBase item = m_InventoryService.GetItem(source, itemID); + + if (item != null) + { + InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); + destinationItem.Name = item.Name; + destinationItem.Owner = destination; + destinationItem.Description = item.Description; + destinationItem.InvType = item.InvType; + destinationItem.CreatorId = item.CreatorId; + destinationItem.CreatorData = item.CreatorData; + destinationItem.NextPermissions = item.NextPermissions; + destinationItem.CurrentPermissions = item.CurrentPermissions; + destinationItem.BasePermissions = item.BasePermissions; + destinationItem.EveryOnePermissions = item.EveryOnePermissions; + destinationItem.GroupPermissions = item.GroupPermissions; + destinationItem.AssetType = item.AssetType; + destinationItem.AssetID = item.AssetID; + destinationItem.GroupID = item.GroupID; + destinationItem.GroupOwned = item.GroupOwned; + destinationItem.SalePrice = item.SalePrice; + destinationItem.SaleType = item.SaleType; + destinationItem.Flags = item.Flags; + destinationItem.CreationDate = item.CreationDate; + destinationItem.Folder = destinationFolder.ID; + ApplyNextOwnerPermissions(destinationItem); + + m_InventoryService.AddItem(destinationItem); + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); + + // Attach item + avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID); + + // Add to Current Outfit + CreateCurrentOutfitLink(destinationItem.InvType, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID); + } + else + { + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); + } + } + } + } + + protected void CreateCurrentOutfitLink(int invType, uint itemType, string name, UUID itemID, UUID userID, UUID currentOutfitFolderUUID) + { + UUID LinkInvItem = UUID.Random(); + InventoryItemBase itembase = new InventoryItemBase(LinkInvItem, userID) + { + AssetID = itemID, + AssetType = (int)AssetType.Link, + CreatorId = userID.ToString(), + InvType = invType, + Description = "", + //Folder = m_InventoryService.GetFolderForType(userID, FolderType.CurrentOutfit).ID, + Folder = currentOutfitFolderUUID, + Flags = itemType, + Name = name, + BasePermissions = (uint)PermissionMask.Copy, + CurrentPermissions = (uint)PermissionMask.Copy, + EveryOnePermissions = (uint)PermissionMask.Copy, + GroupPermissions = (uint)PermissionMask.Copy, + NextPermissions = (uint)PermissionMask.Copy + }; + + m_InventoryService.AddItem(itembase); + } + + /// + /// Apply next owner permissions. + /// + private void ApplyNextOwnerPermissions(InventoryItemBase item) + { + if (item.InvType == (int)InventoryType.Object) + { + uint perms = item.CurrentPermissions; + item.CurrentPermissions = perms; + } + + item.CurrentPermissions &= item.NextPermissions; + item.BasePermissions &= item.NextPermissions; + item.EveryOnePermissions &= item.NextPermissions; + } } } diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs index 96c13c0..76aa093 100644 --- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs +++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs @@ -45,7 +45,7 @@ namespace OpenSim.Services.ProfilesService static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - + IUserAccountService userAccounts; public UserProfilesService(IConfigSource config, string configName): @@ -58,23 +58,23 @@ namespace OpenSim.Services.ProfilesService return; } Object[] args = null; - + args = new Object[] { config }; string accountService = Config.GetString("UserAccountService", String.Empty); if (accountService != string.Empty) userAccounts = ServerUtils.LoadPlugin(accountService, args); - + args = new Object[] { config }; } - + #region Classifieds public OSD AvatarClassifiedsRequest(UUID creatorId) { OSDArray records = ProfilesData.GetClassifiedRecords(creatorId); - + return records; } - + public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result) { if(!ProfilesData.UpdateClassifiedRecord(ad, ref result)) @@ -84,74 +84,74 @@ namespace OpenSim.Services.ProfilesService result = "success"; return true; } - + public bool ClassifiedDelete(UUID recordId) { if(ProfilesData.DeleteClassifiedRecord(recordId)) return true; - + return false; } - + public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result) { if(ProfilesData.GetClassifiedInfo(ref ad, ref result)) return true; - + return false; } #endregion Classifieds - + #region Picks public OSD AvatarPicksRequest(UUID creatorId) { OSDArray records = ProfilesData.GetAvatarPicks(creatorId); - + return records; } - + public bool PickInfoRequest(ref UserProfilePick pick, ref string result) { pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId); result = "OK"; return true; } - + public bool PicksUpdate(ref UserProfilePick pick, ref string result) { return ProfilesData.UpdatePicksRecord(pick); } - + public bool PicksDelete(UUID pickId) { return ProfilesData.DeletePicksRecord(pickId); } #endregion Picks - + #region Notes public bool AvatarNotesRequest(ref UserProfileNotes note) { return ProfilesData.GetAvatarNotes(ref note); } - + public bool NotesUpdate(ref UserProfileNotes note, ref string result) { return ProfilesData.UpdateAvatarNotes(ref note, ref result); } #endregion Notes - + #region Profile Properties public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result) { return ProfilesData.GetAvatarProperties(ref prop, ref result); } - + public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result) { return ProfilesData.UpdateAvatarProperties(ref prop, ref result); } #endregion Profile Properties - + #region Interests public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result) { @@ -159,6 +159,7 @@ namespace OpenSim.Services.ProfilesService } #endregion Interests + #region User Preferences public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) { @@ -239,6 +240,7 @@ namespace OpenSim.Services.ProfilesService } #endregion User Preferences + #region Utility public OSD AvatarImageAssetsRequest(UUID avatarId) { @@ -252,7 +254,7 @@ namespace OpenSim.Services.ProfilesService { return ProfilesData.GetUserAppData(ref prop, ref result); } - + public bool SetUserAppData(UserAppData prop, ref string result) { return true; diff --git a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs index c31578f..48b43a6 100644 --- a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs +++ b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.ProfilesService if (string.IsNullOrEmpty(connString)) connString = dbConfig.GetString("ConnectionString", String.Empty); } - + IConfig ProfilesConfig = config.Configs[configName]; if (ProfilesConfig != null) { @@ -76,7 +76,7 @@ namespace OpenSim.Services.ProfilesService connString = ProfilesConfig.GetString("ConnectionString", connString); realm = ProfilesConfig.GetString("Realm", realm); } - + ProfilesData = LoadPlugin(dllName, new Object[] { connString }); if (ProfilesData == null) throw new Exception("Could not find a storage interface in the given module"); -- cgit v1.1 From 295e91b8f44a356ab742dedd27c1b7edfe7b1157 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:15:41 +1000 Subject: Move cache, config, logs out of tree, and various related clean ups. --- OpenSim/Services/GridService/HypergridLinker.cs | 3 ++- OpenSim/Services/MapImageService/MapImageService.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index dabfd3b..67114ef 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -122,7 +122,8 @@ namespace OpenSim.Services.GridService // m_Check4096 = gridConfig.GetBoolean("Check4096", true); - m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); +//// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. + m_MapTileDirectory = Path.Combine(Util.cacheDir(), Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles"))); m_ThisGatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index c90f5bd..e9db41d 100644 --- a/OpenSim/Services/MapImageService/MapImageService.cs +++ b/OpenSim/Services/MapImageService/MapImageService.cs @@ -63,7 +63,7 @@ namespace OpenSim.Services.MapImageService private const int HALF_WIDTH = 128; private const int JPEG_QUALITY = 80; - private static string m_TilesStoragePath = "maptiles"; + private static string m_TilesStoragePath = Path.Combine(Util.cacheDir(), "/maptiles"); private static object m_Sync = new object(); private static bool m_Initialized = false; -- cgit v1.1 From 66d7ba733f296f81398a040f05dd945c2facb2b4 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:25:06 +1000 Subject: Various logging fix ups. Mostly removing console spam. Default to INFO on the console and DEBUG in the log files. More time stamp resolution. --- OpenSim/Services/FSAssetService/FSAssetService.cs | 2 +- OpenSim/Services/GridService/GridService.cs | 4 ++-- OpenSim/Services/PresenceService/PresenceService.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index ca2f459..812d89d 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs @@ -231,7 +231,7 @@ namespace OpenSim.Services.FSAssetService double avg = (double)m_readTicks / (double)m_readCount; // if (avg > 10000) // Environment.Exit(0); - m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS); +//// m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS); } m_readCount = 0; m_readTicks = 0; diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a5c7d34..2a2d8a8 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -345,7 +345,7 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } - m_log.DebugFormat + m_log.InfoFormat ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, regionInfos.RegionCoordX, regionInfos.RegionCoordY, @@ -374,7 +374,7 @@ namespace OpenSim.Services.GridService if (region == null) return false; - m_log.DebugFormat( + m_log.InfoFormat( "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}", region.RegionName, region.RegionID, region.coordX, region.coordY); diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index ae92919..0392409 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -88,7 +88,7 @@ namespace OpenSim.Services.PresenceService { PresenceInfo presence = GetAgent(sessionID); - m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}", + m_log.InfoFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}", sessionID, (presence == null) ? null : presence.UserID, (presence == null) ? null : presence.RegionID.ToString()); -- cgit v1.1 From 30cc9a733f4e7013c82696985c8481be1a8aac1c Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:28:19 +1000 Subject: Remove silly 4096 sim TP check for a client bug that was fixed long ago. --- OpenSim/Services/GridService/HypergridLinker.cs | 62 ------------------------- 1 file changed, 62 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 67114ef..bd68056 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -63,7 +63,6 @@ namespace OpenSim.Services.GridService protected GatekeeperServiceConnector m_GatekeeperConnector; protected UUID m_ScopeID = UUID.Zero; -// protected bool m_Check4096 = true; protected string m_MapTileDirectory = string.Empty; protected string m_ThisGatekeeper = string.Empty; protected Uri m_ThisGatekeeperURI = null; @@ -120,8 +119,6 @@ namespace OpenSim.Services.GridService if (scope != string.Empty) UUID.TryParse(scope, out m_ScopeID); -// m_Check4096 = gridConfig.GetBoolean("Check4096", true); - //// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. m_MapTileDirectory = Path.Combine(Util.cacheDir(), Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles"))); @@ -337,19 +334,6 @@ namespace OpenSim.Services.GridService return true; } - // We are now performing this check for each individual teleport in the EntityTransferModule instead. This - // allows us to give better feedback when teleports fail because of the distance reason (which can't be - // done here) and it also hypergrid teleports that are within range (possibly because the source grid - // itself has regions that are very far apart). -// uint x, y; -// if (m_Check4096 && !Check4096(handle, out x, out y)) -// { -// //RemoveHyperlinkRegion(regInfo.RegionID); -// reason = "Region is too far (" + x + ", " + y + ")"; -// m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")"); -// //return false; -// } - regInfo.RegionID = regionID; regInfo.RegionSizeX = sizeX; regInfo.RegionSizeY = sizeY; @@ -402,52 +386,6 @@ namespace OpenSim.Services.GridService } } -// Not currently used -// /// -// /// Cope with this viewer limitation. -// /// -// /// -// /// -// public bool Check4096(ulong realHandle, out uint x, out uint y) -// { -// uint ux = 0, uy = 0; -// Utils.LongToUInts(realHandle, out ux, out uy); -// x = Util.WorldToRegionLoc(ux); -// y = Util.WorldToRegionLoc(uy); -// -// const uint limit = Util.RegionToWorldLoc(4096 - 1); -// uint xmin = ux - limit; -// uint xmax = ux + limit; -// uint ymin = uy - limit; -// uint ymax = uy + limit; -// // World map boundary checks -// if (xmin < 0 || xmin > ux) -// xmin = 0; -// if (xmax > int.MaxValue || xmax < ux) -// xmax = int.MaxValue; -// if (ymin < 0 || ymin > uy) -// ymin = 0; -// if (ymax > int.MaxValue || ymax < uy) -// ymax = int.MaxValue; -// -// // Check for any regions that are within the possible teleport range to the linked region -// List regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); -// if (regions.Count == 0) -// { -// return false; -// } -// else -// { -// // Check for regions which are not linked regions -// List hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); -// IEnumerable availableRegions = regions.Except(hyperlinks); -// if (availableRegions.Count() == 0) -// return false; -// } -// -// return true; -// } - private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) { RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); -- cgit v1.1 From c01dd9a65981946703be7e3d551ffc9c4a394d02 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:33:21 +1000 Subject: Clean up maptile directory creation code. --- OpenSim/Services/GridService/HypergridLinker.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index bd68056..4887232 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -145,17 +145,14 @@ namespace OpenSim.Services.GridService m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); - if (!string.IsNullOrEmpty(m_MapTileDirectory)) + try { - try - { - Directory.CreateDirectory(m_MapTileDirectory); - } - catch (Exception e) - { - m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); - m_MapTileDirectory = string.Empty; - } + Directory.CreateDirectory(m_MapTileDirectory); + } + catch (Exception e) + { + m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); + m_MapTileDirectory = string.Empty; } if (MainConsole.Instance != null) -- cgit v1.1 From cdb1851f438349a8721c0d9cef54837d0b302189 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 4 Jun 2019 00:50:59 +1000 Subject: Warnings-- --- OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs index 5f075ac..33b3866 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs @@ -151,7 +151,7 @@ namespace OpenSim.Services.Connectors os.Write(buffer, 0, strBuffer.Length); //Send it //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); } - catch (Exception e) + catch (Exception /*e*/) { // m_log.WarnFormat( // "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", -- cgit v1.1 From 52fac1eb5dc10c0c264f5a6ce515922c2d8d1a8f Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 4 Jul 2019 18:38:39 +1000 Subject: Log FS asset base and spool directory. The assets cache directory is already logged. --- OpenSim/Services/FSAssetService/FSAssetService.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index 812d89d..4d47589 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs @@ -179,6 +179,7 @@ namespace OpenSim.Services.FSAssetService Directory.CreateDirectory(spoolTmp); m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty); + m_log.InfoFormat("[FSASSETS]: Assets base and spool directory are {0} and {1}", m_FSBase, m_SpoolDirectory); if (m_FSBase == String.Empty) { m_log.ErrorFormat("[FSASSETS]: BaseDirectory not specified"); -- cgit v1.1 From 5e0fa2a7587ebf70482e32e4227813c9b820f484 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 18 Jul 2019 05:16:15 +1000 Subject: OpenSim changed the way FSAssets directory structure works by default, sort that out. Otherwise updating from 0.8 to 0.9 with FSAssets will fail to find new assets. --- OpenSim/Services/FSAssetService/FSAssetService.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index 4d47589..27b04f7 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs @@ -186,7 +186,18 @@ namespace OpenSim.Services.FSAssetService throw new Exception("Configuration error"); } + // OSGrid format is /3/3/, OpenSims default format is /2/2/2/4/. Try to figure out which we have. + List dirs = new List(Directory.EnumerateDirectories(m_FSBase)); + foreach (var dir in dirs) + { + if (3 == dir.Substring(dir.LastIndexOf(Path.DirectorySeparatorChar) + 1).Length) + { + m_useOsgridFormat = true; + break; + } + } m_useOsgridFormat = assetConfig.GetBoolean("UseOsgridFormat", m_useOsgridFormat); + m_log.InfoFormat("[FSASSETS]: UseOsgridFormat is {0}", m_useOsgridFormat); // Default is to show stats to retain original behaviour m_showStats = assetConfig.GetBoolean("ShowConsoleStats", m_showStats); -- cgit v1.1 From 6d2826110259083208a130587ac107411b1cec4e Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 19 Jul 2019 13:00:52 +1000 Subject: Tweak the login logging a bit, especially for impersonations. --- .../AuthenticationService/PasswordAuthenticationService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 0204699..aef3e9f 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -87,6 +87,7 @@ namespace OpenSim.Services.AuthenticationService if (!data.Data.ContainsKey("passwordHash") || !data.Data.ContainsKey("passwordSalt")) { + m_log.DebugFormat("[AUTH SERVICE]: No credentials."); return String.Empty; } @@ -109,9 +110,12 @@ namespace OpenSim.Services.AuthenticationService int impersonateFlag = 1 << 6; if ((user.UserFlags & impersonateFlag) == 0) + { + m_log.DebugFormat("[AUTH SERVICE]: Not trying impersonation {0} {1}.", user.UserFlags, impersonateFlag); return String.Empty; + } - m_log.DebugFormat("[PASS AUTH]: Attempting impersonation"); + m_log.DebugFormat("[PASS AUTH]: Attempting impersonation."); List accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200"); if (accounts == null || accounts.Count == 0) @@ -134,7 +138,7 @@ namespace OpenSim.Services.AuthenticationService if (data.Data["passwordHash"].ToString() == hashed) { - m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID); + m_log.InfoFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID); realID = a.PrincipalID; return GetToken(principalID, lifetime); } @@ -146,7 +150,7 @@ namespace OpenSim.Services.AuthenticationService // } } - m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID); + m_log.InfoFormat("[PASS AUTH]: Impersonation of {0} failed", principalID); return String.Empty; } } -- cgit v1.1 From 15b2a91ffc6d240277a852aa750a0259ae6a2a17 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 24 Jul 2019 05:49:26 +1000 Subject: For the "teleport from above" case, do the right thing. Which includes looking for designated floor prims, which have ^ as the first character of their description. Don't do "teleport from above" when we have proper coords. --- OpenSim/Services/LLLoginService/LLLoginService.cs | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 3ccdc9c..53a3c2f 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -489,7 +489,7 @@ namespace OpenSim.Services.LLLoginService Vector3 position = Vector3.Zero; Vector3 lookAt = Vector3.Zero; GridRegion gatekeeper = null; - TeleportFlags flags; + Constants.TeleportFlags flags; GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags); if (destination == null) { @@ -508,7 +508,7 @@ namespace OpenSim.Services.LLLoginService } if (account.UserLevel >= 200) - flags |= TeleportFlags.Godlike; + flags |= Constants.TeleportFlags.Godlike; // // Get the avatar // @@ -582,9 +582,9 @@ namespace OpenSim.Services.LLLoginService protected GridRegion FindDestination( UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out GridRegion gatekeeper, - out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags) + out string where, out Vector3 position, out Vector3 lookAt, out Constants.TeleportFlags flags) { - flags = TeleportFlags.ViaLogin; + flags = Constants.TeleportFlags.ViaLogin; m_log.DebugFormat( "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}", @@ -618,7 +618,7 @@ namespace OpenSim.Services.LLLoginService position = pinfo.HomePosition; lookAt = pinfo.HomeLookAt; - flags |= TeleportFlags.ViaHome; + flags |= Constants.TeleportFlags.ViaHome; } if (tryDefaults) @@ -626,7 +626,7 @@ namespace OpenSim.Services.LLLoginService List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { - flags |= TeleportFlags.ViaRegionID; + flags |= Constants.TeleportFlags.ViaRegionID; region = defaults[0]; where = "safe"; } @@ -637,7 +637,7 @@ namespace OpenSim.Services.LLLoginService region = FindAlternativeRegion(scopeID); if (region != null) { - flags |= TeleportFlags.ViaRegionID; + flags |= Constants.TeleportFlags.ViaRegionID; where = "safe"; } } @@ -660,7 +660,7 @@ namespace OpenSim.Services.LLLoginService List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) { - flags |= TeleportFlags.ViaRegionID; + flags |= Constants.TeleportFlags.ViaRegionID; region = defaults[0]; where = "safe"; } @@ -670,7 +670,7 @@ namespace OpenSim.Services.LLLoginService region = FindAlternativeRegion(scopeID); if (region != null) { - flags |= TeleportFlags.ViaRegionID; + flags |= Constants.TeleportFlags.ViaRegionID; where = "safe"; } } @@ -686,7 +686,7 @@ namespace OpenSim.Services.LLLoginService } else { - flags |= TeleportFlags.ViaRegionID; + flags |= Constants.TeleportFlags.ViaRegionID; // free uri form // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 @@ -704,6 +704,8 @@ namespace OpenSim.Services.LLLoginService position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo), float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo), float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); + if (0 == position.Z) + flags |= Constants.TeleportFlags.ViaMap; string regionName = uriMatch.Groups["region"].ToString(); if (regionName != null) @@ -858,7 +860,7 @@ namespace OpenSim.Services.LLLoginService protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar, UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, - IPEndPoint clientIP, TeleportFlags flags, out string where, out string reason, out GridRegion dest) + IPEndPoint clientIP, Constants.TeleportFlags flags, out string where, out string reason, out GridRegion dest) { where = currentWhere; ISimulationService simConnector = null; @@ -895,7 +897,7 @@ namespace OpenSim.Services.LLLoginService { foreach (GridRegion r in fallbacks) { - success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | TeleportFlags.ViaRegionID, out reason); + success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | Constants.TeleportFlags.ViaRegionID | Constants.TeleportFlags.ViaMap, out reason); if (success) { where = "safe"; @@ -1041,7 +1043,7 @@ namespace OpenSim.Services.LLLoginService } - private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason) + private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, Constants.TeleportFlags flags, out string reason) { EntityTransferContext ctx = new EntityTransferContext(); -- cgit v1.1 From 77737c81234c98d72bffaa6ddca374504f971b12 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 25 Jul 2019 20:19:51 +1000 Subject: Gatekeeper -> GatekeeperURI Coz it says all over the source code - // Legacy. Remove soon! And has since later OpenSim 0.7s. --- OpenSim/Services/GridService/HypergridLinker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 4887232..7c384d5 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -125,7 +125,7 @@ namespace OpenSim.Services.GridService m_ThisGatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); // Legacy. Remove soon! - m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); +//// m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); try { m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); -- cgit v1.1 From 85fcb4e75c94ff7b5b45609826df5113f32aacc0 Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 2 Aug 2019 21:20:11 +1000 Subject: Another attempt at sorting out the auto group chicken and egg problems. Are you a local? Asking for a friend. --- OpenSim/Services/AuthorizationService/AuthorizationService.cs | 3 ++- OpenSim/Services/Interfaces/IAuthorizationService.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AuthorizationService/AuthorizationService.cs b/OpenSim/Services/AuthorizationService/AuthorizationService.cs index 03da6e1..2fe43e7 100644 --- a/OpenSim/Services/AuthorizationService/AuthorizationService.cs +++ b/OpenSim/Services/AuthorizationService/AuthorizationService.cs @@ -49,9 +49,10 @@ namespace OpenSim.Services.AuthorizationService } public bool IsAuthorizedForRegion( - string userID, string firstName, string lastName, string regionID, out string message) + string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal) { message = "Authorized"; + isLocal = true; return true; } } diff --git a/OpenSim/Services/Interfaces/IAuthorizationService.cs b/OpenSim/Services/Interfaces/IAuthorizationService.cs index d4c697a..1974234 100644 --- a/OpenSim/Services/Interfaces/IAuthorizationService.cs +++ b/OpenSim/Services/Interfaces/IAuthorizationService.cs @@ -48,7 +48,7 @@ namespace OpenSim.Services.Interfaces /// /// bool IsAuthorizedForRegion( - string userID, string firstName, string lastName, string regionID, out string message); + string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal); } public class AuthorizationRequest -- cgit v1.1 From 412e317b2f54db3b316d17d10dbf6c6ff7fa22c6 Mon Sep 17 00:00:00 2001 From: onefang Date: Mon, 5 Aug 2019 04:17:54 +1000 Subject: Limits -= 2 Low Y regions are no longer reserved for HG links. Varregions don't have to be square. Both now report a warning, but continue anyway. Cool VL Viewer handles non square regions, Singularity crashes. Not tested on others. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2a2d8a8..e0500a6 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -198,7 +198,8 @@ namespace OpenSim.Services.GridService return "Invalid RegionID - cannot be zero UUID"; if (regionInfos.RegionLocY <= Constants.MaximumRegionSize) - return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString(); + m_log.WarnFormat("{0} Region location reserved for HG links coord Y should be higher than {1}.", LogHeader, (Constants.MaximumRegionSize/256).ToString()); +//// return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString(); String reason = "Region overlaps another region"; -- cgit v1.1 From 7aecb3c7d9262b7dcd43b45736bb008a2f1ca742 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 15 Aug 2019 02:18:35 +1000 Subject: Bandaid for ghost users, check and remove them from Presence when they log on. Once again OOP proves it's worse that spaghetti, but cutting up the spaghetti and hiding it all over the kitchen. Note the commented out bits from GateKeeperService.cs, this stuff is checked TWICE, though this time is for HGers, or not. --- .../Presence/PresenceServicesConnector.cs | 57 ++++++++++++++++++++++ .../SimianGrid/SimianPresenceServiceConnector.cs | 12 +++++ .../Services/HypergridService/GatekeeperService.cs | 30 +++++++++++- OpenSim/Services/Interfaces/IPresenceService.cs | 11 +++++ OpenSim/Services/LLLoginService/LLLoginService.cs | 25 +++++++++- .../Services/PresenceService/PresenceService.cs | 17 +++++++ 6 files changed, 149 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs index 89d64ca..04a0c5e 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs @@ -329,6 +329,63 @@ namespace OpenSim.Services.Connectors return pinfo; } + public PresenceInfo GetAgentByUser(UUID userID) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "getagentbyuser"; + + sendData["UserID"] = userID.ToString(); + + string reply = string.Empty; + string reqString = ServerUtils.BuildQueryString(sendData); + string uri = m_ServerURI + "/presence"; + // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + reqString, + m_Auth); + if (reply == null || (reply != null && reply == string.Empty)) + { + m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgentByUser received null or empty reply"); + return null; + } + } + catch (Exception e) + { + m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message); + return null; + } + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + PresenceInfo pinfo = null; + + if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + { + pinfo = new PresenceInfo((Dictionary)replyData["result"]); + } + else + { + if (replyData["result"].ToString() == "null") + return null; + + m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for userID {0}", userID.ToString()); + } + } + else + { + m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for userID {0}", userID.ToString()); + } + + return pinfo; + } + public PresenceInfo[] GetAgents(string[] userIDs) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 08efefb..2a34379 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -222,6 +222,18 @@ namespace OpenSim.Services.Connectors.SimianGrid return ResponseToPresenceInfo(sessionResponse); } + public PresenceInfo GetAgentByUser(UUID userID) + { + OSDMap userResponse = GetUserData(userID); + if (userResponse == null) + { + m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString()); + return null; + } + + return ResponseToPresenceInfo(userResponse); + } + public PresenceInfo[] GetAgents(string[] userIDs) { List presences = new List(); diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 5c6abd2..24979be 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -391,13 +391,39 @@ namespace OpenSim.Services.HypergridService if(!m_allowDuplicatePresences) { +//// TODO - Should also check Presence.UserID if RegionID == UUID.Zero, they are a ghost. Maybe. +//// NOTE - this is a person hypergridding in, or returning home, or just logging in and it's duplicating effort in OpenSim/Services/LLLoginService/LLLoginService.cs. if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) { - if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo)) + // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost. + // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login. + // Might also need to double check if they are out hypergridding. + + bool success = false; + if (m_PresenceService != null) + { + PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID); + if (null != pi) + { + Dictionary pid = pi.ToKeyValuePairs(); + if ((pid["RegionID"].ToString() == UUID.Zero.ToString()) && (0 != String.Compare(pid["SessionID"].ToString(), aCircuit.SessionID.ToString()))) + { + m_log.WarnFormat("[GATEKEEPER SERVICE]: Exorcising ghost avatar {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID); +m_log.WarnFormat("[GATEKEEPER SERVICE]: NOT REALLY."); +//// Don't do this until after more checking. +//// success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString())); +//// if (success) +//// m_log.WarnFormat("[GATEKEEPER SERVICE]: Ghost avatar exorcised {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID); +//// else +//// m_log.ErrorFormat("[GATEKEEPER SERVICE]: Ghost avatar not exorcised {0}, session {1}, new session {2}!", pid["UserID"], pid["SessionID"], aCircuit.SessionID); + } + } + } + if ((!success) && SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo)) { if(account != null) m_log.InfoFormat( - "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in", + "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in. This may be bogus if a ghost avatar was exorcised above.", account.FirstName, account.LastName); reason = "You appear to be already logged in on the destination grid " + "Please wait a a minute or two and retry. " + diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs index 90f9842..4843759 100644 --- a/OpenSim/Services/Interfaces/IPresenceService.cs +++ b/OpenSim/Services/Interfaces/IPresenceService.cs @@ -36,6 +36,7 @@ namespace OpenSim.Services.Interfaces { public string UserID; public UUID RegionID; + public UUID SessionID; public PresenceInfo() { @@ -47,6 +48,8 @@ namespace OpenSim.Services.Interfaces UserID = kvp["UserID"].ToString(); if (kvp.ContainsKey("RegionID")) UUID.TryParse(kvp["RegionID"].ToString(), out RegionID); + if (kvp.ContainsKey("SessionID")) + UUID.TryParse(kvp["SessionID"].ToString(), out SessionID); } public Dictionary ToKeyValuePairs() @@ -54,6 +57,7 @@ namespace OpenSim.Services.Interfaces Dictionary result = new Dictionary(); result["UserID"] = UserID; result["RegionID"] = RegionID.ToString(); + result["SessionID"] = SessionID.ToString(); return result; } @@ -100,6 +104,13 @@ namespace OpenSim.Services.Interfaces PresenceInfo GetAgent(UUID sessionID); /// + /// Get session information for a given session ID. + /// + /// + /// + PresenceInfo GetAgentByUser(UUID userID); + + /// /// Get session information for a collection of users. /// /// Session information for the users. diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 53a3c2f..cad0988 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -390,7 +390,30 @@ namespace OpenSim.Services.LLLoginService { if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) { - if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo)) + // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost. + // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login. + // Might also need to double check if they are out hypergridding. + + success = false; + if (m_PresenceService != null) + { + PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID); + if (null != pi) + { + Dictionary pid = pi.ToKeyValuePairs(); + if (pid["RegionID"].ToString() == UUID.Zero.ToString()) + { + m_log.WarnFormat("[LLOGIN SERVICE]: Exorcising ghost avatar {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session); + success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString())); + if (success) + m_log.WarnFormat("[LLOGIN SERVICE]: Ghost avatar exorcised {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session); + else + m_log.ErrorFormat("[LLOGIN SERVICE]: Ghost avatar not exorcised {0} {1}, session {2}, new session {3}!", firstName, lastName, pid["SessionID"], session); + } + } + } + + if ((!success) && SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo)) { m_log.InfoFormat( "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in", diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 0392409..1059b2b 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -151,6 +151,22 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; + ret.SessionID = data.SessionID; + + return ret; + } + + public PresenceInfo GetAgentByUser(UUID userID) + { + PresenceInfo ret = new PresenceInfo(); + + PresenceData data = m_Database.GetByUser(userID); + if (data == null) + return null; + + ret.UserID = data.UserID; + ret.RegionID = data.RegionID; + ret.SessionID = data.SessionID; return ret; } @@ -169,6 +185,7 @@ namespace OpenSim.Services.PresenceService ret.UserID = d.UserID; ret.RegionID = d.RegionID; + ret.SessionID = d.SessionID; info.Add(ret); } -- cgit v1.1