diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index f378925a89..1d080ff037 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -127,12 +127,14 @@ what it is today. * maimedleech * Mana Janus * MarcelEdward +* Matt Lehmann * Mic Bowman * Michelle Argus * Michael Cortez (The Flotsam Project, http://osflotsam.org/) * Micheil Merlin * Mike Osias (IBM) * Mike Pitman (IBM) +* mikemig * mikkopa/_someone - RealXtend * Misterblue * Mircea Kitsune diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs index bbb5e059d3..e6a4765e33 100644 --- a/OpenSim/Addons/Groups/GroupsMessagingModule.cs +++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs @@ -56,8 +56,8 @@ namespace OpenSim.Groups private IGroupsServicesConnector m_groupData = null; // Config Options - private bool m_groupMessagingEnabled = false; - private bool m_debugEnabled = true; + private bool m_groupMessagingEnabled; + private bool m_debugEnabled; /// /// If enabled, module only tries to send group IMs to online users by querying cached presence information. @@ -120,7 +120,7 @@ namespace OpenSim.Groups return; } - m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); + m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled); m_log.InfoFormat( "[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}", @@ -140,6 +140,14 @@ namespace OpenSim.Groups scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; scene.EventManager.OnClientLogin += OnClientLogin; + + scene.AddCommand( + "Debug", + this, + "debug groups messaging verbose", + "debug groups messaging verbose ", + "This setting turns on very verbose groups messaging debugging", + HandleDebugGroupsMessagingVerbose); } public void RegionLoaded(Scene scene) @@ -227,6 +235,26 @@ namespace OpenSim.Groups #endregion + private void HandleDebugGroupsMessagingVerbose(object modules, string[] args) + { + if (args.Length < 5) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + bool verbose = false; + if (!bool.TryParse(args[4], out verbose)) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + m_debugEnabled = verbose; + + MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled); + } + /// /// Not really needed, but does confirm that the group exists. /// @@ -255,6 +283,8 @@ namespace OpenSim.Groups public void SendMessageToGroup( GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func sendCondition) { + int requestStartTick = Environment.TickCount; + UUID fromAgentID = new UUID(im.fromAgentID); // Unlike current XmlRpcGroups, Groups V2 can accept UUID.Zero when a perms check for the requesting agent @@ -287,8 +317,6 @@ namespace OpenSim.Groups // "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online", // groupID, groupMembersCount, groupMembers.Count()); - int requestStartTick = Environment.TickCount; - im.imSessionID = groupID.Guid; im.fromGroup = true; IClientAPI thisClient = GetActiveClient(fromAgentID); diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs index 1425a23c39..7450c1442e 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs @@ -32,29 +32,47 @@ using System.Reflection; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenMetaverse; using log4net; +using Nini.Config; namespace OpenSim.Groups { - public class GroupsServiceRemoteConnector + public class GroupsServiceRemoteConnector { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI; - private string m_SecretKey; + private IServiceAuth m_Auth; private object m_Lock = new object(); - public GroupsServiceRemoteConnector(string url, string secret) + public GroupsServiceRemoteConnector(IConfigSource config) { + IConfig groupsConfig = config.Configs["Groups"]; + string url = groupsConfig.GetString("GroupsServerURI", string.Empty); + if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) + throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); + m_ServerURI = url; if (!m_ServerURI.EndsWith("/")) m_ServerURI += "/"; - m_SecretKey = secret; - m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); + /// This is from BaseServiceConnector + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", "Groups" }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, "Groups"); + break; + } + /// + + m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}", + m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); } public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, @@ -656,14 +674,13 @@ namespace OpenSim.Groups private Dictionary MakeRequest(string method, Dictionary sendData) { sendData["METHOD"] = method; - if (m_SecretKey != string.Empty) - sendData["KEY"] = m_SecretKey; string reply = string.Empty; lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "groups", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), + m_Auth); if (reply == string.Empty) return null; diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs index 5fb3c19883..fddda225ce 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs @@ -72,13 +72,7 @@ namespace OpenSim.Groups private void Init(IConfigSource config) { - IConfig groupsConfig = config.Configs["Groups"]; - string url = groupsConfig.GetString("GroupsServerURI", string.Empty); - if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) - throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); - - string secret = groupsConfig.GetString("SecretKey", string.Empty); - m_GroupsService = new GroupsServiceRemoteConnector(url, secret); + m_GroupsService = new GroupsServiceRemoteConnector(config); m_Scenes = new List(); } diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 828965f9ae..55ae6dbc20 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; using log4net; using OpenMetaverse; @@ -64,12 +65,14 @@ namespace OpenSim.Groups key = groupsConfig.GetString("SecretKey", string.Empty); m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); } - else - m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); +// else +// m_log.DebugFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); m_GroupsService = new GroupsService(config); - server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth)); } } @@ -78,13 +81,11 @@ namespace OpenSim.Groups private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private GroupsService m_GroupsService; - private string m_SecretKey = String.Empty; - public GroupsServicePostHandler(GroupsService service, string key) : - base("POST", "/groups") + public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) : + base("POST", "/groups", auth) { m_GroupsService = service; - m_SecretKey = key; } protected override byte[] ProcessRequest(string path, Stream requestData, @@ -108,20 +109,6 @@ namespace OpenSim.Groups string method = request["METHOD"].ToString(); request.Remove("METHOD"); - if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required - { - // Sender didn't send key - if (!request.ContainsKey("KEY") || (request["KEY"] == null)) - return FailureResult("This service requires a secret key"); - - // Sender sent wrong key - if (!m_SecretKey.Equals(request["KEY"])) - return FailureResult("Provided key does not match existing one"); - - // OK, key matches. Remove it. - request.Remove("KEY"); - } - m_log.DebugFormat("[Groups.Handler]: {0}", method); switch (method) { diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs index 5ef068a251..5340bcd094 100644 --- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs +++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs @@ -66,7 +66,7 @@ namespace OpenSim.OfflineIM if (serviceLocation == string.Empty) m_OfflineIMService = new OfflineIMService(config); else - m_OfflineIMService = new OfflineIMServiceRemoteConnector(serviceLocation); + m_OfflineIMService = new OfflineIMServiceRemoteConnector(config); m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); m_log.DebugFormat("[OfflineIM.V2]: Offline messages enabled by {0}", Name); @@ -226,10 +226,6 @@ namespace OpenSim.OfflineIM return; } - Scene scene = FindScene(new UUID(im.fromAgentID)); - if (scene == null) - scene = m_SceneList[0]; - string reason = string.Empty; bool success = m_OfflineIMService.StoreMessage(im, out reason); diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs index eb287a4918..047b8becf3 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs @@ -32,6 +32,7 @@ using System.Reflection; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; @@ -46,6 +47,7 @@ namespace OpenSim.OfflineIM private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI = string.Empty; + private IServiceAuth m_Auth; private object m_Lock = new object(); public OfflineIMServiceRemoteConnector(string url) @@ -65,6 +67,18 @@ namespace OpenSim.OfflineIM m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty); + /// This is from BaseServiceConnector + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", "Messaging" }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, "Messaging"); + break; + } + /// + m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}", + m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); } #region IOfflineIMService @@ -143,7 +157,8 @@ namespace OpenSim.OfflineIM lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/offlineim", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), + m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs index ed5c742b78..c44b6ccb68 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; using log4net; using OpenMetaverse; @@ -59,7 +60,9 @@ namespace OpenSim.OfflineIM m_OfflineIMService = new OfflineIMService(config); - server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService, auth)); } } @@ -69,8 +72,8 @@ namespace OpenSim.OfflineIM private IOfflineIMService m_OfflineIMService; - public OfflineIMServicePostHandler(IOfflineIMService service) : - base("POST", "/offlineim") + public OfflineIMServicePostHandler(IOfflineIMService service, IServiceAuth auth) : + base("POST", "/offlineim", auth) { m_OfflineIMService = service; } diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs index 690c955660..02084ffbfe 100644 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs +++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs @@ -104,7 +104,7 @@ namespace OpenSim.OfflineIM using (MemoryStream mstream = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; + settings.Encoding = Util.UTF8NoBomEncoding; using (XmlWriter writer = XmlWriter.Create(mstream, settings)) { @@ -112,7 +112,7 @@ namespace OpenSim.OfflineIM writer.Flush(); } - imXml = Util.UTF8.GetString(mstream.ToArray()); + imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray()); } OfflineIMData data = new OfflineIMData(); diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 7b3124af57..828e943df8 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -56,12 +56,15 @@ namespace OpenSim.Capabilities.Handlers public const string DefaultFormat = "x-j2c"; // TODO: Change this to a config option - const string REDIRECT_URL = null; + private string m_RedirectURL = null; - public GetTextureHandler(string path, IAssetService assService, string name, string description) + public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL) : base("GET", path, name, description) { m_assetService = assService; + m_RedirectURL = redirectURL; + if (m_RedirectURL != null && !m_RedirectURL.EndsWith("/")) + m_RedirectURL += "/"; } protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) @@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers if (format != DefaultFormat) fullID = fullID + "-" + format; - if (!String.IsNullOrEmpty(REDIRECT_URL)) + if (!String.IsNullOrEmpty(m_RedirectURL)) { // Only try to fetch locally cached textures. Misses are redirected texture = m_assetService.GetCached(fullID); @@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers } else { - string textureUrl = REDIRECT_URL + textureID.ToString(); + string textureUrl = m_RedirectURL + "?texture_id="+ textureID.ToString(); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); + httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; httpResponse.RedirectLocation = textureUrl; return true; } diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs index 71cf033437..fa0b2280ef 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs @@ -62,8 +62,10 @@ namespace OpenSim.Capabilities.Handlers if (m_AssetService == null) throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); + string rurl = serverConfig.GetString("GetTextureRedirectURL"); + ; server.AddStreamHandler( - new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null)); + new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null, rurl)); } } } \ No newline at end of file diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index d4d6d10d83..8ffafa4889 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs @@ -52,7 +52,7 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests // Overkill - we only really need the asset service, not a whole scene. Scene scene = new SceneHelpers().SetupScene(); - GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null); + GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null, null); TestOSHttpRequest req = new TestOSHttpRequest(); TestOSHttpResponse resp = new TestOSHttpResponse(); req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012"); diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 8e39229939..afa499e126 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL if (string.IsNullOrEmpty(pattern)) pattern = "1"; else - pattern = string.Format("Name LIKE '%{0}%'", pattern); + pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); } diff --git a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs index 2151568a01..826c6fc11a 100644 --- a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs +++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs @@ -300,7 +300,6 @@ namespace OpenSim.Data.PGSQL m_Realm, where); cmd.Connection = conn; cmd.CommandText = query; - //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); conn.Open(); @@ -308,6 +307,25 @@ namespace OpenSim.Data.PGSQL } } + public virtual T[] Get(string where, NpgsqlParameter parameter) + { + using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + + string query = String.Format("SELECT * FROM {0} WHERE {1}", + m_Realm, where); + cmd.Connection = conn; + cmd.CommandText = query; + //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); + + cmd.Parameters.Add(parameter); + + conn.Open(); + return DoQuery(cmd); + } + } + public virtual bool Store(T row) { List constraintFields = GetConstraints(); diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index ed75b638a9..669e3c8174 100644 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs @@ -83,11 +83,15 @@ namespace OpenSim.Data.PGSQL public GroupData[] RetrieveGroups(string pattern) { if (string.IsNullOrEmpty(pattern)) // True for where clause + { pattern = " true ORDER BY lower(\"Name\") LIMIT 100"; + return m_Groups.Get(pattern); + } else - pattern = string.Format(" lower(\"Name\") LIKE lower('%{0}%') ORDER BY lower(\"Name\") LIMIT 100", pattern); - - return m_Groups.Get(pattern); + { + pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"; + return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); + } } public bool DeleteGroup(UUID groupID) diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index f2fe49452a..0d053e4db4 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -321,6 +321,8 @@ namespace OpenSim.Framework Mac = args["mac"].AsString(); if (args["id0"] != null) Id0 = args["id0"].AsString(); + if (args["teleport_flags"] != null) + teleportFlags = args["teleport_flags"].AsUInteger(); if (args["start_pos"] != null) Vector3.TryParse(args["start_pos"].AsString(), out startpos); diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e7f0ca8266..89e6aa1cce 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -35,6 +35,8 @@ using System.Threading; using System.Web; using log4net; +using OpenSim.Framework.ServiceAuth; + namespace OpenSim.Framework.Communications { /// @@ -297,7 +299,7 @@ namespace OpenSim.Framework.Communications /// /// Perform a synchronous request /// - public Stream Request() + public Stream Request(IServiceAuth auth) { lock (_lock) { @@ -307,6 +309,8 @@ namespace OpenSim.Framework.Communications _request.Timeout = 200000; _request.Method = RequestMethod; _asyncException = null; + if (auth != null) + auth.AddAuthorization(_request.Headers); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); try @@ -358,7 +362,7 @@ namespace OpenSim.Framework.Communications } } - public Stream Request(Stream src) + public Stream Request(Stream src, IServiceAuth auth) { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; @@ -367,6 +371,8 @@ namespace OpenSim.Framework.Communications _request.Method = RequestMethod; _asyncException = null; _request.ContentLength = src.Length; + if (auth != null) + auth.AddAuthorization(_request.Headers); m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); @@ -384,7 +390,22 @@ namespace OpenSim.Framework.Communications length = src.Read(buf, 0, 1024); } - _response = (HttpWebResponse) _request.GetResponse(); + try + { + _response = (HttpWebResponse)_request.GetResponse(); + } + catch (WebException e) + { + m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", + RequestMethod, _request.RequestUri, e.Status, e.Message); + } + catch (Exception e) + { + m_log.WarnFormat( + "[REST]: Request {0} {1} failed with exception {2} {3}", + RequestMethod, _request.RequestUri, e.Message, e.StackTrace); + } + // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -423,7 +444,7 @@ namespace OpenSim.Framework.Communications try { // Perform the operation; if sucessful set the result - Stream s = Request(); + Stream s = Request(null); ar.SetAsCompleted(s, false); } catch (Exception e) diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index a967db6271..260a86fb9a 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -46,6 +46,11 @@ namespace OpenSim.Framework.Console // private readonly object m_syncRoot = new object(); private const string LOGLEVEL_NONE = "(none)"; + // Used to extract categories for colourization. + private Regex m_categoryRegex + = new Regex( + @"^(?.*?)\[(?[^\]]+)\]:?(?.*)", RegexOptions.Singleline | RegexOptions.Compiled); + private int m_cursorYPosition = -1; private int m_cursorXPosition = 0; private StringBuilder m_commandLine = new StringBuilder(); @@ -280,11 +285,8 @@ namespace OpenSim.Framework.Console string outText = text; if (level != LOGLEVEL_NONE) - { - string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - - Regex RE = new Regex(regex, RegexOptions.Multiline); - MatchCollection matches = RE.Matches(text); + { + MatchCollection matches = m_categoryRegex.Matches(text); if (matches.Count == 1) { diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index 709b5160d2..4b5326a7fc 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs @@ -213,8 +213,13 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate)); xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice)); xtw.WriteElementString("GlobalID", landData.GlobalID.ToString()); - xtw.WriteElementString("GroupID", landData.GroupID.ToString()); - xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned)); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : landData.GroupID; + xtw.WriteElementString("GroupID", groupID.ToString()); + + bool isGroupOwned = options.ContainsKey("wipe-owners") ? false : landData.IsGroupOwned; + xtw.WriteElementString("IsGroupOwned", Convert.ToString(isGroupOwned)); + xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap)); xtw.WriteElementString("Description", landData.Description); xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags)); @@ -227,13 +232,8 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("MediaURL", landData.MediaURL); xtw.WriteElementString("MusicURL", landData.MusicURL); - UUID ownerIdToWrite; - if (options != null && options.ContainsKey("wipe-owners")) - ownerIdToWrite = UUID.Zero; - else - ownerIdToWrite = landData.OwnerID; - - xtw.WriteElementString("OwnerID", ownerIdToWrite.ToString()); + UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : landData.OwnerID; + xtw.WriteElementString("OwnerID", ownerID.ToString()); xtw.WriteStartElement("ParcelAccessList"); foreach (LandAccessEntry pal in landData.ParcelAccessList) diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index ea100ee71c..e81cb78cfd 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs @@ -121,7 +121,8 @@ namespace OpenSim.Framework.Serialization.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, null)); + Dictionary options = new Dictionary(); + LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, options)); Assert.That(ld, Is.Not.Null, "Deserialize(string) returned null"); // Assert.That(ld.AABBMax, Is.EqualTo(land.AABBMax)); // Assert.That(ld.AABBMin, Is.EqualTo(land.AABBMin)); diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 252cc2ad81..f1607342d4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs @@ -26,6 +26,8 @@ */ using System.IO; +using System.Net; +using OpenSim.Framework.ServiceAuth; namespace OpenSim.Framework.Servers.HttpServer { @@ -37,15 +39,30 @@ namespace OpenSim.Framework.Servers.HttpServer /// public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler { - protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} + protected IServiceAuth m_Auth; + + protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { } protected BaseStreamHandler(string httpMethod, string path, string name, string description) : base(httpMethod, path, name, description) {} + protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth) + : base(httpMethod, path, null, null) + { + m_Auth = auth; + } + public virtual byte[] Handle( string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { RequestsReceived++; + if (m_Auth != null && !m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader)) + { + + httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; + httpResponse.ContentType = "text/plain"; + return new byte[0]; + } byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index ed6a14cd81..2fe1a7d8bc 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs @@ -90,14 +90,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -107,15 +107,15 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } if (!response.ContainsKey("result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } @@ -161,14 +161,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -176,8 +176,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs new file mode 100644 index 0000000000..f33a045917 --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Reflection; + +using Nini.Config; +using log4net; + +namespace OpenSim.Framework.ServiceAuth +{ + public class BasicHttpAuthentication : IServiceAuth + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_Username, m_Password; + private string m_CredentialsB64; + + private string remove_me; + + public string Credentials + { + get { return m_CredentialsB64; } + } + + public BasicHttpAuthentication(IConfigSource config, string section) + { + remove_me = section; + m_Username = Util.GetConfigVarFromSections(config, "HttpAuthUsername", new string[] { "Network", section }, string.Empty); + m_Password = Util.GetConfigVarFromSections(config, "HttpAuthPassword", new string[] { "Network", section }, string.Empty); + string str = m_Username + ":" + m_Password; + byte[] encData_byte = Util.UTF8.GetBytes(str); + + m_CredentialsB64 = Convert.ToBase64String(encData_byte); + m_log.DebugFormat("[HTTP BASIC AUTH]: {0} {1} [{2}]", m_Username, m_Password, section); + } + + public void AddAuthorization(NameValueCollection headers) + { + //m_log.DebugFormat("[HTTP BASIC AUTH]: Adding authorization for {0}", remove_me); + headers["Authorization"] = "Basic " + m_CredentialsB64; + } + + public bool Authenticate(string data) + { + string recovered = Util.Base64ToString(data); + if (!String.IsNullOrEmpty(recovered)) + { + string[] parts = recovered.Split(new char[] { ':' }); + if (parts.Length >= 2) + { + return m_Username.Equals(parts[0]) && m_Password.Equals(parts[1]); + } + } + + return false; + } + + public bool Authenticate(NameValueCollection requestHeaders, AddHeaderDelegate d) + { + //m_log.DebugFormat("[HTTP BASIC AUTH]: Authenticate in {0}", remove_me); + if (requestHeaders != null) + { + string value = requestHeaders.Get("Authorization"); + if (value != null) + { + value = value.Trim(); + if (value.StartsWith("Basic ")) + { + value = value.Replace("Basic ", string.Empty); + if (Authenticate(value)) + return true; + } + } + } + d("WWW-Authenticate", "Basic realm = \"Asset Server\""); + return false; + } + } +} diff --git a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs new file mode 100644 index 0000000000..415dc12e18 --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; + +namespace OpenSim.Framework.ServiceAuth +{ + public delegate void AddHeaderDelegate(string key, string value); + + public interface IServiceAuth + { + bool Authenticate(string data); + bool Authenticate(NameValueCollection headers, AddHeaderDelegate d); + void AddAuthorization(NameValueCollection headers); + } +} diff --git a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs new file mode 100644 index 0000000000..bc32d901bf --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +using Nini.Config; + +namespace OpenSim.Framework.ServiceAuth +{ + public class ServiceAuth + { + public static IServiceAuth Create(IConfigSource config, string section) + { + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", section }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + return new BasicHttpAuthentication(config, section); + } + + return null; + } + } +} diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 70fab77809..e614fd5f63 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -45,6 +45,8 @@ using Nwc.XmlRpc; using OpenMetaverse.StructuredData; using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; +using OpenSim.Framework.ServiceAuth; + namespace OpenSim.Framework { /// @@ -772,6 +774,13 @@ namespace OpenSim.Framework public static void MakeRequest(string verb, string requestUrl, TRequest obj, Action action, int maxConnections) + { + MakeRequest(verb, requestUrl, obj, action, maxConnections, null); + } + + public static void MakeRequest(string verb, + string requestUrl, TRequest obj, Action action, + int maxConnections, IServiceAuth auth) { int reqnum = WebUtil.RequestNumber++; @@ -786,6 +795,10 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; + + if (auth != null) + auth.AddAuthorization(ht.Headers); + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) ht.ServicePoint.ConnectionLimit = maxConnections; @@ -969,7 +982,7 @@ namespace OpenSim.Framework /// /// Thrown if we encounter a network issue while posting /// the request. You'll want to make sure you deal with this as they're not uncommon - public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) + public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs, IServiceAuth auth) { int reqnum = WebUtil.RequestNumber++; @@ -984,6 +997,10 @@ namespace OpenSim.Framework request.Method = verb; if (timeoutsecs > 0) request.Timeout = timeoutsecs * 1000; + + if (auth != null) + auth.AddAuthorization(request.Headers); + string respstring = String.Empty; using (MemoryStream buffer = new MemoryStream()) @@ -1068,10 +1085,20 @@ namespace OpenSim.Framework return respstring; } + public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) + { + return MakeRequest(verb, requestUrl, obj, timeoutsecs, null); + } + public static string MakeRequest(string verb, string requestUrl, string obj) { return MakeRequest(verb, requestUrl, obj, -1); } + + public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, -1, auth); + } } public class SynchronousRestObjectRequester @@ -1085,22 +1112,75 @@ namespace OpenSim.Framework /// /// /// - /// - /// - /// - /// Thrown if we encounter a network issue while posting - /// the request. You'll want to make sure you deal with this as they're not uncommon + /// + /// + /// The response. If there was an internal exception, then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj) { return MakeRequest(verb, requestUrl, obj, 0); } + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, 0, auth); + } + /// + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout) { return MakeRequest(verb, requestUrl, obj, pTimeout, 0); } + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, pTimeout, 0, auth); + } + + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// + /// + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) + { + return MakeRequest(verb, requestUrl, obj, pTimeout, maxConnections, null); + } + + /// + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// + /// + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections, IServiceAuth auth) { int reqnum = WebUtil.RequestNumber++; @@ -1116,6 +1196,13 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; + + if (auth != null) + auth.AddAuthorization(ht.Headers); + + if (pTimeout != 0) + ht.Timeout = pTimeout; + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) ht.ServicePoint.ConnectionLimit = maxConnections; @@ -1191,8 +1278,18 @@ namespace OpenSim.Framework { using (HttpWebResponse hwr = (HttpWebResponse)e.Response) { - if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) - return deserial; + if (hwr != null) + { + if (hwr.StatusCode == HttpStatusCode.NotFound) + return deserial; + if (hwr.StatusCode == HttpStatusCode.Unauthorized) + { + m_log.Error(string.Format( + "[SynchronousRestObjectRequester]: Web request {0} requires authentication ", + requestUrl)); + return deserial; + } + } else m_log.Error(string.Format( "[SynchronousRestObjectRequester]: WebException for {0} {1} {2} ", diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 54cf285cf6..bb932f293f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_Enabled = false; // TODO: Change this to a config option - const string REDIRECT_URL = null; + private string m_RedirectURL = null; private string m_URL; @@ -78,7 +78,10 @@ namespace OpenSim.Region.ClientStack.Linden m_URL = config.GetString("Cap_GetTexture", string.Empty); // Cap doesn't exist if (m_URL != string.Empty) + { m_Enabled = true; + m_RedirectURL = config.GetString("GetTextureRedirectURL"); + } } public void AddRegion(Scene s) @@ -132,14 +135,14 @@ namespace OpenSim.Region.ClientStack.Linden // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); caps.RegisterHandler( "GetTexture", - new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); + new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL)); } else { // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); IExternalCapsModule handler = m_scene.RequestModuleInterface(); if (handler != null) - handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture",m_URL); + handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL); else caps.RegisterHandler("GetTexture", m_URL); } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs index edc5016064..ee1ea1a548 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs @@ -152,7 +152,7 @@ namespace OpenSim.Region.ClientStack.Linden.Caps.Tests // A sanity check that the response has the expected number of descendents for a default inventory // TODO: Need a more thorough check. - Assert.That((int)folderOsd["descendents"], Is.EqualTo(14)); + Assert.That((int)folderOsd["descendents"], Is.EqualTo(16)); } } } \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 53217a09dc..c28e58d6a9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -8949,7 +8949,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - return ((Scene)Scene).AssetService.Get(assetServer + "/" + id); + if (!string.IsNullOrEmpty(assetServer)) + return ((Scene)Scene).AssetService.Get(assetServer + "/" + id); } return null; @@ -12658,16 +12659,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (asset == null) { - req.AssetInf = null; - req.AssetRequestSource = source; - req.IsTextureRequest = false; - req.NumPackets = 0; - req.Params = transferRequest.TransferInfo.Params; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; + // Try the user's asset server + IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface(); + + string assetServerURL = string.Empty; + if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL)) + { + if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("=")) + assetServerURL = assetServerURL + "/"; + + //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id); + asset = m_scene.AssetService.Get(assetServerURL + id); + } + + if (asset == null) + { + req.AssetInf = null; + req.AssetRequestSource = source; + req.IsTextureRequest = false; + req.NumPackets = 0; + req.Params = transferRequest.TransferInfo.Params; + req.RequestAssetID = requestID; + req.TransferRequestID = transferRequest.TransferInfo.TransferID; + + SendAssetNotFound(req); + return; + } - SendAssetNotFound(req); - return; } if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e9b2f4fc73..73337695b1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -774,15 +774,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), sp.UUID); - m_scene.AssetService.Store(asset); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = (int)InventoryType.Object; + IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); - m_scene.InventoryService.UpdateItem(item); + invAccess.UpdateInventoryItemAsset(sp.UUID, item, asset); // If the name of the object has been changed whilst attached then we want to update the inventory // item in the viewer. diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index af8a0c1a86..780d17b172 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs @@ -37,6 +37,7 @@ using System.Collections.Generic; using System.Reflection; using log4net; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -54,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures private string m_URL = String.Empty; private static XmlSerializer m_serializer = new XmlSerializer(typeof(AssetBase)); - + private static IServiceAuth m_Auth; public void Initialise(IConfigSource configSource) { @@ -63,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures return; m_URL = config.GetString("URL", String.Empty); + m_Auth = ServiceAuth.Create(configSource, "XBakes"); } public void AddRegion(Scene scene) @@ -110,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures try { - Stream s = rc.Request(); + Stream s = rc.Request(m_Auth); XmlTextReader sr = new XmlTextReader(s); sr.ReadStartElement("BakedAppearance"); @@ -183,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures Util.FireAndForget( delegate { - rc.Request(reqStream); + rc.Request(reqStream, m_Auth); } ); } diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs new file mode 100644 index 0000000000..7b8c418d79 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -0,0 +1,286 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using log4net.Config; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.CoreModules.Avatar.Chat; +using OpenSim.Region.CoreModules.Framework; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests +{ + [TestFixture] + public class ChatModuleTests : OpenSimTestCase + { + [TestFixtureSetUp] + public void FixtureInit() + { + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + // We must do this here so that child agent positions are updated in a predictable manner. + Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; + } + + [TestFixtureTearDown] + public void TearDown() + { + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple + // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression + // tests really shouldn't). + Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; + } + + private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB) + { + // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the + // CapabilitiesModule complain when it can't set up HTTP endpoints. + // BaseHttpServer httpServer = new BaseHttpServer(99999); + // MainServer.AddHttpServer(httpServer); + // MainServer.Instance = httpServer; + + // We need entity transfer modules so that when sp2 logs into the east region, the region calls + // EntityTransferModuleto set up a child agent on the west region. + // XXX: However, this is not an entity transfer so is misleading. + EntityTransferModule etmA = new EntityTransferModule(); + EntityTransferModule etmB = new EntityTransferModule(); + LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Chat"); + IConfig modulesConfig = config.AddConfig("Modules"); + modulesConfig.Set("EntityTransferModule", etmA.Name); + modulesConfig.Set("SimulationServices", lscm.Name); + + SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); + SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule()); + SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule()); + } + + /// + /// Tests chat between neighbour regions on the east-west axis + /// + /// + /// Really, this is a combination of a child agent position update test and a chat range test. These need + /// to be separated later on. + /// + [Test] + public void TestInterRegionChatDistanceEastWest() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID sp1Uuid = TestHelpers.ParseTail(0x11); + UUID sp2Uuid = TestHelpers.ParseTail(0x12); + + Vector3 sp1Position = new Vector3(6, 128, 20); + Vector3 sp2Position = new Vector3(250, 128, 20); + + SceneHelpers sh = new SceneHelpers(); + TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000); + TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000); + + SetupNeighbourRegions(sceneWest, sceneEast); + + ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid); + TestClient sp1Client = (TestClient)sp1.ControllingClient; + + // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0. + // TODO: May need to create special complete no-op test physics module rather than basic physics, since + // physics is irrelevant to this test. + sp1.Flying = true; + + // When sp1 logs in to sceneEast, it sets up a child agent in sceneWest and informs the sp2 client to + // make the connection. For this test, will simplify this chain by making the connection directly. + ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneWest, sp1Uuid); + TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; + + sp1.AbsolutePosition = sp1Position; + + ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid); + TestClient sp2Client = (TestClient)sp2.ControllingClient; + sp2.Flying = true; + + ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid); + TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; + + sp2.AbsolutePosition = sp2Position; + + // We must update the scenes in order to make the root new root agents trigger position updates in their + // children. + sceneWest.Update(1); + sceneEast.Update(1); + + // Check child positions are correct. + Assert.AreEqual( + new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + Assert.AreEqual( + new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z), + sp2ChildClient.SceneAgent.AbsolutePosition); + + string receivedSp1ChatMessage = ""; + string receivedSp2ChatMessage = ""; + + sp1ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; + + TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); + TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage); + + sp1Position = new Vector3(30, 128, 20); + sp1.AbsolutePosition = sp1Position; + sceneEast.Update(1); + + // Check child position is correct. + Assert.AreEqual( + new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); + TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage); + } + + /// + /// Tests chat between neighbour regions on the north-south axis + /// + /// + /// Really, this is a combination of a child agent position update test and a chat range test. These need + /// to be separated later on. + /// + [Test] + public void TestInterRegionChatDistanceNorthSouth() + { + TestHelpers.InMethod(); + // TestHelpers.EnableLogging(); + + UUID sp1Uuid = TestHelpers.ParseTail(0x11); + UUID sp2Uuid = TestHelpers.ParseTail(0x12); + + Vector3 sp1Position = new Vector3(128, 250, 20); + Vector3 sp2Position = new Vector3(128, 6, 20); + + SceneHelpers sh = new SceneHelpers(); + TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000); + TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001); + + SetupNeighbourRegions(sceneNorth, sceneSouth); + + ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid); + TestClient sp1Client = (TestClient)sp1.ControllingClient; + + // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0. + // TODO: May need to create special complete no-op test physics module rather than basic physics, since + // physics is irrelevant to this test. + sp1.Flying = true; + + // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to + // make the connection. For this test, will simplify this chain by making the connection directly. + ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid); + TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; + + sp1.AbsolutePosition = sp1Position; + + ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid); + TestClient sp2Client = (TestClient)sp2.ControllingClient; + sp2.Flying = true; + + ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid); + TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; + + sp2.AbsolutePosition = sp2Position; + + // We must update the scenes in order to make the root new root agents trigger position updates in their + // children. + sceneNorth.Update(1); + sceneSouth.Update(1); + + // Check child positions are correct. + Assert.AreEqual( + new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + Assert.AreEqual( + new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z), + sp2ChildClient.SceneAgent.AbsolutePosition); + + string receivedSp1ChatMessage = ""; + string receivedSp2ChatMessage = ""; + + sp1ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; + + TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); + TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage); + + sp1Position = new Vector3(30, 128, 20); + sp1.AbsolutePosition = sp1Position; + sceneNorth.Update(1); + + // Check child position is correct. + Assert.AreEqual( + new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); + TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage); + } + + private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage) + { + receivedMessage = ""; + + speakClient.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreEqual(testMessage, receivedMessage); + } + + private void TestUserOutOfRange(TestClient speakClient, string testMessage, ref string receivedMessage) + { + receivedMessage = ""; + + speakClient.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreNotEqual(testMessage, receivedMessage); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index c51b30fe6e..6f3c80a260 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage success = m_IMService.OutgoingInstantMessage(im, url, foreigner); if (!success && !foreigner) - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); else result(success); }); @@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return successful; } - protected void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) + public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result) { UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 40a400f957..2462ff837b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage SendGridInstantMessageViaXMLRPC(im, result); } - private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) + public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result) { UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; @@ -428,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -442,138 +442,87 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, GridInstantMessageCompleted, d); } /// - /// Recursive SendGridInstantMessage over XMLRPC method. - /// This is called from within a dedicated thread. - /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from - /// itself, prevRegionHandle will be the last region handle that we tried to send. - /// If the handles are the same, we look up the user's location using the grid. - /// If the handles are still the same, we end. The send failed. + /// Internal SendGridInstantMessage over XMLRPC method. /// - /// - /// Pass in 0 the first time this method is called. It will be called recursively with the last - /// regionhandle tried - /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) + /// + /// This is called from within a dedicated thread. + /// + private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); - - PresenceInfo upd = null; - - bool lookupAgent = false; + UUID regionID; + bool needToLookupAgent; lock (m_UserRegionMap) - { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - upd = new PresenceInfo(); - upd.RegionID = m_UserRegionMap[toAgentID]; + needToLookupAgent = !m_UserRegionMap.TryGetValue(toAgentID, out regionID); - // We need to compare the current regionhandle with the previous region handle - // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionID == upd.RegionID) - { - lookupAgent = true; - } - } - else - { - lookupAgent = true; - } - } - - - // Are we needing to look-up an agent? - if (lookupAgent) + while (true) { - // Non-cached user agent lookup. - PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - if (presences != null && presences.Length > 0) + if (needToLookupAgent) { - foreach (PresenceInfo p in presences) + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + + UUID foundRegionID = UUID.Zero; + + if (presences != null) { - if (p.RegionID != UUID.Zero) + foreach (PresenceInfo p in presences) { - upd = p; - break; + if (p.RegionID != UUID.Zero) + { + foundRegionID = p.RegionID; + break; + } } } + + // If not found or the found region is the same as the last lookup, then message is undeliverable + if (foundRegionID == UUID.Zero || foundRegionID == regionID) + break; + else + regionID = foundRegionID; } - if (upd != null) + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, regionID); + if (reginfo == null) { - // check if we've tried this before.. - // This is one way to end the recursive loop - // - if (upd.RegionID == prevRegionID) - { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); - return; - } + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", regionID); + break; } - else + + // Try to send the message to the agent via the retrieved region. + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + + // If the message delivery was successful, then cache the entry. + if (imresult) { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); + lock (m_UserRegionMap) + { + m_UserRegionMap[toAgentID] = regionID; + } + result(true); return; } + + // If we reach this point in the first iteration of the while, then we may have unsuccessfully tried + // to use a locally cached region ID. All subsequent attempts need to lookup agent details from + // the presence service. + needToLookupAgent = true; } - if (upd != null) - { - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) - { - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - if (imresult) - { - // IM delivery successful, so store the Agent's location in our local cache. - lock (m_UserRegionMap) - { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - m_UserRegionMap[toAgentID] = upd.RegionID; - } - else - { - m_UserRegionMap.Add(toAgentID, upd.RegionID); - } - } - result(true); - } - else - { - // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC + // If we reached this point then the message was not deliverable. Remove the bad cache entry and + // signal the delivery failure. + lock (m_UserRegionMap) + m_UserRegionMap.Remove(toAgentID); - // This is recursive!!!!! - SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.RegionID); - } - } - else - { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliveredMessage(im, result); - } - } - else - { - HandleUndeliveredMessage(im, result); - } + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + HandleUndeliverableMessage(im, result); } /// @@ -584,7 +533,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// Bool if the message was successfully delivered at the other side. protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata) { - ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 7f3d0a2584..c75920d8df 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -226,12 +226,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; } - Scene scene = FindScene(new UUID(im.fromAgentID)); - if (scene == null) - scene = m_SceneList[0]; - bool success = SynchronousRestObjectRequester.MakeRequest( - "POST", m_RestURL+"/SaveMessage/", im); + "POST", m_RestURL+"/SaveMessage/", im, 10000); if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) { diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 1ee2a7bb84..c4b5aac50f 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -484,6 +484,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating classified", false); + return; } } @@ -510,6 +511,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error classified delete", false); + return; } parameters = (OSDMap)Params; @@ -612,6 +614,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error selecting pick", false); + return; } pick = (UserProfilePick) Pick; @@ -714,6 +717,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating pick", false); + return; } m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString()); @@ -740,6 +744,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error picks delete", false); + return; } } #endregion Picks @@ -807,6 +812,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles object Note = note; if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString())) { + remoteClient.SendAgentAlertMessage( + "Error updating note", false); return; } } @@ -916,6 +923,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating interests", false); + return; } } @@ -1044,6 +1052,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating properties", false); + return; } RequestAvatarProperties(remoteClient, newProfile.ID); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 539367d87f..e5835902c1 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -761,12 +761,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason; string version; if (!Scene.SimulationService.QueryAccess( - finalDestination, sp.ControllingClient.AgentId, homeURI, position, out version, out reason)) + finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, out version, out reason)) { sp.ControllingClient.SendTeleportFailed(reason); m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", + "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because: {3}", sp.Name, sp.Scene.Name, finalDestination.RegionName, reason); return; @@ -1510,7 +1510,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Check to see if we have access to the target region. if (neighbourRegion != null - && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, newpos, out version, out failureReason)) + && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, out version, out failureReason)) { // remember banned m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index ce7ed26832..5e831cca63 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -64,6 +64,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess private bool m_bypassPermissions = true; + // This simple check makes it possible to support grids in which all the simulators + // share all central services of the Robust server EXCEPT assets. In other words, + // grids where the simulators' assets are kept in one DB and the users' inventory assets + // are kept on another. When users rez items from inventory or take objects from world, + // an HG-like asset copy takes place between the 2 servers, the world asset server and + // the user's asset server. + private bool m_CheckSeparateAssets = false; + private string m_LocalAssetsURL = string.Empty; + // private bool m_Initialized = false; #region INonSharedRegionModule @@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); + m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false); + m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty); + m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' }); + } else m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); @@ -240,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return newAssetID; } + /// + /// UpdateInventoryItemAsset + /// + public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) + { + if (base.UpdateInventoryItemAsset(ownerID, item, asset)) + { + UploadInventoryItem(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); + return true; + } + + return false; + } + /// /// Used in DeleteToInventory /// @@ -284,50 +311,98 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, RezSelected, RemoveItem, fromTaskID, attachment); - if (sog == null) - remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false); - return sog; } public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) { - string userAssetServer = string.Empty; - if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) - m_assMapper.Get(item.AssetID, sender, userAssetServer); + string senderAssetServer = string.Empty; + string receiverAssetServer = string.Empty; + bool isForeignSender, isForeignReceiver; + isForeignSender = IsForeignUser(sender, out senderAssetServer); + isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); - if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) - m_assMapper.Post(item.AssetID, receiver, userAssetServer); + // They're both local. Nothing to do. + if (!isForeignSender && !isForeignReceiver) + return; + + // At least one of them is foreign. + // If both users have the same asset server, no need to transfer the asset + if (senderAssetServer.Equals(receiverAssetServer)) + { + m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); + return; + } + + if (isForeignSender && senderAssetServer != string.Empty) + m_assMapper.Get(item.AssetID, sender, senderAssetServer); + + if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) + m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); } public override bool IsForeignUser(UUID userID, out string assetServerURL) { assetServerURL = string.Empty; - if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) - { // foreign - ScenePresence sp = null; - if (m_Scene.TryGetScenePresence(userID, out sp)) + if (UserManagementModule != null) + { + if (!m_CheckSeparateAssets) { - AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) - { - assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - assetServerURL = assetServerURL.Trim(new char[] { '/' }); + if (!UserManagementModule.IsLocalGridUser(userID)) + { // foreign + ScenePresence sp = null; + if (m_Scene.TryGetScenePresence(userID, out sp)) + { + AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) + { + assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); + assetServerURL = assetServerURL.Trim(new char[] { '/' }); + } + } + else + { + assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); + assetServerURL = assetServerURL.Trim(new char[] { '/' }); + } + return true; } } else { - assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); - assetServerURL = assetServerURL.Trim(new char[] { '/' }); + if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) + { + m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); + return false; + } + else + { + m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); + return true; + } } - return true; } - return false; } + private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) + { + assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); + if (assetsURL == string.Empty) + { + AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); + if (agent != null) + { + assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); + assetsURL = assetsURL.Trim(new char[] { '/' }); + } + } + return m_LocalAssetsURL.Equals(assetsURL); + } + + protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) { InventoryItemBase item = base.GetItem(agentID, itemID); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index d30ce72171..b4771fd2ca 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_Scene.AssetService.Store(asset); m_Scene.CreateNewInventoryItem( remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); + name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate); } else { @@ -292,7 +292,31 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return UUID.Zero; } - + + public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) + { + if (item != null && item.Owner == ownerID && asset != null) + { + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + + m_Scene.AssetService.Store(asset); + m_Scene.InventoryService.UpdateItem(item); + + return true; + } + else + { + m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}", + (item == null || asset == null? "null item or asset" : "wrong owner")); + return false; + } + + } + public virtual List CopyToInventory( DeRezAction action, UUID folderID, List objectGroups, IClientAPI remoteClient, bool asAttachment) @@ -532,6 +556,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { + // Changing ownership, so apply the "Next Owner" permissions to all of the + // inventory item's permissions. + uint perms = effectivePerms; PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); @@ -546,6 +573,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { + // Not changing ownership. + // In this case we apply the permissions in the object's items ONLY to the inventory + // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions. + // E.g., if the object contains a No-Transfer item then the item's "Next Owner" + // permissions are also No-Transfer. + PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms); + item.BasePermissions = effectivePerms; item.CurrentPermissions = effectivePerms; item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms; @@ -773,12 +807,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", assetID, item.Name, item.ID, remoteClient.Name); + remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0} for item {1}.", assetID, item.Name), false); } else { m_log.WarnFormat( "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()", assetID, remoteClient.Name); + remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0}.", assetID), false); } return null; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs index 4470799f79..93dff1f083 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs @@ -89,35 +89,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization public bool IsAuthorizedForRegion( string user, string firstName, string lastName, string regionID, out string message) { - message = "authorized"; - // This should not happen if (m_Scene.RegionInfo.RegionID.ToString() != regionID) { m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID); - return true; + message = string.Format("Region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID); + return false; } if (m_accessValue == AccessFlags.None) + { + message = "Authorized"; return true; + } UUID userID = new UUID(user); - bool authorized = true; - if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners) + + if ((m_accessValue & AccessFlags.DisallowForeigners) != 0) { - authorized = m_UserManagement.IsLocalGridUser(userID); - if (!authorized) - message = "no foreigner users allowed in this region"; - } - if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents) - { - authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID); - if (!authorized) - message = "only Admins and Managers allowed in this region"; + if (!m_UserManagement.IsLocalGridUser(userID)) + { + message = "No foreign users allowed in this region"; + return false; + } } - return authorized; + if ((m_accessValue & AccessFlags.DisallowResidents) != 0) + { + if (!(m_Scene.Permissions.IsGod(userID) || m_Scene.Permissions.IsAdministrator(userID))) + { + message = "Only Admins and Managers allowed in this region"; + return false; + } + } + + message = "Authorized"; + return true; } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 516ad40fc7..50c252c817 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -69,7 +69,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnMakeRootAgent(ScenePresence sp) { // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); - m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); + if (sp.PresenceType != PresenceType.Npc) + m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); } public void OnNewClient(IClientAPI client) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3348b4272b..926ef05180 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return true; } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Communications failure"; version = ServiceVersion; @@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); - return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, position, out reason); + return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, out reason); } //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 8436488983..0444e49559 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return m_remoteConnector.UpdateAgent(destination, cAgentData); } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Communications failure"; version = "Unknown"; @@ -216,12 +216,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; // Try local first - if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason)) + if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionID)) - return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason); + return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); return false; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index e08a42da9d..b31257dad0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -585,7 +585,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); - tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null)); + Dictionary options = new Dictionary(); + tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index a032bc73d3..eecc4783cf 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -1106,13 +1106,14 @@ namespace OpenSim.Region.CoreModules.World.Estate TerrainUploader = null; } + + m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name); remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); + ITerrainModule terr = Scene.RequestModuleInterface(); if (terr != null) { - m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); - try { MemoryStream terrainStream = new MemoryStream(terrainData); @@ -1161,7 +1162,10 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (TerrainUploader == null) { - m_log.DebugFormat("Starting to receive uploaded terrain"); + m_log.DebugFormat( + "[TERRAIN]: Started receiving terrain upload for region {0} from {1}", + Scene.Name, remote_client.Name); + TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); remote_client.OnXferReceive += TerrainUploader.XferReceive; remote_client.OnAbortXfer += AbortTerrainXferHandler; @@ -1182,7 +1186,7 @@ namespace OpenSim.Region.CoreModules.World.Estate if (terr != null) { - m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); +// m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); if (File.Exists(Util.dataDir() + "/terrain.raw")) { File.Delete(Util.dataDir() + "/terrain.raw"); @@ -1194,8 +1198,9 @@ namespace OpenSim.Region.CoreModules.World.Estate input.Read(bdata, 0, (int)input.Length); remote_client.SendAlertMessage("Terrain file written, starting download..."); Scene.XferManager.AddNewFile("terrain.raw", bdata); - // Tell client about it - m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); + + m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name); + remote_client.SendInitiateDownload("terrain.raw", clientFileName); } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c35f6b7535..de7ea6d79f 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -49,6 +49,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List m_scenes = new List(); List m_Clients; + IWorldMapModule m_WorldMap; + IWorldMapModule WorldMap + { + get + { + if (m_WorldMap == null) + m_WorldMap = m_scene.RequestModuleInterface(); + return m_WorldMap; + } + + } + #region ISharedRegionModule Members public void Initialise(IConfigSource source) { @@ -64,6 +76,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scenes.Add(scene); scene.EventManager.OnNewClient += OnNewClient; m_Clients = new List(); + } public void RemoveRegion(Scene scene) @@ -129,7 +142,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) { List blocks = new List(); - MapBlockData data; if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) { // final block, closing the search result @@ -143,50 +155,50 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } - //m_log.DebugFormat("MAP NAME=({0})", mapName); - - // Hack to get around the fact that ll V3 now drops the port from the - // map name. See https://jira.secondlife.com/browse/VWR-28570 - // - // Caller, use this magic form instead: - // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 - // or url encode if possible. - // the hacks we do with this viewer... - // - string mapNameOrig = mapName; - if (mapName.Contains("|")) - mapName = mapName.Replace('|', ':'); - if (mapName.Contains("+")) - mapName = mapName.Replace('+', ' '); - if (mapName.Contains("!")) - mapName = mapName.Replace('!', '/'); - - // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); - + + string mapNameOrig = mapName; + if (regionInfos.Count == 0) + { + // Hack to get around the fact that ll V3 now drops the port from the + // map name. See https://jira.secondlife.com/browse/VWR-28570 + // + // Caller, use this magic form instead: + // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 + // or url encode if possible. + // the hacks we do with this viewer... + // + if (mapName.Contains("|")) + mapName = mapName.Replace('|', ':'); + if (mapName.Contains("+")) + mapName = mapName.Replace('+', ' '); + if (mapName.Contains("!")) + mapName = mapName.Replace('!', '/'); + + if (mapName != mapNameOrig) + regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); + } + m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); + if (regionInfos.Count > 0) { foreach (GridRegion info in regionInfos) { - data = new MapBlockData(); - data.Agents = 0; - data.Access = info.Access; - if (flags == 2) // V2 sends this - data.MapImageId = UUID.Zero; + if ((flags & 2) == 2) // V2 sends this + { + List datas = WorldMap.Map2BlockFromGridRegion(info, flags); + // ugh! V2-3 is very sensitive about the result being + // exactly the same as the requested name + if (regionInfos.Count == 1 && (mapName != mapNameOrig)) + datas.ForEach(d => d.Name = mapNameOrig); + + blocks.AddRange(datas); + } else - data.MapImageId = info.TerrainImage; - // ugh! V2-3 is very sensitive about the result being - // exactly the same as the requested name - if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) - data.Name = mapNameOrig; - else - data.Name = info.RegionName; - data.RegionFlags = 0; // TODO not used? - data.WaterHeight = 0; // not used - data.X = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocX); - data.Y = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocY); - blocks.Add(data); + { + MapBlockData data = WorldMap.MapBlockFromGridRegion(info, flags); + } } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index a3b0f39498..b98afbcb3d 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1064,7 +1064,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // Fill a passed MapBlockData from a GridRegion - protected MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) + public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) { MapBlockData block = new MapBlockData(); @@ -1090,7 +1090,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return block; } - protected List Map2BlockFromGridRegion(GridRegion r, uint flag) + public List Map2BlockFromGridRegion(GridRegion r, uint flag) { List blocks = new List(); MapBlockData block = new MapBlockData(); diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 0c0a7aafd7..4a06f6e90f 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -381,7 +381,7 @@ namespace OpenSim.Region.DataSnapshot cli.RequestMethod = "GET"; try { - reply = cli.Request(); + reply = cli.Request(null); } catch (WebException) { diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs index 3576e35798..6bad018ea7 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs @@ -38,7 +38,9 @@ namespace OpenSim.Region.Framework.Interfaces public interface IInventoryAccessModule { UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); - + + bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset); + /// /// Copy objects to a user's inventory. /// diff --git a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs index b0b47a787b..290b82689c 100644 --- a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs @@ -36,6 +36,26 @@ namespace OpenSim.Region.Framework.Interfaces { event UndeliveredMessage OnUndeliveredMessage; + /// + /// Attempt to send an instant message to a given destination. + /// + /// + /// If the message cannot be delivered for any reason, this will be signalled on the OnUndeliveredMessage + /// event. result(false) will also be called if the message cannot be delievered unless the type is + /// InstantMessageDialog.MessageFromAgent. For successful message delivery, result(true) is called. + /// + /// + /// void SendInstantMessage(GridInstantMessage im, MessageResultNotification result); + + /// + /// Appropriately handle a known undeliverable message without attempting a send. + /// + /// + /// Essentially, this invokes the OnUndeliveredMessage event. + /// + /// + /// + void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result); } } diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index 65c57a6eb8..9c781e13d2 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs @@ -24,6 +24,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.Framework.Interfaces { @@ -33,5 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Generate a map tile for the scene. a terrain texture for this scene /// void GenerateMaptile(); + List Map2BlockFromGridRegion(GridRegion r, uint flag); + MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 91f1b633e4..542d454629 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -125,13 +125,18 @@ namespace OpenSim.Region.Framework.Scenes return false; } + } + + public bool AddInventoryItem(InventoryItemBase item) + { + return AddInventoryItem(item, true); } /// /// Add the given inventory item to a user's inventory. /// /// - public bool AddInventoryItem(InventoryItemBase item) + public bool AddInventoryItem(InventoryItemBase item, bool trigger) { if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) { @@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + if (trigger) + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); return true; } @@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + if (trigger) + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); if (originalFolder != UUID.Zero) { @@ -764,7 +771,7 @@ namespace OpenSim.Region.Framework.Scenes IInventoryAccessModule invAccess = RequestModuleInterface(); if (invAccess != null) invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); - AddInventoryItem(itemCopy); + AddInventoryItem(itemCopy, false); if (!Permissions.BypassPermissions()) { @@ -872,50 +879,33 @@ namespace OpenSim.Region.Framework.Scenes return; } - AssetBase asset = AssetService.Get(item.AssetID.ToString()); + if (newName == String.Empty) + newName = item.Name; - if (asset != null) + if (remoteClient.AgentId == oldAgentID + || (LibraryService != null + && LibraryService.LibraryRootFolder != null + && oldAgentID == LibraryService.LibraryRootFolder.Owner)) { - if (newName != String.Empty) - { - asset.Name = newName; - } - else - { - newName = item.Name; - } - - if (remoteClient.AgentId == oldAgentID - || (LibraryService != null - && LibraryService.LibraryRootFolder != null - && oldAgentID == LibraryService.LibraryRootFolder.Owner)) - { - CreateNewInventoryItem( - remoteClient, item.CreatorId, item.CreatorData, newFolderID, - newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType, - item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, - item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); - } - else - { - // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. - if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) - && (m_permissions.BypassPermissions() - || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) - { - CreateNewInventoryItem( - remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, - asset, (sbyte) item.InvType, - item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, - item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); - } - } + CreateNewInventoryItem( + remoteClient, item.CreatorId, item.CreatorData, newFolderID, + newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType, + item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, + item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); } else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found", - item.Name, item.AssetID); + { + // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. + if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) + && (m_permissions.BypassPermissions() + || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) + { + CreateNewInventoryItem( + remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, + item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType, + item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, + item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); + } } } @@ -966,11 +956,12 @@ namespace OpenSim.Region.Framework.Scenes public void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, - AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) + UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) { CreateNewInventoryItem( - remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, - (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); + remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, + creationDate, true); } /// @@ -994,19 +985,20 @@ namespace OpenSim.Region.Framework.Scenes /// Unix timestamp at which this item was created. private void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, - string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, - uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, + bool assetUpload) { InventoryItemBase item = new InventoryItemBase(); item.Owner = remoteClient.AgentId; item.CreatorId = creatorID; item.CreatorData = creatorData; item.ID = UUID.Random(); - item.AssetID = asset.FullID; + item.AssetID = assetID; item.Name = name; item.Description = description; item.Flags = flags; - item.AssetType = asset.Type; + item.AssetType = assetType; item.InvType = invType; item.Folder = folderID; item.CurrentPermissions = currentMask; @@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Framework.Scenes item.BasePermissions = baseMask; item.CreationDate = creationDate; - if (AddInventoryItem(item)) + if (AddInventoryItem(item, assetUpload)) { remoteClient.SendInventoryItemCreateUpdate(item, callbackID); } @@ -1079,17 +1071,12 @@ namespace OpenSim.Region.Framework.Scenes // return; // } - AssetBase asset = new AssetBase(); - asset.FullID = olditemID; - asset.Type = type; - asset.Name = name; - asset.Description = description; - CreateNewInventoryItem( - remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, + remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, + name, description, 0, callbackID, olditemID, type, invType, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, - (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch(), + false); } else { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e6887b46ba..eff24f8c78 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3751,6 +3751,13 @@ namespace OpenSim.Region.Framework.Scenes RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); } + // Final permissions check; this time we don't allow changing the position + if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason)) + { + m_authenticateHandler.RemoveCircuit(acd.circuitcode); + return false; + } + return true; } @@ -3760,6 +3767,13 @@ namespace OpenSim.Region.Framework.Scenes if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) { acd.startpos = land.LandData.UserLocation; + + // Final permissions check; this time we don't allow changing the position + if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason)) + { + m_authenticateHandler.RemoveCircuit(acd.circuitcode); + return false; + } } } } @@ -3767,6 +3781,21 @@ namespace OpenSim.Region.Framework.Scenes return true; } + private bool IsPositionAllowed(UUID agentID, Vector3 pos, ref string reason) + { + ILandObject land = LandChannel.GetLandObject(pos); + if (land == null) + return true; + + if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID)) + { + reason = "You are banned from the region."; + return false; + } + + return true; + } + public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { if (posX < 0) @@ -3865,7 +3894,7 @@ namespace OpenSim.Region.Framework.Scenes if (!AuthorizationService.IsAuthorizedForRegion( agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because {4}", + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason); return false; @@ -4133,7 +4162,10 @@ namespace OpenSim.Region.Framework.Scenes /// true if we handled it. public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) { - //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}", +// cAgentData.AgentID, Name, cAgentData.Position); + ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) { @@ -5150,7 +5182,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); if (nearestPoint != null) { - Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); + m_log.Debug("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); return nearestPoint.Value; } @@ -5160,7 +5192,7 @@ namespace OpenSim.Region.Framework.Scenes nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); if (nearestPoint != null) { - Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); + m_log.Debug("They had a zero velocity, sending them to: " + nearestPoint.ToString()); return nearestPoint.Value; } @@ -5169,7 +5201,7 @@ namespace OpenSim.Region.Framework.Scenes { // Ultimate backup if we have no idea where they are and // the last allowed position was in another parcel - Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); + m_log.Debug("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); return avatar.lastKnownAllowedPosition; } @@ -5179,7 +5211,7 @@ namespace OpenSim.Region.Framework.Scenes //Go to the edge, this happens in teleporting to a region with no available parcels Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); - //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); + //m_log.Debug("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); return nearestRegionEdgePoint; } @@ -5463,9 +5495,9 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public bool QueryAccess(UUID agentID, string agentHomeURI, Vector3 position, out string reason) + public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason) { - reason = "You are banned from the region"; + reason = string.Empty; if (Permissions.IsGod(agentID)) { @@ -5525,10 +5557,11 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); + reason = "Error authorizing agent: " + e.Message; return false; } - if (position == Vector3.Zero) // Teleport + if (viaTeleport) { if (!RegionInfo.EstateSettings.AllowDirectTeleport) { @@ -5568,6 +5601,7 @@ namespace OpenSim.Region.Framework.Scenes if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) { // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); + reason = "You are banned from the region on all parcels"; return false; } } @@ -5575,13 +5609,22 @@ namespace OpenSim.Region.Framework.Scenes { ILandObject land = LandChannel.GetLandObject(position.X, position.Y); if (land == null) + { + reason = "No parcel found"; return false; + } bool banned = land.IsBannedFromLand(agentID); bool restricted = land.IsRestrictedFromLand(agentID); if (banned || restricted) + { + if (banned) + reason = "You are banned from the parcel"; + else + reason = "The parcel is restricted"; return false; + } } reason = String.Empty; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index fb8ecd5df9..75e1cbbdbc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -751,7 +751,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 bbox; float offsetHeight; - bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); + m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); for (int i = 0; i < objlist.Count; i++) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8c569758e0..17f54c2d79 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -208,7 +208,6 @@ namespace OpenSim.Region.Framework.Scenes // private int m_lastColCount = -1; //KF: Look for Collision chnages // private int m_updateCount = 0; //KF: Update Anims for a while // private static readonly int UPDATE_COUNT = 10; // how many frames to update for - private List m_lastColliders = new List(); private TeleportFlags m_teleportFlags; public TeleportFlags TeleportFlags @@ -271,8 +270,6 @@ namespace OpenSim.Region.Framework.Scenes //private int m_moveToPositionStateStatus; //***************************************************** - private object m_collisionEventLock = new Object(); - private int m_movementAnimationUpdateCounter = 0; public Vector3 PrevSitOffset { get; set; } @@ -1328,6 +1325,11 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); + // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating + // from the source simulator has completed on a V2 teleport. + lock (m_originRegionIDAccessLock) + m_originRegionID = UUID.Zero; + // Reset these so that teleporting in and walking out isn't seen // as teleporting back TeleportFlags = TeleportFlags.Default; @@ -2752,7 +2754,34 @@ namespace OpenSim.Region.Framework.Scenes part.AddSittingAvatar(this); cameraAtOffset = part.GetCameraAtOffset(); + + if (!part.IsRoot && cameraAtOffset == Vector3.Zero) + cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset(); + + bool cameraEyeOffsetFromRootForChild = false; cameraEyeOffset = part.GetCameraEyeOffset(); + + if (!part.IsRoot && cameraEyeOffset == Vector3.Zero) + { + cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); + cameraEyeOffsetFromRootForChild = true; + } + + if ((cameraEyeOffset != Vector3.Zero && !cameraEyeOffsetFromRootForChild) || cameraAtOffset != Vector3.Zero) + { + if (!part.IsRoot) + { + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + cameraAtOffset += part.OffsetPosition; + } + + cameraEyeOffset += part.OffsetPosition; + } + +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Using cameraAtOffset {0}, cameraEyeOffset {1} for sit on {2} by {3} in {4}", +// cameraAtOffset, cameraEyeOffset, part.Name, Name, Scene.Name); + forceMouselook = part.GetForceMouselook(); // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is @@ -3772,10 +3801,15 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) return; - //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", +// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); + // Find the distance (in meters) between the two regions - uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); - uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); + // XXX: We cannot use Util.RegionLocToHandle() here because a negative value will silently overflow the + // uint + int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); + int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); Vector3 offset = new Vector3(shiftx, shifty, 0f); @@ -3876,9 +3910,6 @@ namespace OpenSim.Region.Framework.Scenes private void CopyFrom(AgentData cAgent) { - lock (m_originRegionIDAccessLock) - m_originRegionID = cAgent.RegionID; - m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", @@ -3951,6 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); + + // This must occur after attachments are copied, as it releases the CompleteMovement() calling thread + // originating from the client completing a teleport. Otherwise, CompleteMovement() code to restart + // script attachments can outrace this thread. + lock (m_originRegionIDAccessLock) + m_originRegionID = cAgent.RegionID; } public bool CopyAgent(out IAgentData agent) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 85650d6595..e68f954956 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1343,7 +1343,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); - WriteUUID(writer, "GroupID", sop.GroupID, options); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.GroupID; + WriteUUID(writer, "GroupID", groupID, options); UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID; WriteUUID(writer, "OwnerID", ownerID, options); @@ -1469,7 +1471,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Description", item.Description); writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); writer.WriteElementString("Flags", item.Flags.ToString()); - WriteUUID(writer, "GroupID", item.GroupID, options); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.GroupID; + WriteUUID(writer, "GroupID", groupID, options); + writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); writer.WriteElementString("InvType", item.InvType.ToString()); WriteUUID(writer, "ItemID", item.ItemID, options); @@ -1490,7 +1495,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "PermsGranter", item.PermsGranter, options); writer.WriteElementString("PermsMask", item.PermsMask.ToString()); writer.WriteElementString("Type", item.Type.ToString()); - writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); + + bool ownerChanged = options.ContainsKey("wipe-owners") ? false : item.OwnerChanged; + writer.WriteElementString("OwnerChanged", ownerChanged.ToString().ToLower()); writer.WriteEndElement(); // TaskInventoryItem } diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs index e79720703b..396f1e8f03 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { public static class OpenSimTerrainCompressor { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #pragma warning disable 414 private static string LogHeader = "[TERRAIN COMPRESSOR]"; diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index fd804cda95..e1b6abb3ae 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -55,8 +55,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private IGroupsServicesConnector m_groupData = null; // Config Options - private bool m_groupMessagingEnabled = false; - private bool m_debugEnabled = true; + private bool m_groupMessagingEnabled; + private bool m_debugEnabled; /// /// If enabled, module only tries to send group IMs to online users by querying cached presence information. @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_messageOnlineAgentsOnly) m_usersOnlineCache = new ExpiringCache(); - m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); + m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled); } m_log.InfoFormat( @@ -127,6 +127,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; scene.RegisterModuleInterface(this); + + scene.AddCommand( + "Debug", + this, + "debug groups messaging verbose", + "debug groups messaging verbose ", + "This setting turns on very verbose groups messaging debugging", + HandleDebugGroupsMessagingVerbose); } public void RegionLoaded(Scene scene) @@ -218,6 +226,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups #endregion + private void HandleDebugGroupsMessagingVerbose(object modules, string[] args) + { + if (args.Length < 5) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + bool verbose = false; + if (!bool.TryParse(args[4], out verbose)) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + m_debugEnabled = verbose; + + MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled); + } + /// /// Not really needed, but does confirm that the group exists. /// @@ -246,8 +274,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups public void SendMessageToGroup( GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func sendCondition) { + int requestStartTick = Environment.TickCount; + List groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); int groupMembersCount = groupMembers.Count; + HashSet attemptDeliveryUuidSet = null; if (m_messageOnlineAgentsOnly) { @@ -263,10 +294,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); } - HashSet onlineAgentsUuidSet = new HashSet(); - Array.ForEach(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID)); + attemptDeliveryUuidSet + = new HashSet(Array.ConvertAll(onlineAgents, pi => pi.UserID)); - groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); + //Array.ForEach(onlineAgents, pi => attemptDeliveryUuidSet.Add(pi.UserID)); + + //groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); // if (m_debugEnabled) // m_log.DebugFormat( @@ -275,13 +308,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } else { + attemptDeliveryUuidSet + = new HashSet(groupMembers.ConvertAll(gmd => gmd.AgentID.ToString())); + if (m_debugEnabled) m_log.DebugFormat( "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", groupID, groupMembers.Count); - } - - int requestStartTick = Environment.TickCount; + } foreach (GroupMembersData member in groupMembers) { @@ -309,7 +343,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Copy Message GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = groupID.Guid; + msg.imSessionID = im.imSessionID; msg.fromAgentName = im.fromAgentName; msg.message = im.message; msg.dialog = im.dialog; @@ -325,26 +359,51 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups msg.toAgentID = member.AgentID.Guid; - IClientAPI client = GetActiveClient(member.AgentID); - if (client == null) + if (attemptDeliveryUuidSet.Contains(member.AgentID.ToString())) { - // If they're not local, forward across the grid - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); - m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); + IClientAPI client = GetActiveClient(member.AgentID); + if (client == null) + { + int startTick = Environment.TickCount; + + // If they're not local, forward across the grid + m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); + + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms", + member.AgentID, Environment.TickCount - startTick); + } + else + { + int startTick = Environment.TickCount; + + ProcessMessageFromGroupSession(msg, client); + + // Deliver locally, directly + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms", + member.AgentID, Environment.TickCount - startTick); + } } else { - // Deliver locally, directly - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); - ProcessMessageFromGroupSession(msg, client); + int startTick = Environment.TickCount; + + m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); + + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms", + member.AgentID, Environment.TickCount - startTick); } } - // Temporary for assessing how long it still takes to send messages to large online groups. - if (m_messageOnlineAgentsOnly) + if (m_debugEnabled) m_log.DebugFormat( - "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms", - groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick); + "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms", + groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); } #region SimGridEventHandlers @@ -407,7 +466,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}", + msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog); UUID AgentID = new UUID(msg.fromAgentID); UUID GroupID = new UUID(msg.imSessionID); @@ -431,8 +493,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Add them to the session for now, and Invite them m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); - UUID toAgentID = new UUID(msg.toAgentID); - GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); if (groupInfo != null) { @@ -577,15 +637,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Don't log any normal IMs (privacy!) if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) { - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); } } @@ -596,7 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups /// private IClientAPI GetActiveClient(UUID agentID) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); IClientAPI child = null; @@ -608,12 +669,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { if (!sp.IsChildAgent) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); + return sp.ControllingClient; } else { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); + child = sp.ControllingClient; } } @@ -622,12 +687,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // If we didn't find a root, then just return whichever child we found, or null if none if (child == null) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); } else { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); } + return child; } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index f34152c17c..8a9e4d2dc4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -357,7 +357,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS]: {0} called for {1}, message type {2}", + System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog); // Group invitations if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) @@ -551,6 +554,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups UUID noticeID = new UUID(im.imSessionID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId); + GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); if (notice != null) { @@ -572,6 +578,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); } + else + { + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.", + noticeID, remoteClient.AgentId); + } } // Interop, received special 210 code for ejecting a group member diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index 71f10986f2..d944087894 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -132,6 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests MessageTransferModule mtm = new MessageTransferModule(); GroupsModule gm = new GroupsModule(); GroupsMessagingModule gmm = new GroupsMessagingModule(); + MockGroupsServicesConnector mgsc = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); @@ -149,6 +150,83 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests config.Set("MessagingEnabled", true); } + SceneHelpers.SetupSceneModules(scene, configSource, mgsc, mtm, gm, gmm); + + UUID userId = TestHelpers.ParseTail(0x1); + string subjectText = "newman"; + string messageText = "Hello"; + string combinedSubjectMessage = string.Format("{0}|{1}", subjectText, messageText); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + TestClient tc = (TestClient)sp.ControllingClient; + + UUID groupID = gm.CreateGroup(tc, "group1", null, true, UUID.Zero, 0, true, true, true); + gm.JoinGroupRequest(tc, groupID); + + // Create a second user who doesn't want to receive notices + ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x2)); + TestClient tc2 = (TestClient)sp2.ControllingClient; + gm.JoinGroupRequest(tc2, groupID); + gm.SetGroupAcceptNotices(tc2, groupID, false, true); + + List spReceivedMessages = new List(); + tc.OnReceivedInstantMessage += im => spReceivedMessages.Add(im); + + List sp2ReceivedMessages = new List(); + tc2.OnReceivedInstantMessage += im => sp2ReceivedMessages.Add(im); + + GridInstantMessage noticeIm = new GridInstantMessage(); + noticeIm.fromAgentID = userId.Guid; + noticeIm.toAgentID = groupID.Guid; + noticeIm.message = combinedSubjectMessage; + noticeIm.dialog = (byte)InstantMessageDialog.GroupNotice; + + tc.HandleImprovedInstantMessage(noticeIm); + + Assert.That(spReceivedMessages.Count, Is.EqualTo(1)); + Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage)); + + List notices = mgsc.GetGroupNotices(UUID.Zero, groupID); + Assert.AreEqual(1, notices.Count); + + // OpenSimulator (possibly also SL) transport the notice ID as the session ID! + Assert.AreEqual(notices[0].NoticeID.Guid, spReceivedMessages[0].imSessionID); + + Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); + } + + /// + /// Run test with the MessageOnlineUsersOnly flag set. + /// + [Test] + public void TestSendGroupNoticeOnlineOnly() + { + TestHelpers.InMethod(); + // TestHelpers.EnableLogging(); + + TestScene scene = new SceneHelpers().SetupScene(); + + MessageTransferModule mtm = new MessageTransferModule(); + GroupsModule gm = new GroupsModule(); + GroupsMessagingModule gmm = new GroupsMessagingModule(); + + IConfigSource configSource = new IniConfigSource(); + + { + IConfig config = configSource.AddConfig("Messaging"); + config.Set("MessageTransferModule", mtm.Name); + } + + { + IConfig config = configSource.AddConfig("Groups"); + config.Set("Enabled", true); + config.Set("Module", gm.Name); + config.Set("DebugEnabled", true); + config.Set("MessagingModule", gmm.Name); + config.Set("MessagingEnabled", true); + config.Set("MessageOnlineUsersOnly", true); + } + SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); UUID userId = TestHelpers.ParseTail(0x1); diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index d059b97516..870c0bbce9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -105,8 +105,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.LoginLock = true; m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; - // Warn level because the region cannot be used while logins are disabled - m_log.WarnFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); + // This should always show up to the user but should not trigger warn/errors as these messages are + // expected and are not simulator problems. Ideally, there would be a status level in log4net but + // failing that, we will print out to console instead. + MainConsole.Instance.OutputFormat("Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); if (m_uri != string.Empty) { diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 8e405616fa..f53adcb065 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs @@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; float height = terrainHeight + actor.Size.Z; +// Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition); if (actor.Flying) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 1bcf879e39..1b8a454493 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -399,8 +399,8 @@ public class BSActorAvatarMove : BSActor m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement; } } - m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,disp={1},force={2}", - m_controllingPrim.LocalID, displacement, ret); + m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,stepUp={1},isp={2},force={3}", + m_controllingPrim.LocalID, stepUp, displacement, ret); } return ret; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 6683446200..de42a4cdd0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -598,9 +598,9 @@ public static class BSParam new ParameterDefn("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step", 1.0f ), new ParameterDefn("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step", - 1.0f ), + 2.0f ), new ParameterDefn("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs", - 2 ), + 1 ), new ParameterDefn("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle", 1000.0f, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 9fa55ce4bb..23bada9927 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -639,15 +639,18 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (collidersCount > 0) { - for (int ii = 0; ii < collidersCount; ii++) + lock (PhysObjects) { - uint cA = m_collisionArray[ii].aID; - uint cB = m_collisionArray[ii].bID; - Vector3 point = m_collisionArray[ii].point; - Vector3 normal = m_collisionArray[ii].normal; - float penetration = m_collisionArray[ii].penetration; - SendCollision(cA, cB, point, normal, penetration); - SendCollision(cB, cA, point, -normal, penetration); + for (int ii = 0; ii < collidersCount; ii++) + { + uint cA = m_collisionArray[ii].aID; + uint cB = m_collisionArray[ii].bID; + Vector3 point = m_collisionArray[ii].point; + Vector3 normal = m_collisionArray[ii].normal; + float penetration = m_collisionArray[ii].penetration; + SendCollision(cA, cB, point, normal, penetration); + SendCollision(cB, cA, point, -normal, penetration); + } } } } @@ -658,14 +661,17 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (updatedEntityCount > 0) { - for (int ii = 0; ii < updatedEntityCount; ii++) + lock (PhysObjects) { - EntityProperties entprop = m_updateArray[ii]; - BSPhysObject pobj; - if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + for (int ii = 0; ii < updatedEntityCount; ii++) { - if (pobj.IsInitialized) - pobj.UpdateProperties(entprop); + EntityProperties entprop = m_updateArray[ii]; + BSPhysObject pobj; + if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + { + if (pobj.IsInitialized) + pobj.UpdateProperties(entprop); + } } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5590cd53b7..7d8821cc08 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6846,12 +6846,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); m_host.SetCameraEyeOffset(offset); + + if (m_host.ParentGroup.RootPart.GetCameraEyeOffset() == Vector3.Zero) + m_host.ParentGroup.RootPart.SetCameraEyeOffset(offset); } public void llSetCameraAtOffset(LSL_Vector offset) { m_host.AddScriptLPS(1); m_host.SetCameraAtOffset(offset); + + if (m_host.ParentGroup.RootPart.GetCameraAtOffset() == Vector3.Zero) + m_host.ParentGroup.RootPart.SetCameraAtOffset(offset); } public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 6aa717db03..8b8e038951 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -162,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools m_braceCount++; // line number - m_CSharpLine += 3; + m_CSharpLine += 9; // here's the payload retstr += GenerateLine(); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index b4640eff12..1efe798d2f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -444,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // return compileScript; // } - private static string CreateCSCompilerScript( + public static string CreateCSCompilerScript( string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) { compileScript = string.Format( @@ -472,7 +472,7 @@ namespace SecondLife return compileScript; } - private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) + public static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) { compileScript = String.Empty + "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 05a8756e6e..713b280497 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -25,12 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.IO; using System.CodeDom.Compiler; using System.Collections.Generic; using Microsoft.CSharp; using NUnit.Framework; using OpenSim.Region.ScriptEngine.Shared.CodeTools; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Tests.Common; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests @@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests private CSharpCodeProvider m_CSCodeProvider; private CompilerParameters m_compilerParameters; private CompilerResults m_compilerResults; + private ResolveEventHandler m_resolveEventHandler; /// /// Creates a temporary directory where build artifacts are stored. @@ -66,9 +69,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests m_CSCodeProvider = new CSharpCodeProvider(); m_compilerParameters = new CompilerParameters(); - string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "bin"); + string rootPath = System.AppDomain.CurrentDomain.BaseDirectory; + + m_resolveEventHandler = new ResolveEventHandler(AssemblyResolver.OnAssemblyResolve); + + System.AppDomain.CurrentDomain.AssemblyResolve += m_resolveEventHandler; + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); m_compilerParameters.GenerateExecutable = false; } @@ -79,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests [TestFixtureTearDown] public void CleanUp() { + System.AppDomain.CurrentDomain.AssemblyResolve -= m_resolveEventHandler; + if (Directory.Exists(m_testDir)) { // Blow away the temporary directory with artifacts. @@ -90,7 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests /// Test the C# compiler error message can be mapped to the correct /// line/column in the LSL source when an undeclared variable is used. /// - //[Test] + [Test] public void TestUseUndeclaredVariable() { TestHelpers.InMethod(); @@ -106,25 +117,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests }"; CSCodeGenerator cg = new CSCodeGenerator(); - string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + - "namespace SecondLife { " + - "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + - "public Script() { } " + - cg.Convert(input) + - "} }\n"; + string output = cg.Convert(input); + + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); +// System.Console.WriteLine(output); + Dictionary, KeyValuePair> positionMap = cg.PositionMap; m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); +// +// foreach (KeyValuePair key in positionMap.Keys) +// { +// KeyValuePair val = positionMap[key]; +// +// System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value); +// } +// +// foreach (CompilerError compErr in m_compilerResults.Errors) +// { +// System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr); +// } - Assert.AreEqual(new KeyValuePair(5, 21), - positionMap[new KeyValuePair(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); + Assert.AreEqual( + new KeyValuePair(5, 21), + positionMap[new KeyValuePair(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); } /// /// Test that a string can be cast to string and another string /// concatenated. /// - //[Test] + [Test] public void TestCastAndConcatString() { TestHelpers.InMethod(); @@ -143,15 +166,21 @@ default } }"; +// System.Console.WriteLine(input); CSCodeGenerator cg = new CSCodeGenerator(); - string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + - "namespace SecondLife { " + - "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + - "public Script() { } " + - cg.Convert(input) + - "} }\n"; + string output = cg.Convert(input); + + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); +// System.Console.WriteLine(output); + m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); + System.Console.WriteLine("ERRORS: {0}", m_compilerResults.Errors.Count); + foreach (CompilerError compErr in m_compilerResults.Errors) + { + System.Console.WriteLine("Error: {0}", compErr); + } + Assert.AreEqual(0, m_compilerResults.Errors.Count); } } diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 9b86986c55..ab81dd69d3 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -30,6 +30,7 @@ using System.IO; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; @@ -69,6 +70,8 @@ namespace OpenSim.Server.Handlers.Asset bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); + string redirectURL = serverConfig.GetString("RedirectURL", string.Empty); + AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; if (!allowDelete) @@ -83,9 +86,11 @@ namespace OpenSim.Server.Handlers.Asset allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; } - server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL)); + server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth)); + server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth)); server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); MainConsole.Instance.Commands.AddCommand("Assets", false, diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 941b97d2f0..d85d4713f1 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset @@ -70,6 +71,12 @@ namespace OpenSim.Server.Handlers.Asset m_allowedTypes = allowedTypes; } + public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) : + base("DELETE", "/assets", auth) + { + m_AssetService = service; + m_allowedTypes = allowedTypes; + } protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index ed3b4af62e..91c5c54ca8 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs @@ -38,20 +38,31 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset { public class AssetServerGetHandler : BaseStreamHandler { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; + private string m_RedirectURL; public AssetServerGetHandler(IAssetService service) : base("GET", "/assets") + { + m_AssetService = service; + } + + public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) : + base("GET", "/assets", auth) { m_AssetService = service; + m_RedirectURL = redirectURL; + if (!m_RedirectURL.EndsWith("/")) + m_RedirectURL = m_RedirectURL.TrimEnd('/'); } protected override byte[] ProcessRequest(string path, Stream request, @@ -64,9 +75,10 @@ namespace OpenSim.Server.Handlers.Asset if (p.Length == 0) return result; + string id = string.Empty; if (p.Length > 1) { - string id = p[0]; + id = p[0]; string cmd = p[1]; if (cmd == "data") @@ -117,7 +129,7 @@ namespace OpenSim.Server.Handlers.Asset { // Get the entire asset (metadata + data) - string id = p[0]; + id = p[0]; AssetBase asset = m_AssetService.Get(id); if (asset != null) @@ -144,6 +156,16 @@ namespace OpenSim.Server.Handlers.Asset result = new byte[0]; } + if (httpResponse.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(m_RedirectURL) && !string.IsNullOrEmpty(id)) + { + httpResponse.StatusCode = (int)HttpStatusCode.Redirect; + string rurl = m_RedirectURL; + if (!path.StartsWith("/")) + rurl += "/"; + rurl += path; + httpResponse.AddHeader("Location", rurl); + m_log.DebugFormat("[ASSET GET HANDLER]: Asset not found, redirecting to {0} ({1})", rurl, httpResponse.StatusCode); + } return result; } } diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index a77e67d1a5..1c706a7208 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset @@ -54,6 +55,12 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = service; } + public AssetServerPostHandler(IAssetService service, IServiceAuth auth) : + base("POST", "/assets", auth) + { + m_AssetService = service; + } + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { diff --git a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs index 6d01f86d6c..32901b3b47 100644 --- a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,6 +56,12 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = service; } + public AssetsExistHandler(IAssetService service, IServiceAuth auth) : + base("POST", "/get_assets_exist", auth) + { + m_AssetService = service; + } + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { XmlSerializer xs; diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs index 848a037aa6..c9a8dce46f 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -58,7 +59,9 @@ namespace OpenSim.Server.Handlers.Authentication Object[] args = new Object[] { config }; m_AuthenticationService = ServerUtils.LoadPlugin(authenticationService, args); - server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig, auth)); } } } diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 16e011aaea..5d65f67b08 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,10 +56,10 @@ namespace OpenSim.Server.Handlers.Authentication private bool m_AllowSetPassword = false; public AuthenticationServerPostHandler(IAuthenticationService service) : - this(service, null) {} + this(service, null, null) {} - public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config) : - base("POST", "/auth") + public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config, IServiceAuth auth) : + base("POST", "/auth", auth) { m_AuthenticationService = service; @@ -73,6 +74,7 @@ namespace OpenSim.Server.Handlers.Authentication protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { +// m_log.Error("[XXX]: Authenticating..."); string[] p = SplitParams(path); if (p.Length > 0) diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs index 9a57cd9ddc..1831e84d59 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Avatar Object[] args = new Object[] { config }; m_AvatarService = ServerUtils.LoadPlugin(avatarService, args); - server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index d6bbb8fc4e..59dbed459b 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Avatar private IAvatarService m_AvatarService; - public AvatarServerPostHandler(IAvatarService service) : - base("POST", "/avatar") + public AvatarServerPostHandler(IAvatarService service, IServiceAuth auth) : + base("POST", "/avatar", auth) { m_AvatarService = service; } diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs index fb4b79492d..9e703f17de 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.BakedTextures @@ -50,14 +51,14 @@ namespace OpenSim.Server.Handlers.BakedTextures private System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(); - public BakesServerGetHandler(IBakedTextureService service) : - base("GET", "/bakes") + public BakesServerGetHandler(IBakedTextureService service, IServiceAuth auth) : + base("GET", "/bakes", auth) { m_BakesService = service; } - public override byte[] Handle(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override byte[] ProcessRequest( + string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { string[] p = SplitParams(path); diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs index 7bf7641e70..4c129673dc 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -59,8 +60,10 @@ namespace OpenSim.Server.Handlers.BakedTextures m_BakesService = ServerUtils.LoadPlugin(assetService, args); - server.AddStreamHandler(new BakesServerGetHandler(m_BakesService)); - server.AddStreamHandler(new BakesServerPostHandler(m_BakesService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new BakesServerGetHandler(m_BakesService, auth)); + server.AddStreamHandler(new BakesServerPostHandler(m_BakesService, auth)); } } } diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs index 69adb7f36d..1aacbc982c 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs @@ -38,27 +38,28 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.BakedTextures { public class BakesServerPostHandler : BaseStreamHandler { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IBakedTextureService m_BakesService; private System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(); - public BakesServerPostHandler(IBakedTextureService service) : - base("POST", "/bakes") + public BakesServerPostHandler(IBakedTextureService service, IServiceAuth auth) : + base("POST", "/bakes", auth) { m_BakesService = service; } - public override byte[] Handle(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override byte[] ProcessRequest( + string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { string[] p = SplitParams(path); diff --git a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs index 5784bdf652..b0e6c7dea3 100644 --- a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs +++ b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,8 @@ namespace OpenSim.Server.Handlers.Friends Object[] args = new Object[] { config }; m_FriendsService = ServerUtils.LoadPlugin(theService, args); - server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index ca0a24c36f..d442443f85 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -51,8 +52,8 @@ namespace OpenSim.Server.Handlers.Friends private IFriendsService m_FriendsService; - public FriendsServerPostHandler(IFriendsService service) : - base("POST", "/friends") + public FriendsServerPostHandler(IFriendsService service, IServiceAuth auth) : + base("POST", "/friends", auth) { m_FriendsService = service; } diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index 14daf12fa0..6eb6a79b14 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Grid Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin(gridService, args); - server.AddStreamHandler(new GridServerPostHandler(m_GridService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new GridServerPostHandler(m_GridService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 37ca5a4835..dda47565db 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,8 +56,8 @@ namespace OpenSim.Server.Handlers.Grid private IGridService m_GridService; - public GridServerPostHandler(IGridService service) : - base("POST", "/grid") + public GridServerPostHandler(IGridService service, IServiceAuth auth) : + base("POST", "/grid", auth) { m_GridService = service; } diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs index 66f35e3bdc..1e29378c26 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.GridUser Object[] args = new Object[] { config }; m_GridUserService = ServerUtils.LoadPlugin(service, args); - server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; + + server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService, auth)); } } } diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 0b98e9a12b..006f6ab232 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.GridUser private IGridUserService m_GridUserService; - public GridUserServerPostHandler(IGridUserService service) : - base("POST", "/griduser") + public GridUserServerPostHandler(IGridUserService service, IServiceAuth auth) : + base("POST", "/griduser", auth) { m_GridUserService = service; } diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index ce975a82e6..7283237898 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.IO; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; @@ -71,7 +72,9 @@ namespace OpenSim.Server.Handlers.Asset m_InventoryService = ServerUtils.LoadPlugin(inventoryService, args); - server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth)); } } @@ -81,8 +84,8 @@ namespace OpenSim.Server.Handlers.Asset private IInventoryService m_InventoryService; - public XInventoryConnectorPostHandler(IInventoryService service) : - base("POST", "/xinventory") + public XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth) : + base("POST", "/xinventory", auth) { m_InventoryService = service; } diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 4d1729ec68..a896fdb5ff 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -79,7 +80,8 @@ namespace OpenSim.Server.Handlers.MapImage m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); bool proxy = serverConfig.GetBoolean("HasProxy", false); - server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy, auth)); } } @@ -91,8 +93,8 @@ namespace OpenSim.Server.Handlers.MapImage private IGridService m_GridService; bool m_Proxy; - public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : - base("POST", "/map") + public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy, IServiceAuth auth) : + base("POST", "/map", auth) { m_MapService = service; m_GridService = grid; diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs index 899cd8f661..7a63c3605a 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs @@ -30,6 +30,7 @@ using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; namespace OpenSim.Server.Handlers.Presence @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Presence Object[] args = new Object[] { config }; m_PresenceService = ServerUtils.LoadPlugin(gridService, args); - server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index abb4b19642..0b3b961471 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenMetaverse; namespace OpenSim.Server.Handlers.Presence @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Presence private IPresenceService m_PresenceService; - public PresenceServerPostHandler(IPresenceService service) : - base("POST", "/presence") + public PresenceServerPostHandler(IPresenceService service, IServiceAuth auth) : + base("POST", "/presence", auth) { m_PresenceService = service; } diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 06392f7938..72919313ad 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -132,6 +132,10 @@ namespace OpenSim.Server.Handlers.Simulation // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]); OSDMap args = Utils.GetOSDMap((string)request["body"]); + bool viaTeleport = true; + if (args.ContainsKey("viaTeleport")) + viaTeleport = args["viaTeleport"].AsBoolean(); + Vector3 position = Vector3.Zero; if (args.ContainsKey("position")) position = Vector3.Parse(args["position"].AsString()); @@ -145,7 +149,7 @@ namespace OpenSim.Server.Handlers.Simulation string reason; string version; - bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason); + bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); responsedata["int_response_code"] = HttpStatusCode.OK; diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs index 344b513ad2..e95e3dccc2 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs @@ -30,6 +30,7 @@ using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; namespace OpenSim.Server.Handlers.UserAccounts @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.UserAccounts Object[] args = new Object[] { config }; m_UserAccountService = ServerUtils.LoadPlugin(service, args); - server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig, auth)); } } } diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index 24c9de6a9d..c87e0224c5 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -41,6 +41,7 @@ using OpenSim.Services.Interfaces; using OpenSim.Services.UserAccountService; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenMetaverse; namespace OpenSim.Server.Handlers.UserAccounts @@ -54,10 +55,10 @@ namespace OpenSim.Server.Handlers.UserAccounts private bool m_AllowSetAccount = false; public UserAccountServerPostHandler(IUserAccountService service) - : this(service, null) {} + : this(service, null, null) {} - public UserAccountServerPostHandler(IUserAccountService service, IConfig config) : - base("POST", "/accounts") + public UserAccountServerPostHandler(IUserAccountService service, IConfig config, IServiceAuth auth) : + base("POST", "/accounts", auth) { m_UserAccountService = service; diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index ee047e0a61..0996acbdb7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -39,7 +39,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AssetServicesConnector : IAssetService + public class AssetServicesConnector : BaseServiceConnector, IAssetService { private static readonly ILog m_log = LogManager.GetLogger( @@ -71,6 +71,7 @@ namespace OpenSim.Services.Connectors } public AssetServicesConnector(IConfigSource source) + : base(source, "AssetService") { Initialise(source); } @@ -117,8 +118,16 @@ namespace OpenSim.Services.Connectors if (asset == null) { - asset = SynchronousRestObjectRequester. - MakeRequest("GET", uri, 0, m_maxAssetRequestConcurrency); + // 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. + // Wasn't noticed before because timeout wasn't actually used. + // Not attempting concurrency setting for now as this omission was discovered in release candidate + // phase for OpenSimulator 0.8. Need to revisit afterwards. +// asset +// = SynchronousRestObjectRequester.MakeRequest( +// "GET", uri, 0, m_maxAssetRequestConcurrency); + + asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); if (m_Cache != null) m_Cache.Cache(asset); @@ -148,8 +157,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id + "/metadata"; - AssetMetadata asset = SynchronousRestObjectRequester. - MakeRequest("GET", uri, 0); + AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); return asset; } @@ -170,7 +178,7 @@ namespace OpenSim.Services.Connectors rc.RequestMethod = "GET"; - Stream s = rc.Request(); + Stream s = rc.Request(m_Auth); if (s == null) return null; @@ -231,7 +239,7 @@ namespace OpenSim.Services.Connectors m_AssetHandlers.Remove(id); } handlers.Invoke(a); - }, m_maxAssetRequestConcurrency); + }, m_maxAssetRequestConcurrency, m_Auth); success = true; } @@ -261,7 +269,7 @@ namespace OpenSim.Services.Connectors bool[] exist = null; try { - exist = SynchronousRestObjectRequester.MakeRequest("POST", uri, ids); + exist = SynchronousRestObjectRequester.MakeRequest("POST", uri, ids, m_Auth); } catch (Exception) { @@ -290,8 +298,7 @@ namespace OpenSim.Services.Connectors string newID; try { - newID = SynchronousRestObjectRequester. - MakeRequest("POST", uri, asset); + newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth); } catch (Exception e) { @@ -337,8 +344,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester. - MakeRequest("POST", uri, asset)) + if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth)) { if (m_Cache != null) m_Cache.Cache(asset); @@ -352,8 +358,7 @@ namespace OpenSim.Services.Connectors { string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester. - MakeRequest("DELETE", uri, 0)) + if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0, m_Auth)) { if (m_Cache != null) m_Cache.Expire(id); diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index 2b77154a7b..c8a4912e8c 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -32,14 +32,14 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AuthenticationServicesConnector : IAuthenticationService + public class AuthenticationServicesConnector : BaseServiceConnector, IAuthenticationService { private static readonly ILog m_log = LogManager.GetLogger( @@ -57,6 +57,7 @@ namespace OpenSim.Services.Connectors } public AuthenticationServicesConnector(IConfigSource source) + : base(source, "AuthenticationService") { Initialise(source); } @@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Authentication connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "AuthenticationService"); } public string Authenticate(UUID principalID, string password, int lifetime) @@ -92,7 +95,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); @@ -105,6 +108,7 @@ namespace OpenSim.Services.Connectors public bool Verify(UUID principalID, string token, int lifetime) { +// m_log.Error("[XXX]: Verify"); Dictionary sendData = new Dictionary(); sendData["LIFETIME"] = lifetime.ToString(); sendData["PRINCIPAL"] = principalID.ToString(); @@ -114,7 +118,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); @@ -135,7 +139,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs index 35b7109496..63730b3a83 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs @@ -105,7 +105,7 @@ namespace OpenSim.Services.Connectors catch (Exception e) { m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); - message = ""; + message = e.Message; return m_ResponseOnFailure; } if (response == null) diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs index ddfca57c81..3f44efab73 100644 --- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs +++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs @@ -32,7 +32,7 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; @@ -41,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AvatarServicesConnector : IAvatarService + public class AvatarServicesConnector : BaseServiceConnector, IAvatarService { private static readonly ILog m_log = LogManager.GetLogger( @@ -59,6 +59,7 @@ namespace OpenSim.Services.Connectors } public AvatarServicesConnector(IConfigSource source) + : base(source, "AvatarService") { Initialise(source); } @@ -81,6 +82,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Avatar connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "AvatarService"); } @@ -114,7 +117,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply"); @@ -162,7 +165,7 @@ namespace OpenSim.Services.Connectors //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -207,7 +210,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -250,7 +253,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -293,7 +296,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/OpenSim/Services/Connectors/BaseServiceConnector.cs b/OpenSim/Services/Connectors/BaseServiceConnector.cs new file mode 100644 index 0000000000..98cd4897bf --- /dev/null +++ b/OpenSim/Services/Connectors/BaseServiceConnector.cs @@ -0,0 +1,33 @@ +using System; +using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; + +using Nini.Config; + +namespace OpenSim.Services.Connectors +{ + public class BaseServiceConnector + { + protected IServiceAuth m_Auth; + + public BaseServiceConnector() { } + + public BaseServiceConnector(IConfigSource config, string section) + { + Initialise(config, section); + } + + public void Initialise(IConfigSource config, string section) + { + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", section }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, section); + break; + } + + } + } +} diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs index b1dd84e887..74851a94db 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs @@ -32,6 +32,7 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Communications; using OpenSim.Services.Interfaces; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors.Friends { - public class FriendsServicesConnector : IFriendsService + public class FriendsServicesConnector : BaseServiceConnector, IFriendsService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors.Friends throw new Exception("Friends connector init error"); } m_ServerURI = serviceURI; + base.Initialise(source, "FriendsService"); } @@ -112,7 +114,7 @@ namespace OpenSim.Services.Connectors.Friends try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -168,7 +170,7 @@ namespace OpenSim.Services.Connectors.Friends string uri = m_ServerURI + "/friends"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -223,7 +225,7 @@ namespace OpenSim.Services.Connectors.Friends string uri = m_ServerURI + "/friends"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs index 0f5a61361a..7f86cffc5d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class GridServicesConnector : IGridService + public class GridServicesConnector : BaseServiceConnector, IGridService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Grid connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "GridService"); } @@ -102,7 +105,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -158,7 +161,7 @@ namespace OpenSim.Services.Connectors try { string reply - = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); if (reply != string.Empty) { @@ -195,7 +198,7 @@ namespace OpenSim.Services.Connectors try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); } catch (Exception e) { @@ -238,7 +241,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/grid"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -285,7 +288,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -330,7 +333,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -374,7 +377,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -428,7 +431,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -479,7 +482,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -530,7 +533,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -583,7 +586,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -634,7 +637,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -685,7 +688,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs index 1a62d2f1e7..ffdd94aca8 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class GridUserServicesConnector : IGridUserService + public class GridUserServicesConnector : BaseServiceConnector, IGridUserService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors throw new Exception("GridUser connector init error"); } m_ServerURI = serviceURI; + base.Initialise(source, "GridUserService"); } @@ -162,7 +164,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -198,7 +201,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -243,7 +247,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply"); diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 85d105e549..f86d2f104d 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs @@ -40,7 +40,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class XInventoryServicesConnector : IInventoryService + public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( @@ -60,6 +60,7 @@ namespace OpenSim.Services.Connectors } public XInventoryServicesConnector(IConfigSource source) + : base(source, "InventoryService") { Initialise(source); } @@ -505,7 +506,7 @@ namespace OpenSim.Services.Connectors lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/xinventory", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index 725204d9b3..677825e098 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -36,6 +36,7 @@ using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -43,7 +44,7 @@ using OpenMetaverse.StructuredData; namespace OpenSim.Services.Connectors { - public class MapImageServicesConnector : IMapImageService + public class MapImageServicesConnector : BaseServiceConnector, IMapImageService { private static readonly ILog m_log = LogManager.GetLogger( @@ -84,6 +85,7 @@ namespace OpenSim.Services.Connectors } m_ServerURI = serviceURI; m_ServerURI = serviceURI.TrimEnd('/'); + base.Initialise(source, "MapImageService"); } public bool RemoveMapTile(int x, int y, out string reason) @@ -101,7 +103,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -163,7 +166,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs index f7d8c5379c..aade7145c8 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class PresenceServicesConnector : IPresenceService + public class PresenceServicesConnector : BaseServiceConnector, IPresenceService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Presence connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "PresenceService"); } @@ -104,7 +107,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -149,7 +153,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -193,7 +198,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -238,7 +244,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -283,7 +290,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply"); @@ -327,7 +335,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null or empty reply"); diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index d9fe5a014d..099ba98d83 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -282,7 +282,7 @@ namespace OpenSim.Services.Connectors.Simulation } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Failed to contact destination"; version = "Unknown"; @@ -296,6 +296,7 @@ namespace OpenSim.Services.Connectors.Simulation 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())); if (agentHomeURI != null) request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index 8110fe56e1..3f61d9a7c4 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -33,13 +33,14 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class UserAccountServicesConnector : IUserAccountService + public class UserAccountServicesConnector : BaseServiceConnector, IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger( @@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors throw new Exception("User account connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "UserAccountService"); } public virtual UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) @@ -144,7 +147,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply"); @@ -224,7 +228,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); @@ -260,7 +265,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index c6d2ee32ca..09c7938725 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -156,18 +156,18 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region []", "Link a HyperGrid Region. Examples for : http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region []", "Link a hypergrid region (deprecated)", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region", "unlink-region ", "Unlink a hypergrid region", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [ ]", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [ ]", "Set local coordinate to map HG regions to", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks", "List the HG regions", HandleShow); } } diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 3de2330410..d1585373b9 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -122,7 +122,7 @@ namespace OpenSim.Services.HypergridService } List tree = GetFolderTree(principalID, suitcase.folderID); - if (tree == null || (tree != null && tree.Count == 0)) + if (tree.Count == 0) return null; List folders = new List(); @@ -164,8 +164,6 @@ namespace OpenSim.Services.HypergridService m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); return null; } - - m_Database.StoreFolder(suitcase); CreateSystemFolders(principalID, suitcase.folderID); } @@ -188,6 +186,10 @@ namespace OpenSim.Services.HypergridService CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) + CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) + CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) @@ -208,11 +210,6 @@ namespace OpenSim.Services.HypergridService CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash"); - if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) - CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); - if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) - CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); - } public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) @@ -249,7 +246,7 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(principalID, folderID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} is not within Suitcase tree", folderID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID); return new InventoryCollection(); } @@ -269,7 +266,7 @@ namespace OpenSim.Services.HypergridService // make sure the given folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(principalID, folderID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} is not within Suitcase tree", folderID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID); return new List(); } @@ -284,7 +281,7 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} is not within Suitcase tree", folder.ParentID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); return false; } @@ -306,7 +303,7 @@ namespace OpenSim.Services.HypergridService //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} is not within Suitcase tree", folder.Name, folder.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", folder.Name, folder.ID, folder.Owner); return false; } @@ -318,13 +315,13 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner); return false; } if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ParentID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); return false; } @@ -349,7 +346,7 @@ namespace OpenSim.Services.HypergridService // make sure the given folder's parent folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } @@ -362,7 +359,7 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } @@ -378,7 +375,7 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } } @@ -389,7 +386,7 @@ namespace OpenSim.Services.HypergridService InventoryItemBase originalItem = base.GetItem(item); if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", originalItem.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } } @@ -414,8 +411,8 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0}/{1} (folder {2}) is not within Suitcase tree or Appearance", - it.Name, it.ID, it.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetItem: item {0}/{1} (folder {2}) (user {3}) is not within Suitcase tree or Appearance", + it.Name, it.ID, it.Folder, it.Owner); return null; } @@ -437,8 +434,8 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(f.Owner, f.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Folder {0}/{1} is not within Suitcase tree", - f.Name, f.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", + f.Name, f.ID, f.Owner); return null; } } @@ -537,13 +534,13 @@ namespace OpenSim.Services.HypergridService private List GetFolderTree(UUID principalID, UUID folder) { - List t = null; + List t; if (m_SuitcaseTrees.TryGetValue(principalID, out t)) return t; // Get the tree of the suitcase folder t = GetFolderTreeRecursive(folder); - m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes + m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5 minutes return t; } @@ -554,8 +551,10 @@ namespace OpenSim.Services.HypergridService new string[] { "parentFolderID" }, new string[] { root.ToString() }); - if (folders == null || (folders != null && folders.Length == 0)) + if (folders == null || folders.Length == 0) + { return tree; // empty tree + } else { foreach (XInventoryFolder f in folders) @@ -588,17 +587,18 @@ namespace OpenSim.Services.HypergridService List tree = new List(); tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); + // Also add the Current Outfit folder to the list of available folders - tree.Add(GetCurrentOutfitXFolder(principalID)); + XInventoryFolder folder = GetCurrentOutfitXFolder(principalID); + if (folder != null) + tree.Add(folder); XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) { - if (fl.folderID == folderID) return true; - else return false; + return (fl.folderID == folderID); }); - if (f == null) return false; - else return true; + return (f != null); } #endregion diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 375a35cbb6..8b87ac0ce7 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -83,11 +83,12 @@ namespace OpenSim.Services.Interfaces /// Desired destination /// The visitor's User ID /// The visitor's Home URI. Will be missing (null) in older OpenSims. + /// True: via teleport; False: via cross (walking) /// Position in the region /// /// [out] Optional error message /// True: ok; False: not allowed - bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason); + bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason); /// /// Message from receiving region to departing region, telling it got contacted by the client. diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 7c16ca945a..362ff8f8c1 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -122,10 +122,18 @@ namespace OpenSim.Services.InventoryService if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts"); if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards"); + { + XInventoryFolder folder = CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards"); + folder = CreateFolder(principalID, folder.folderID, (int)AssetType.CallingCard, "Friends"); + CreateFolder(principalID, folder.folderID, (int)AssetType.CallingCard, "All"); + } if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) + if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)AssetType.FavoriteFolder, "Favorites"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures"); if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks"); diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 874ff625fa..342cd06004 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -574,7 +574,11 @@ namespace OpenSim.Tests.Common public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) { - AgentCircuitData acd = GenerateAgentData(agentId); + return AddChildScenePresence(scene, GenerateAgentData(agentId)); + } + + public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd) + { acd.child = true; // XXX: ViaLogin may not be correct for child agents diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs index b3f8c36672..5a257e9454 100644 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs @@ -324,7 +324,29 @@ namespace OpenSim.Tests.Common.Mock public List GetGroupNotices(UUID requestingAgentID, UUID groupID) { - return null; + XGroup group = GetXGroup(groupID, null); + + if (group == null) + return null; + + List notices = new List(); + + foreach (XGroupNotice notice in group.notices.Values) + { + GroupNoticeData gnd = new GroupNoticeData() + { + NoticeID = notice.noticeID, + Timestamp = notice.timestamp, + FromName = notice.fromName, + Subject = notice.subject, + HasAttachment = notice.hasAttachment, + AssetType = (byte)notice.assetType + }; + + notices.Add(gnd); + } + + return notices; } public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index c2b0935788..8eeaf99222 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -62,14 +62,23 @@ namespace OpenSim.Tests.Common.Mock public event Action OnReceivedMoveAgentIntoRegion; public event Action OnTestClientInformClientOfNeighbour; public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; + public event Action OnReceivedEntityUpdate; + + public event OnReceivedChatMessageDelegate OnReceivedChatMessage; public event Action OnReceivedInstantMessage; + public event Action OnReceivedSendRebakeAvatarTextures; public delegate void TestClientOnSendRegionTeleportDelegate( ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL); + public delegate void OnReceivedChatMessageDelegate( + string message, byte type, Vector3 fromPos, string fromName, + UUID fromAgentID, UUID ownerID, byte source, byte audible); + + // disable warning: public events, part of the public API #pragma warning disable 67 @@ -466,6 +475,34 @@ namespace OpenSim.Tests.Common.Mock SentImageNotInDatabasePackets = new List(); } + /// + /// Trigger chat coming from this connection. + /// + /// + /// + /// + public bool Chat(int channel, ChatTypeEnum type, string message) + { + ChatMessage handlerChatFromClient = OnChatFromClient; + + if (handlerChatFromClient != null) + { + OSChatMessage args = new OSChatMessage(); + args.Channel = channel; + args.From = Name; + args.Message = message; + args.Type = type; + + args.Scene = Scene; + args.Sender = this; + args.SenderUUID = AgentId; + + handlerChatFromClient(this, args); + } + + return true; + } + /// /// Attempt a teleport to the given region. /// @@ -550,6 +587,9 @@ namespace OpenSim.Tests.Common.Mock string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) { +// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId); + if (OnReceivedChatMessage != null) + OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); } public void SendInstantMessage(GridInstantMessage im) diff --git a/OpenSim/Tools/Configger/ConfigurationLoader.cs b/OpenSim/Tools/Configger/ConfigurationLoader.cs index 0b6ee9c825..f1d3649258 100644 --- a/OpenSim/Tools/Configger/ConfigurationLoader.cs +++ b/OpenSim/Tools/Configger/ConfigurationLoader.cs @@ -64,14 +64,13 @@ namespace OpenSim.Tools.Configger /// /// /// A configuration that gets passed to modules - public IConfigSource LoadConfigSettings() + public IConfigSource LoadConfigSettings(IConfig startupConfig) { bool iniFileExists = false; List sources = new List(); - string iniFileName = "OpenSim.ini"; - string iniFilePath = Path.Combine(".", iniFileName); + string iniFileName = startupConfig.GetString("inifile", Path.Combine(".", "OpenSim.ini")); if (IsUri(iniFileName)) { @@ -80,10 +79,10 @@ namespace OpenSim.Tools.Configger } else { - if (File.Exists(iniFilePath)) + if (File.Exists(iniFileName)) { - if (!sources.Contains(iniFilePath)) - sources.Add(iniFilePath); + if (!sources.Contains(iniFileName)) + sources.Add(iniFileName); } } diff --git a/OpenSim/Tools/Configger/Main.cs b/OpenSim/Tools/Configger/Main.cs index 61a12e32a5..d7d918b29c 100644 --- a/OpenSim/Tools/Configger/Main.cs +++ b/OpenSim/Tools/Configger/Main.cs @@ -35,15 +35,16 @@ namespace OpenSim.Tools.Configger public static int Main(string[] args) { ArgvConfigSource argvConfig = new ArgvConfigSource(args); + argvConfig.AddSwitch("Startup", "format", "f"); + argvConfig.AddSwitch("Startup", "inifile"); IConfig startupConfig = argvConfig.Configs["Startup"]; string format = startupConfig.GetString("format", "ini"); ConfigurationLoader loader = new ConfigurationLoader(); - - IConfigSource s = loader.LoadConfigSettings(); + IConfigSource s = loader.LoadConfigSettings(startupConfig); if (format == "mysql") { diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 7f2cba6c31..3f9aed6e88 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -470,6 +470,16 @@ ;; web server ; user_agent = "OpenSim LSL (Mozilla Compatible)" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. The username and password + ;; here need to match the ones in the Robust service configuration. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; Any of these 3 variables above can be overriden in any of the service sections. + [XMLRPC] ;# {XmlRpcRouterModule} {} {Module used to route incoming llRemoteData calls} {XmlRpcRouterModule XmlRpcGridRouterModule} XmlRpcRouterModule @@ -1033,9 +1043,12 @@ ; Applies Flotsam Group only. V2 has this always on, no other option ; MessageOnlineUsersOnly = false - ;; This makes the Groups modules very chatty on the console. + ;; This makes the Group module very chatty on the console. ; DebugEnabled = false + ; This makes the Group Messaging module very chatty on the console. + ; DebugMessagingEnabled = false + ;; XmlRpc Security settings. These must match those set on your backend ;; groups service if the service is using these keys ; XmlRpcServiceReadKey = 1234 diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index cae29589fb..fd6e8b7fc3 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1661,9 +1661,12 @@ ; Enable Group Notices ;NoticesEnabled = true - ; This makes the Groups modules very chatty on the console. + ; This makes the Group module very chatty on the console. DebugEnabled = false + ; This makes the Groups Messaging module very chatty on the console. + DebugMessagingEnabled = false + ; Groups data is cached for this number of seconds before another request is made to the groups service ; Set to 0 to disable the cache. ; Default is 30 seconds diff --git a/bin/Robust.32BitLaunch.exe.config b/bin/Robust.32BitLaunch.exe.config index 95061e1938..0399a1bd34 100644 --- a/bin/Robust.32BitLaunch.exe.config +++ b/bin/Robust.32BitLaunch.exe.config @@ -17,7 +17,7 @@ - + diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 14e9bff296..aaa78ff228 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -104,6 +104,21 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset ; Password for cert ; cert_pass = "password" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; AuthType above can be overriden in any of the service sections below by + ; AuthType = "None" + ;; This is useful in cases where you want to protect most of the services, + ;; but unprotect individual services. Username and Password can also be + ;; overriden if you want to use different credentials for the different services. + ;; Hypgergrid services are not affected by this; they are publicly available + ;; by design. + ; * The following are for the remote console ; * They have no effect for the local or basic console types @@ -163,8 +178,6 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset [GridService] LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - HypergridLinker = true - ; Realm = "regions" ; AllowDuplicateNames = "True" @@ -284,6 +297,7 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. diff --git a/bin/Robust.exe.config b/bin/Robust.exe.config index b9e01f1bc7..3a978b20d4 100644 --- a/bin/Robust.exe.config +++ b/bin/Robust.exe.config @@ -17,7 +17,7 @@ - + diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 829e3930b5..203c0e096d 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -81,6 +81,19 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto ; Password for cert ; cert_pass = "password" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; AuthType above can be overriden in any of the service sections below by + ; AuthType = "None" + ;; This is useful in cases where you want to protect most of the services, + ;; but unprotect individual services. Username and Password can also be + ;; overriden if you want to use different credentials for the different services. + ; * The following are for the remote console ; * They have no effect for the local or basic console types @@ -240,6 +253,7 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 5460c0a0f0..59eebd891a 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -160,13 +160,21 @@ HomeURI = "http://mygridserver.com:8002" Gatekeeper = "http://mygridserver.com:8002" ;; If you want to protect your assets from being copied by foreign visitors - ;; uncomment the next line. You may want to do this on sims that have licensed content. - ; OutboundPermission = False + ;; set this to false. You may want to do this on sims that have licensed content. + ;; Default is true. + ; OutboundPermission = True ;; Send visual reminder to local users that their inventories are unavailable while they are traveling ;; and available when they return. True by default. ;RestrictInventoryAccessAbroad = True + ;; Warning: advanced and unusual. Default is false. + ;; Enables configurations where grids share user services, including inventory, + ;; while separating regions' assets from users' assets. Asset transfer between + ;; the users' asset server and the regions' asset server is done in HG-like manner. + ; CheckSeparateAssets = false + ; RegionHGAssetServerURI = http://mygridserver.com:8002 + [HGAssetService] ; diff --git a/bin/pCampBot.exe.config b/bin/pCampBot.exe.config index 791299118b..89350b053d 100755 --- a/bin/pCampBot.exe.config +++ b/bin/pCampBot.exe.config @@ -11,7 +11,7 @@ - + diff --git a/prebuild.xml b/prebuild.xml index 9a419eb3c2..3da76398ef 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -111,6 +111,7 @@ + @@ -3081,6 +3082,7 @@ +