aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2010-01-16 21:42:44 -0800
committerDiva Canto2010-01-16 21:42:44 -0800
commit04e29c1bacbc1e2df980ae15896a847ce7535da2 (patch)
treee799d2837af1a41bc2c3b2d571201e9a8a6d7ae7
parentFinished moving object crossings into EntityTransferModule (diff)
downloadopensim-SC_OLD-04e29c1bacbc1e2df980ae15896a847ce7535da2.zip
opensim-SC_OLD-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.gz
opensim-SC_OLD-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.bz2
opensim-SC_OLD-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.xz
Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet.
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs650
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs24
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs140
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs245
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs167
-rw-r--r--OpenSim/Services/HypergridService/HGCommands.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs)90
-rw-r--r--OpenSim/Services/HypergridService/HypergridService.cs415
-rw-r--r--OpenSim/Services/HypergridService/HypergridServiceBase.cs84
-rw-r--r--OpenSim/Services/Interfaces/IGatekeeperService.cs13
-rw-r--r--OpenSim/Services/Interfaces/IHypergridService.cs47
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs2
-rw-r--r--bin/config-include/StandaloneHypergrid.ini13
-rw-r--r--prebuild.xml32
16 files changed, 1278 insertions, 668 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;
36using OpenSim.Region.Framework.Interfaces; 36using 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.Hypergrid;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using 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
50namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 50namespace 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/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
new file mode 100644
index 0000000..ec8dde4
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
@@ -0,0 +1,140 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Server.Handlers.Hypergrid
46{
47 public class GatekeeperServiceInConnector : ServiceConnector
48 {
49 private static readonly ILog m_log =
50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 private IGatekeeperService m_GatekeeperService;
54
55 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
56 base(config, server, String.Empty)
57 {
58 IConfig gridConfig = config.Configs["GatekeeperService"];
59 if (gridConfig != null)
60 {
61 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
62 Object[] args = new Object[] { config, simService };
63 m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(serviceDll, args);
64 }
65 if (m_GatekeeperService == null)
66 throw new Exception("Gatekeeper server connector cannot proceed because of missing service");
67
68 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
69 server.AddXmlRPCHandler("get_region", GetRegion, false);
70 }
71
72 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server)
73 : this(config, server, null)
74 {
75 }
76
77 /// <summary>
78 /// Someone wants to link to us
79 /// </summary>
80 /// <param name="request"></param>
81 /// <returns></returns>
82 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
83 {
84 Hashtable requestData = (Hashtable)request.Params[0];
85 //string host = (string)requestData["host"];
86 //string portstr = (string)requestData["port"];
87 string name = (string)requestData["region_name"];
88
89 m_log.DebugFormat("[HGrid]: Hyperlink request");
90
91 UUID regionID = UUID.Zero;
92 string imageURL = string.Empty;
93 ulong regionHandle = 0;
94 string reason = string.Empty;
95
96 bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason);
97
98 Hashtable hash = new Hashtable();
99 hash["result"] = success.ToString();
100 hash["uuid"] = regionID.ToString();
101 hash["handle"] = regionHandle.ToString();
102 hash["region_image"] = imageURL;
103
104 XmlRpcResponse response = new XmlRpcResponse();
105 response.Value = hash;
106 return response;
107 }
108
109 public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
110 {
111 Hashtable requestData = (Hashtable)request.Params[0];
112 //string host = (string)requestData["host"];
113 //string portstr = (string)requestData["port"];
114 string regionID_str = (string)requestData["regionID"];
115 UUID regionID = UUID.Zero;
116 UUID.TryParse(regionID_str, out regionID);
117
118 GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID);
119
120 Hashtable hash = new Hashtable();
121 if (regInfo == null)
122 hash["result"] = "false";
123 else
124 {
125 hash["result"] = "true";
126 hash["uuid"] = regInfo.RegionID.ToString();
127 hash["x"] = regInfo.RegionLocX.ToString();
128 hash["y"] = regInfo.RegionLocY.ToString();
129 hash["region_name"] = regInfo.RegionName;
130 hash["hostname"] = regInfo.ExternalHostName;
131 hash["http_port"] = regInfo.HttpPort.ToString();
132 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
133 }
134 XmlRpcResponse response = new XmlRpcResponse();
135 response.Value = hash;
136 return response;
137
138 }
139 }
140}
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index 7098b07..8b39171 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -55,6 +55,14 @@ namespace OpenSim.Services.Connectors.Grid
55 m_AssetService = assService; 55 m_AssetService = assService;
56 } 56 }
57 57
58 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong regionHandle, out string reason)
59 {
60 regionID = LinkRegion(info, out regionHandle);
61 // reason...
62 reason = string.Empty;
63 return true;
64 }
65
58 public UUID LinkRegion(GridRegion info, out ulong realHandle) 66 public UUID LinkRegion(GridRegion info, out ulong realHandle)
59 { 67 {
60 UUID uuid = UUID.Zero; 68 UUID uuid = UUID.Zero;
diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..460acae
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
@@ -0,0 +1,245 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Hypergrid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
59 {
60 regionID = UUID.Zero;
61 imageURL = string.Empty;
62 realHandle = 0;
63 reason = string.Empty;
64
65 Hashtable hash = new Hashtable();
66 hash["region_name"] = info.RegionName;
67
68 IList paramList = new ArrayList();
69 paramList.Add(hash);
70
71 XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
72 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
73 m_log.Debug("[HGrid]: Linking to " + uri);
74 XmlRpcResponse response = null;
75 try
76 {
77 response = request.Send(uri, 10000);
78 }
79 catch (Exception e)
80 {
81 m_log.Debug("[HGrid]: Exception " + e.Message);
82 reason = "Error contacting remote server";
83 return false;
84 }
85
86 if (response.IsFault)
87 {
88 reason = response.FaultString;
89 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
90 return false;
91 }
92
93 hash = (Hashtable)response.Value;
94 //foreach (Object o in hash)
95 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
96 try
97 {
98 bool success = false;
99 Boolean.TryParse((string)hash["result"], out success);
100 if (success)
101 {
102 UUID.TryParse((string)hash["uuid"], out regionID);
103 //m_log.Debug(">> HERE, uuid: " + uuid);
104 if ((string)hash["handle"] != null)
105 {
106 realHandle = Convert.ToUInt64((string)hash["handle"]);
107 //m_log.Debug(">> HERE, realHandle: " + realHandle);
108 }
109 if (hash["region_image"] != null)
110 {
111 imageURL = (string)hash["region_image"];
112 }
113 }
114
115 }
116 catch (Exception e)
117 {
118 reason = "Error parsing return arguments";
119 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
120 return false;
121 }
122
123 return true;
124 }
125
126 public UUID GetMapImage(UUID regionID, string imageURL)
127 {
128 try
129 {
130
131 WebClient c = new WebClient();
132 //m_log.Debug("JPEG: " + uri);
133 string filename = regionID.ToString();
134 c.DownloadFile(imageURL, filename + ".jpg");
135 Bitmap m = new Bitmap(filename + ".jpg");
136 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
137 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
138 AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture);
139
140 // !!! for now
141 //info.RegionSettings.TerrainImageID = ass.FullID;
142
143 ass.Temporary = true;
144 ass.Local = true;
145 ass.Data = imageData;
146
147 m_AssetService.Store(ass);
148
149 // finally
150 return ass.FullID;
151
152 }
153 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
154 {
155 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
156 }
157 return UUID.Zero;
158 }
159
160 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID)
161 {
162 Hashtable hash = new Hashtable();
163 hash["region_uuid"] = regionID.ToString();
164
165 IList paramList = new ArrayList();
166 paramList.Add(hash);
167
168 XmlRpcRequest request = new XmlRpcRequest("get_region", paramList);
169 string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/";
170 m_log.Debug("[HGrid]: contacting " + uri);
171 XmlRpcResponse response = null;
172 try
173 {
174 response = request.Send(uri, 10000);
175 }
176 catch (Exception e)
177 {
178 m_log.Debug("[HGrid]: Exception " + e.Message);
179 return null;
180 }
181
182 if (response.IsFault)
183 {
184 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
185 return null;
186 }
187
188 hash = (Hashtable)response.Value;
189 //foreach (Object o in hash)
190 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
191 try
192 {
193 bool success = false;
194 Boolean.TryParse((string)hash["result"], out success);
195 if (success)
196 {
197 GridRegion region = new GridRegion();
198
199 UUID.TryParse((string)hash["uuid"], out region.RegionID);
200 //m_log.Debug(">> HERE, uuid: " + uuid);
201 int n = 0;
202 if (hash["x"] != null)
203 {
204 Int32.TryParse((string)hash["x"], out n);
205 region.RegionLocX = n;
206 }
207 if (hash["y"] != null)
208 {
209 Int32.TryParse((string)hash["y"], out n);
210 region.RegionLocY = n;
211 }
212 if (hash["region_name"] != null)
213 {
214 region.RegionName = (string)hash["region_name"];
215 }
216 if (hash["hostname"] != null)
217 region.ExternalHostName = (string)hash["hostname"];
218 if (hash["http_port"] != null)
219 {
220 uint p = 0;
221 UInt32.TryParse((string)hash["http_port"], out p);
222 region.HttpPort = p;
223 }
224 if (hash["internal_port"] != null)
225 {
226 int p = 0;
227 Int32.TryParse((string)hash["internal_port"], out p);
228 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
229 }
230
231 // Successful return
232 return region;
233 }
234
235 }
236 catch (Exception e)
237 {
238 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
239 return null;
240 }
241
242 return null;
243 }
244 }
245}
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
new file mode 100644
index 0000000..174174c
--- /dev/null
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -0,0 +1,167 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Framework;
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8using OpenSim.Server.Base;
9
10using OpenMetaverse;
11
12using Nini.Config;
13using log4net;
14
15namespace OpenSim.Services.HypergridService
16{
17 public class GatekeeperService : IGatekeeperService
18 {
19 private static readonly ILog m_log =
20 LogManager.GetLogger(
21 MethodBase.GetCurrentMethod().DeclaringType);
22
23 IGridService m_GridService;
24 IPresenceService m_PresenceService;
25 IAuthenticationService m_AuthenticationService;
26 IUserAccountService m_UserAccountService;
27 ISimulationService m_SimulationService;
28
29 string m_AuthDll;
30
31 UUID m_ScopeID;
32 bool m_AllowTeleportsToAnyRegion;
33 GridRegion m_DefaultGatewayRegion;
34
35 public GatekeeperService(IConfigSource config, ISimulationService simService)
36 {
37 IConfig serverConfig = config.Configs["GatekeeperService"];
38 if (serverConfig == null)
39 throw new Exception(String.Format("No section GatekeeperService in config file"));
40
41 string accountService = serverConfig.GetString("UserAccountService", String.Empty);
42 string gridService = serverConfig.GetString("GridService", String.Empty);
43 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
44 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
45
46 m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty);
47
48 if (accountService == string.Empty || gridService == string.Empty ||
49 presenceService == string.Empty || m_AuthDll == string.Empty)
50 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
51
52 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
53 UUID.TryParse(scope, out m_ScopeID);
54 //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
55 m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true);
56
57 Object[] args = new Object[] { config };
58 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
59 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
60 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
61 if (simService != null)
62 m_SimulationService = simService;
63 else if (simulationService != string.Empty)
64 m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
65
66 if (m_UserAccountService == null || m_GridService == null ||
67 m_PresenceService == null || m_SimulationService == null)
68 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
69
70 m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
71 }
72
73 public GatekeeperService(IConfigSource config)
74 : this(config, null)
75 {
76 }
77
78 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason)
79 {
80 regionID = m_DefaultGatewayRegion.RegionID;
81 regionHandle = m_DefaultGatewayRegion.RegionHandle;
82 imageURL = string.Empty;
83 reason = string.Empty;
84
85 if (!m_AllowTeleportsToAnyRegion)
86 {
87 regionID = m_DefaultGatewayRegion.RegionID;
88 regionHandle = m_DefaultGatewayRegion.RegionHandle;
89 if (regionName != string.Empty)
90 {
91 reason = "Direct links to regions not allowed";
92 return false;
93 }
94
95 return true;
96 }
97
98 GridRegion region = m_GridService.GetRegionByName(m_ScopeID, regionName);
99 if (region == null)
100 {
101 reason = "Region not found";
102 return false;
103 }
104
105 regionID = region.RegionID;
106 regionHandle = region.RegionHandle;
107 string regionimage = "regionImage" + region.RegionID.ToString();
108 regionimage = regionimage.Replace("-", "");
109
110 imageURL = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/index.php?method=" + regionimage;
111
112 return true;
113 }
114
115 public GridRegion GetHyperlinkRegion(UUID regionID)
116 {
117 if (!m_AllowTeleportsToAnyRegion)
118 // Don't even check the given regionID
119 return m_DefaultGatewayRegion;
120
121 GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID);
122 return region;
123 }
124
125 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination)
126 {
127 if (!Authenticate(aCircuit))
128 return false;
129
130 // Check to see if we have a local user with that UUID
131 UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
132 if (account != null)
133 // No, sorry; go away
134 return false;
135
136 // May want to authorize
137
138 // Login the presence
139 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
140 return false;
141
142 // Finally launch the agent at the destination
143 string reason = string.Empty;
144 return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason);
145 }
146
147 public bool LoginAttachments(ISceneObject sog, GridRegion destination)
148 {
149 // May want to filter attachments
150 return m_SimulationService.CreateObject(destination, sog, false);
151 }
152
153 protected bool Authenticate(AgentCircuitData aCircuit)
154 {
155 string authURL = string.Empty; // GetAuthURL(aCircuit);
156 if (authURL == string.Empty)
157 return false;
158
159 Object[] args = new Object[] { authURL };
160 IAuthenticationService authService = ServerUtils.LoadPlugin<IAuthenticationService>(m_AuthDll, args);
161 if (authService != null)
162 return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30);
163
164 return false;
165 }
166 }
167}
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;
34using OpenSim.Framework; 34using OpenSim.Framework;
35//using OpenSim.Framework.Communications; 35//using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework; 37using OpenSim.Services.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion; 38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 39
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 40namespace 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 }
diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs
new file mode 100644
index 0000000..747b98a
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HypergridService.cs
@@ -0,0 +1,415 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data;
37using OpenSim.Server.Base;
38using OpenSim.Services.Interfaces;
39using OpenSim.Services.Connectors.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenMetaverse;
42
43namespace OpenSim.Services.HypergridService
44{
45 public class HypergridService : HypergridServiceBase, IHypergridService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private static HypergridService m_RootInstance = null;
52 protected IConfigSource m_config;
53
54 protected IAuthenticationService m_AuthenticationService = null;
55 protected IGridService m_GridService;
56 protected IAssetService m_AssetService;
57 protected HypergridServiceConnector m_HypergridConnector;
58
59 protected bool m_AllowDuplicateNames = false;
60 protected UUID m_ScopeID = UUID.Zero;
61
62 // Hyperlink regions are hyperlinks on the map
63 public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
64 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
65
66 protected GridRegion m_DefaultRegion;
67 protected GridRegion DefaultRegion
68 {
69 get
70 {
71 if (m_DefaultRegion == null)
72 {
73 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
74 if (defs != null && defs.Count > 0)
75 m_DefaultRegion = defs[0];
76 else
77 {
78 // Best guess, may be totally off
79 m_DefaultRegion = new GridRegion(1000, 1000);
80 m_log.WarnFormat("[HYPERGRID SERVICE]: This grid does not have a default region. Assuming default coordinates at 1000, 1000.");
81 }
82 }
83 return m_DefaultRegion;
84 }
85 }
86
87 public HypergridService(IConfigSource config)
88 : base(config)
89 {
90 m_log.DebugFormat("[HYPERGRID SERVICE]: Starting...");
91
92 m_config = config;
93 IConfig gridConfig = config.Configs["HypergridService"];
94 if (gridConfig != null)
95 {
96 string gridService = gridConfig.GetString("GridService", string.Empty);
97 string authService = gridConfig.GetString("AuthenticationService", String.Empty);
98 string assetService = gridConfig.GetString("AssetService", string.Empty);
99
100 Object[] args = new Object[] { config };
101 if (gridService != string.Empty)
102 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
103
104 if (m_GridService == null)
105 throw new Exception("HypergridService cannot function without a GridService");
106
107 if (authService != String.Empty)
108 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
109
110 if (assetService != string.Empty)
111 m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);
112
113 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
114
115 string scope = gridConfig.GetString("ScopeID", string.Empty);
116 if (scope != string.Empty)
117 UUID.TryParse(scope, out m_ScopeID);
118
119 m_HypergridConnector = new HypergridServiceConnector(m_AssetService);
120
121 m_log.DebugFormat("[HYPERGRID SERVICE]: Loaded all services...");
122 }
123
124 if (m_RootInstance == null)
125 {
126 m_RootInstance = this;
127
128 HGCommands hgCommands = new HGCommands(this);
129 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
130 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
131 "Link a hypergrid region", hgCommands.RunCommand);
132 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
133 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
134 "Unlink a hypergrid region", hgCommands.RunCommand);
135 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
136 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
137 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
138 "List the HG regions", hgCommands.HandleShow);
139 }
140 }
141
142 #region Link Region
143
144 public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason)
145 {
146 regionID = UUID.Zero;
147 imageURL = string.Empty;
148 regionHandle = 0;
149 reason = string.Empty;
150 int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize;
151 GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason);
152 if (region == null)
153 return false;
154
155 regionID = region.RegionID;
156 regionHandle = region.RegionHandle;
157 return true;
158 }
159
160 private static Random random = new Random();
161
162 // From the command line link-region
163 public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason)
164 {
165 reason = string.Empty;
166 string host = "127.0.0.1";
167 string portstr;
168 string regionName = "";
169 uint port = 9000;
170 string[] parts = mapName.Split(new char[] { ':' });
171 if (parts.Length >= 1)
172 {
173 host = parts[0];
174 }
175 if (parts.Length >= 2)
176 {
177 portstr = parts[1];
178 //m_log.Debug("-- port = " + portstr);
179 if (!UInt32.TryParse(portstr, out port))
180 regionName = parts[1];
181 }
182 // always take the last one
183 if (parts.Length >= 3)
184 {
185 regionName = parts[2];
186 }
187
188 // Sanity check. Don't ever link to this sim.
189 IPAddress ipaddr = null;
190 try
191 {
192 ipaddr = Util.GetHostFromDNS(host);
193 }
194 catch { }
195
196 GridRegion regInfo;
197 bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason);
198 if (success)
199 {
200 regInfo.RegionName = mapName;
201 return regInfo;
202 }
203
204 return null;
205 }
206
207
208 // From the command line and the 2 above
209 public bool TryCreateLink(int xloc, int yloc,
210 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason)
211 {
212 m_log.DebugFormat("[HYPERGRID SERVICE]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
213
214 reason = string.Empty;
215 regInfo = new GridRegion();
216 regInfo.RegionName = externalRegionName;
217 regInfo.HttpPort = externalPort;
218 regInfo.ExternalHostName = externalHostName;
219 regInfo.RegionLocX = xloc;
220 regInfo.RegionLocY = yloc;
221
222 try
223 {
224 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
225 }
226 catch (Exception e)
227 {
228 m_log.Warn("[HYPERGRID SERVICE]: Wrong format for link-region: " + e.Message);
229 reason = "Internal error";
230 return false;
231 }
232
233 // Finally, link it
234 ulong handle = 0;
235 UUID regionID = UUID.Zero;
236 string imageURL = string.Empty;
237 if (!m_HypergridConnector.LinkRegion(regInfo, out regionID, out handle, out imageURL, out reason))
238 return false;
239
240 if (regionID != UUID.Zero)
241 {
242 regInfo.RegionID = regionID;
243
244 AddHyperlinkRegion(regInfo, handle);
245 m_log.Info("[HYPERGRID SERVICE]: Successfully linked to region_uuid " + regInfo.RegionID);
246
247 // Try get the map image
248 regInfo.TerrainImage = m_HypergridConnector.GetMapImage(regionID, imageURL);
249 }
250 else
251 {
252 m_log.Warn("[HYPERGRID SERVICE]: Unable to link region");
253 reason = "Remote region could not be found";
254 return false;
255 }
256
257 uint x, y;
258 if (!Check4096(regInfo, out x, out y))
259 {
260 RemoveHyperlinkRegion(regInfo.RegionID);
261 reason = "Region is too far (" + x + ", " + y + ")";
262 m_log.Info("[HYPERGRID SERVICE]: Unable to link, region is too far (" + x + ", " + y + ")");
263 return false;
264 }
265
266 m_log.Debug("[HYPERGRID SERVICE]: link region succeeded");
267 return true;
268 }
269
270 public bool TryUnlinkRegion(string mapName)
271 {
272 GridRegion regInfo = null;
273 if (mapName.Contains(":"))
274 {
275 string host = "127.0.0.1";
276 //string portstr;
277 //string regionName = "";
278 uint port = 9000;
279 string[] parts = mapName.Split(new char[] { ':' });
280 if (parts.Length >= 1)
281 {
282 host = parts[0];
283 }
284
285 foreach (GridRegion r in m_HyperlinkRegions.Values)
286 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
287 regInfo = r;
288 }
289 else
290 {
291 foreach (GridRegion r in m_HyperlinkRegions.Values)
292 if (r.RegionName.Equals(mapName))
293 regInfo = r;
294 }
295 if (regInfo != null)
296 {
297 RemoveHyperlinkRegion(regInfo.RegionID);
298 return true;
299 }
300 else
301 {
302 m_log.InfoFormat("[HYPERGRID SERVICE]: Region {0} not found", mapName);
303 return false;
304 }
305 }
306
307 /// <summary>
308 /// Cope with this viewer limitation.
309 /// </summary>
310 /// <param name="regInfo"></param>
311 /// <returns></returns>
312 public bool Check4096(GridRegion regInfo, out uint x, out uint y)
313 {
314 GridRegion defRegion = DefaultRegion;
315
316 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
317 uint ux = 0, uy = 0;
318 Utils.LongToUInts(realHandle, out ux, out uy);
319 x = ux / Constants.RegionSize;
320 y = uy / Constants.RegionSize;
321
322 if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) ||
323 (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize))
324 {
325 return false;
326 }
327 return true;
328 }
329
330 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
331 {
332 m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
333 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
334 }
335
336 private void RemoveHyperlinkRegion(UUID regionID)
337 {
338 // Try the hyperlink collection
339 if (m_HyperlinkRegions.ContainsKey(regionID))
340 {
341 m_HyperlinkRegions.Remove(regionID);
342 m_HyperlinkHandles.Remove(regionID);
343 }
344 }
345
346 #endregion
347
348 #region Get Hyperlinks
349
350 public GridRegion GetHyperlinkRegion(UUID regionID)
351 {
352 //GridRegion region = m_HypergridConnector.
353 return null;
354 }
355
356 #endregion
357
358 #region GetRegionBy X
359
360 public GridRegion GetRegionByUUID(UUID regionID)
361 {
362 if (m_HyperlinkRegions.ContainsKey(regionID))
363 return m_HyperlinkRegions[regionID];
364
365 return null;
366 }
367
368 public GridRegion GetRegionByPosition(int x, int y)
369 {
370 foreach (GridRegion r in m_HyperlinkRegions.Values)
371 if (r.RegionLocX == x && r.RegionLocY == y)
372 return r;
373
374 return null;
375 }
376
377 public GridRegion GetRegionByName(string name)
378 {
379 foreach (GridRegion r in m_HyperlinkRegions.Values)
380 if (r.RegionName.ToLower() == name.ToLower())
381 return r;
382
383 return null;
384 }
385
386 public List<GridRegion> GetRegionsByName(string name)
387 {
388 List<GridRegion> regions = new List<GridRegion>();
389
390 foreach (GridRegion r in m_HyperlinkRegions.Values)
391 if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower()))
392 regions.Add(r);
393
394 return regions;
395
396 }
397
398 public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax)
399 {
400 List<GridRegion> regions = new List<GridRegion>();
401
402 foreach (GridRegion r in m_HyperlinkRegions.Values)
403 if ((r.RegionLocX > xmin) && (r.RegionLocX < xmax) &&
404 (r.RegionLocY > ymin) && (r.RegionLocY < ymax))
405 regions.Add(r);
406
407 return regions;
408 }
409
410 #endregion
411
412
413
414 }
415}
diff --git a/OpenSim/Services/HypergridService/HypergridServiceBase.cs b/OpenSim/Services/HypergridService/HypergridServiceBase.cs
new file mode 100644
index 0000000..4f91f64
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HypergridServiceBase.cs
@@ -0,0 +1,84 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace OpenSim.Services.HypergridService
37{
38 public class HypergridServiceBase : ServiceBase
39 {
40 protected IRegionData m_Database = null;
41
42 public HypergridServiceBase(IConfigSource config)
43 : base(config)
44 {
45 string dllName = String.Empty;
46 string connString = String.Empty;
47 string realm = "TBD";
48
49 //
50 // Try reading the [DatabaseService] section, if it exists
51 //
52 IConfig dbConfig = config.Configs["DatabaseService"];
53 if (dbConfig != null)
54 {
55 if (dllName == String.Empty)
56 dllName = dbConfig.GetString("StorageProvider", String.Empty);
57 if (connString == String.Empty)
58 connString = dbConfig.GetString("ConnectionString", String.Empty);
59 }
60
61 //
62 // [HypergridService] section overrides [DatabaseService], if it exists
63 //
64 IConfig gridConfig = config.Configs["HypergridService"];
65 if (gridConfig != null)
66 {
67 dllName = gridConfig.GetString("StorageProvider", dllName);
68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm);
70 }
71
72 ////
73 //// We tried, but this doesn't exist. We can't proceed.
74 ////
75 //if (dllName.Equals(String.Empty))
76 // throw new Exception("No StorageProvider configured");
77
78 //m_Database = LoadPlugin<IRegionData>(dllName, new Object[] { connString, realm });
79 //if (m_Database == null)
80 // throw new Exception("Could not find a storage interface in the given module");
81
82 }
83 }
84}
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
new file mode 100644
index 0000000..c4d1cbf
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -0,0 +1,13 @@
1using System;
2using System.Collections.Generic;
3
4using OpenMetaverse;
5
6namespace OpenSim.Services.Interfaces
7{
8 public interface IGatekeeperService
9 {
10 bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason);
11 GridRegion GetHyperlinkRegion(UUID regionID);
12 }
13}
diff --git a/OpenSim/Services/Interfaces/IHypergridService.cs b/OpenSim/Services/Interfaces/IHypergridService.cs
new file mode 100644
index 0000000..b49657a
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IHypergridService.cs
@@ -0,0 +1,47 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using OpenSim.Framework;
30using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31
32using OpenMetaverse;
33
34namespace OpenSim.Services.Interfaces
35{
36 public interface IHypergridService
37 {
38 bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason);
39 GridRegion GetHyperlinkRegion(UUID regionID);
40
41 GridRegion GetRegionByUUID(UUID regionID);
42 GridRegion GetRegionByPosition(int x, int y);
43 GridRegion GetRegionByName(string name);
44 List<GridRegion> GetRegionsByName(string name);
45 List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax);
46 }
47}
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 85031f7..076cb7a 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Tests.Common.Mock
56 /// 56 ///
57 /// <param name="agent"></param> 57 /// <param name="agent"></param>
58 /// <returns></returns> 58 /// <returns></returns>
59 public override bool AuthenticateUser(AgentCircuitData agent, out string reason) 59 public override bool VerifyUserPresence(AgentCircuitData agent, out string reason)
60 { 60 {
61 reason = String.Empty; 61 reason = String.Empty;
62 return true; 62 return true;
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index 7f44bb7..cd09091 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -63,9 +63,22 @@
63[GridService] 63[GridService]
64 ; for the HGGridServicesConnector to instantiate 64 ; for the HGGridServicesConnector to instantiate
65 GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector" 65 GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector"
66 HypergridService = "OpenSim.Services.HypergridService.dll:HypergridService"
66 ; LocalGridServicesConnector needs this 67 ; LocalGridServicesConnector needs this
67 LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" 68 LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
68 Realm = "regions" 69 Realm = "regions"
70
71[HypergridService]
72 GridService = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector"
73 AssetService = "OpenSim.Services.AssetService.dll:AssetService"
74
75[GatekeeperService]
76 LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService"
77 ;; for the service
78 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
79 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
80 GridService = "OpenSim.Services.GridService.dll:GridService"
81 AuthenticationService = "OpenSim.Services.Connectors.dll:AuthenticationServicesConnector"
69 82
70[PresenceService] 83[PresenceService]
71 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" 84 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService"
diff --git a/prebuild.xml b/prebuild.xml
index 284913a..a3b4a53 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1193,6 +1193,38 @@
1193 </Files> 1193 </Files>
1194 </Project> 1194 </Project>
1195 1195
1196 <Project frameworkVersion="v3_5" name="OpenSim.Services.HypergridService" path="OpenSim/Services/HypergridService" type="Library">
1197 <Configuration name="Debug">
1198 <Options>
1199 <OutputPath>../../../bin/</OutputPath>
1200 </Options>
1201 </Configuration>
1202 <Configuration name="Release">
1203 <Options>
1204 <OutputPath>../../../bin/</OutputPath>
1205 </Options>
1206 </Configuration>
1207
1208 <ReferencePath>../../../bin/</ReferencePath>
1209 <Reference name="System"/>
1210 <Reference name="System.Xml"/>
1211 <Reference name="OpenMetaverseTypes.dll"/>
1212 <Reference name="OpenMetaverse.dll"/>
1213 <Reference name="OpenSim.Framework"/>
1214 <Reference name="OpenSim.Framework.Console"/>
1215 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
1216 <Reference name="OpenSim.Services.Interfaces"/>
1217 <Reference name="OpenSim.Services.Base"/>
1218 <Reference name="OpenSim.Services.Connectors"/>
1219 <Reference name="OpenSim.Data"/>
1220 <Reference name="OpenSim.Server.Base"/>
1221 <Reference name="Nini.dll" />
1222 <Reference name="log4net.dll"/>
1223
1224 <Files>
1225 <Match pattern="*.cs" recurse="true"/>
1226 </Files>
1227 </Project>
1196 1228
1197 1229
1198 <Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers" path="OpenSim/Server/Handlers" type="Library"> 1230 <Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers" path="OpenSim/Server/Handlers" type="Library">