diff options
author | UbitUmarov | 2016-12-16 03:38:20 +0000 |
---|---|---|
committer | UbitUmarov | 2016-12-16 03:38:20 +0000 |
commit | e2d46c060c4b9557cf596d6d828ddd296fa0af70 (patch) | |
tree | c2c44730340c9785b9b373c937a2a54b2e6ec34e /OpenSim/Services | |
parent | reserve constant OBJECT_ATTACHED_SLOTS_AVAILABLE from mantis 8096. But do not... (diff) | |
download | opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.zip opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.gz opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.bz2 opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.xz |
ok.. another try on the HG uri
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 25 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 121 |
2 files changed, 22 insertions, 124 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 82b910a..c51bb8b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -505,11 +505,16 @@ namespace OpenSim.Services.GridService | |||
505 | { | 505 | { |
506 | string regionURI = ""; | 506 | string regionURI = ""; |
507 | string regionName = ""; | 507 | string regionName = ""; |
508 | if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) | 508 | if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) |
509 | return null; | 509 | return null; |
510 | 510 | ||
511 | bool localGrid = string.IsNullOrWhiteSpace(regionURI); | 511 | string mapname; |
512 | string mapname = regionURI + regionName; | 512 | bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); |
513 | if(localGrid) | ||
514 | mapname = regionName; | ||
515 | else | ||
516 | mapname = regionURI + regionName; | ||
517 | |||
513 | bool haveMatch = false; | 518 | bool haveMatch = false; |
514 | 519 | ||
515 | if (rdatas != null && (rdatas.Count > 0)) | 520 | if (rdatas != null && (rdatas.Count > 0)) |
@@ -555,7 +560,7 @@ namespace OpenSim.Services.GridService | |||
555 | if(haveMatch) | 560 | if(haveMatch) |
556 | return rinfos; | 561 | return rinfos; |
557 | } | 562 | } |
558 | if(!localGrid) | 563 | if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) |
559 | { | 564 | { |
560 | string HGname = regionURI +" "+ regionName; // include space for compatibility | 565 | string HGname = regionURI +" "+ regionName; // include space for compatibility |
561 | GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); | 566 | GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); |
@@ -592,15 +597,21 @@ namespace OpenSim.Services.GridService | |||
592 | { | 597 | { |
593 | string regionURI = ""; | 598 | string regionURI = ""; |
594 | string regionName = ""; | 599 | string regionName = ""; |
595 | if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) | 600 | if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) |
596 | return null; | 601 | return null; |
597 | 602 | ||
598 | string mapname = regionURI + regionName; | 603 | string mapname; |
604 | bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); | ||
605 | if(localGrid) | ||
606 | mapname = regionName; | ||
607 | else | ||
608 | mapname = regionURI + regionName; | ||
609 | |||
599 | List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID); | 610 | List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID); |
600 | if ((rdatas != null) && (rdatas.Count > 0)) | 611 | if ((rdatas != null) && (rdatas.Count > 0)) |
601 | return RegionData2RegionInfo(rdatas[0]); // get the first | 612 | return RegionData2RegionInfo(rdatas[0]); // get the first |
602 | 613 | ||
603 | if(!string.IsNullOrWhiteSpace(regionURI)) | 614 | if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) |
604 | { | 615 | { |
605 | string HGname = regionURI +" "+ regionName; | 616 | string HGname = regionURI +" "+ regionName; |
606 | return m_HypergridLinker.LinkRegion(scopeID, HGname); | 617 | return m_HypergridLinker.LinkRegion(scopeID, HGname); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 185f2ff..aa394ce 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -196,123 +196,10 @@ namespace OpenSim.Services.GridService | |||
196 | { | 196 | { |
197 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); | 197 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); |
198 | } | 198 | } |
199 | 199 | ||
200 | public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) | 200 | public bool IsLocalGrid(string serverURI) |
201 | { | 201 | { |
202 | serverURI = string.Empty; | 202 | return serverURI == m_ThisGatekeeper; |
203 | regionName = string.Empty; | ||
204 | |||
205 | inputName = inputName.Trim(); | ||
206 | |||
207 | if (!inputName.StartsWith("http") && !inputName.StartsWith("https")) | ||
208 | { | ||
209 | // Formats: grid.example.com:8002:region name | ||
210 | // grid.example.com:region name | ||
211 | // grid.example.com:8002 | ||
212 | // grid.example.com | ||
213 | |||
214 | string host; | ||
215 | uint port = 80; | ||
216 | |||
217 | string[] parts = inputName.Split(new char[] { ':' }); | ||
218 | int indx; | ||
219 | if(parts.Length == 0) | ||
220 | return false; | ||
221 | if (parts.Length == 1) | ||
222 | { | ||
223 | indx = inputName.IndexOf('/'); | ||
224 | if (indx < 0) | ||
225 | serverURI = "http://"+ inputName + "/"; | ||
226 | else | ||
227 | { | ||
228 | serverURI = "http://"+ inputName.Substring(0,indx + 1); | ||
229 | if(indx + 2 < inputName.Length) | ||
230 | regionName = inputName.Substring(indx + 1); | ||
231 | } | ||
232 | } | ||
233 | else | ||
234 | { | ||
235 | host = parts[0]; | ||
236 | |||
237 | if (parts.Length >= 2) | ||
238 | { | ||
239 | indx = parts[1].IndexOf('/'); | ||
240 | if(indx < 0) | ||
241 | { | ||
242 | // If it's a number then assume it's a port. Otherwise, it's a region name. | ||
243 | if (!UInt32.TryParse(parts[1], out port)) | ||
244 | { | ||
245 | port = 80; | ||
246 | regionName = parts[1]; | ||
247 | } | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | string portstr = parts[1].Substring(0, indx); | ||
252 | if(indx + 2 < parts[1].Length) | ||
253 | regionName = parts[1].Substring(indx + 1); | ||
254 | if (!UInt32.TryParse(portstr, out port)) | ||
255 | port = 80; | ||
256 | } | ||
257 | } | ||
258 | // always take the last one | ||
259 | if (parts.Length >= 3) | ||
260 | { | ||
261 | regionName = parts[2]; | ||
262 | } | ||
263 | |||
264 | serverURI = "http://"+ host +":"+ port.ToString() + "/"; | ||
265 | } | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | // Formats: http://grid.example.com region name | ||
270 | // http://grid.example.com "region name" | ||
271 | // http://grid.example.com | ||
272 | |||
273 | string[] parts = inputName.Split(new char[] { ' ' }); | ||
274 | |||
275 | if (parts.Length == 0) | ||
276 | return false; | ||
277 | |||
278 | serverURI = parts[0]; | ||
279 | |||
280 | int indx = serverURI.LastIndexOf('/'); | ||
281 | if(indx > 10) | ||
282 | { | ||
283 | if(indx + 2 < inputName.Length) | ||
284 | regionName = inputName.Substring(indx + 1); | ||
285 | serverURI = inputName.Substring(0, indx + 1); | ||
286 | } | ||
287 | else if (parts.Length >= 2) | ||
288 | { | ||
289 | regionName = inputName.Substring(serverURI.Length); | ||
290 | } | ||
291 | } | ||
292 | |||
293 | // use better code for sanity check | ||
294 | Uri uri; | ||
295 | try | ||
296 | { | ||
297 | uri = new Uri(serverURI); | ||
298 | } | ||
299 | catch | ||
300 | { | ||
301 | return false; | ||
302 | } | ||
303 | |||
304 | if(!string.IsNullOrEmpty(regionName)) | ||
305 | regionName = regionName.Trim(new char[] { '"', ' ' }); | ||
306 | serverURI = uri.AbsoluteUri; | ||
307 | if(uri.Port == 80) | ||
308 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; | ||
309 | else if(uri.Port == 443) | ||
310 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; | ||
311 | |||
312 | if(serverURI == m_ThisGatekeeper) | ||
313 | serverURI = ""; // local grid, look for region name only | ||
314 | |||
315 | return true; | ||
316 | } | 203 | } |
317 | 204 | ||
318 | public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) | 205 | public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) |
@@ -323,7 +210,7 @@ namespace OpenSim.Services.GridService | |||
323 | string serverURI = string.Empty; | 210 | string serverURI = string.Empty; |
324 | string regionName = string.Empty; | 211 | string regionName = string.Empty; |
325 | 212 | ||
326 | if(!buildHGRegionURI(mapName, out serverURI, out regionName)) | 213 | if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName)) |
327 | { | 214 | { |
328 | reason = "Wrong URI format for link-region"; | 215 | reason = "Wrong URI format for link-region"; |
329 | return null; | 216 | return null; |