diff options
author | UbitUmarov | 2015-10-31 12:57:14 +0000 |
---|---|---|
committer | UbitUmarov | 2015-10-31 12:57:14 +0000 |
commit | 1030d07f31516b303ddbb0c428f8f28419f3fa82 (patch) | |
tree | 6f36d19e1ae91ebbf6e2d9b2e0d6835fea11738c /OpenSim/Server/Handlers | |
parent | let silly tests override version on local connections (diff) | |
download | opensim-SC-1030d07f31516b303ddbb0c428f8f28419f3fa82.zip opensim-SC-1030d07f31516b303ddbb0c428f8f28419f3fa82.tar.gz opensim-SC-1030d07f31516b303ddbb0c428f8f28419f3fa82.tar.bz2 opensim-SC-1030d07f31516b303ddbb0c428f8f28419f3fa82.tar.xz |
simplify new regions protocol version control. (May not work, and babies safety warnings still valid
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index e0fa799..e8456b4 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -156,8 +156,8 @@ namespace OpenSim.Server.Handlers.Simulation | |||
156 | } | 156 | } |
157 | 157 | ||
158 | // Decode the new versioning data | 158 | // Decode the new versioning data |
159 | float minVersionRequired = 0f; | 159 | // float minVersionRequired = 0f; |
160 | float maxVersionRequired = 0f; | 160 | // float maxVersionRequired = 0f; |
161 | float minVersionProvided = 0f; | 161 | float minVersionProvided = 0f; |
162 | float maxVersionProvided = 0f; | 162 | float maxVersionProvided = 0f; |
163 | 163 | ||
@@ -166,50 +166,49 @@ namespace OpenSim.Server.Handlers.Simulation | |||
166 | if (args.ContainsKey("simulation_service_supported_max")) | 166 | if (args.ContainsKey("simulation_service_supported_max")) |
167 | maxVersionProvided = (float)args["simulation_service_supported_max"].AsReal(); | 167 | maxVersionProvided = (float)args["simulation_service_supported_max"].AsReal(); |
168 | 168 | ||
169 | if (args.ContainsKey("simulation_service_accepted_min")) | 169 | // if (args.ContainsKey("simulation_service_accepted_min")) |
170 | minVersionRequired = (float)args["simulation_service_accepted_min"].AsReal(); | 170 | // minVersionRequired = (float)args["simulation_service_accepted_min"].AsReal(); |
171 | if (args.ContainsKey("simulation_service_accepted_max")) | 171 | // if (args.ContainsKey("simulation_service_accepted_max")) |
172 | maxVersionRequired = (float)args["simulation_service_accepted_max"].AsReal(); | 172 | // maxVersionRequired = (float)args["simulation_service_accepted_max"].AsReal(); |
173 | 173 | ||
174 | responsedata["int_response_code"] = HttpStatusCode.OK; | 174 | responsedata["int_response_code"] = HttpStatusCode.OK; |
175 | OSDMap resp = new OSDMap(3); | 175 | OSDMap resp = new OSDMap(3); |
176 | 176 | ||
177 | |||
178 | // If there is no version in the packet at all we're looking at 0.6 or | ||
179 | // even more ancient. Refuse it. | ||
180 | if (minVersionProvided == 0f && theirVersion == 0f) // 0.6 or earlier | ||
181 | { | ||
182 | resp["success"] = OSD.FromBoolean(false); | ||
183 | resp["reason"] = OSD.FromString("Version not supported"); | ||
184 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | ||
185 | return; | ||
186 | } | ||
187 | |||
188 | float version; | 177 | float version; |
189 | 178 | ||
190 | if (minVersionProvided == 0f) // Legacy version | 179 | |
180 | if (minVersionProvided == 0f) // string version or older | ||
191 | { | 181 | { |
192 | if (theirVersion >= VersionInfo.SimulationServiceVersionAcceptedMin && | 182 | // If there is no version in the packet at all we're looking at 0.6 or |
193 | theirVersion <= VersionInfo.SimulationServiceVersionAcceptedMax) | 183 | // even more ancient. Refuse it. |
184 | if(theirVersion == 0f) | ||
194 | { | 185 | { |
195 | version = Math.Max(theirVersion, VersionInfo.SimulationServiceVersionAcceptedMax); | 186 | resp["success"] = OSD.FromBoolean(false); |
187 | resp["reason"] = OSD.FromString("Your region is running a old version of opensim no longer supported. Consider updating it"); | ||
188 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | ||
189 | return; | ||
196 | } | 190 | } |
197 | else | 191 | |
192 | version = theirVersion; | ||
193 | |||
194 | if (version < VersionInfo.SimulationServiceVersionAcceptedMin || | ||
195 | version > VersionInfo.SimulationServiceVersionAcceptedMax ) | ||
198 | { | 196 | { |
199 | resp["success"] = OSD.FromBoolean(false); | 197 | resp["success"] = OSD.FromBoolean(false); |
200 | resp["reason"] = OSD.FromString(String.Format("Your version is {0} and we accept only {1} - {2}", theirVersion, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax)); | 198 | resp["reason"] = OSD.FromString(String.Format("Your region protocol version is {0} and destiny accepts only {1} - {2}", theirVersion, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax)); |
201 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | 199 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); |
202 | return; | 200 | return; |
203 | } | 201 | } |
204 | } | 202 | } |
205 | else | 203 | else |
206 | { | 204 | { |
205 | /* | ||
207 | // Test for no overlap | 206 | // Test for no overlap |
208 | if (minVersionProvided > VersionInfo.SimulationServiceVersionAcceptedMax || | 207 | if (minVersionProvided > VersionInfo.SimulationServiceVersionAcceptedMax || |
209 | maxVersionProvided < VersionInfo.SimulationServiceVersionAcceptedMin) | 208 | maxVersionProvided < VersionInfo.SimulationServiceVersionAcceptedMin) |
210 | { | 209 | { |
211 | resp["success"] = OSD.FromBoolean(false); | 210 | resp["success"] = OSD.FromBoolean(false); |
212 | resp["reason"] = OSD.FromString(String.Format("You provide versions {0} - {1} and we accept only {2} - {3}. No version overlap.", minVersionProvided, maxVersionProvided, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax)); | 211 | resp["reason"] = OSD.FromString(String.Format("Your region provide protocol versions {0} - {1} and we accept only {2} - {3}. No version overlap.", minVersionProvided, maxVersionProvided, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax)); |
213 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | 212 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); |
214 | return; | 213 | return; |
215 | } | 214 | } |
@@ -217,23 +216,38 @@ namespace OpenSim.Server.Handlers.Simulation | |||
217 | maxVersionRequired < VersionInfo.SimulationServiceVersionSupportedMin) | 216 | maxVersionRequired < VersionInfo.SimulationServiceVersionSupportedMin) |
218 | { | 217 | { |
219 | resp["success"] = OSD.FromBoolean(false); | 218 | resp["success"] = OSD.FromBoolean(false); |
220 | resp["reason"] = OSD.FromString(String.Format("You require versions {0} - {1} and we provide only {2} - {3}. No version overlap.", minVersionRequired, maxVersionRequired, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax)); | 219 | resp["reason"] = OSD.FromString(String.Format("You require region protocol versions {0} - {1} and we provide only {2} - {3}. No version overlap.", minVersionRequired, maxVersionRequired, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax)); |
221 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | 220 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); |
222 | return; | 221 | return; |
223 | } | 222 | } |
224 | 223 | ||
225 | // Determine version to use | 224 | // Determine version to use |
226 | version = Math.Max(Math.Max(maxVersionProvided, VersionInfo.SimulationServiceVersionAcceptedMax), Math.Max(maxVersionRequired, VersionInfo.SimulationServiceVersionSupportedMax)); | 225 | |
226 | version = Math.Max(Math.Min(maxVersionProvided, VersionInfo.SimulationServiceVersionAcceptedMax), Math.Min(maxVersionRequired, VersionInfo.SimulationServiceVersionSupportedMax)); | ||
227 | if (version < VersionInfo.SimulationServiceVersionAcceptedMin || | 227 | if (version < VersionInfo.SimulationServiceVersionAcceptedMin || |
228 | version > VersionInfo.SimulationServiceVersionAcceptedMax || | 228 | version > VersionInfo.SimulationServiceVersionAcceptedMax || |
229 | version < VersionInfo.SimulationServiceVersionSupportedMin || | 229 | version < VersionInfo.SimulationServiceVersionSupportedMin || |
230 | version > VersionInfo.SimulationServiceVersionSupportedMax) | 230 | version > VersionInfo.SimulationServiceVersionSupportedMax) |
231 | { | 231 | { |
232 | resp["success"] = OSD.FromBoolean(false); | 232 | resp["success"] = OSD.FromBoolean(false); |
233 | resp["reason"] = OSD.FromString(String.Format("The protocol version we determined, {0}, is incompatible with the version windows, {1} - {2} and {3} - {4}. No version overlap.", version, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax)); | 233 | resp["reason"] = OSD.FromString(String.Format("The region protocol version we determined, {0}, is incompatible with the version windows, {1} - {2} and {3} - {4}. No version overlap.", version, VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax)); |
234 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | 234 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); |
235 | return; | 235 | return; |
236 | } | 236 | } |
237 | */ | ||
238 | // find max possible version to use | ||
239 | version = Math.Min(VersionInfo.SimulationServiceVersionAcceptedMax, maxVersionProvided); | ||
240 | // check if within lower bounds | ||
241 | if(version < VersionInfo.SimulationServiceVersionAcceptedMin || | ||
242 | version < minVersionProvided) | ||
243 | { | ||
244 | resp["success"] = OSD.FromBoolean(false); | ||
245 | resp["reason"] = OSD.FromString(String.Format("Region protocol versions are incompatible. Destiny accepts {0} - {1} and source provides {2} - {3}.", VersionInfo.SimulationServiceVersionAcceptedMin, VersionInfo.SimulationServiceVersionAcceptedMax, | ||
246 | minVersionProvided, | ||
247 | maxVersionProvided)); | ||
248 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true); | ||
249 | return; | ||
250 | } | ||
237 | } | 251 | } |
238 | 252 | ||
239 | List<UUID> features = new List<UUID>(); | 253 | List<UUID> features = new List<UUID>(); |