aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2016-12-16 03:38:20 +0000
committerUbitUmarov2016-12-16 03:38:20 +0000
commite2d46c060c4b9557cf596d6d828ddd296fa0af70 (patch)
treec2c44730340c9785b9b373c937a2a54b2e6ec34e
parentreserve constant OBJECT_ATTACHED_SLOTS_AVAILABLE from mantis 8096. But do not... (diff)
downloadopensim-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
-rw-r--r--OpenSim/Framework/Util.cs114
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs27
-rw-r--r--OpenSim/Services/GridService/GridService.cs25
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs121
4 files changed, 160 insertions, 127 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index a6fd99f..5d8a5e0 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -414,6 +414,120 @@ namespace OpenSim.Framework
414 return regionCoord << 8; 414 return regionCoord << 8;
415 } 415 }
416 416
417 public static bool buildHGRegionURI(string inputName, out string serverURI, out string regionName)
418 {
419 serverURI = string.Empty;
420 regionName = string.Empty;
421
422 inputName = inputName.Trim();
423
424 if (!inputName.StartsWith("http") && !inputName.StartsWith("https"))
425 {
426 // Formats: grid.example.com:8002:region name
427 // grid.example.com:region name
428 // grid.example.com:8002
429 // grid.example.com
430
431 string host;
432 uint port = 80;
433
434 string[] parts = inputName.Split(new char[] { ':' });
435 int indx;
436 if(parts.Length == 0)
437 return false;
438 if (parts.Length == 1)
439 {
440 indx = inputName.IndexOf('/');
441 if (indx < 0)
442 serverURI = "http://"+ inputName + "/";
443 else
444 {
445 serverURI = "http://"+ inputName.Substring(0,indx + 1);
446 if(indx + 2 < inputName.Length)
447 regionName = inputName.Substring(indx + 1);
448 }
449 }
450 else
451 {
452 host = parts[0];
453
454 if (parts.Length >= 2)
455 {
456 indx = parts[1].IndexOf('/');
457 if(indx < 0)
458 {
459 // If it's a number then assume it's a port. Otherwise, it's a region name.
460 if (!UInt32.TryParse(parts[1], out port))
461 {
462 port = 80;
463 regionName = parts[1];
464 }
465 }
466 else
467 {
468 string portstr = parts[1].Substring(0, indx);
469 if(indx + 2 < parts[1].Length)
470 regionName = parts[1].Substring(indx + 1);
471 if (!UInt32.TryParse(portstr, out port))
472 port = 80;
473 }
474 }
475 // always take the last one
476 if (parts.Length >= 3)
477 {
478 regionName = parts[2];
479 }
480
481 serverURI = "http://"+ host +":"+ port.ToString() + "/";
482 }
483 }
484 else
485 {
486 // Formats: http://grid.example.com region name
487 // http://grid.example.com "region name"
488 // http://grid.example.com
489
490 string[] parts = inputName.Split(new char[] { ' ' });
491
492 if (parts.Length == 0)
493 return false;
494
495 serverURI = parts[0];
496
497 int indx = serverURI.LastIndexOf('/');
498 if(indx > 10)
499 {
500 if(indx + 2 < inputName.Length)
501 regionName = inputName.Substring(indx + 1);
502 serverURI = inputName.Substring(0, indx + 1);
503 }
504 else if (parts.Length >= 2)
505 {
506 regionName = inputName.Substring(serverURI.Length);
507 }
508 }
509
510 // use better code for sanity check
511 Uri uri;
512 try
513 {
514 uri = new Uri(serverURI);
515 }
516 catch
517 {
518 return false;
519 }
520
521 if(!string.IsNullOrEmpty(regionName))
522 regionName = regionName.Trim(new char[] { '"', ' ' });
523 serverURI = uri.AbsoluteUri;
524 if(uri.Port == 80)
525 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/";
526 else if(uri.Port == 443)
527 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/";
528 return true;
529 }
530
417 public static T Clamp<T>(T x, T min, T max) 531 public static T Clamp<T>(T x, T min, T max)
418 where T : IComparable<T> 532 where T : IComparable<T>
419 { 533 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index e6e3abb..f9ce5e1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -227,11 +227,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
227 return rinfo; 227 return rinfo;
228 } 228 }
229 229
230 public GridRegion GetRegionByName(UUID scopeID, string regionName) 230 public GridRegion GetRegionByName(UUID scopeID, string name)
231 { 231 {
232 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); 232 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, name);
233 if (rinfo != null) 233 if (rinfo != null)
234 return rinfo; 234 return rinfo;
235
236 // HG urls should not get here, strip them
237 string regionName = name;
238 if(name.Contains("."))
239 {
240 string regionURI = "";
241 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
242 return rinfo;
243 }
235 244
236 rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); 245 rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
237 m_RegionInfoCache.Cache(scopeID, rinfo); 246 m_RegionInfoCache.Cache(scopeID, rinfo);
@@ -242,7 +251,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
242 { 251 {
243 List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber); 252 List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
244 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count); 253 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count);
245 List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, name, maxNumber); 254
255 // HG urls should not get here, strip them
256 // side effect is that local regions with same name as HG may also be found
257 // this mb good or bad
258 string regionName = name;
259 if(name.Contains("."))
260 {
261 string regionURI = "";
262 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
263 return rinfo;
264 }
265
266 List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);
246 267
247 if (grinfo != null) 268 if (grinfo != null)
248 { 269 {
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;