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.cs109
1 files changed, 75 insertions, 34 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index a67404f..eed3207 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -127,11 +127,12 @@ namespace OpenSim.Services.GridService
127 127
128 if (MainConsole.Instance != null) 128 if (MainConsole.Instance != null)
129 { 129 {
130 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", "Link a HyperGrid Region", RunCommand);
130 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 131 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
131 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 132 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
132 "Link a hypergrid region", RunCommand); 133 "Link a hypergrid region (deprecated)", RunCommand);
133 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", 134 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
134 "unlink-region <local name> or <HostName>:<HttpPort> <cr>", 135 "unlink-region <local name>",
135 "Unlink a hypergrid region", RunCommand); 136 "Unlink a hypergrid region", RunCommand);
136 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", 137 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
137 "Set local coordinate to map HG regions to", RunCommand); 138 "Set local coordinate to map HG regions to", RunCommand);
@@ -204,30 +205,37 @@ namespace OpenSim.Services.GridService
204 205
205 return null; 206 return null;
206 } 207 }
207 208
208 209 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason)
209 // From the command line and the 2 above 210 {
210 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, 211 return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason);
211 string externalRegionName, uint externalPort, string externalHostName, UUID ownerID, 212 }
212 out GridRegion regInfo, out string reason) 213
214 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)
213 { 215 {
214 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); 216 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, remoteRegionName, xloc, yloc);
215 217
216 reason = string.Empty; 218 reason = string.Empty;
217 regInfo = new GridRegion(); 219 regInfo = new GridRegion();
218 regInfo.RegionName = externalRegionName; 220 if ( externalPort > 0)
219 regInfo.HttpPort = externalPort; 221 regInfo.HttpPort = externalPort;
220 regInfo.ExternalHostName = externalHostName; 222 else
223 regInfo.HttpPort = 0;
224 if ( externalHostName != null)
225 regInfo.ExternalHostName = externalHostName;
226 else
227 regInfo.ExternalHostName = "0.0.0.0";
228 if ( serverURI != null)
229 regInfo.ServerURI = serverURI;
230
231 if ( remoteRegionName != string.Empty )
232 regInfo.RegionName = remoteRegionName;
233
221 regInfo.RegionLocX = xloc; 234 regInfo.RegionLocX = xloc;
222 regInfo.RegionLocY = yloc; 235 regInfo.RegionLocY = yloc;
223 regInfo.ScopeID = scopeID; 236 regInfo.ScopeID = scopeID;
224 regInfo.EstateOwner = ownerID; 237 regInfo.EstateOwner = ownerID;
225 238
226 // Big HACK for Simian Grid !!!
227 // We need to clean up all URLs used in OpenSim !!!
228 if (externalHostName.Contains("/"))
229 regInfo.ServerURI = externalHostName;
230
231 // Check for free coordinates 239 // Check for free coordinates
232 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); 240 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
233 if (region != null) 241 if (region != null)
@@ -267,9 +275,14 @@ namespace OpenSim.Services.GridService
267 } 275 }
268 276
269 regInfo.RegionID = regionID; 277 regInfo.RegionID = regionID;
270 if (regInfo.RegionName == string.Empty)
271 regInfo.RegionName = regInfo.ExternalHostName;
272 278
279 if ( externalName == string.Empty )
280 regInfo.RegionName = regInfo.ServerURI;
281 else
282 regInfo.RegionName = externalName;
283
284 m_log.Debug("naming linked region " + regInfo.RegionName);
285
273 // Try get the map image 286 // Try get the map image
274 //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); 287 //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL);
275 // I need a texture that works for this... the one I tried doesn't seem to be working 288 // I need a texture that works for this... the one I tried doesn't seem to be working
@@ -316,13 +329,6 @@ namespace OpenSim.Services.GridService
316 } 329 }
317 } 330 }
318 331
319 //foreach (GridRegion r in m_HyperlinkRegions.Values)
320 //{
321 // m_log.DebugFormat("XXX Comparing {0}:{1} with {2}:{3}", host, port, r.ExternalHostName, r.HttpPort);
322 // if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
323 // regInfo = r;
324 //}
325
326 if (regInfo != null) 332 if (regInfo != null)
327 { 333 {
328 RemoveHyperlinkRegion(regInfo.RegionID); 334 RemoveHyperlinkRegion(regInfo.RegionID);
@@ -442,6 +448,21 @@ namespace OpenSim.Services.GridService
442 RunHGCommand(command, cmdparams); 448 RunHGCommand(command, cmdparams);
443 449
444 } 450 }
451
452 private void RunLinkRegionCommand(string[] cmdparams)
453 {
454 int xloc, yloc;
455 string serverURI;
456 string remoteName = null;
457 xloc = Convert.ToInt32(cmdparams[0]) * (int)Constants.RegionSize;
458 yloc = Convert.ToInt32(cmdparams[1]) * (int)Constants.RegionSize;
459 serverURI = cmdparams[2];
460 if (cmdparams.Length == 4)
461 remoteName = cmdparams[3];
462 string reason = string.Empty;
463 GridRegion regInfo;
464 TryCreateLink(UUID.Zero, xloc, yloc, remoteName, 0, null, serverURI, UUID.Zero, out regInfo, out reason);
465 }
445 466
446 private void RunHGCommand(string command, string[] cmdparams) 467 private void RunHGCommand(string command, string[] cmdparams)
447 { 468 {
@@ -465,6 +486,18 @@ namespace OpenSim.Services.GridService
465 } 486 }
466 else if (command.Equals("link-region")) 487 else if (command.Equals("link-region"))
467 { 488 {
489 if (cmdparams.Length > 0 && cmdparams.Length < 5)
490 {
491 RunLinkRegionCommand(cmdparams);
492 }
493 else
494 {
495 LinkRegionCmdUsage();
496 }
497 return;
498 }
499 else if (command.Equals("link-region"))
500 {
468 if (cmdparams.Length < 3) 501 if (cmdparams.Length < 3)
469 { 502 {
470 if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) 503 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
@@ -478,7 +511,11 @@ namespace OpenSim.Services.GridService
478 return; 511 return;
479 } 512 }
480 513
481 if (cmdparams[2].Contains(":")) 514 //this should be the prefererred way of setting up hg links now
515 if ( cmdparams[2].StartsWith("http") && ( cmdparams.Length >= 3 && cmdparams.Length <= 5 )) {
516 RunLinkRegionCommand(cmdparams);
517 }
518 else if (cmdparams[2].Contains(":"))
482 { 519 {
483 // New format 520 // New format
484 int xloc, yloc; 521 int xloc, yloc;
@@ -517,12 +554,16 @@ namespace OpenSim.Services.GridService
517 int xloc, yloc; 554 int xloc, yloc;
518 uint externalPort; 555 uint externalPort;
519 string externalHostName; 556 string externalHostName;
557 string serverURI;
520 try 558 try
521 { 559 {
522 xloc = Convert.ToInt32(cmdparams[0]); 560 xloc = Convert.ToInt32(cmdparams[0]);
523 yloc = Convert.ToInt32(cmdparams[1]); 561 yloc = Convert.ToInt32(cmdparams[1]);
524 externalPort = Convert.ToUInt32(cmdparams[3]); 562 externalPort = Convert.ToUInt32(cmdparams[3]);
525 externalHostName = cmdparams[2]; 563 externalHostName = cmdparams[2];
564 if ( cmdparams.Length == 4 ) {
565
566 }
526 //internalPort = Convert.ToUInt32(cmdparams[4]); 567 //internalPort = Convert.ToUInt32(cmdparams[4]);
527 //remotingPort = Convert.ToUInt32(cmdparams[5]); 568 //remotingPort = Convert.ToUInt32(cmdparams[5]);
528 } 569 }
@@ -537,7 +578,7 @@ namespace OpenSim.Services.GridService
537 xloc = xloc * (int)Constants.RegionSize; 578 xloc = xloc * (int)Constants.RegionSize;
538 yloc = yloc * (int)Constants.RegionSize; 579 yloc = yloc * (int)Constants.RegionSize;
539 string reason = string.Empty; 580 string reason = string.Empty;
540 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) 581 if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
541 { 582 {
542 if (cmdparams.Length >= 5) 583 if (cmdparams.Length >= 5)
543 { 584 {
@@ -551,7 +592,7 @@ namespace OpenSim.Services.GridService
551 } 592 }
552 else if (command.Equals("unlink-region")) 593 else if (command.Equals("unlink-region"))
553 { 594 {
554 if (cmdparams.Length < 1) 595 if (cmdparams.Length < 1 || cmdparams.Length > 1)
555 { 596 {
556 UnlinkRegionCmdUsage(); 597 UnlinkRegionCmdUsage();
557 return; 598 return;
@@ -639,7 +680,7 @@ namespace OpenSim.Services.GridService
639 xloc = xloc * (int)Constants.RegionSize; 680 xloc = xloc * (int)Constants.RegionSize;
640 yloc = yloc * (int)Constants.RegionSize; 681 yloc = yloc * (int)Constants.RegionSize;
641 string reason = string.Empty; 682 string reason = string.Empty;
642 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) 683 if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
643 { 684 {
644 regInfo.RegionName = config.GetString("localName", ""); 685 regInfo.RegionName = config.GetString("localName", "");
645 } 686 }
@@ -651,14 +692,14 @@ namespace OpenSim.Services.GridService
651 692
652 private void LinkRegionCmdUsage() 693 private void LinkRegionCmdUsage()
653 { 694 {
654 MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); 695 MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]");
655 MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); 696 MainConsole.Instance.Output("Usage (deprecated): link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
697 MainConsole.Instance.Output("Usage (deprecated): link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
656 MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]"); 698 MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]");
657 } 699 }
658 700
659 private void UnlinkRegionCmdUsage() 701 private void UnlinkRegionCmdUsage()
660 { 702 {
661 MainConsole.Instance.Output("Usage: unlink-region <HostName>:<HttpPort>");
662 MainConsole.Instance.Output("Usage: unlink-region <LocalName>"); 703 MainConsole.Instance.Output("Usage: unlink-region <LocalName>");
663 } 704 }
664 705