aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2009-09-26 21:00:51 -0700
committerDiva Canto2009-09-26 21:00:51 -0700
commitf4bf581b96347b8d7f115eca74fa84a644eb729c (patch)
treec1e42376edb8d2e5a6094854dd1ac4320f0c6f23
parentFixed a bug with link-region. (diff)
downloadopensim-SC_OLD-f4bf581b96347b8d7f115eca74fa84a644eb729c.zip
opensim-SC_OLD-f4bf581b96347b8d7f115eca74fa84a644eb729c.tar.gz
opensim-SC_OLD-f4bf581b96347b8d7f115eca74fa84a644eb729c.tar.bz2
opensim-SC_OLD-f4bf581b96347b8d7f115eca74fa84a644eb729c.tar.xz
Moved all HG1 operations to HGGridConnector.cs and HypergridServerConnector.cs/HypergridServiceConnector.cs, away from Region.Communications and HGNetworkServersInfo.
Fixed small bugs with hyperlinked regions' map positions.
-rw-r--r--OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs1
-rw-r--r--OpenSim/Framework/Util.cs26
-rw-r--r--OpenSim/Region/Application/HGCommands.cs3
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServices.cs50
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs227
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs22
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs9
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs19
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs111
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs89
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs14
14 files changed, 537 insertions, 100 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
index 6a66116..18641f1 100644
--- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
@@ -144,7 +144,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
144 // We are in grid mode 144 // We are in grid mode
145 InitialiseHGGridServices(libraryRootFolder); 145 InitialiseHGGridServices(libraryRootFolder);
146 } 146 }
147 HGCommands.HGServices = HGServices;
148 } 147 }
149 148
150 protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder) 149 protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 45b5a10..a28a617 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1203,6 +1203,32 @@ namespace OpenSim.Framework
1203 return found.ToArray(); 1203 return found.ToArray();
1204 } 1204 }
1205 1205
1206 public static string ServerURI(string uri)
1207 {
1208 if (uri == string.Empty)
1209 return string.Empty;
1210
1211 // Get rid of eventual slashes at the end
1212 uri = uri.TrimEnd('/');
1213
1214 IPAddress ipaddr1 = null;
1215 string port1 = "";
1216 try
1217 {
1218 ipaddr1 = Util.GetHostFromURL(uri);
1219 }
1220 catch { }
1221
1222 try
1223 {
1224 port1 = uri.Split(new char[] { ':' })[2];
1225 }
1226 catch { }
1227
1228 // We tried our best to convert the domain names to IP addresses
1229 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
1230 }
1231
1206 #region FireAndForget Threading Pattern 1232 #region FireAndForget Threading Pattern
1207 1233
1208 public static void FireAndForget(System.Threading.WaitCallback callback) 1234 public static void FireAndForget(System.Threading.WaitCallback callback)
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
index f99c1a5..f503db7 100644
--- a/OpenSim/Region/Application/HGCommands.cs
+++ b/OpenSim/Region/Application/HGCommands.cs
@@ -43,12 +43,11 @@ namespace OpenSim
43 public class HGCommands 43 public class HGCommands
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public static IHyperlink HGServices = null;
47 46
48 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, 47 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
49 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) 48 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
50 { 49 {
51 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); 50 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
52 51
53 return 52 return
54 new HGScene( 53 new HGScene(
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
index 54cde0f..85bfab4 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
@@ -596,16 +596,16 @@ namespace OpenSim.Region.Communications.Hypergrid
596 //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); 596 //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
597 //m_log.Debug(" --------- ---------------- -------"); 597 //m_log.Debug(" --------- ---------------- -------");
598 598
599 string serverURI = ""; 599 //string serverURI = "";
600 if (u.UserProfile is ForeignUserProfileData) 600 //if (u.UserProfile is ForeignUserProfileData)
601 serverURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI); 601 // serverURI = Util.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI);
602 loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI; 602 //loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI;
603 603
604 serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI); 604 //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI);
605 loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI; 605 //loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI;
606 606
607 serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI); 607 //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI);
608 loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI; 608 //loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI;
609 609
610 loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID; 610 loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID;
611 611
@@ -949,33 +949,35 @@ namespace OpenSim.Region.Communications.Hypergrid
949 949
950 protected bool IsComingHome(ForeignUserProfileData userData) 950 protected bool IsComingHome(ForeignUserProfileData userData)
951 { 951 {
952 return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); 952 return false; //(userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI);
953 } 953 }
954 954
955 protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo) 955 protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo)
956 { 956 {
957 if (uinfo.UserProfile == null) 957 return false;
958 return false; 958 //if (uinfo.UserProfile == null)
959 // return false;
959 960
960 string userUserServerURI = String.Empty; 961 //string userUserServerURI = String.Empty;
961 if (uinfo.UserProfile is ForeignUserProfileData) 962 //if (uinfo.UserProfile is ForeignUserProfileData)
962 { 963 //{
963 userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); 964 // userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
964 } 965 //}
965 966
966 return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) && 967 //return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) &&
967 (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI)); 968 // (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI));
968 } 969 }
969 970
970 protected bool IsLocalUser(CachedUserInfo uinfo) 971 protected bool IsLocalUser(CachedUserInfo uinfo)
971 { 972 {
972 if (uinfo == null) 973 return true;
973 return true; 974 //if (uinfo == null)
975 // return true;
974 976
975 if (uinfo.UserProfile is ForeignUserProfileData) 977 //if (uinfo.UserProfile is ForeignUserProfileData)
976 return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); 978 // return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
977 else 979 //else
978 return true; 980 // return true;
979 981
980 } 982 }
981 983
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
index 41f96b3..9bf31a4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid; 39using OpenSim.Server.Handlers.Grid;
40using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 42
42namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid 43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
@@ -95,20 +96,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
95 if (!m_Enabled) 96 if (!m_Enabled)
96 return; 97 return;
97 98
98 if (!m_Registered)
99 {
100 m_Registered = true;
101
102 m_log.Info("[HypergridService]: Starting...");
103
104 Object[] args = new Object[] { m_Config, MainServer.Instance };
105
106 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
107 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
108 }
109
110 GridRegion rinfo = new GridRegion(scene.RegionInfo);
111 m_HypergridHandler.AddRegion(rinfo);
112 } 99 }
113 100
114 public void RemoveRegion(Scene scene) 101 public void RemoveRegion(Scene scene)
@@ -122,6 +109,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
122 109
123 public void RegionLoaded(Scene scene) 110 public void RegionLoaded(Scene scene)
124 { 111 {
112 if (!m_Registered)
113 {
114 m_Registered = true;
115
116 m_log.Info("[HypergridService]: Starting...");
117
118 Object[] args = new Object[] { m_Config, MainServer.Instance };
119
120 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 }
123
124 GridRegion rinfo = new GridRegion(scene.RegionInfo);
125 m_HypergridHandler.AddRegion(rinfo);
125 } 126 }
126 127
127 #endregion 128 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 0bb4206..52db400 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -31,6 +31,7 @@ using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33 33
34using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -52,10 +53,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
52 private static readonly ILog m_log = 53 private static readonly ILog m_log =
53 LogManager.GetLogger( 54 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
55 57
56 private bool m_Enabled = false; 58 private bool m_Enabled = false;
57 private bool m_Initialized = false; 59 private bool m_Initialized = false;
58 60
61 private Scene m_aScene;
62 private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
63
59 private IGridService m_GridServiceConnector; 64 private IGridService m_GridServiceConnector;
60 private HypergridServiceConnector m_HypergridServiceConnector; 65 private HypergridServiceConnector m_HypergridServiceConnector;
61 66
@@ -141,6 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
141 if (!m_Enabled) 146 if (!m_Enabled)
142 return; 147 return;
143 148
149 m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
144 scene.RegisterModuleInterface<IGridService>(this); 150 scene.RegisterModuleInterface<IGridService>(this);
145 scene.RegisterModuleInterface<IHyperlinkService>(this); 151 scene.RegisterModuleInterface<IHyperlinkService>(this);
146 152
@@ -148,6 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
148 154
149 public void RemoveRegion(Scene scene) 155 public void RemoveRegion(Scene scene)
150 { 156 {
157 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
151 } 158 }
152 159
153 public void RegionLoaded(Scene scene) 160 public void RegionLoaded(Scene scene)
@@ -157,7 +164,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
157 164
158 if (!m_Initialized) 165 if (!m_Initialized)
159 { 166 {
167 m_aScene = scene;
168 LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
169 LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
170 LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
171
160 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); 172 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
173
161 HGCommands hgCommands = new HGCommands(this, scene); 174 HGCommands hgCommands = new HGCommands(this, scene);
162 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", 175 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
163 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 176 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
@@ -167,6 +180,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
167 "Unlink a hypergrid region", hgCommands.RunCommand); 180 "Unlink a hypergrid region", hgCommands.RunCommand);
168 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>", 181 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
169 "Set local coordinate to map HG regions to", hgCommands.RunCommand); 182 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
183
184 // Yikes!! Remove this as soon as user services get refactored
185 HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
186
170 m_Initialized = true; 187 m_Initialized = true;
171 } 188 }
172 } 189 }
@@ -240,7 +257,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
240 // Try the foreign users home collection 257 // Try the foreign users home collection
241 foreach (GridRegion r in m_knownRegions.Values) 258 foreach (GridRegion r in m_knownRegions.Values)
242 if (r.RegionID == regionID) 259 if (r.RegionID == regionID)
243 return m_knownRegions[regionID]; 260 return r;
244 261
245 // Finally, try the normal route 262 // Finally, try the normal route
246 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); 263 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@@ -261,7 +278,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
261 foreach (GridRegion r in m_knownRegions.Values) 278 foreach (GridRegion r in m_knownRegions.Values)
262 { 279 {
263 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 280 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
281 {
264 return r; 282 return r;
283 }
265 } 284 }
266 285
267 // Finally, try the normal route 286 // Finally, try the normal route
@@ -328,8 +347,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
328 347
329 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) 348 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
330 { 349 {
331 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); 350 m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
332 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 351 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
333 } 352 }
334 353
335 private void RemoveHyperlinkRegion(UUID regionID) 354 private void RemoveHyperlinkRegion(UUID regionID)
@@ -340,8 +359,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
340 359
341 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) 360 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
342 { 361 {
343 m_knownRegions.Add(userID, regionInfo); 362 m_knownRegions[userID] = regionInfo;
344 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 363 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
345 } 364 }
346 365
347 private void RemoveHyperlinkHomeRegion(UUID regionID) 366 private void RemoveHyperlinkHomeRegion(UUID regionID)
@@ -412,7 +431,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
412 // From the map search and secondlife://blah 431 // From the map search and secondlife://blah
413 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 432 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
414 { 433 {
415 int xloc = random.Next(0, Int16.MaxValue); 434 int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
416 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 435 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
417 } 436 }
418 437
@@ -563,10 +582,206 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
563 foreach (GridRegion r in m_HyperlinkRegions.Values) 582 foreach (GridRegion r in m_HyperlinkRegions.Values)
564 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) 583 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
565 return m_HyperlinkHandles[r.RegionID]; 584 return m_HyperlinkHandles[r.RegionID];
585
586 foreach (GridRegion r in m_knownRegions.Values)
587 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
588 return m_HyperlinkHandles[r.RegionID];
589
566 return handle; 590 return handle;
567 } 591 }
568 592
593 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
594 {
595 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
596
597 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
598 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
599 {
600 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
601
602 // Set the position of the region on the remote grid
603 ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
604 uint x = 0, y = 0;
605 Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
606 GridRegion clonedRegion = new GridRegion(regInfo);
607 clonedRegion.RegionLocX = (int)x;
608 clonedRegion.RegionLocY = (int)y;
609
610 // Get the user's home region information
611 GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
612
613 // Get the user's service URLs
614 string serverURI = "";
615 if (uinfo.UserProfile is ForeignUserProfileData)
616 serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
617 string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
618
619 string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
620 if ((assetServer == null) || (assetServer == ""))
621 assetServer = LocalAssetServerURI;
622
623 string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
624 if ((inventoryServer == null) || (inventoryServer == ""))
625 inventoryServer = LocalInventoryServerURI;
626
627 if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
628 {
629 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
630 return false;
631 }
632 }
633 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
634 //{
635 // m_log.Info("[HGrid]: User seems to be going to foreign region.");
636 // if (!InformRegionOfUser(regInfo, agentData))
637 // {
638 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
639 // return false;
640 // }
641 //}
642 //else
643 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
644
645 // May need to change agent's name
646 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
647 {
648 agentData.firstname = agentData.firstname + "." + agentData.lastname;
649 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
650 }
651
652 return true;
653 }
654
655 public void AdjustUserInformation(AgentCircuitData agentData)
656 {
657 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
658 if ((uinfo != null) && (uinfo.UserProfile != null) &&
659 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
660 {
661 //m_log.Debug("---------------> Local User!");
662 string[] parts = agentData.firstname.Split(new char[] { '.' });
663 if (parts.Length == 2)
664 {
665 agentData.firstname = parts[0];
666 agentData.lastname = parts[1];
667 }
668 }
669 //else
670 // m_log.Debug("---------------> Foreign User!");
671 }
672
673 // Check if a local user exists with the same UUID as the incoming foreign user
674 public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
675 {
676 comingHome = false;
677 if (!m_aScene.SceneGridService.RegionLoginsEnabled)
678 return false;
679
680 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
681 if (uinfo != null)
682 {
683 // uh-oh we have a potential intruder
684 if (uinfo.SessionID != sessionID)
685 // can't have a foreigner with a local UUID
686 return false;
687 else
688 // oh, so it's you! welcome back
689 comingHome = true;
690 }
691
692 // OK, user can come in
693 return true;
694 }
695
696 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
697 {
698 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
699 ulong realHandle = home.RegionHandle;
700 // Change the local coordinates
701 // X=0 on the map
702 home.RegionLocX = 0;
703 home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
704
705 AddHyperlinkHomeRegion(user.ID, home, realHandle);
706
707 DumpUserData(user);
708 DumpRegionData(home);
709
710 }
711
712 public bool IsLocalUser(UUID userID)
713 {
714 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
715 return IsLocalUser(uinfo);
716 }
717
569 #endregion 718 #endregion
570 719
720 #region IHyperlink Misc
721
722 protected bool IsComingHome(ForeignUserProfileData userData)
723 {
724 return (userData.UserServerURI == LocalUserServerURI);
725 }
726
727 // Is the user going back to the home region or the home grid?
728 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
729 {
730 if (uinfo.UserProfile == null)
731 return false;
732
733 if (!(uinfo.UserProfile is ForeignUserProfileData))
734 // it's a home user, can't be outside to return home
735 return false;
736
737 // OK, it's a foreign user with a ForeignUserProfileData
738 // and is going back to exactly the home region.
739 // We can't check if it's going back to a non-home region
740 // of the home grid. That will be dealt with in the
741 // receiving end
742 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
743 }
744
745 protected bool IsLocalUser(CachedUserInfo uinfo)
746 {
747 if (uinfo == null)
748 return false;
749
750 return !(uinfo.UserProfile is ForeignUserProfileData);
751
752 }
753
754 protected bool IsLocalRegion(ulong handle)
755 {
756 return m_LocalScenes.ContainsKey(handle);
757 }
758
759 private void DumpUserData(ForeignUserProfileData userData)
760 {
761 m_log.Info(" ------------ User Data Dump ----------");
762 m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
763 m_log.Info(" >> HomeID: " + userData.HomeRegionID);
764 m_log.Info(" >> UserServer: " + userData.UserServerURI);
765 m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
766 m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
767 m_log.Info(" ------------ -------------- ----------");
768 }
769
770 private void DumpRegionData(GridRegion rinfo)
771 {
772 m_log.Info(" ------------ Region Data Dump ----------");
773 m_log.Info(" >> handle: " + rinfo.RegionHandle);
774 m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
775 m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
776 m_log.Info(" >> http port: " + rinfo.HttpPort);
777 m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
778 m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
779 m_log.Info(" ------------ -------------- ----------");
780 }
781
782
783 #endregion
784
785
571 } 786 }
572} 787}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index adf747a..696225c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -824,29 +824,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
824 824
825 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) 825 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
826 { 826 {
827 try 827 if (m_hyperlinkService != null)
828 { 828 m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
829 if (m_aScene.SceneGridService is HGSceneCommunicationService)
830 {
831 // big hack for now
832 RegionInfo r = new RegionInfo();
833 r.ExternalHostName = regInfo.ExternalHostName;
834 r.HttpPort = regInfo.HttpPort;
835 r.RegionID = regInfo.RegionID;
836 r.RegionLocX = (uint)regInfo.RegionLocX;
837 r.RegionLocY = (uint)regInfo.RegionLocY;
838 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(r, aCircuit);
839 }
840 }
841 catch // Bad cast
842 { }
843 829
844 } 830 }
845 831
846 public override void AdjustUserInformation(AgentCircuitData aCircuit) 832 public override void AdjustUserInformation(AgentCircuitData aCircuit)
847 { 833 {
848 if (m_aScene.SceneGridService is HGSceneCommunicationService) 834 if (m_hyperlinkService != null)
849 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); 835 m_hyperlinkService.AdjustUserInformation(aCircuit);
850 } 836 }
851 } 837 }
852 838
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1c66254..fd1a759 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
525 return true; 525 return true;
526 } 526 }
527 527
528 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 528 if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
529 // this happens in standalone profiles, apparently
530 return true;
531
532 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
533
529 string uri = m_LocalGridInventoryURI.TrimEnd('/'); 534 string uri = m_LocalGridInventoryURI.TrimEnd('/');
530 535
531 if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) 536 if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
544 if ((uinfo == null) || (uinfo.UserProfile == null)) 549 if ((uinfo == null) || (uinfo.UserProfile == null))
545 return invURI; 550 return invURI;
546 551
547 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 552 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
548 553
549 if ((userInventoryServerURI != null) && 554 if ((userInventoryServerURI != null) &&
550 (userInventoryServerURI != "")) 555 (userInventoryServerURI != ""))
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index e3661fa..436f332 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -137,8 +137,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
137 data.Name = info.RegionName; 137 data.Name = info.RegionName;
138 data.RegionFlags = 0; // TODO not used? 138 data.RegionFlags = 0; // TODO not used?
139 data.WaterHeight = 0; // not used 139 data.WaterHeight = 0; // not used
140 data.X = (ushort)info.RegionLocX; 140 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
141 data.Y = (ushort)info.RegionLocY; 141 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
142 blocks.Add(data); 142 blocks.Add(data);
143 } 143 }
144 } 144 }
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 62efd60..b6fa41d 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Services.Interfaces;
38 39
39//using HyperGrid.Framework; 40//using HyperGrid.Framework;
40//using OpenSim.Region.Communications.Hypergrid; 41//using OpenSim.Region.Communications.Hypergrid;
@@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 51// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
51 52
52 private Scene m_scene; 53 private Scene m_scene;
54
55 private IHyperlinkService m_hyper;
56 IHyperlinkService HyperlinkService
57 {
58 get
59 {
60 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
62 return m_hyper;
63 }
64 }
65
53 #endregion 66 #endregion
54 67
55 #region Constructor 68 #region Constructor
@@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
79// return null; 92// return null;
80// } 93// }
81 94
82 private bool IsLocalUser(UUID userID)
83 {
84 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
85
86 if (uinfo != null)
87 {
88 if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
89 {
90 m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
91 return true;
92 }
93 }
94
95 m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
96 return false;
97 }
98 95
99 public AssetBase FetchAsset(string url, UUID assetID) 96 public AssetBase FetchAsset(string url, UUID assetID)
100 { 97 {
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
170 167
171 public void Get(UUID assetID, UUID ownerID) 168 public void Get(UUID assetID, UUID ownerID)
172 { 169 {
173 if (!IsLocalUser(ownerID)) 170 if (!HyperlinkService.IsLocalUser(ownerID))
174 { 171 {
175 // Get the item from the remote asset server onto the local AssetCache 172 // Get the item from the remote asset server onto the local AssetCache
176 // and place an entry in m_assetMap 173 // and place an entry in m_assetMap
@@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
228 225
229 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
230 { 227 {
231 if (!IsLocalUser(ownerID)) 228 if (!HyperlinkService.IsLocalUser(ownerID))
232 { 229 {
233 // Post the item from the local AssetCache onto the remote asset server 230 // Post the item from the local AssetCache onto the remote asset server
234 // and place an entry in m_assetMap 231 // and place an entry in m_assetMap
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index ee5eb90..1217f9b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42 43
43namespace OpenSim.Region.Framework.Scenes.Hypergrid 44namespace OpenSim.Region.Framework.Scenes.Hypergrid
@@ -46,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
46 { 47 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 49
49 public readonly IHyperlink m_hg; 50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
50 60
51 public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) 61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
52 { 62 {
53 m_hg = hg;
54 } 63 }
55 64
56 65
@@ -129,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 /// Hypergrid mod start 138 /// Hypergrid mod start
130 /// 139 ///
131 /// 140 ///
132 bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); 141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
133 bool isHomeUser = true; 142 bool isHomeUser = true;
134 ulong realHandle = regionHandle; 143 ulong realHandle = regionHandle;
135 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); 144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
136 if (uinfo != null) 145 if (uinfo != null)
137 { 146 {
138 isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); 147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
139 realHandle = m_hg.FindRegionHandle(regionHandle); 148 realHandle = m_hg.FindRegionHandle(regionHandle);
140 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); 149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
141 } 150 }
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
index d2e791b..c47f652 100644
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
41using OpenMetaverse;
41using log4net; 42using log4net;
42using Nwc.XmlRpc; 43using Nwc.XmlRpc;
43 44
@@ -50,11 +51,25 @@ namespace OpenSim.Server.Handlers.Grid
50 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>(); 53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
53 55
54 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : 56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
55 base(config, server) 57 base(config, server)
56 { 58 {
59 m_HyperlinkService = hyperService;
57 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); 60 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
61 server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
62 }
63
64 public void AddRegion(GridRegion rinfo)
65 {
66 m_RegionsOnSim.Add(rinfo);
67 }
68
69 public void RemoveRegion(GridRegion rinfo)
70 {
71 if (m_RegionsOnSim.Contains(rinfo))
72 m_RegionsOnSim.Remove(rinfo);
58 } 73 }
59 74
60 /// <summary> 75 /// <summary>
@@ -99,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
99 return response; 114 return response;
100 } 115 }
101 116
102 public void AddRegion(GridRegion rinfo) 117 /// <summary>
118 /// Received from other HGrid nodes when a user wants to teleport here. This call allows
119 /// the region to prepare for direct communication from the client. Sends back an empty
120 /// xmlrpc response on completion.
121 /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
122 /// registering the user in the local user cache.
123 /// </summary>
124 /// <param name="request"></param>
125 /// <returns></returns>
126 public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
103 { 127 {
104 m_RegionsOnSim.Add(rinfo); 128 Hashtable requestData = (Hashtable)request.Params[0];
105 } 129 ForeignUserProfileData userData = new ForeignUserProfileData();
106 130
107 public void RemoveRegion(GridRegion rinfo) 131 userData.FirstName = (string)requestData["firstname"];
108 { 132 userData.SurName = (string)requestData["lastname"];
109 if (m_RegionsOnSim.Contains(rinfo)) 133 userData.ID = new UUID((string)requestData["agent_id"]);
110 m_RegionsOnSim.Remove(rinfo); 134 UUID sessionID = new UUID((string)requestData["session_id"]);
135 userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
136 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
137 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
138
139 userData.UserServerURI = (string)requestData["userserver_id"];
140 userData.UserAssetURI = (string)requestData["assetserver_id"];
141 userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
142
143 m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
144 userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
145
146 ulong userRegionHandle = 0;
147 int userhomeinternalport = 0;
148 if (requestData.ContainsKey("region_uuid"))
149 {
150 UUID uuid = UUID.Zero;
151 UUID.TryParse((string)requestData["region_uuid"], out uuid);
152 userData.HomeRegionID = uuid;
153 userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
154 userData.UserHomeAddress = (string)requestData["home_address"];
155 userData.UserHomePort = (string)requestData["home_port"];
156 userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
157
158 m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
159 "; home_port: " + userData.UserHomePort);
160 }
161 else
162 m_log.WarnFormat("[HGrid]: User has no home region information");
163
164 XmlRpcResponse resp = new XmlRpcResponse();
165
166 // Let's check if someone is trying to get in with a stolen local identity.
167 // The need for this test is a consequence of not having truly global names :-/
168 bool comingHome = false;
169 if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
170 {
171 m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
172 Hashtable respdata = new Hashtable();
173 respdata["success"] = "FALSE";
174 respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
175 resp.Value = respdata;
176 return resp;
177 }
178
179 // Finally, everything looks ok
180 //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
181
182 if (!comingHome)
183 {
184 // We don't do this if the user is coming to the home grid
185 GridRegion home = new GridRegion();
186 home.RegionID = userData.HomeRegionID;
187 home.ExternalHostName = userData.UserHomeAddress;
188 home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
189 uint x = 0, y = 0;
190 Utils.LongToUInts(userRegionHandle, out x, out y);
191 home.RegionLocX = (int)x;
192 home.RegionLocY = (int)y;
193 home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
194
195 m_HyperlinkService.AcceptUser(userData, home);
196 }
197 // else the user is coming to a non-home region of the home grid
198 // We simply drop this user information altogether
199
200 Hashtable respdata2 = new Hashtable();
201 respdata2["success"] = "TRUE";
202 resp.Value = respdata2;
203
204 return resp;
111 } 205 }
206
112 } 207 }
113} 208}
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index cf17557..dd19b01 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -149,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid
149 } 149 }
150 } 150 }
151 151
152 public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
153 {
154 string capsPath = agentData.CapsPath;
155 Hashtable loginParams = new Hashtable();
156 loginParams["session_id"] = agentData.SessionID.ToString();
157
158 loginParams["firstname"] = agentData.firstname;
159 loginParams["lastname"] = agentData.lastname;
160
161 loginParams["agent_id"] = agentData.AgentID.ToString();
162 loginParams["circuit_code"] = agentData.circuitcode.ToString();
163 loginParams["startpos_x"] = agentData.startpos.X.ToString();
164 loginParams["startpos_y"] = agentData.startpos.Y.ToString();
165 loginParams["startpos_z"] = agentData.startpos.Z.ToString();
166 loginParams["caps_path"] = capsPath;
167
168 if (home != null)
169 {
170 loginParams["region_uuid"] = home.RegionID.ToString();
171 loginParams["regionhandle"] = home.RegionHandle.ToString();
172 loginParams["home_address"] = home.ExternalHostName;
173 loginParams["home_port"] = home.HttpPort.ToString();
174 loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
175
176 m_log.Debug(" --------- Home -------");
177 m_log.Debug(" >> " + loginParams["home_address"] + " <<");
178 m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
179 m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
180 m_log.Debug(" >> " + loginParams["home_port"] + " <<");
181 m_log.Debug(" --------- ------------ -------");
182 }
183 else
184 m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
185
186 loginParams["userserver_id"] = userServer;
187 loginParams["assetserver_id"] = assetServer;
188 loginParams["inventoryserver_id"] = inventoryServer;
189
190
191 ArrayList SendParams = new ArrayList();
192 SendParams.Add(loginParams);
193
194 // Send
195 string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
196 //m_log.Debug("XXX uri: " + uri);
197 XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
198 XmlRpcResponse reply;
199 try
200 {
201 reply = request.Send(uri, 6000);
202 }
203 catch (Exception e)
204 {
205 m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
206 return false;
207 }
208
209 if (!reply.IsFault)
210 {
211 bool responseSuccess = true;
212 if (reply.Value != null)
213 {
214 Hashtable resp = (Hashtable)reply.Value;
215 if (resp.ContainsKey("success"))
216 {
217 if ((string)resp["success"] == "FALSE")
218 {
219 responseSuccess = false;
220 }
221 }
222 }
223 if (responseSuccess)
224 {
225 m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
226 return true;
227 }
228 else
229 {
230 m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
231 return false;
232 }
233 }
234 else
235 {
236 m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
237 return false;
238 }
239 }
240
152 } 241 }
153} 242}
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 96dc82b9..c5495fb 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -191,6 +191,20 @@ namespace OpenSim.Services.Interfaces
191 Maturity = ConvertFrom.RegionSettings.Maturity; 191 Maturity = ConvertFrom.RegionSettings.Maturity;
192 } 192 }
193 193
194 public GridRegion(GridRegion ConvertFrom)
195 {
196 m_regionName = ConvertFrom.RegionName;
197 m_regionLocX = ConvertFrom.RegionLocX;
198 m_regionLocY = ConvertFrom.RegionLocY;
199 m_internalEndPoint = ConvertFrom.InternalEndPoint;
200 m_externalHostName = ConvertFrom.ExternalHostName;
201 m_httpPort = ConvertFrom.HttpPort;
202 RegionID = ConvertFrom.RegionID;
203 ServerURI = ConvertFrom.ServerURI;
204 TerrainImage = ConvertFrom.TerrainImage;
205 Access = ConvertFrom.Access;
206 Maturity = ConvertFrom.Maturity;
207 }
194 208
195 /// <value> 209 /// <value>
196 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. 210 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.