From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- .../Connectors/Simulation/EstateDataService.cs | 139 ---------------- .../Connectors/Simulation/SimulationDataService.cs | 182 --------------------- .../Simulation/SimulationServiceConnector.cs | 165 +++++++++++-------- 3 files changed, 101 insertions(+), 385 deletions(-) delete mode 100644 OpenSim/Services/Connectors/Simulation/EstateDataService.cs delete mode 100644 OpenSim/Services/Connectors/Simulation/SimulationDataService.cs (limited to 'OpenSim/Services/Connectors/Simulation') diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs deleted file mode 100644 index cdcdecf..0000000 --- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 OpenMetaverse; -using log4net; -using Mono.Addins; -using Nini.Config; -using System.Reflection; -using OpenSim.Services.Base; -using OpenSim.Services.Interfaces; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Services.Connectors -{ - public class EstateDataService : ServiceBase, IEstateDataService - { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - - protected IEstateDataStore m_database; - - public EstateDataService(IConfigSource config) - : base(config) - { - string dllName = String.Empty; - string connString = String.Empty; - - // Try reading the [DatabaseService] section, if it exists - IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) - { - dllName = dbConfig.GetString("StorageProvider", String.Empty); - connString = dbConfig.GetString("ConnectionString", String.Empty); - connString = dbConfig.GetString("EstateConnectionString", connString); - } - - // Try reading the [EstateDataStore] section, if it exists - IConfig estConfig = config.Configs["EstateDataStore"]; - if (estConfig != null) - { - dllName = estConfig.GetString("StorageProvider", dllName); - connString = estConfig.GetString("ConnectionString", connString); - } - - // We tried, but this doesn't exist. We can't proceed - if (dllName == String.Empty) - throw new Exception("No StorageProvider configured"); - - m_database = LoadPlugin(dllName, new Object[] { connString }); - if (m_database == null) - throw new Exception("Could not find a storage interface in the given module"); - } - - public EstateSettings LoadEstateSettings(UUID regionID, bool create) - { - return m_database.LoadEstateSettings(regionID, create); - } - - public EstateSettings LoadEstateSettings(int estateID) - { - return m_database.LoadEstateSettings(estateID); - } - - public EstateSettings CreateNewEstate() - { - return m_database.CreateNewEstate(); - } - - public List LoadEstateSettingsAll() - { - return m_database.LoadEstateSettingsAll(); - } - - public void StoreEstateSettings(EstateSettings es) - { - m_database.StoreEstateSettings(es); - } - - public List GetEstates(string search) - { - return m_database.GetEstates(search); - } - - public List GetEstatesAll() - { - return m_database.GetEstatesAll(); - } - - public List GetEstatesByOwner(UUID ownerID) - { - return m_database.GetEstatesByOwner(ownerID); - } - - public bool LinkRegion(UUID regionID, int estateID) - { - return m_database.LinkRegion(regionID, estateID); - } - - public List GetRegions(int estateID) - { - return m_database.GetRegions(estateID); - } - - public bool DeleteEstate(int estateID) - { - return m_database.DeleteEstate(estateID); - } - } -} diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs deleted file mode 100644 index 504fcaf..0000000 --- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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 OpenMetaverse; -using log4net; -using Mono.Addins; -using Nini.Config; -using System.Reflection; -using OpenSim.Services.Base; -using OpenSim.Services.Interfaces; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Services.Connectors -{ - public class SimulationDataService : ServiceBase, ISimulationDataService - { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - - protected ISimulationDataStore m_database; - - public SimulationDataService(IConfigSource config) - : base(config) - { - string dllName = String.Empty; - string connString = String.Empty; - - // Try reading the [DatabaseService] section, if it exists - IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) - { - dllName = dbConfig.GetString("StorageProvider", String.Empty); - connString = dbConfig.GetString("ConnectionString", String.Empty); - } - - // Try reading the [SimulationDataStore] section - IConfig simConfig = config.Configs["SimulationDataStore"]; - if (simConfig != null) - { - dllName = simConfig.GetString("StorageProvider", dllName); - connString = simConfig.GetString("ConnectionString", connString); - } - - // We tried, but this doesn't exist. We can't proceed - if (dllName == String.Empty) - throw new Exception("No StorageProvider configured"); - - m_database = LoadPlugin(dllName, new Object[] { connString }); - if (m_database == null) - throw new Exception("Could not find a storage interface in the given module"); - } - - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) - { - m_database.StoreObject(obj, regionUUID); - } - - public void RemoveObject(UUID uuid, UUID regionUUID) - { - m_database.RemoveObject(uuid, regionUUID); - } - - public void StorePrimInventory(UUID primID, ICollection items) - { - m_database.StorePrimInventory(primID, items); - } - - public List LoadObjects(UUID regionUUID) - { - return m_database.LoadObjects(regionUUID); - } - - public void StoreTerrain(double[,] terrain, UUID regionID) - { - m_database.StoreTerrain(terrain, regionID); - } - - public double[,] LoadTerrain(UUID regionID) - { - return m_database.LoadTerrain(regionID); - } - - public void StoreLandObject(ILandObject Parcel) - { - m_database.StoreLandObject(Parcel); - } - - public void RemoveLandObject(UUID globalID) - { - m_database.RemoveLandObject(globalID); - } - - public List LoadLandObjects(UUID regionUUID) - { - return m_database.LoadLandObjects(regionUUID); - } - - public void StoreRegionSettings(RegionSettings rs) - { - m_database.StoreRegionSettings(rs); - } - - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - return m_database.LoadRegionSettings(regionUUID); - } - - public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) - { - return m_database.LoadRegionWindlightSettings(regionUUID); - } - - public void StoreRegionWindlightSettings(RegionLightShareData wl) - { - m_database.StoreRegionWindlightSettings(wl); - } - public void RemoveRegionWindlightSettings(UUID regionID) - { - m_database.RemoveRegionWindlightSettings(regionID); - } - - public string LoadRegionEnvironmentSettings(UUID regionUUID) - { - return m_database.LoadRegionEnvironmentSettings(regionUUID); - } - - public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) - { - m_database.StoreRegionEnvironmentSettings(regionUUID, settings); - } - - public void RemoveRegionEnvironmentSettings(UUID regionUUID) - { - m_database.RemoveRegionEnvironmentSettings(regionUUID); - } - - public void SaveExtra(UUID regionID, string name, string val) - { - m_database.SaveExtra(regionID, name, val); - } - - public void RemoveExtra(UUID regionID, string name) - { - m_database.RemoveExtra(regionID, name); - } - - public Dictionary GetExtra(UUID regionID) - { - return m_database.GetExtra(regionID); - } - } -} diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 57f2ffa..cea870b 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -79,11 +79,37 @@ namespace OpenSim.Services.Connectors.Simulation return "agent/"; } - public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) + protected virtual void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags) { - // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); - + if (source != null) + { + args["source_x"] = OSD.FromString(source.RegionLocX.ToString()); + args["source_y"] = OSD.FromString(source.RegionLocY.ToString()); + args["source_name"] = OSD.FromString(source.RegionName); + args["source_uuid"] = OSD.FromString(source.RegionID.ToString()); + if (!String.IsNullOrEmpty(source.RawServerURI)) + args["source_server_uri"] = OSD.FromString(source.RawServerURI); + } + + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + args["teleport_flags"] = OSD.FromString(flags.ToString()); + } + + public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) + { + string tmp = String.Empty; + return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason); + } + + public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) + { + m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); reason = String.Empty; + myipaddress = String.Empty; + if (destination == null) { m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); @@ -95,12 +121,7 @@ namespace OpenSim.Services.Connectors.Simulation try { OSDMap args = aCircuit.PackAgentCircuitData(); - - args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); - args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); - args["destination_name"] = OSD.FromString(destination.RegionName); - args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); - args["teleport_flags"] = OSD.FromString(flags.ToString()); + PackData(args, source, aCircuit, destination, flags); OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); bool success = result["success"].AsBoolean(); @@ -110,11 +131,12 @@ namespace OpenSim.Services.Connectors.Simulation reason = data["reason"].AsString(); success = data["success"].AsBoolean(); + myipaddress = data["your_ip"].AsString(); return success; } // Try the old version, uncompressed - result = WebUtil.PostToService(uri, args, 30000); + result = WebUtil.PostToService(uri, args, 30000, false); if (result["Success"].AsBoolean()) { @@ -124,6 +146,7 @@ namespace OpenSim.Services.Connectors.Simulation reason = data["reason"].AsString(); success = data["success"].AsBoolean(); + myipaddress = data["your_ip"].AsString(); m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); return success; @@ -228,7 +251,7 @@ namespace OpenSim.Services.Connectors.Simulation /// private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) { - // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start"); + // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; @@ -258,48 +281,10 @@ namespace OpenSim.Services.Connectors.Simulation return false; } - /// - /// Not sure what sequence causes this function to be invoked. The only calling - /// path is through the GET method - /// - public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) - { - // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start"); - - agent = null; - - // Eventually, we want to use a caps url instead of the agentID - string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; - - try - { - OSDMap result = WebUtil.GetFromService(uri, 10000); - if (result["Success"].AsBoolean()) - { - // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString()); - OSDMap args = (OSDMap)result["_Result"]; - if (args != null) - { - agent = new CompleteAgentData(); - agent.Unpack(args, null); - return true; - } - } - } - catch (Exception e) - { - m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString()); - } - - return false; - } - /// - /// - public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List featuresAvailable, EntityTransferContext ctx, out string reason) { reason = "Failed to contact destination"; - version = "Unknown"; // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); @@ -307,14 +292,32 @@ namespace OpenSim.Services.Connectors.Simulation if (ext == null) return false; // Eventually, we want to use a caps url instead of the agentID - string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; + string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); + request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); + // To those who still understad this field, we're telling them + // the lowest version just to be safe + request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin))); + // New simulation service negotiation + request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin)); + request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax)); + request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); + request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); + + OSDArray features = new OSDArray(); + foreach (UUID feature in featuresAvailable) + features.Add(OSD.FromString(feature.ToString())); + + request.Add("features", features); + + if (agentHomeURI != null) + request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); try { - OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false); + OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false); bool success = result["success"].AsBoolean(); if (result.ContainsKey("_Result")) { @@ -325,15 +328,32 @@ namespace OpenSim.Services.Connectors.Simulation success = data["success"]; reason = data["reason"].AsString(); - if (data["version"] != null && data["version"].AsString() != string.Empty) - version = data["version"].AsString(); + // We will need to plumb this and start sing the outbound version as well + // TODO: lay the pipe for version plumbing + if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null) + { + ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal(); + ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal(); + } + else if (data["version"] != null && data["version"].AsString() != string.Empty) + { + string versionString = data["version"].AsString(); + String[] parts = versionString.Split(new char[] {'/'}); + if (parts.Length > 1) + { + ctx.InboundVersion = float.Parse(parts[1]); + ctx.OutboundVersion = float.Parse(parts[1]); + } + } + if (data.ContainsKey("variable_wearables_count_supported")) + ctx.VariableWearablesSupported = true; m_log.DebugFormat( - "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3} ({4})", - uri, success, reason, version, data["version"].AsString()); + "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", + uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion); } - if (!success) + if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f) { // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the // actual failure message @@ -359,6 +379,17 @@ namespace OpenSim.Services.Connectors.Simulation return false; } + + featuresAvailable.Clear(); + + if (result.ContainsKey("features")) + { + OSDArray array = (OSDArray)result["features"]; + + foreach (OSD o in array) + featuresAvailable.Add(new UUID(o.AsString())); + } + return success; } catch (Exception e) @@ -377,7 +408,7 @@ namespace OpenSim.Services.Connectors.Simulation try { - WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); + WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false); } catch (Exception e) { @@ -389,15 +420,14 @@ namespace OpenSim.Services.Connectors.Simulation /// /// - public bool CloseAgent(GridRegion destination, UUID id) + public bool CloseAgent(GridRegion destination, UUID id, string auth_code) { -// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); - - string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; + string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code; + m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri); try { - WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); + WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false); } catch (Exception e) { @@ -444,11 +474,18 @@ namespace OpenSim.Services.Connectors.Simulation args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); - WebUtil.PostToService(uri, args, 40000); + OSDMap result = WebUtil.PostToService(uri, args, 40000, false); + + if (result == null) + return false; + bool success = result["success"].AsBoolean(); + if (!success) + return false; } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString()); + return false; } return true; -- cgit v1.1