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.cs263
1 files changed, 149 insertions, 114 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 131febd..274de2a 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 {
@@ -577,6 +573,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
577 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); 573 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
578 } 574 }
579 575
576 // From the map and secondlife://blah
580 public GridRegion GetHyperlinkRegion(ulong handle) 577 public GridRegion GetHyperlinkRegion(ulong handle)
581 { 578 {
582 foreach (GridRegion r in m_HyperlinkRegions.Values) 579 foreach (GridRegion r in m_HyperlinkRegions.Values)
@@ -603,93 +600,105 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
603 600
604 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) 601 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
605 { 602 {
606 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); 603 // 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 604
611 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || 605 //UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, agentData.AgentID);
612 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) 606 //if (account == null)
613 { 607 // 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 608
635 // Get the user's service URLs 609 //if ((IsLocalUser(account) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
636 string serverURI = ""; 610 // (!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 //{ 611 //{
657 // m_log.Info("[HGrid]: User seems to be going to foreign region."); 612 // m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
658 // if (!InformRegionOfUser(regInfo, agentData)) 613
614 // PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(agentData.SessionID);
615 // if (pinfo != null)
616 // {
617 // // Set the position of the region on the remote grid
618 // // ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
619 // uint x = 0, y = 0;
620 // Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
621 // GridRegion clonedRegion = new GridRegion(regInfo);
622 // clonedRegion.RegionLocX = (int)x;
623 // clonedRegion.RegionLocY = (int)y;
624
625 // // Get the user's home region information and adapt the region handle
626 // GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, pinfo.HomeRegionID);
627 // if (m_HyperlinkHandles.ContainsKey(pinfo.HomeRegionID))
628 // {
629 // ulong realHandle = m_HyperlinkHandles[pinfo.HomeRegionID];
630 // Utils.LongToUInts(realHandle, out x, out y);
631 // m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y);
632 // home.RegionLocX = (int)x;
633 // home.RegionLocY = (int)y;
634 // }
635
636 // // Get the user's service URLs
637 // string serverURI = "";
638 // if (uinfo.UserProfile is ForeignUserProfileData)
639 // serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
640 // string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
641
642 // string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
643 // if ((assetServer == null) || (assetServer == ""))
644 // assetServer = LocalAssetServerURI;
645
646 // string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
647 // if ((inventoryServer == null) || (inventoryServer == ""))
648 // inventoryServer = LocalInventoryServerURI;
649
650 // if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
651 // {
652 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
653 // return false;
654 // }
655 // }
656 // else
659 // { 657 // {
660 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); 658 // m_log.Warn("[HGrid]: Unable to find local presence of transferring user.");
661 // return false; 659 // return false;
662 // } 660 // }
663 //} 661 //}
664 //else 662 ////if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
665 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); 663 ////{
666 664 //// m_log.Info("[HGrid]: User seems to be going to foreign region.");
667 // May need to change agent's name 665 //// if (!InformRegionOfUser(regInfo, agentData))
668 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) 666 //// {
669 { 667 //// m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
670 agentData.firstname = agentData.firstname + "." + agentData.lastname; 668 //// return false;
671 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; 669 //// }
672 } 670 ////}
671 ////else
672 //// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
673
674 //// May need to change agent's name
675 //if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
676 //{
677 // agentData.firstname = agentData.firstname + "." + agentData.lastname;
678 // agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
679 //}
673 680
674 return true; 681 return true;
675 } 682 }
676 683
677 public void AdjustUserInformation(AgentCircuitData agentData) 684 public void AdjustUserInformation(AgentCircuitData agentData)
678 { 685 {
679 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); 686 // REFACTORING PROBLEM!!! This needs to change
680 if ((uinfo != null) && (uinfo.UserProfile != null) && 687
681 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) 688 //CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
682 { 689 //if ((uinfo != null) && (uinfo.UserProfile != null) &&
683 //m_log.Debug("---------------> Local User!"); 690 // (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
684 string[] parts = agentData.firstname.Split(new char[] { '.' }); 691 //{
685 if (parts.Length == 2) 692 // //m_log.Debug("---------------> Local User!");
686 { 693 // string[] parts = agentData.firstname.Split(new char[] { '.' });
687 agentData.firstname = parts[0]; 694 // if (parts.Length == 2)
688 agentData.lastname = parts[1]; 695 // {
689 } 696 // agentData.firstname = parts[0];
690 } 697 // agentData.lastname = parts[1];
691 //else 698 // }
692 // m_log.Debug("---------------> Foreign User!"); 699 //}
700 ////else
701 //// m_log.Debug("---------------> Foreign User!");
693 } 702 }
694 703
695 // Check if a local user exists with the same UUID as the incoming foreign user 704 // Check if a local user exists with the same UUID as the incoming foreign user
@@ -697,16 +706,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
697 { 706 {
698 comingHome = false; 707 comingHome = false;
699 708
700 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 709 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID);
701 if (uinfo != null) 710 if (account != null)
702 { 711 {
703 // uh-oh we have a potential intruder 712 if (m_aScene.AuthenticationService.Verify(userID, sessionID.ToString(), 30))
704 if (uinfo.SessionID != sessionID) 713 {
705 // can't have a foreigner with a local UUID
706 return false;
707 else
708 // oh, so it's you! welcome back 714 // oh, so it's you! welcome back
709 comingHome = true; 715 comingHome = true;
716 }
717 else
718 // can't have a foreigner with a local UUID
719 return false;
710 } 720 }
711 721
712 // OK, user can come in 722 // OK, user can come in
@@ -715,7 +725,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
715 725
716 public void AcceptUser(ForeignUserProfileData user, GridRegion home) 726 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
717 { 727 {
718 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); 728 // REFACTORING PROBLEM. uh-oh, commenting this breaks HG completely
729 // Needs to be rewritten
730 //m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
731
719 ulong realHandle = home.RegionHandle; 732 ulong realHandle = home.RegionHandle;
720 // Change the local coordinates 733 // Change the local coordinates
721 // X=0 on the map 734 // X=0 on the map
@@ -731,8 +744,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
731 744
732 public bool IsLocalUser(UUID userID) 745 public bool IsLocalUser(UUID userID)
733 { 746 {
734 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 747 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID);
735 return IsLocalUser(uinfo); 748 return IsLocalUser(account);
736 } 749 }
737 750
738 #endregion 751 #endregion
@@ -741,37 +754,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
741 754
742 protected bool IsComingHome(ForeignUserProfileData userData) 755 protected bool IsComingHome(ForeignUserProfileData userData)
743 { 756 {
744 return (userData.UserServerURI == LocalUserServerURI); 757 return false;
758 // REFACTORING PROBLEM
759 //return (userData.UserServerURI == LocalUserServerURI);
745 } 760 }
746 761
747 // Is the user going back to the home region or the home grid? 762 // REFACTORING PROBLEM
748 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) 763 //// Is the user going back to the home region or the home grid?
749 { 764 //protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
750 if (uinfo == null) 765 //{
751 return false; 766 // if (uinfo == null)
767 // return false;
752 768
753 if (uinfo.UserProfile == null) 769 // if (uinfo.UserProfile == null)
754 return false; 770 // return false;
755 771
756 if (!(uinfo.UserProfile is ForeignUserProfileData)) 772 // if (!(uinfo.UserProfile is ForeignUserProfileData))
757 // it's a home user, can't be outside to return home 773 // // it's a home user, can't be outside to return home
758 return false; 774 // return false;
759 775
760 // OK, it's a foreign user with a ForeignUserProfileData 776 // // OK, it's a foreign user with a ForeignUserProfileData
761 // and is going back to exactly the home region. 777 // // and is going back to exactly the home region.
762 // We can't check if it's going back to a non-home region 778 // // 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 779 // // of the home grid. That will be dealt with in the
764 // receiving end 780 // // receiving end
765 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); 781 // return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
766 } 782 //}
767 783
768 protected bool IsLocalUser(CachedUserInfo uinfo) 784 protected bool IsLocalUser(UserAccount account)
769 { 785 {
770 if (uinfo == null) 786 return true;
771 return false; 787
788 // REFACTORING PROBLEM
789 //if (account != null &&
790 // account.ServiceURLs.ContainsKey("HomeURI") &&
791 // account.ServiceURLs["HomeURI"] != null)
772 792
773 return !(uinfo.UserProfile is ForeignUserProfileData); 793 // return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI);
774 794
795 //return false;
775 } 796 }
776 797
777 798
@@ -806,6 +827,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
806 827
807 #endregion 828 #endregion
808 829
830 public List<GridRegion> GetDefaultRegions(UUID scopeID)
831 {
832 return null;
833 }
834
835 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
836 {
837 return null;
838 }
839
840 public int GetRegionFlags(UUID scopeID, UUID regionID)
841 {
842 return 0;
843 }
809 844
810 } 845 }
811} 846}