aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs141
1 files changed, 105 insertions, 36 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 0448b54..b4577b0 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -47,7 +47,7 @@ using OpenMetaverse;
47 47
48namespace OpenSim.Services.GridService 48namespace OpenSim.Services.GridService
49{ 49{
50 public class HypergridLinker 50 public class HypergridLinker : IHypergridLinker
51 { 51 {
52 private static readonly ILog m_log = 52 private static readonly ILog m_log =
53 LogManager.GetLogger( 53 LogManager.GetLogger(
@@ -68,10 +68,6 @@ namespace OpenSim.Services.GridService
68 protected string m_ThisGatekeeper = string.Empty; 68 protected string m_ThisGatekeeper = string.Empty;
69 protected Uri m_ThisGatekeeperURI = null; 69 protected Uri m_ThisGatekeeperURI = null;
70 70
71 // Hyperlink regions are hyperlinks on the map
72 public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
73 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
74
75 protected GridRegion m_DefaultRegion; 71 protected GridRegion m_DefaultRegion;
76 protected GridRegion DefaultRegion 72 protected GridRegion DefaultRegion
77 { 73 {
@@ -160,18 +156,18 @@ namespace OpenSim.Services.GridService
160 156
161 if (MainConsole.Instance != null) 157 if (MainConsole.Instance != null)
162 { 158 {
163 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 159 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
164 "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", 160 "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
165 "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); 161 "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
166 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 162 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
167 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", 163 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
168 "Link a hypergrid region (deprecated)", RunCommand); 164 "Link a hypergrid region (deprecated)", RunCommand);
169 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", 165 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
170 "unlink-region <local name>", 166 "unlink-region <local name>",
171 "Unlink a hypergrid region", RunCommand); 167 "Unlink a hypergrid region", RunCommand);
172 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>]", 168 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
173 "Set local coordinate to map HG regions to", RunCommand); 169 "Set local coordinate to map HG regions to", RunCommand);
174 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks", 170 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
175 "List the HG regions", HandleShow); 171 "List the HG regions", HandleShow);
176 } 172 }
177 } 173 }
@@ -190,7 +186,7 @@ namespace OpenSim.Services.GridService
190 private static Random random = new Random(); 186 private static Random random = new Random();
191 187
192 // From the command line link-region (obsolete) and the map 188 // From the command line link-region (obsolete) and the map
193 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 189 private GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
194 { 190 {
195 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 191 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
196 } 192 }
@@ -200,24 +196,36 @@ namespace OpenSim.Services.GridService
200 reason = string.Empty; 196 reason = string.Empty;
201 GridRegion regInfo = null; 197 GridRegion regInfo = null;
202 198
199 mapName = mapName.Trim();
200
203 if (!mapName.StartsWith("http")) 201 if (!mapName.StartsWith("http"))
204 { 202 {
205 string host = "127.0.0.1"; 203 // Formats: grid.example.com:8002:region name
206 string portstr; 204 // grid.example.com:region name
205 // grid.example.com:8002
206 // grid.example.com
207
208 string host;
209 uint port = 80;
207 string regionName = ""; 210 string regionName = "";
208 uint port = 0; 211
209 string[] parts = mapName.Split(new char[] { ':' }); 212 string[] parts = mapName.Split(new char[] { ':' });
210 if (parts.Length >= 1) 213
214 if (parts.Length == 0)
211 { 215 {
212 host = parts[0]; 216 reason = "Wrong format for link-region";
217 return null;
213 } 218 }
219
220 host = parts[0];
221
214 if (parts.Length >= 2) 222 if (parts.Length >= 2)
215 { 223 {
216 portstr = parts[1]; 224 // If it's a number then assume it's a port. Otherwise, it's a region name.
217 //m_log.Debug("-- port = " + portstr); 225 if (!UInt32.TryParse(parts[1], out port))
218 if (!UInt32.TryParse(portstr, out port))
219 regionName = parts[1]; 226 regionName = parts[1];
220 } 227 }
228
221 // always take the last one 229 // always take the last one
222 if (parts.Length >= 3) 230 if (parts.Length >= 3)
223 { 231 {
@@ -234,14 +242,30 @@ namespace OpenSim.Services.GridService
234 } 242 }
235 else 243 else
236 { 244 {
237 string[] parts = mapName.Split(new char[] {' '}); 245 // Formats: http://grid.example.com region name
238 string regionName = String.Empty; 246 // http://grid.example.com "region name"
239 if (parts.Length > 1) 247 // http://grid.example.com
248
249 string serverURI;
250 string regionName = "";
251
252 string[] parts = mapName.Split(new char[] { ' ' });
253
254 if (parts.Length == 0)
240 { 255 {
241 regionName = mapName.Substring(parts[0].Length + 1); 256 reason = "Wrong format for link-region";
242 regionName = regionName.Trim(new char[] {'"'}); 257 return null;
243 } 258 }
244 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) 259
260 serverURI = parts[0];
261
262 if (parts.Length >= 2)
263 {
264 regionName = mapName.Substring(serverURI.Length);
265 regionName = regionName.Trim(new char[] { '"', ' ' });
266 }
267
268 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
245 { 269 {
246 regInfo.RegionName = mapName; 270 regInfo.RegionName = mapName;
247 return regInfo; 271 return regInfo;
@@ -250,15 +274,23 @@ namespace OpenSim.Services.GridService
250 274
251 return null; 275 return null;
252 } 276 }
253 277
254 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason) 278 private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason)
255 { 279 {
256 return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason); 280 return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason);
257 } 281 }
258 282
259 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 283 private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
284 {
285 lock (this)
286 {
287 return TryCreateLinkImpl(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, serverURI, ownerID, out regInfo, out reason);
288 }
289 }
290
291 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
260 { 292 {
261 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", 293 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
262 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 294 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
263 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 295 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
264 296
@@ -266,15 +298,15 @@ namespace OpenSim.Services.GridService
266 Uri uri = null; 298 Uri uri = null;
267 299
268 regInfo = new GridRegion(); 300 regInfo = new GridRegion();
269 if ( externalPort > 0) 301 if (externalPort > 0)
270 regInfo.HttpPort = externalPort; 302 regInfo.HttpPort = externalPort;
271 else 303 else
272 regInfo.HttpPort = 0; 304 regInfo.HttpPort = 80;
273 if ( externalHostName != null) 305 if (externalHostName != null)
274 regInfo.ExternalHostName = externalHostName; 306 regInfo.ExternalHostName = externalHostName;
275 else 307 else
276 regInfo.ExternalHostName = "0.0.0.0"; 308 regInfo.ExternalHostName = "0.0.0.0";
277 if ( serverURI != null) 309 if (serverURI != null)
278 { 310 {
279 regInfo.ServerURI = serverURI; 311 regInfo.ServerURI = serverURI;
280 try 312 try
@@ -286,7 +318,7 @@ namespace OpenSim.Services.GridService
286 catch {} 318 catch {}
287 } 319 }
288 320
289 if ( remoteRegionName != string.Empty ) 321 if (remoteRegionName != string.Empty)
290 regInfo.RegionName = remoteRegionName; 322 regInfo.RegionName = remoteRegionName;
291 323
292 regInfo.RegionLocX = xloc; 324 regInfo.RegionLocX = xloc;
@@ -299,6 +331,7 @@ namespace OpenSim.Services.GridService
299 { 331 {
300 if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) 332 if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
301 { 333 {
334 m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
302 reason = "Cannot hyperlink to regions on the same grid"; 335 reason = "Cannot hyperlink to regions on the same grid";
303 return false; 336 return false;
304 } 337 }
@@ -310,7 +343,11 @@ namespace OpenSim.Services.GridService
310 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); 343 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
311 if (region != null) 344 if (region != null)
312 { 345 {
346<<<<<<< HEAD
347 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
348=======
313 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", 349 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}",
350>>>>>>> avn/ubitvar
314 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), 351 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
315 region.RegionName, region.RegionID); 352 region.RegionName, region.RegionID);
316 reason = "Coordinates are already in use"; 353 reason = "Coordinates are already in use";
@@ -346,8 +383,13 @@ namespace OpenSim.Services.GridService
346 region = m_GridService.GetRegionByUUID(scopeID, regionID); 383 region = m_GridService.GetRegionByUUID(scopeID, regionID);
347 if (region != null) 384 if (region != null)
348 { 385 {
386<<<<<<< HEAD
387 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
388 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
389=======
349 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", 390 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
350 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY)); 391 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY));
392>>>>>>> avn/ubitvar
351 regInfo = region; 393 regInfo = region;
352 return true; 394 return true;
353 } 395 }
@@ -381,7 +423,8 @@ namespace OpenSim.Services.GridService
381 regInfo.RegionSecret = handle.ToString(); 423 regInfo.RegionSecret = handle.ToString();
382 424
383 AddHyperlinkRegion(regInfo, handle); 425 AddHyperlinkRegion(regInfo, handle);
384 m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage); 426 m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
427 regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
385 return true; 428 return true;
386 } 429 }
387 430
@@ -502,10 +545,21 @@ namespace OpenSim.Services.GridService
502 MainConsole.Instance.Output(new string('-', 72)); 545 MainConsole.Instance.Output(new string('-', 72));
503 foreach (RegionData r in regions) 546 foreach (RegionData r in regions)
504 { 547 {
548<<<<<<< HEAD
549 MainConsole.Instance.Output(
550 String.Format("{0}\n{2,-32} {1}\n",
551 r.RegionName, r.RegionID,
552 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
553 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
554 )
555 )
556 );
557=======
505 MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n", 558 MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n",
506 r.RegionName, r.RegionID, 559 r.RegionName, r.RegionID,
507 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 560 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
508 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY))) ); 561 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY))) );
562>>>>>>> avn/ubitvar
509 } 563 }
510 return; 564 return;
511 } 565 }
@@ -607,8 +661,13 @@ namespace OpenSim.Services.GridService
607 string externalHostName; 661 string externalHostName;
608 try 662 try
609 { 663 {
664<<<<<<< HEAD
665 xloc = Convert.ToUInt32(cmdparams[0]);
666 yloc = Convert.ToUInt32(cmdparams[1]);
667=======
610 xloc = (uint)Convert.ToInt32(cmdparams[0]); 668 xloc = (uint)Convert.ToInt32(cmdparams[0]);
611 yloc = (uint)Convert.ToInt32(cmdparams[1]); 669 yloc = (uint)Convert.ToInt32(cmdparams[1]);
670>>>>>>> avn/ubitvar
612 externalPort = Convert.ToUInt32(cmdparams[3]); 671 externalPort = Convert.ToUInt32(cmdparams[3]);
613 externalHostName = cmdparams[2]; 672 externalHostName = cmdparams[2];
614 //internalPort = Convert.ToUInt32(cmdparams[4]); 673 //internalPort = Convert.ToUInt32(cmdparams[4]);
@@ -711,8 +770,13 @@ namespace OpenSim.Services.GridService
711 string externalHostName; 770 string externalHostName;
712 uint realXLoc, realYLoc; 771 uint realXLoc, realYLoc;
713 772
773<<<<<<< HEAD
774 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
775 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
776=======
714 xloc = (uint)Convert.ToInt32(config.GetString("xloc", "0")); 777 xloc = (uint)Convert.ToInt32(config.GetString("xloc", "0"));
715 yloc = (uint)Convert.ToInt32(config.GetString("yloc", "0")); 778 yloc = (uint)Convert.ToInt32(config.GetString("yloc", "0"));
779>>>>>>> avn/ubitvar
716 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); 780 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
717 externalHostName = config.GetString("externalHostName", ""); 781 externalHostName = config.GetString("externalHostName", "");
718 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); 782 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
@@ -720,8 +784,13 @@ namespace OpenSim.Services.GridService
720 784
721 if (m_enableAutoMapping) 785 if (m_enableAutoMapping)
722 { 786 {
787<<<<<<< HEAD
788 xloc = (xloc % 100) + m_autoMappingX;
789 yloc = (yloc % 100) + m_autoMappingY;
790=======
723 xloc = (uint)((xloc % 100) + m_autoMappingX); 791 xloc = (uint)((xloc % 100) + m_autoMappingX);
724 yloc = (uint)((yloc % 100) + m_autoMappingY); 792 yloc = (uint)((yloc % 100) + m_autoMappingY);
793>>>>>>> avn/ubitvar
725 } 794 }
726 795
727 if (((realXLoc == 0) && (realYLoc == 0)) || 796 if (((realXLoc == 0) && (realYLoc == 0)) ||