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