aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs264
1 files changed, 150 insertions, 114 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 131febd..de71b56 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -31,13 +31,14 @@ using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33 33
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.Framework.Scenes.Hypergrid; 38using OpenSim.Region.Framework.Scenes.Hypergrid;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
41using OpenSim.Server.Base; 42using OpenSim.Server.Base;
42using OpenSim.Services.Connectors.Grid; 43using OpenSim.Services.Connectors.Grid;
43using OpenSim.Framework.Console; 44using OpenSim.Framework.Console;
@@ -154,12 +155,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
154 155
155 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); 156 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
156 157
157 // Yikes!! Remove this as soon as user services get refactored
158 LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL;
159 LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL;
160 LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL;
161 HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
162
163 } 158 }
164 159
165 public void RemoveRegion(Scene scene) 160 public void RemoveRegion(Scene scene)
@@ -390,7 +385,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
390 385
391 private static Random random = new Random(); 386 private static Random random = new Random();
392 387
393 388 // From the command line link-region
394 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) 389 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
395 { 390 {
396 string host = "127.0.0.1"; 391 string host = "127.0.0.1";
@@ -446,6 +441,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
446 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 441 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
447 } 442 }
448 443
444 // From the command line and the 2 above
449 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, 445 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
450 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) 446 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
451 { 447 {
@@ -572,11 +568,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
572 return true; 568 return true;
573 } 569 }
574 570
571 // From the map search
575 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) 572 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
576 { 573 {
577 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); 574 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
578 } 575 }
579 576
577 // From the map and secondlife://blah
580 public GridRegion GetHyperlinkRegion(ulong handle) 578 public GridRegion GetHyperlinkRegion(ulong handle)
581 { 579 {
582 foreach (GridRegion r in m_HyperlinkRegions.Values) 580 foreach (GridRegion r in m_HyperlinkRegions.Values)
@@ -603,93 +601,105 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
603 601
604 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) 602 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
605 { 603 {
606 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); 604 // REFACTORING PROBLEM. This needs to change. Some of this info should go with the agent circuit data.
607
608 if (uinfo == null)
609 return false;
610 605
611 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || 606 //UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, agentData.AgentID);
612 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) 607 //if (account == null)
613 { 608 // return false;
614 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
615
616 // Set the position of the region on the remote grid
617// ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
618 uint x = 0, y = 0;
619 Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
620 GridRegion clonedRegion = new GridRegion(regInfo);
621 clonedRegion.RegionLocX = (int)x;
622 clonedRegion.RegionLocY = (int)y;
623
624 // Get the user's home region information and adapt the region handle
625 GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
626 if (m_HyperlinkHandles.ContainsKey(uinfo.UserProfile.HomeRegionID))
627 {
628 ulong realHandle = m_HyperlinkHandles[uinfo.UserProfile.HomeRegionID];
629 Utils.LongToUInts(realHandle, out x, out y);
630 m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y);
631 home.RegionLocX = (int)x;
632 home.RegionLocY = (int)y;
633 }
634 609
635 // Get the user's service URLs 610 //if ((IsLocalUser(account) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
636 string serverURI = ""; 611 // (!IsLocalUser(account) && !IsGoingHome(uinfo, regInfo)))
637 if (uinfo.UserProfile is ForeignUserProfileData)
638 serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
639 string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
640
641 string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
642 if ((assetServer == null) || (assetServer == ""))
643 assetServer = LocalAssetServerURI;
644
645 string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
646 if ((inventoryServer == null) || (inventoryServer == ""))
647 inventoryServer = LocalInventoryServerURI;
648
649 if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
650 {
651 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
652 return false;
653 }
654 }
655 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
656 //{ 612 //{
657 // m_log.Info("[HGrid]: User seems to be going to foreign region."); 613 // m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
658 // if (!InformRegionOfUser(regInfo, agentData)) 614
615 // PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(agentData.SessionID);
616 // if (pinfo != null)
617 // {
618 // // Set the position of the region on the remote grid
619 // // ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
620 // uint x = 0, y = 0;
621 // Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
622 // GridRegion clonedRegion = new GridRegion(regInfo);
623 // clonedRegion.RegionLocX = (int)x;
624 // clonedRegion.RegionLocY = (int)y;
625
626 // // Get the user's home region information and adapt the region handle
627 // GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, pinfo.HomeRegionID);
628 // if (m_HyperlinkHandles.ContainsKey(pinfo.HomeRegionID))
629 // {
630 // ulong realHandle = m_HyperlinkHandles[pinfo.HomeRegionID];
631 // Utils.LongToUInts(realHandle, out x, out y);
632 // m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y);
633 // home.RegionLocX = (int)x;
634 // home.RegionLocY = (int)y;
635 // }
636
637 // // Get the user's service URLs
638 // string serverURI = "";
639 // if (uinfo.UserProfile is ForeignUserProfileData)
640 // serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
641 // string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
642
643 // string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
644 // if ((assetServer == null) || (assetServer == ""))
645 // assetServer = LocalAssetServerURI;
646
647 // string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
648 // if ((inventoryServer == null) || (inventoryServer == ""))
649 // inventoryServer = LocalInventoryServerURI;
650
651 // if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
652 // {
653 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
654 // return false;
655 // }
656 // }
657 // else
659 // { 658 // {
660 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); 659 // m_log.Warn("[HGrid]: Unable to find local presence of transferring user.");
661 // return false; 660 // return false;
662 // } 661 // }
663 //} 662 //}
664 //else 663 ////if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
665 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); 664 ////{
666 665 //// m_log.Info("[HGrid]: User seems to be going to foreign region.");
667 // May need to change agent's name 666 //// if (!InformRegionOfUser(regInfo, agentData))
668 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) 667 //// {
669 { 668 //// m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
670 agentData.firstname = agentData.firstname + "." + agentData.lastname; 669 //// return false;
671 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; 670 //// }
672 } 671 ////}
672 ////else
673 //// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
674
675 //// May need to change agent's name
676 //if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
677 //{
678 // agentData.firstname = agentData.firstname + "." + agentData.lastname;
679 // agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
680 //}
673 681
674 return true; 682 return true;
675 } 683 }
676 684
677 public void AdjustUserInformation(AgentCircuitData agentData) 685 public void AdjustUserInformation(AgentCircuitData agentData)
678 { 686 {
679 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); 687 // REFACTORING PROBLEM!!! This needs to change
680 if ((uinfo != null) && (uinfo.UserProfile != null) && 688
681 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) 689 //CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
682 { 690 //if ((uinfo != null) && (uinfo.UserProfile != null) &&
683 //m_log.Debug("---------------> Local User!"); 691 // (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
684 string[] parts = agentData.firstname.Split(new char[] { '.' }); 692 //{
685 if (parts.Length == 2) 693 // //m_log.Debug("---------------> Local User!");
686 { 694 // string[] parts = agentData.firstname.Split(new char[] { '.' });
687 agentData.firstname = parts[0]; 695 // if (parts.Length == 2)
688 agentData.lastname = parts[1]; 696 // {
689 } 697 // agentData.firstname = parts[0];
690 } 698 // agentData.lastname = parts[1];
691 //else 699 // }
692 // m_log.Debug("---------------> Foreign User!"); 700 //}
701 ////else
702 //// m_log.Debug("---------------> Foreign User!");
693 } 703 }
694 704
695 // Check if a local user exists with the same UUID as the incoming foreign user 705 // Check if a local user exists with the same UUID as the incoming foreign user
@@ -697,16 +707,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
697 { 707 {
698 comingHome = false; 708 comingHome = false;
699 709
700 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 710 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID);
701 if (uinfo != null) 711 if (account != null)
702 { 712 {
703 // uh-oh we have a potential intruder 713 if (m_aScene.AuthenticationService.Verify(userID, sessionID.ToString(), 30))
704 if (uinfo.SessionID != sessionID) 714 {
705 // can't have a foreigner with a local UUID
706 return false;
707 else
708 // oh, so it's you! welcome back 715 // oh, so it's you! welcome back
709 comingHome = true; 716 comingHome = true;
717 }
718 else
719 // can't have a foreigner with a local UUID
720 return false;
710 } 721 }
711 722
712 // OK, user can come in 723 // OK, user can come in
@@ -715,7 +726,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
715 726
716 public void AcceptUser(ForeignUserProfileData user, GridRegion home) 727 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
717 { 728 {
718 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); 729 // REFACTORING PROBLEM. uh-oh, commenting this breaks HG completely
730 // Needs to be rewritten
731 //m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
732
719 ulong realHandle = home.RegionHandle; 733 ulong realHandle = home.RegionHandle;
720 // Change the local coordinates 734 // Change the local coordinates
721 // X=0 on the map 735 // X=0 on the map
@@ -731,8 +745,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
731 745
732 public bool IsLocalUser(UUID userID) 746 public bool IsLocalUser(UUID userID)
733 { 747 {
734 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 748 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID);
735 return IsLocalUser(uinfo); 749 return IsLocalUser(account);
736 } 750 }
737 751
738 #endregion 752 #endregion
@@ -741,37 +755,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
741 755
742 protected bool IsComingHome(ForeignUserProfileData userData) 756 protected bool IsComingHome(ForeignUserProfileData userData)
743 { 757 {
744 return (userData.UserServerURI == LocalUserServerURI); 758 return false;
759 // REFACTORING PROBLEM
760 //return (userData.UserServerURI == LocalUserServerURI);
745 } 761 }
746 762
747 // Is the user going back to the home region or the home grid? 763 // REFACTORING PROBLEM
748 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) 764 //// Is the user going back to the home region or the home grid?
749 { 765 //protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
750 if (uinfo == null) 766 //{
751 return false; 767 // if (uinfo == null)
768 // return false;
752 769
753 if (uinfo.UserProfile == null) 770 // if (uinfo.UserProfile == null)
754 return false; 771 // return false;
755 772
756 if (!(uinfo.UserProfile is ForeignUserProfileData)) 773 // if (!(uinfo.UserProfile is ForeignUserProfileData))
757 // it's a home user, can't be outside to return home 774 // // it's a home user, can't be outside to return home
758 return false; 775 // return false;
759 776
760 // OK, it's a foreign user with a ForeignUserProfileData 777 // // OK, it's a foreign user with a ForeignUserProfileData
761 // and is going back to exactly the home region. 778 // // and is going back to exactly the home region.
762 // We can't check if it's going back to a non-home region 779 // // We can't check if it's going back to a non-home region
763 // of the home grid. That will be dealt with in the 780 // // of the home grid. That will be dealt with in the
764 // receiving end 781 // // receiving end
765 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); 782 // return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
766 } 783 //}
767 784
768 protected bool IsLocalUser(CachedUserInfo uinfo) 785 protected bool IsLocalUser(UserAccount account)
769 { 786 {
770 if (uinfo == null) 787 return true;
771 return false; 788
789 // REFACTORING PROBLEM
790 //if (account != null &&
791 // account.ServiceURLs.ContainsKey("HomeURI") &&
792 // account.ServiceURLs["HomeURI"] != null)
772 793
773 return !(uinfo.UserProfile is ForeignUserProfileData); 794 // return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI);
774 795
796 //return false;
775 } 797 }
776 798
777 799
@@ -806,6 +828,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
806 828
807 #endregion 829 #endregion
808 830
831 public List<GridRegion> GetDefaultRegions(UUID scopeID)
832 {
833 return null;
834 }
835
836 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
837 {
838 return null;
839 }
840
841 public int GetRegionFlags(UUID scopeID, UUID regionID)
842 {
843 return 0;
844 }
809 845
810 } 846 }
811} 847}