aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginService.cs
diff options
context:
space:
mode:
authorDiva Canto2010-01-28 19:19:42 -0800
committerDiva Canto2010-01-28 19:19:42 -0800
commit00f7d622cbc2c2e61d2efaacd8275da3f9821d8b (patch)
tree1bfc6dd3ac2a93443bc75baa03ceefba4cfacc1e /OpenSim/Services/LLLoginService/LLLoginService.cs
parentAdded ExternalName config on Gatekeeper. (diff)
downloadopensim-SC_OLD-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.zip
opensim-SC_OLD-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.gz
opensim-SC_OLD-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.bz2
opensim-SC_OLD-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.xz
HG 1.5 is in place. Tested in standalone only.
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginService.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs224
1 files changed, 174 insertions, 50 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index d4f89d9..cacedf8 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -14,6 +14,7 @@ using OpenSim.Framework.Console;
14using OpenSim.Server.Base; 14using OpenSim.Server.Base;
15using OpenSim.Services.Interfaces; 15using OpenSim.Services.Interfaces;
16using GridRegion = OpenSim.Services.Interfaces.GridRegion; 16using GridRegion = OpenSim.Services.Interfaces.GridRegion;
17using OpenSim.Services.Connectors.Hypergrid;
17 18
18namespace OpenSim.Services.LLLoginService 19namespace OpenSim.Services.LLLoginService
19{ 20{
@@ -31,11 +32,15 @@ namespace OpenSim.Services.LLLoginService
31 private ISimulationService m_RemoteSimulationService; 32 private ISimulationService m_RemoteSimulationService;
32 private ILibraryService m_LibraryService; 33 private ILibraryService m_LibraryService;
33 private IAvatarService m_AvatarService; 34 private IAvatarService m_AvatarService;
35 private IUserAgentService m_UserAgentService;
36
37 private GatekeeperServiceConnector m_GatekeeperConnector;
34 38
35 private string m_DefaultRegionName; 39 private string m_DefaultRegionName;
36 private string m_WelcomeMessage; 40 private string m_WelcomeMessage;
37 private bool m_RequireInventory; 41 private bool m_RequireInventory;
38 private int m_MinLoginLevel; 42 private int m_MinLoginLevel;
43 private string m_GatekeeperURL;
39 44
40 IConfig m_LoginServerConfig; 45 IConfig m_LoginServerConfig;
41 46
@@ -46,6 +51,7 @@ namespace OpenSim.Services.LLLoginService
46 throw new Exception(String.Format("No section LoginService in config file")); 51 throw new Exception(String.Format("No section LoginService in config file"));
47 52
48 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty); 53 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty);
54 string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty);
49 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty); 55 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty);
50 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty); 56 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty);
51 string gridService = m_LoginServerConfig.GetString("GridService", String.Empty); 57 string gridService = m_LoginServerConfig.GetString("GridService", String.Empty);
@@ -57,6 +63,7 @@ namespace OpenSim.Services.LLLoginService
57 m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty); 63 m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty);
58 m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); 64 m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
59 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); 65 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true);
66 m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty);
60 67
61 // These are required; the others aren't 68 // These are required; the others aren't
62 if (accountService == string.Empty || authService == string.Empty) 69 if (accountService == string.Empty || authService == string.Empty)
@@ -74,6 +81,9 @@ namespace OpenSim.Services.LLLoginService
74 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); 81 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args);
75 if (simulationService != string.Empty) 82 if (simulationService != string.Empty)
76 m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); 83 m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
84 if (agentService != string.Empty)
85 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args);
86
77 // 87 //
78 // deal with the services given as argument 88 // deal with the services given as argument
79 // 89 //
@@ -89,6 +99,8 @@ namespace OpenSim.Services.LLLoginService
89 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args); 99 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args);
90 } 100 }
91 101
102 m_GatekeeperConnector = new GatekeeperServiceConnector();
103
92 if (!Initialized) 104 if (!Initialized)
93 { 105 {
94 Initialized = true; 106 Initialized = true;
@@ -185,7 +197,8 @@ namespace OpenSim.Services.LLLoginService
185 string where = string.Empty; 197 string where = string.Empty;
186 Vector3 position = Vector3.Zero; 198 Vector3 position = Vector3.Zero;
187 Vector3 lookAt = Vector3.Zero; 199 Vector3 lookAt = Vector3.Zero;
188 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); 200 GridRegion gatekeeper = null;
201 GridRegion destination = FindDestination(account, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt);
189 if (destination == null) 202 if (destination == null)
190 { 203 {
191 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); 204 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
@@ -205,50 +218,16 @@ namespace OpenSim.Services.LLLoginService
205 // 218 //
206 // Instantiate/get the simulation interface and launch an agent at the destination 219 // Instantiate/get the simulation interface and launch an agent at the destination
207 // 220 //
208 ISimulationService simConnector = null;
209 string reason = string.Empty; 221 string reason = string.Empty;
210 uint circuitCode = 0; 222 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, out where, out reason);
211 AgentCircuitData aCircuit = null; 223
212 Object[] args = new Object[] { destination };
213 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
214 // non-HG standalones have just a localSimulationDll
215 // independent login servers have just a remoteSimulationDll
216 if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
217 simConnector = m_LocalSimulationService;
218 else if (m_RemoteSimulationService != null)
219 simConnector = m_RemoteSimulationService;
220 if (simConnector != null)
221 {
222 circuitCode = (uint)Util.RandomClass.Next(); ;
223 aCircuit = LaunchAgent(simConnector, destination, account, avatar, session, secureSession, circuitCode, position, out reason);
224 }
225 if (aCircuit == null) 224 if (aCircuit == null)
226 { 225 {
227 // Try the fallback regions 226 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
228 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); 227 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
229 if (fallbacks != null) 228 return LLFailedLoginResponse.AuthorizationProblem;
230 {
231 foreach (GridRegion r in fallbacks)
232 {
233 aCircuit = LaunchAgent(simConnector, r, account, avatar, session, secureSession, circuitCode, position, out reason);
234 if (aCircuit != null)
235 {
236 where = "safe";
237 destination = r;
238 break;
239 }
240 }
241 }
242 229
243 if (aCircuit == null)
244 {
245 // we tried...
246 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
247 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
248 return LLFailedLoginResponse.AuthorizationProblem;
249 }
250 } 230 }
251
252 // TODO: Get Friends list... 231 // TODO: Get Friends list...
253 232
254 // 233 //
@@ -268,10 +247,11 @@ namespace OpenSim.Services.LLLoginService
268 } 247 }
269 } 248 }
270 249
271 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) 250 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt)
272 { 251 {
273 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); 252 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
274 253
254 gatekeeper = null;
275 where = "home"; 255 where = "home";
276 position = new Vector3(128, 128, 0); 256 position = new Vector3(128, 128, 0);
277 lookAt = new Vector3(0, 1, 0); 257 lookAt = new Vector3(0, 1, 0);
@@ -376,6 +356,11 @@ namespace OpenSim.Services.LLLoginService
376 } 356 }
377 else 357 else
378 { 358 {
359 if (m_UserAgentService == null)
360 {
361 m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids");
362 return null;
363 }
379 string[] parts = regionName.Split(new char[] { '@' }); 364 string[] parts = regionName.Split(new char[] { '@' });
380 if (parts.Length < 2) 365 if (parts.Length < 2)
381 { 366 {
@@ -390,10 +375,7 @@ namespace OpenSim.Services.LLLoginService
390 uint port = 0; 375 uint port = 0;
391 if (parts.Length > 1) 376 if (parts.Length > 1)
392 UInt32.TryParse(parts[1], out port); 377 UInt32.TryParse(parts[1], out port);
393 GridRegion region = new GridRegion(); 378 GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
394 region.ExternalHostName = domainName;
395 region.HttpPort = port;
396 region.RegionName = regionName;
397 return region; 379 return region;
398 } 380 }
399 } 381 }
@@ -417,10 +399,139 @@ namespace OpenSim.Services.LLLoginService
417 399
418 } 400 }
419 401
420 private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, 402 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper)
421 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason) 403 {
404 gatekeeper = new GridRegion();
405 gatekeeper.ExternalHostName = domainName;
406 gatekeeper.HttpPort = port;
407 gatekeeper.RegionName = regionName;
408
409 UUID regionID;
410 ulong handle;
411 string imageURL = string.Empty, reason = string.Empty;
412 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason))
413 {
414 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID);
415 return destination;
416 }
417
418 return null;
419 }
420
421 private string hostName = string.Empty;
422 private int port = 0;
423
424 private void SetHostAndPort(string url)
425 {
426 try
427 {
428 Uri uri = new Uri(url);
429 hostName = uri.Host;
430 port = uri.Port;
431 }
432 catch
433 {
434 m_log.WarnFormat("[LLLogin SERVICE]: Unable to parse GatekeeperURL {0}", url);
435 }
436 }
437
438 private AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar,
439 UUID session, UUID secureSession, Vector3 position, string currentWhere, out string where, out string reason)
422 { 440 {
441 where = currentWhere;
442 ISimulationService simConnector = null;
423 reason = string.Empty; 443 reason = string.Empty;
444 uint circuitCode = 0;
445 AgentCircuitData aCircuit = null;
446
447 if (m_UserAgentService == null)
448 {
449 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
450 // non-HG standalones have just a localSimulationDll
451 // independent login servers have just a remoteSimulationDll
452 if (m_LocalSimulationService != null)
453 simConnector = m_LocalSimulationService;
454 else if (m_RemoteSimulationService != null)
455 simConnector = m_RemoteSimulationService;
456 }
457 else // User Agent Service is on
458 {
459 if (gatekeeper == null) // login to local grid
460 {
461 if (hostName == string.Empty)
462 SetHostAndPort(m_GatekeeperURL);
463
464 gatekeeper = new GridRegion(destination);
465 gatekeeper.ExternalHostName = hostName;
466 gatekeeper.HttpPort = (uint)port;
467
468 }
469 else // login to foreign grid
470 {
471 }
472 }
473
474 bool success = false;
475
476 if (m_UserAgentService == null && simConnector != null)
477 {
478 circuitCode = (uint)Util.RandomClass.Next(); ;
479 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
480 success = LaunchAgentDirectly(simConnector, destination, aCircuit, out reason);
481 if (!success && m_GridService != null)
482 {
483 // Try the fallback regions
484 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
485 if (fallbacks != null)
486 {
487 foreach (GridRegion r in fallbacks)
488 {
489 success = LaunchAgentDirectly(simConnector, r, aCircuit, out reason);
490 if (success)
491 {
492 where = "safe";
493 destination = r;
494 break;
495 }
496 }
497 }
498 }
499 }
500
501 if (m_UserAgentService != null)
502 {
503 circuitCode = (uint)Util.RandomClass.Next(); ;
504 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
505 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, out reason);
506 if (!success && m_GridService != null)
507 {
508 // Try the fallback regions
509 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
510 if (fallbacks != null)
511 {
512 foreach (GridRegion r in fallbacks)
513 {
514 success = LaunchAgentIndirectly(gatekeeper, r, aCircuit, out reason);
515 if (success)
516 {
517 where = "safe";
518 destination = r;
519 break;
520 }
521 }
522 }
523 }
524 }
525
526 if (success)
527 return aCircuit;
528 else
529 return null;
530 }
531
532 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
533 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position)
534 {
424 AgentCircuitData aCircuit = new AgentCircuitData(); 535 AgentCircuitData aCircuit = new AgentCircuitData();
425 536
426 aCircuit.AgentID = account.PrincipalID; 537 aCircuit.AgentID = account.PrincipalID;
@@ -442,10 +553,13 @@ namespace OpenSim.Services.LLLoginService
442 aCircuit.startpos = position; 553 aCircuit.startpos = position;
443 SetServiceURLs(aCircuit, account); 554 SetServiceURLs(aCircuit, account);
444 555
445 if (simConnector.CreateAgent(region, aCircuit, 0, out reason)) 556 return aCircuit;
446 return aCircuit;
447 557
448 return null; 558 //m_UserAgentService.LoginAgentToGrid(aCircuit, GatekeeperServiceConnector, region, out reason);
559 //if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
560 // return aCircuit;
561
562 //return null;
449 563
450 } 564 }
451 565
@@ -468,6 +582,16 @@ namespace OpenSim.Services.LLLoginService
468 } 582 }
469 } 583 }
470 584
585 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)
586 {
587 return simConnector.CreateAgent(region, aCircuit, (int)Constants.TeleportFlags.ViaLogin, out reason);
588 }
589
590 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, out string reason)
591 {
592 return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason);
593 }
594
471 #region Console Commands 595 #region Console Commands
472 private void RegisterCommands() 596 private void RegisterCommands()
473 { 597 {