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. --- .../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 ++++- 33 files changed, 1079 insertions(+), 325 deletions(-) create mode 100644 OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs (limited to 'OpenSim/Services/Connectors') 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; -- 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/Connectors') 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 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 +++++ 2 files changed, 69 insertions(+) (limited to 'OpenSim/Services/Connectors') 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(); -- cgit v1.1