diff options
author | Diva Canto | 2010-01-16 21:42:44 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-16 21:42:44 -0800 |
commit | 04e29c1bacbc1e2df980ae15896a847ce7535da2 (patch) | |
tree | e799d2837af1a41bc2c3b2d571201e9a8a6d7ae7 /OpenSim/Region | |
parent | Finished moving object crossings into EntityTransferModule (diff) | |
download | opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.zip opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.gz opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.bz2 opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.xz |
Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 650 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 24 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HGCommands.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs) | 90 |
5 files changed, 113 insertions, 667 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 25415af..827dafe 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1154,7 +1154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1154 | 1154 | ||
1155 | #endregion | 1155 | #endregion |
1156 | 1156 | ||
1157 | #region Object Crossings | 1157 | #region Object Transfers |
1158 | /// <summary> | 1158 | /// <summary> |
1159 | /// Move the given scene object into a new region depending on which region its absolute position has moved | 1159 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
1160 | /// into. | 1160 | /// into. |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index b12d778..6ec0fcf 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs | |||
@@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 37 | using OpenSim.Server.Base; |
38 | using OpenSim.Server.Handlers.Base; | 38 | using OpenSim.Server.Handlers.Base; |
39 | using OpenSim.Server.Handlers.Grid; | 39 | using OpenSim.Server.Handlers.Hypergrid; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | 42 | ||
@@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | |||
49 | 49 | ||
50 | private IConfigSource m_Config; | 50 | private IConfigSource m_Config; |
51 | bool m_Registered = false; | 51 | bool m_Registered = false; |
52 | HypergridServiceInConnector m_HypergridHandler; | 52 | GatekeeperServiceInConnector m_HypergridHandler; |
53 | 53 | ||
54 | #region IRegionModule interface | 54 | #region IRegionModule interface |
55 | 55 | ||
@@ -102,9 +102,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | |||
102 | { | 102 | { |
103 | if (!m_Enabled) | 103 | if (!m_Enabled) |
104 | return; | 104 | return; |
105 | |||
106 | GridRegion rinfo = new GridRegion(scene.RegionInfo); | ||
107 | m_HypergridHandler.RemoveRegion(rinfo); | ||
108 | } | 105 | } |
109 | 106 | ||
110 | public void RegionLoaded(Scene scene) | 107 | public void RegionLoaded(Scene scene) |
@@ -119,13 +116,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | |||
119 | m_log.Info("[HypergridService]: Starting..."); | 116 | m_log.Info("[HypergridService]: Starting..."); |
120 | 117 | ||
121 | // Object[] args = new Object[] { m_Config, MainServer.Instance }; | 118 | // Object[] args = new Object[] { m_Config, MainServer.Instance }; |
122 | 119 | ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); | |
123 | m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>()); | 120 | m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); |
124 | //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); | 121 | //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); |
125 | } | 122 | } |
126 | |||
127 | GridRegion rinfo = new GridRegion(scene.RegionInfo); | ||
128 | m_HypergridHandler.AddRegion(rinfo); | ||
129 | } | 123 | } |
130 | 124 | ||
131 | #endregion | 125 | #endregion |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index de71b56..75eb889 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | |||
@@ -49,12 +49,11 @@ using Nini.Config; | |||
49 | 49 | ||
50 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 50 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
51 | { | 51 | { |
52 | public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService | 52 | public class HGGridConnector : ISharedRegionModule, IGridService |
53 | { | 53 | { |
54 | private static readonly ILog m_log = | 54 | private static readonly ILog m_log = |
55 | LogManager.GetLogger( | 55 | LogManager.GetLogger( |
56 | MethodBase.GetCurrentMethod().DeclaringType); | 56 | MethodBase.GetCurrentMethod().DeclaringType); |
57 | private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI; | ||
58 | 57 | ||
59 | private bool m_Enabled = false; | 58 | private bool m_Enabled = false; |
60 | private bool m_Initialized = false; | 59 | private bool m_Initialized = false; |
@@ -63,18 +62,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
63 | private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>(); | 62 | private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>(); |
64 | 63 | ||
65 | private IGridService m_GridServiceConnector; | 64 | private IGridService m_GridServiceConnector; |
66 | private HypergridServiceConnector m_HypergridServiceConnector; | 65 | private IHypergridService m_HypergridService; |
67 | 66 | ||
68 | // Hyperlink regions are hyperlinks on the map | ||
69 | protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | ||
70 | |||
71 | // Known regions are home regions of visiting foreign users. | ||
72 | // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when | ||
73 | // the visitor goes away. They are mapped to X=0 on the map. | ||
74 | // This is key-ed on agent ID | ||
75 | protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>(); | ||
76 | |||
77 | protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); | ||
78 | 67 | ||
79 | #region ISharedRegionModule | 68 | #region ISharedRegionModule |
80 | 69 | ||
@@ -125,13 +114,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
125 | if (module == String.Empty) | 114 | if (module == String.Empty) |
126 | { | 115 | { |
127 | m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); | 116 | m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); |
128 | //return; | ||
129 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | 117 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); |
130 | } | 118 | } |
131 | 119 | ||
132 | Object[] args = new Object[] { source }; | 120 | Object[] args = new Object[] { source }; |
133 | m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args); | 121 | m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args); |
134 | 122 | ||
123 | string hypergrid = gridConfig.GetString("HypergridService", string.Empty); | ||
124 | if (hypergrid == String.Empty) | ||
125 | { | ||
126 | m_log.Error("[HGGRID CONNECTOR]: No HypergridService named in section GridService"); | ||
127 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
128 | } | ||
129 | m_HypergridService = ServerUtils.LoadPlugin<IHypergridService>(hypergrid, args); | ||
130 | |||
131 | if (m_GridServiceConnector == null || m_HypergridService == null) | ||
132 | throw new Exception("Unable to proceed. HGGrid services could not be loaded."); | ||
135 | } | 133 | } |
136 | 134 | ||
137 | public void PostInitialise() | 135 | public void PostInitialise() |
@@ -151,7 +149,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
151 | 149 | ||
152 | m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; | 150 | m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; |
153 | scene.RegisterModuleInterface<IGridService>(this); | 151 | scene.RegisterModuleInterface<IGridService>(this); |
154 | scene.RegisterModuleInterface<IHyperlinkService>(this); | ||
155 | 152 | ||
156 | ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); | 153 | ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); |
157 | 154 | ||
@@ -175,18 +172,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
175 | { | 172 | { |
176 | m_aScene = scene; | 173 | m_aScene = scene; |
177 | 174 | ||
178 | m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); | ||
179 | |||
180 | HGCommands hgCommands = new HGCommands(this, scene); | ||
181 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", | ||
182 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", | ||
183 | "Link a hypergrid region", hgCommands.RunCommand); | ||
184 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region", | ||
185 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", | ||
186 | "Unlink a hypergrid region", hgCommands.RunCommand); | ||
187 | MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>", | ||
188 | "Set local coordinate to map HG regions to", hgCommands.RunCommand); | ||
189 | |||
190 | m_Initialized = true; | 175 | m_Initialized = true; |
191 | } | 176 | } |
192 | } | 177 | } |
@@ -197,50 +182,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
197 | 182 | ||
198 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) | 183 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) |
199 | { | 184 | { |
200 | // Region doesn't exist here. Trying to link remote region | 185 | return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); |
201 | if (regionInfo.RegionID.Equals(UUID.Zero)) | ||
202 | { | ||
203 | m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); | ||
204 | ulong regionHandle = 0; | ||
205 | regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle); | ||
206 | if (!regionInfo.RegionID.Equals(UUID.Zero)) | ||
207 | { | ||
208 | AddHyperlinkRegion(regionInfo, regionHandle); | ||
209 | m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); | ||
210 | |||
211 | // Try get the map image | ||
212 | m_HypergridServiceConnector.GetMapImage(regionInfo); | ||
213 | return String.Empty; | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); | ||
218 | return "No such region"; | ||
219 | } | ||
220 | // Note that these remote regions aren't registered in localBackend, so return null, no local listeners | ||
221 | } | ||
222 | else // normal grid | ||
223 | return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); | ||
224 | } | 186 | } |
225 | 187 | ||
226 | public bool DeregisterRegion(UUID regionID) | 188 | public bool DeregisterRegion(UUID regionID) |
227 | { | 189 | { |
228 | // Try the hyperlink collection | ||
229 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
230 | { | ||
231 | RemoveHyperlinkRegion(regionID); | ||
232 | return true; | ||
233 | } | ||
234 | // Try the foreign users home collection | ||
235 | |||
236 | foreach (GridRegion r in m_knownRegions.Values) | ||
237 | if (r.RegionID == regionID) | ||
238 | { | ||
239 | RemoveHyperlinkHomeRegion(regionID); | ||
240 | return true; | ||
241 | } | ||
242 | |||
243 | // Finally, try the normal route | ||
244 | return m_GridServiceConnector.DeregisterRegion(regionID); | 190 | return m_GridServiceConnector.DeregisterRegion(regionID); |
245 | } | 191 | } |
246 | 192 | ||
@@ -253,41 +199,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
253 | 199 | ||
254 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | 200 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
255 | { | 201 | { |
256 | // Try the hyperlink collection | 202 | GridRegion region = m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); |
257 | if (m_HyperlinkRegions.ContainsKey(regionID)) | 203 | if (region != null) |
258 | return m_HyperlinkRegions[regionID]; | 204 | return region; |
259 | 205 | ||
260 | // Try the foreign users home collection | 206 | region = m_HypergridService.GetRegionByUUID(regionID); |
261 | foreach (GridRegion r in m_knownRegions.Values) | 207 | |
262 | if (r.RegionID == regionID) | 208 | return region; |
263 | return r; | ||
264 | |||
265 | // Finally, try the normal route | ||
266 | return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); | ||
267 | } | 209 | } |
268 | 210 | ||
269 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 211 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
270 | { | 212 | { |
271 | int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; | 213 | int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; |
272 | int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; | 214 | int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; |
273 | // Try the hyperlink collection | ||
274 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
275 | { | ||
276 | if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) | ||
277 | return r; | ||
278 | } | ||
279 | 215 | ||
280 | // Try the foreign users home collection | 216 | GridRegion region = m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); |
281 | foreach (GridRegion r in m_knownRegions.Values) | 217 | if (region != null) |
282 | { | 218 | return region; |
283 | if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) | 219 | |
284 | { | 220 | region = m_HypergridService.GetRegionByPosition(snapX, snapY); |
285 | return r; | ||
286 | } | ||
287 | } | ||
288 | 221 | ||
289 | // Finally, try the normal route | 222 | return region; |
290 | return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); | ||
291 | } | 223 | } |
292 | 224 | ||
293 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | 225 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
@@ -297,551 +229,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
297 | if (region != null) | 229 | if (region != null) |
298 | return region; | 230 | return region; |
299 | 231 | ||
300 | // Try the hyperlink collection | 232 | region = m_HypergridService.GetRegionByName(regionName); |
301 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
302 | { | ||
303 | if (r.RegionName == regionName) | ||
304 | return r; | ||
305 | } | ||
306 | 233 | ||
307 | // Try the foreign users home collection | 234 | return region; |
308 | foreach (GridRegion r in m_knownRegions.Values) | ||
309 | { | ||
310 | if (r.RegionName == regionName) | ||
311 | return r; | ||
312 | } | ||
313 | return null; | ||
314 | } | 235 | } |
315 | 236 | ||
316 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | 237 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
317 | { | 238 | { |
318 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
319 | |||
320 | if (name == string.Empty) | 239 | if (name == string.Empty) |
321 | return rinfos; | 240 | return new List<GridRegion>(); |
322 | 241 | ||
323 | foreach (GridRegion r in m_HyperlinkRegions.Values) | 242 | List<GridRegion> rinfos = m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber); |
324 | if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower())) | 243 | |
325 | rinfos.Add(r); | 244 | rinfos.AddRange(m_HypergridService.GetRegionsByName(name)); |
245 | if (rinfos.Count > maxNumber) | ||
246 | rinfos.RemoveRange(maxNumber - 1, rinfos.Count - maxNumber); | ||
326 | 247 | ||
327 | rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); | ||
328 | return rinfos; | 248 | return rinfos; |
329 | } | 249 | } |
330 | 250 | ||
331 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 251 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
332 | { | 252 | { |
333 | int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; | 253 | int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
334 | // int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | 254 | int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; |
335 | int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | 255 | int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; |
336 | int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | 256 | int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; |
337 | 257 | ||
338 | List<GridRegion> rinfos = new List<GridRegion>(); | 258 | List<GridRegion> rinfos = m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); |
339 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
340 | if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && | ||
341 | (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) | ||
342 | rinfos.Add(r); | ||
343 | 259 | ||
344 | rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax)); | 260 | rinfos.AddRange(m_HypergridService.GetRegionRange(snapXmin, snapXmax, snapYmin, snapYmax)); |
345 | 261 | ||
346 | return rinfos; | 262 | return rinfos; |
347 | } | 263 | } |
348 | 264 | ||
349 | #endregion | ||
350 | |||
351 | #region Auxiliary | ||
352 | |||
353 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | ||
354 | { | ||
355 | m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; | ||
356 | m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
357 | } | ||
358 | |||
359 | private void RemoveHyperlinkRegion(UUID regionID) | ||
360 | { | ||
361 | m_HyperlinkRegions.Remove(regionID); | ||
362 | m_HyperlinkHandles.Remove(regionID); | ||
363 | } | ||
364 | |||
365 | private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) | ||
366 | { | ||
367 | m_knownRegions[userID] = regionInfo; | ||
368 | m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
369 | } | ||
370 | |||
371 | private void RemoveHyperlinkHomeRegion(UUID regionID) | ||
372 | { | ||
373 | foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions) | ||
374 | { | ||
375 | if (kvp.Value.RegionID == regionID) | ||
376 | { | ||
377 | m_knownRegions.Remove(kvp.Key); | ||
378 | } | ||
379 | } | ||
380 | m_HyperlinkHandles.Remove(regionID); | ||
381 | } | ||
382 | #endregion | ||
383 | |||
384 | #region IHyperlinkService | ||
385 | |||
386 | private static Random random = new Random(); | ||
387 | |||
388 | // From the command line link-region | ||
389 | public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) | ||
390 | { | ||
391 | string host = "127.0.0.1"; | ||
392 | string portstr; | ||
393 | string regionName = ""; | ||
394 | uint port = 9000; | ||
395 | string[] parts = mapName.Split(new char[] { ':' }); | ||
396 | if (parts.Length >= 1) | ||
397 | { | ||
398 | host = parts[0]; | ||
399 | } | ||
400 | if (parts.Length >= 2) | ||
401 | { | ||
402 | portstr = parts[1]; | ||
403 | //m_log.Debug("-- port = " + portstr); | ||
404 | if (!UInt32.TryParse(portstr, out port)) | ||
405 | regionName = parts[1]; | ||
406 | } | ||
407 | // always take the last one | ||
408 | if (parts.Length >= 3) | ||
409 | { | ||
410 | regionName = parts[2]; | ||
411 | } | ||
412 | |||
413 | // Sanity check. Don't ever link to this sim. | ||
414 | IPAddress ipaddr = null; | ||
415 | try | ||
416 | { | ||
417 | ipaddr = Util.GetHostFromDNS(host); | ||
418 | } | ||
419 | catch { } | ||
420 | |||
421 | if ((ipaddr != null) && | ||
422 | !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) | ||
423 | { | ||
424 | GridRegion regInfo; | ||
425 | bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); | ||
426 | if (success) | ||
427 | { | ||
428 | regInfo.RegionName = mapName; | ||
429 | return regInfo; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | return null; | ||
434 | } | ||
435 | |||
436 | |||
437 | // From the map search and secondlife://blah | ||
438 | public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) | ||
439 | { | ||
440 | int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize; | ||
441 | return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); | ||
442 | } | ||
443 | |||
444 | // From the command line and the 2 above | ||
445 | public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, | ||
446 | string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) | ||
447 | { | ||
448 | m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); | ||
449 | |||
450 | regInfo = new GridRegion(); | ||
451 | regInfo.RegionName = externalRegionName; | ||
452 | regInfo.HttpPort = externalPort; | ||
453 | regInfo.ExternalHostName = externalHostName; | ||
454 | regInfo.RegionLocX = xloc; | ||
455 | regInfo.RegionLocY = yloc; | ||
456 | |||
457 | try | ||
458 | { | ||
459 | regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); | ||
460 | } | ||
461 | catch (Exception e) | ||
462 | { | ||
463 | m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); | ||
464 | return false; | ||
465 | } | ||
466 | |||
467 | // Finally, link it | ||
468 | if (RegisterRegion(UUID.Zero, regInfo) != String.Empty) | ||
469 | { | ||
470 | m_log.Warn("[HGrid]: Unable to link region"); | ||
471 | return false; | ||
472 | } | ||
473 | |||
474 | int x, y; | ||
475 | if (!Check4096(m_scene, regInfo, out x, out y)) | ||
476 | { | ||
477 | DeregisterRegion(regInfo.RegionID); | ||
478 | if (client != null) | ||
479 | client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); | ||
480 | m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
481 | return false; | ||
482 | } | ||
483 | |||
484 | if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) | ||
485 | { | ||
486 | DeregisterRegion(regInfo.RegionID); | ||
487 | if (client != null) | ||
488 | client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); | ||
489 | m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); | ||
490 | return false; | ||
491 | } | ||
492 | |||
493 | m_log.Debug("[HGrid]: link region succeeded"); | ||
494 | return true; | ||
495 | } | ||
496 | |||
497 | public bool TryUnlinkRegion(Scene m_scene, string mapName) | ||
498 | { | ||
499 | GridRegion regInfo = null; | ||
500 | if (mapName.Contains(":")) | ||
501 | { | ||
502 | string host = "127.0.0.1"; | ||
503 | //string portstr; | ||
504 | //string regionName = ""; | ||
505 | uint port = 9000; | ||
506 | string[] parts = mapName.Split(new char[] { ':' }); | ||
507 | if (parts.Length >= 1) | ||
508 | { | ||
509 | host = parts[0]; | ||
510 | } | ||
511 | // if (parts.Length >= 2) | ||
512 | // { | ||
513 | // portstr = parts[1]; | ||
514 | // if (!UInt32.TryParse(portstr, out port)) | ||
515 | // regionName = parts[1]; | ||
516 | // } | ||
517 | // always take the last one | ||
518 | // if (parts.Length >= 3) | ||
519 | // { | ||
520 | // regionName = parts[2]; | ||
521 | // } | ||
522 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
523 | if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) | ||
524 | regInfo = r; | ||
525 | } | ||
526 | else | ||
527 | { | ||
528 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
529 | if (r.RegionName.Equals(mapName)) | ||
530 | regInfo = r; | ||
531 | } | ||
532 | if (regInfo != null) | ||
533 | { | ||
534 | return DeregisterRegion(regInfo.RegionID); | ||
535 | } | ||
536 | else | ||
537 | { | ||
538 | m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); | ||
539 | return false; | ||
540 | } | ||
541 | } | ||
542 | |||
543 | /// <summary> | ||
544 | /// Cope with this viewer limitation. | ||
545 | /// </summary> | ||
546 | /// <param name="regInfo"></param> | ||
547 | /// <returns></returns> | ||
548 | public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y) | ||
549 | { | ||
550 | ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; | ||
551 | uint ux = 0, uy = 0; | ||
552 | Utils.LongToUInts(realHandle, out ux, out uy); | ||
553 | x = (int)(ux / Constants.RegionSize); | ||
554 | y = (int)(uy / Constants.RegionSize); | ||
555 | |||
556 | if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) || | ||
557 | (Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096)) | ||
558 | { | ||
559 | return false; | ||
560 | } | ||
561 | return true; | ||
562 | } | ||
563 | |||
564 | public bool CheckCoords(uint thisx, uint thisy, int x, int y) | ||
565 | { | ||
566 | if ((thisx == x) && (thisy == y)) | ||
567 | return false; | ||
568 | return true; | ||
569 | } | ||
570 | |||
571 | // From the map search | ||
572 | public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) | ||
573 | { | ||
574 | return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); | ||
575 | } | ||
576 | |||
577 | // From the map and secondlife://blah | ||
578 | public GridRegion GetHyperlinkRegion(ulong handle) | ||
579 | { | ||
580 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
581 | if (r.RegionHandle == handle) | ||
582 | return r; | ||
583 | foreach (GridRegion r in m_knownRegions.Values) | ||
584 | if (r.RegionHandle == handle) | ||
585 | return r; | ||
586 | return null; | ||
587 | } | ||
588 | |||
589 | public ulong FindRegionHandle(ulong handle) | ||
590 | { | ||
591 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
592 | if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) | ||
593 | return m_HyperlinkHandles[r.RegionID]; | ||
594 | |||
595 | foreach (GridRegion r in m_knownRegions.Values) | ||
596 | if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) | ||
597 | return m_HyperlinkHandles[r.RegionID]; | ||
598 | |||
599 | return handle; | ||
600 | } | ||
601 | |||
602 | public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) | ||
603 | { | ||
604 | // REFACTORING PROBLEM. This needs to change. Some of this info should go with the agent circuit data. | ||
605 | |||
606 | //UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, agentData.AgentID); | ||
607 | //if (account == null) | ||
608 | // return false; | ||
609 | |||
610 | //if ((IsLocalUser(account) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || | ||
611 | // (!IsLocalUser(account) && !IsGoingHome(uinfo, regInfo))) | ||
612 | //{ | ||
613 | // m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); | ||
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 | ||
658 | // { | ||
659 | // m_log.Warn("[HGrid]: Unable to find local presence of transferring user."); | ||
660 | // return false; | ||
661 | // } | ||
662 | //} | ||
663 | ////if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) | ||
664 | ////{ | ||
665 | //// m_log.Info("[HGrid]: User seems to be going to foreign region."); | ||
666 | //// if (!InformRegionOfUser(regInfo, agentData)) | ||
667 | //// { | ||
668 | //// m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); | ||
669 | //// return false; | ||
670 | //// } | ||
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 | //} | ||
681 | |||
682 | return true; | ||
683 | } | ||
684 | |||
685 | public void AdjustUserInformation(AgentCircuitData agentData) | ||
686 | { | ||
687 | // REFACTORING PROBLEM!!! This needs to change | ||
688 | |||
689 | //CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); | ||
690 | //if ((uinfo != null) && (uinfo.UserProfile != null) && | ||
691 | // (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) | ||
692 | //{ | ||
693 | // //m_log.Debug("---------------> Local User!"); | ||
694 | // string[] parts = agentData.firstname.Split(new char[] { '.' }); | ||
695 | // if (parts.Length == 2) | ||
696 | // { | ||
697 | // agentData.firstname = parts[0]; | ||
698 | // agentData.lastname = parts[1]; | ||
699 | // } | ||
700 | //} | ||
701 | ////else | ||
702 | //// m_log.Debug("---------------> Foreign User!"); | ||
703 | } | ||
704 | |||
705 | // Check if a local user exists with the same UUID as the incoming foreign user | ||
706 | public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome) | ||
707 | { | ||
708 | comingHome = false; | ||
709 | |||
710 | UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); | ||
711 | if (account != null) | ||
712 | { | ||
713 | if (m_aScene.AuthenticationService.Verify(userID, sessionID.ToString(), 30)) | ||
714 | { | ||
715 | // oh, so it's you! welcome back | ||
716 | comingHome = true; | ||
717 | } | ||
718 | else | ||
719 | // can't have a foreigner with a local UUID | ||
720 | return false; | ||
721 | } | ||
722 | |||
723 | // OK, user can come in | ||
724 | return true; | ||
725 | } | ||
726 | |||
727 | public void AcceptUser(ForeignUserProfileData user, GridRegion home) | ||
728 | { | ||
729 | // REFACTORING PROBLEM. uh-oh, commenting this breaks HG completely | ||
730 | // Needs to be rewritten | ||
731 | //m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); | ||
732 | |||
733 | ulong realHandle = home.RegionHandle; | ||
734 | // Change the local coordinates | ||
735 | // X=0 on the map | ||
736 | home.RegionLocX = 0; | ||
737 | home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize; | ||
738 | |||
739 | AddHyperlinkHomeRegion(user.ID, home, realHandle); | ||
740 | |||
741 | DumpUserData(user); | ||
742 | DumpRegionData(home); | ||
743 | |||
744 | } | ||
745 | |||
746 | public bool IsLocalUser(UUID userID) | ||
747 | { | ||
748 | UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); | ||
749 | return IsLocalUser(account); | ||
750 | } | ||
751 | |||
752 | #endregion | ||
753 | |||
754 | #region IHyperlink Misc | ||
755 | |||
756 | protected bool IsComingHome(ForeignUserProfileData userData) | ||
757 | { | ||
758 | return false; | ||
759 | // REFACTORING PROBLEM | ||
760 | //return (userData.UserServerURI == LocalUserServerURI); | ||
761 | } | ||
762 | |||
763 | // REFACTORING PROBLEM | ||
764 | //// Is the user going back to the home region or the home grid? | ||
765 | //protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) | ||
766 | //{ | ||
767 | // if (uinfo == null) | ||
768 | // return false; | ||
769 | |||
770 | // if (uinfo.UserProfile == null) | ||
771 | // return false; | ||
772 | |||
773 | // if (!(uinfo.UserProfile is ForeignUserProfileData)) | ||
774 | // // it's a home user, can't be outside to return home | ||
775 | // return false; | ||
776 | |||
777 | // // OK, it's a foreign user with a ForeignUserProfileData | ||
778 | // // and is going back to exactly the home region. | ||
779 | // // We can't check if it's going back to a non-home region | ||
780 | // // of the home grid. That will be dealt with in the | ||
781 | // // receiving end | ||
782 | // return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); | ||
783 | //} | ||
784 | |||
785 | protected bool IsLocalUser(UserAccount account) | ||
786 | { | ||
787 | return true; | ||
788 | |||
789 | // REFACTORING PROBLEM | ||
790 | //if (account != null && | ||
791 | // account.ServiceURLs.ContainsKey("HomeURI") && | ||
792 | // account.ServiceURLs["HomeURI"] != null) | ||
793 | |||
794 | // return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI); | ||
795 | |||
796 | //return false; | ||
797 | } | ||
798 | |||
799 | |||
800 | protected bool IsLocalRegion(ulong handle) | ||
801 | { | ||
802 | return m_LocalScenes.ContainsKey(handle); | ||
803 | } | ||
804 | |||
805 | private void DumpUserData(ForeignUserProfileData userData) | ||
806 | { | ||
807 | m_log.Info(" ------------ User Data Dump ----------"); | ||
808 | m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); | ||
809 | m_log.Info(" >> HomeID: " + userData.HomeRegionID); | ||
810 | m_log.Info(" >> UserServer: " + userData.UserServerURI); | ||
811 | m_log.Info(" >> InvServer: " + userData.UserInventoryURI); | ||
812 | m_log.Info(" >> AssetServer: " + userData.UserAssetURI); | ||
813 | m_log.Info(" ------------ -------------- ----------"); | ||
814 | } | ||
815 | |||
816 | private void DumpRegionData(GridRegion rinfo) | ||
817 | { | ||
818 | m_log.Info(" ------------ Region Data Dump ----------"); | ||
819 | m_log.Info(" >> handle: " + rinfo.RegionHandle); | ||
820 | m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY); | ||
821 | m_log.Info(" >> external host name: " + rinfo.ExternalHostName); | ||
822 | m_log.Info(" >> http port: " + rinfo.HttpPort); | ||
823 | m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address); | ||
824 | m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port); | ||
825 | m_log.Info(" ------------ -------------- ----------"); | ||
826 | } | ||
827 | |||
828 | |||
829 | #endregion | ||
830 | |||
831 | public List<GridRegion> GetDefaultRegions(UUID scopeID) | 265 | public List<GridRegion> GetDefaultRegions(UUID scopeID) |
832 | { | 266 | { |
833 | return null; | 267 | return m_GridServiceConnector.GetDefaultRegions(scopeID); |
834 | } | 268 | } |
835 | 269 | ||
836 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 270 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
837 | { | 271 | { |
838 | return null; | 272 | return m_GridServiceConnector.GetFallbackRegions(scopeID, x, y); |
839 | } | 273 | } |
840 | 274 | ||
841 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 275 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
842 | { | 276 | { |
843 | return 0; | 277 | return m_GridServiceConnector.GetRegionFlags(scopeID, regionID); |
844 | } | 278 | } |
279 | |||
280 | #endregion | ||
845 | 281 | ||
846 | } | 282 | } |
847 | } | 283 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5654f67..5730b56 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -3157,7 +3157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3157 | agent.AgentID, agent.circuitcode, teleportFlags); | 3157 | agent.AgentID, agent.circuitcode, teleportFlags); |
3158 | 3158 | ||
3159 | reason = String.Empty; | 3159 | reason = String.Empty; |
3160 | if (!AuthenticateUser(agent, out reason)) | 3160 | if (!VerifyUserPresence(agent, out reason)) |
3161 | return false; | 3161 | return false; |
3162 | 3162 | ||
3163 | if (!AuthorizeUser(agent, out reason)) | 3163 | if (!AuthorizeUser(agent, out reason)) |
@@ -3258,30 +3258,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
3258 | } | 3258 | } |
3259 | 3259 | ||
3260 | /// <summary> | 3260 | /// <summary> |
3261 | /// Verifies that the user has a session on the Grid | 3261 | /// Verifies that the user has a presence on the Grid |
3262 | /// </summary> | 3262 | /// </summary> |
3263 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> | 3263 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> |
3264 | /// <param name="reason">Outputs the reason for the false response on this string</param> | 3264 | /// <param name="reason">Outputs the reason for the false response on this string</param> |
3265 | /// <returns>True if the user has a session on the grid. False if it does not. False will | 3265 | /// <returns>True if the user has a session on the grid. False if it does not. False will |
3266 | /// also return a reason.</returns> | 3266 | /// also return a reason.</returns> |
3267 | public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) | 3267 | public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason) |
3268 | { | 3268 | { |
3269 | reason = String.Empty; | 3269 | reason = String.Empty; |
3270 | 3270 | ||
3271 | IAuthenticationService auth = RequestModuleInterface<IAuthenticationService>(); | 3271 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); |
3272 | if (auth == null) | 3272 | if (presence == null) |
3273 | { | 3273 | { |
3274 | reason = String.Format("Failed to authenticate user {0} {1} in region {2}. Authentication service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); | 3274 | reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3275 | return false; | 3275 | return false; |
3276 | } | 3276 | } |
3277 | 3277 | ||
3278 | bool result = auth.Verify(agent.AgentID, agent.SecureSessionID.ToString(), 30); | 3278 | OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); |
3279 | 3279 | ||
3280 | m_log.Debug("[CONNECTION BEGIN]: Session authentication returned " + result); | 3280 | if (pinfo == null || (pinfo != null && pinfo.Online == false)) |
3281 | if (!result) | 3281 | { |
3282 | reason = String.Format("Failed to authenticate user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); | 3282 | reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3283 | return false; | ||
3284 | } | ||
3283 | 3285 | ||
3284 | return result; | 3286 | return true; |
3285 | } | 3287 | } |
3286 | 3288 | ||
3287 | /// <summary> | 3289 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Services/HypergridService/HGCommands.cs index 0974372..10d04ff 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Services/HypergridService/HGCommands.cs | |||
@@ -34,41 +34,52 @@ using Nini.Config; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | //using OpenSim.Framework.Communications; | 35 | //using OpenSim.Framework.Communications; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Region.Framework; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
41 | 39 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 40 | namespace OpenSim.Services.HypergridService |
43 | { | 41 | { |
44 | public class HGCommands | 42 | public class HGCommands |
45 | { | 43 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private HGGridConnector m_HGGridConnector; | 45 | private HypergridService m_HypergridService; |
48 | private Scene m_scene; | ||
49 | 46 | ||
50 | private static uint m_autoMappingX = 0; | 47 | private static uint m_autoMappingX = 0; |
51 | private static uint m_autoMappingY = 0; | 48 | private static uint m_autoMappingY = 0; |
52 | private static bool m_enableAutoMapping = false; | 49 | private static bool m_enableAutoMapping = false; |
53 | 50 | ||
54 | public HGCommands(HGGridConnector hgConnector, Scene scene) | 51 | public HGCommands(HypergridService service) |
55 | { | 52 | { |
56 | m_HGGridConnector = hgConnector; | 53 | m_HypergridService = service; |
57 | m_scene = scene; | ||
58 | } | 54 | } |
59 | 55 | ||
60 | //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, | 56 | public void HandleShow(string module, string[] cmd) |
61 | // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) | 57 | { |
62 | //{ | 58 | if (cmd.Length != 2) |
63 | // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); | 59 | { |
64 | 60 | MainConsole.Instance.Output("Syntax: show hyperlinks"); | |
65 | // return | 61 | return; |
66 | // new HGScene( | 62 | } |
67 | // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, | 63 | List<GridRegion> regions = new List<GridRegion>(m_HypergridService.m_HyperlinkRegions.Values); |
68 | // m_moduleLoader, false, m_configSettings.PhysicalPrim, | 64 | if (regions == null || regions.Count < 1) |
69 | // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | 65 | { |
70 | //} | 66 | MainConsole.Instance.Output("No hyperlinks"); |
67 | return; | ||
68 | } | ||
71 | 69 | ||
70 | MainConsole.Instance.Output("Region Name Region UUID"); | ||
71 | MainConsole.Instance.Output("Location URI"); | ||
72 | MainConsole.Instance.Output("Owner ID Flags"); | ||
73 | MainConsole.Instance.Output("-------------------------------------------------------------------------------"); | ||
74 | foreach (GridRegion r in regions) | ||
75 | { | ||
76 | MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} \n\n", | ||
77 | r.RegionName, r.RegionID, | ||
78 | String.Format("{0},{1}", r.RegionLocX, r.RegionLocY), "http://" + r.ExternalHostName + ":" + r.HttpPort.ToString(), | ||
79 | r.EstateOwner.ToString())); | ||
80 | } | ||
81 | return; | ||
82 | } | ||
72 | public void RunCommand(string module, string[] cmdparams) | 83 | public void RunCommand(string module, string[] cmdparams) |
73 | { | 84 | { |
74 | List<string> args = new List<string>(cmdparams); | 85 | List<string> args = new List<string>(cmdparams); |
@@ -133,13 +144,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
133 | for (int i = 3; i < cmdparams.Length; i++) | 144 | for (int i = 3; i < cmdparams.Length; i++) |
134 | mapName += " " + cmdparams[i]; | 145 | mapName += " " + cmdparams[i]; |
135 | 146 | ||
136 | m_log.Info(">> MapName: " + mapName); | 147 | //m_log.Info(">> MapName: " + mapName); |
137 | //internalPort = Convert.ToUInt32(cmdparams[4]); | ||
138 | //remotingPort = Convert.ToUInt32(cmdparams[5]); | ||
139 | } | 148 | } |
140 | catch (Exception e) | 149 | catch (Exception e) |
141 | { | 150 | { |
142 | m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); | 151 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); |
143 | LinkRegionCmdUsage(); | 152 | LinkRegionCmdUsage(); |
144 | return; | 153 | return; |
145 | } | 154 | } |
@@ -147,7 +156,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
147 | // Convert cell coordinates given by the user to meters | 156 | // Convert cell coordinates given by the user to meters |
148 | xloc = xloc * (int)Constants.RegionSize; | 157 | xloc = xloc * (int)Constants.RegionSize; |
149 | yloc = yloc * (int)Constants.RegionSize; | 158 | yloc = yloc * (int)Constants.RegionSize; |
150 | m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); | 159 | string reason = string.Empty; |
160 | if (m_HypergridService.TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) | ||
161 | MainConsole.Instance.Output("Failed to link region: " + reason); | ||
151 | } | 162 | } |
152 | else | 163 | else |
153 | { | 164 | { |
@@ -167,7 +178,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
167 | } | 178 | } |
168 | catch (Exception e) | 179 | catch (Exception e) |
169 | { | 180 | { |
170 | m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); | 181 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); |
171 | LinkRegionCmdUsage(); | 182 | LinkRegionCmdUsage(); |
172 | return; | 183 | return; |
173 | } | 184 | } |
@@ -175,7 +186,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
175 | // Convert cell coordinates given by the user to meters | 186 | // Convert cell coordinates given by the user to meters |
176 | xloc = xloc * (int)Constants.RegionSize; | 187 | xloc = xloc * (int)Constants.RegionSize; |
177 | yloc = yloc * (int)Constants.RegionSize; | 188 | yloc = yloc * (int)Constants.RegionSize; |
178 | if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) | 189 | string reason = string.Empty; |
190 | if (m_HypergridService.TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) | ||
179 | { | 191 | { |
180 | if (cmdparams.Length >= 5) | 192 | if (cmdparams.Length >= 5) |
181 | { | 193 | { |
@@ -194,10 +206,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
194 | UnlinkRegionCmdUsage(); | 206 | UnlinkRegionCmdUsage(); |
195 | return; | 207 | return; |
196 | } | 208 | } |
197 | if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0])) | 209 | if (m_HypergridService.TryUnlinkRegion(cmdparams[0])) |
198 | m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); | 210 | MainConsole.Instance.Output("Successfully unlinked " + cmdparams[0]); |
199 | else | 211 | else |
200 | m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); | 212 | MainConsole.Instance.Output("Unable to unlink " + cmdparams[0] + ", region not found."); |
201 | } | 213 | } |
202 | } | 214 | } |
203 | 215 | ||
@@ -276,27 +288,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
276 | { | 288 | { |
277 | xloc = xloc * (int)Constants.RegionSize; | 289 | xloc = xloc * (int)Constants.RegionSize; |
278 | yloc = yloc * (int)Constants.RegionSize; | 290 | yloc = yloc * (int)Constants.RegionSize; |
279 | if ( | 291 | string reason = string.Empty; |
280 | m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, | 292 | if (m_HypergridService.TryCreateLink(xloc, yloc, "", externalPort, |
281 | externalHostName, out regInfo)) | 293 | externalHostName, out regInfo, out reason)) |
282 | { | 294 | { |
283 | regInfo.RegionName = config.GetString("localName", ""); | 295 | regInfo.RegionName = config.GetString("localName", ""); |
284 | } | 296 | } |
297 | else | ||
298 | MainConsole.Instance.Output("Unable to link " + externalHostName + ": " + reason); | ||
285 | } | 299 | } |
286 | } | 300 | } |
287 | 301 | ||
288 | 302 | ||
289 | private void LinkRegionCmdUsage() | 303 | private void LinkRegionCmdUsage() |
290 | { | 304 | { |
291 | m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); | 305 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); |
292 | m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); | 306 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); |
293 | m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]"); | 307 | MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]"); |
294 | } | 308 | } |
295 | 309 | ||
296 | private void UnlinkRegionCmdUsage() | 310 | private void UnlinkRegionCmdUsage() |
297 | { | 311 | { |
298 | m_log.Info("Usage: unlink-region <HostName>:<HttpPort>"); | 312 | MainConsole.Instance.Output("Usage: unlink-region <HostName>:<HttpPort>"); |
299 | m_log.Info("Usage: unlink-region <LocalName>"); | 313 | MainConsole.Instance.Output("Usage: unlink-region <LocalName>"); |
300 | } | 314 | } |
301 | 315 | ||
302 | } | 316 | } |