From fe779128b0c50f44cf479444444754298d829910 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 6 Jun 2014 11:04:53 -0700 Subject: [PATCH] Added simulation version compatibility check so that agents coming from 0.7.6 to a varregion running in 0.8 and above will be denied teleport, rather than be allowed and crash the viewer. --- .../EntityTransfer/EntityTransferModule.cs | 10 ++++--- .../Simulation/LocalSimulationConnector.cs | 26 ++++++++++++++++--- .../Simulation/RemoteSimulationConnector.cs | 6 ++--- .../Handlers/Simulation/AgentHandlers.cs | 6 ++++- .../Simulation/SimulationServiceConnector.cs | 3 ++- .../Services/Interfaces/ISimulationService.cs | 5 ++-- bin/config-include/Grid.ini | 10 ++++--- bin/config-include/GridHypergrid.ini | 8 ++++-- bin/config-include/Standalone.ini | 8 ++++-- bin/config-include/StandaloneHypergrid.ini | 8 ++++-- 10 files changed, 67 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 70b0e0abc3..d626771151 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -208,7 +208,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual void InitialiseCommon(IConfigSource source) { string transferVersionName = "SIMULATION"; - float maxTransferVersion = 0.2f; + float maxTransferVersion = 0.3f; IConfig hypergridConfig = source.Configs["Hypergrid"]; if (hypergridConfig != null) @@ -760,8 +760,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason; string version; + string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion); if (!Scene.SimulationService.QueryAccess( - finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, out version, out reason)) + finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, out version, out reason)) { sp.ControllingClient.SendTeleportFailed(reason); @@ -834,7 +835,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (versionComponents.Length >= 2) float.TryParse(versionComponents[1], out versionNumber); - if (versionNumber == 0.2f && MaxOutgoingTransferVersion >= versionNumber) + if (versionNumber >= 0.2f && MaxOutgoingTransferVersion >= versionNumber) TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); else TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); @@ -1510,8 +1511,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // Check to see if we have access to the target region. + string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion); if (neighbourRegion != null - && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, out version, out failureReason)) + && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, myversion, out version, out failureReason)) { // remember banned m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 926ef05180..e6de0b6c29 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation /// Currently valid versions are "SIMULATION/0.1" and "SIMULATION/0.2" /// public string ServiceVersion { get; set; } + private float m_VersionNumber = 0.3f; /// /// Map region ID to scene. @@ -84,15 +85,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation public void InitialiseService(IConfigSource configSource) { - ServiceVersion = "SIMULATION/0.2"; + ServiceVersion = "SIMULATION/0.3"; IConfig config = configSource.Configs["SimulationService"]; if (config != null) { ServiceVersion = config.GetString("ConnectorProtocolVersion", ServiceVersion); - if (ServiceVersion != "SIMULATION/0.1" && ServiceVersion != "SIMULATION/0.2") + if (ServiceVersion != "SIMULATION/0.1" && ServiceVersion != "SIMULATION/0.2" && ServiceVersion != "SIMULATION/0.3") throw new Exception(string.Format("Invalid ConnectorProtocolVersion {0}", ServiceVersion)); + string[] versionComponents = ServiceVersion.Split(new char[] { '/' }); + if (versionComponents.Length >= 2) + float.TryParse(versionComponents[1], out m_VersionNumber); + m_log.InfoFormat( "[LOCAL SIMULATION CONNECTOR]: Initialized with connector protocol version {0}", ServiceVersion); } @@ -264,7 +269,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return true; } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string theirversion, out string version, out string reason) { reason = "Communications failure"; version = ServiceVersion; @@ -276,6 +281,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // m_log.DebugFormat( // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); + uint size = m_scenes[destination.RegionID].RegionInfo.RegionSizeX; + + float theirVersionNumber = 0f; + string[] versionComponents = theirversion.Split(new char[] { '/' }); + if (versionComponents.Length >= 2) + float.TryParse(versionComponents[1], out theirVersionNumber); + + // Var regions here, and the requesting simulator is in an older version. + // We will forbide this, because it crashes the viewers + if (theirVersionNumber < 0.3f && size > 256) + { + reason = "Destination is a variable-sized region, and source is an old simulator. Consider upgrading."; + m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from {0} simulator was denied", theirVersionNumber); + return false; + } return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, out reason); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 0444e49559..6ecc32740c 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, bool viaTeleport, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string sversion, 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, viaTeleport, position, out version, out reason)) + if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, out version, out reason)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionID)) - return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); + return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, sversion, out version, out reason); return false; } diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 72919313ad..6d3a3a7507 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -144,12 +144,16 @@ namespace OpenSim.Server.Handlers.Simulation if (args.ContainsKey("agent_home_uri")) agentHomeURI = args["agent_home_uri"].AsString(); + string theirVersion = string.Empty; + if (args.ContainsKey("my_version")) + theirVersion = args["my_version"].AsString(); + GridRegion destination = new GridRegion(); destination.RegionID = regionID; string reason; string version; - bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); + bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, theirVersion, out version, out reason); responsedata["int_response_code"] = HttpStatusCode.OK; diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 099ba98d83..b6fde726ac 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, bool viaTeleport, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string myversion, out string version, out string reason) { reason = "Failed to contact destination"; version = "Unknown"; @@ -298,6 +298,7 @@ namespace OpenSim.Services.Connectors.Simulation OSDMap request = new OSDMap(); request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); + request.Add("my_version", OSD.FromString(myversion)); if (agentHomeURI != null) request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 8b87ac0ce7..12ab4786ee 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -85,10 +85,11 @@ namespace OpenSim.Services.Interfaces /// The visitor's Home URI. Will be missing (null) in older OpenSims. /// True: via teleport; False: via cross (walking) /// Position in the region - /// + /// version that the requesting simulator is runing + /// version that the target simulator is running /// [out] Optional error message /// True: ok; False: not allowed - bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason); + bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string sversion, out string version, out string reason); /// /// Message from receiving region to departing region, telling it got contacted by the client. diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index e7141a177f..419b40d0f3 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini @@ -33,13 +33,17 @@ [SimulationService] ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport ; It is used to control the teleport handoff process. - ; Valid values are + ; Valid values are + ; "SIMULATION/0.3" + ; - This is the default, and it supports teleports to variable-sized regions + ; - Older versions can teleport to this one, but only if the destination region + ; is 256x256 ; "SIMULATION/0.2" - ; - this is the default. A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol + ; - A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol ; - this protocol is more efficient than "SIMULATION/0.1" ; "SIMULATION/0.1" ; - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. - ConnectorProtocolVersion = "SIMULATION/0.2" + ConnectorProtocolVersion = "SIMULATION/0.3" [SimulationDataStore] LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService" diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 8f17527940..27cc9d80d1 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -39,12 +39,16 @@ ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport ; It is used to control the teleport handoff process. ; Valid values are + ; "SIMULATION/0.3" + ; - This is the default, and it supports teleports to variable-sized regions + ; - Older versions can teleport to this one, but only if the destination region + ; is 256x256 ; "SIMULATION/0.2" - ; - this is the default. A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol + ; - A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol ; - this protocol is more efficient than "SIMULATION/0.1" ; "SIMULATION/0.1" ; - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. - ConnectorProtocolVersion = "SIMULATION/0.2" + ConnectorProtocolVersion = "SIMULATION/0.3" [Profile] Module = "BasicProfileModule" diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index 0072be5c33..887f4d8dd4 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -31,12 +31,16 @@ ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport ; It is used to control the teleport handoff process. ; Valid values are + ; "SIMULATION/0.3" + ; - This is the default, and it supports teleports to variable-sized regions + ; - Older versions can teleport to this one, but only if the destination region + ; is 256x256 ; "SIMULATION/0.2" - ; - this is the default. A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol + ; - A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol ; - this protocol is more efficient than "SIMULATION/0.1" ; "SIMULATION/0.1" ; - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. - ConnectorProtocolVersion = "SIMULATION/0.2" + ConnectorProtocolVersion = "SIMULATION/0.3" [SimulationDataStore] LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService" diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index f39cf097a4..ccb80cb504 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -42,12 +42,16 @@ ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport ; It is used to control the teleport handoff process. ; Valid values are + ; "SIMULATION/0.3" + ; - This is the default, and it supports teleports to variable-sized regions + ; - Older versions can teleport to this one, but only if the destination region + ; is 256x256 ; "SIMULATION/0.2" - ; - this is the default. A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol + ; - A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol ; - this protocol is more efficient than "SIMULATION/0.1" ; "SIMULATION/0.1" ; - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. - ConnectorProtocolVersion = "SIMULATION/0.2" + ConnectorProtocolVersion = "SIMULATION/0.3" [Messaging] MessageTransferModule = HGMessageTransferModule