aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginService.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs254
1 files changed, 187 insertions, 67 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 0b38738..cad0988 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -40,6 +40,7 @@ using OpenMetaverse;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
42using OpenSim.Server.Base; 42using OpenSim.Server.Base;
43using OpenSim.Services.Connectors.InstantMessage;
43using OpenSim.Services.Interfaces; 44using OpenSim.Services.Interfaces;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion; 45using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
@@ -77,16 +78,19 @@ namespace OpenSim.Services.LLLoginService
77 protected string m_GatekeeperURL; 78 protected string m_GatekeeperURL;
78 protected bool m_AllowRemoteSetLoginLevel; 79 protected bool m_AllowRemoteSetLoginLevel;
79 protected string m_MapTileURL; 80 protected string m_MapTileURL;
81 protected string m_ProfileURL;
82 protected string m_OpenIDURL;
80 protected string m_SearchURL; 83 protected string m_SearchURL;
81 protected string m_Currency; 84 protected string m_Currency;
82 protected string m_ClassifiedFee; 85 protected string m_ClassifiedFee;
83 protected int m_MaxAgentGroups; 86 protected int m_MaxAgentGroups = 42;
84 protected string m_DestinationGuide; 87 protected string m_DestinationGuide;
85 protected string m_AvatarPicker; 88 protected string m_AvatarPicker;
86 protected string m_AllowedClients; 89 protected string m_AllowedClients;
87 protected string m_DeniedClients; 90 protected string m_DeniedClients;
88 protected string m_MessageUrl; 91 protected string m_MessageUrl;
89 protected string m_DSTZone; 92 protected string m_DSTZone;
93 protected bool m_allowDuplicatePresences = false;
90 94
91 IConfig m_LoginServerConfig; 95 IConfig m_LoginServerConfig;
92// IConfig m_ClientsConfig; 96// IConfig m_ClientsConfig;
@@ -117,6 +121,8 @@ namespace OpenSim.Services.LLLoginService
117 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 121 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
118 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty); 122 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty);
119 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); 123 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
124 m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty);
125 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);
120 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); 126 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
121 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); 127 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
122 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty); 128 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty);
@@ -127,7 +133,7 @@ namespace OpenSim.Services.LLLoginService
127 m_AllowedClients = Util.GetConfigVarFromSections<string>( 133 m_AllowedClients = Util.GetConfigVarFromSections<string>(
128 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 134 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
129 m_DeniedClients = Util.GetConfigVarFromSections<string>( 135 m_DeniedClients = Util.GetConfigVarFromSections<string>(
130 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 136 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
131 137
132 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty); 138 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
133 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); 139 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
@@ -136,6 +142,11 @@ namespace OpenSim.Services.LLLoginService
136 if (groupConfig != null) 142 if (groupConfig != null)
137 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); 143 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
138 144
145 IConfig presenceConfig = config.Configs["PresenceService"];
146 if (presenceConfig != null)
147 {
148 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
149 }
139 150
140 // Clean up some of these vars 151 // Clean up some of these vars
141 if (m_MapTileURL != String.Empty) 152 if (m_MapTileURL != String.Empty)
@@ -155,7 +166,8 @@ namespace OpenSim.Services.LLLoginService
155 Object[] args = new Object[] { config }; 166 Object[] args = new Object[] { config };
156 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 167 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
157 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 168 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
158 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 169 Object[] authArgs = new Object[] { config, m_UserAccountService };
170 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
159 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 171 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
160 172
161 if (gridService != string.Empty) 173 if (gridService != string.Empty)
@@ -175,9 +187,14 @@ namespace OpenSim.Services.LLLoginService
175 string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty); 187 string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty);
176 if (hgInvServicePlugin != string.Empty) 188 if (hgInvServicePlugin != string.Empty)
177 { 189 {
190 // TODO: Remove HGInventoryServiceConstructorArg after 0.9 release
178 string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty); 191 string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty);
179 Object[] args2 = new Object[] { config, hgInvServiceArg }; 192 if (hgInvServiceArg != String.Empty)
180 m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args2); 193 {
194 m_log.Warn("[LLOGIN SERVICE]: You are using HGInventoryServiceConstructorArg, which is deprecated. See example file for correct syntax.");
195 hgInvServicePlugin = hgInvServiceArg + "@" + hgInvServicePlugin;
196 }
197 m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args);
181 } 198 }
182 199
183 // 200 //
@@ -260,16 +277,20 @@ namespace OpenSim.Services.LLLoginService
260 return response; 277 return response;
261 } 278 }
262 279
263 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, 280 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
264 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) 281 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient)
265 { 282 {
266 bool success = false; 283 bool success = false;
267 UUID session = UUID.Random(); 284 UUID session = UUID.Random();
285
268 string processedMessage; 286 string processedMessage;
269 287
270 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}", 288 if (clientVersion.Contains("Radegast"))
271 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0); 289 LibOMVclient = false;
272 290
291 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}, Possible LibOMVGridProxy: {8} ",
292 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString());
293
273 try 294 try
274 { 295 {
275 // 296 //
@@ -345,7 +366,8 @@ namespace OpenSim.Services.LLLoginService
345 if (!passwd.StartsWith("$1$")) 366 if (!passwd.StartsWith("$1$"))
346 passwd = "$1$" + Util.Md5Hash(passwd); 367 passwd = "$1$" + Util.Md5Hash(passwd);
347 passwd = passwd.Remove(0, 3); //remove $1$ 368 passwd = passwd.Remove(0, 3); //remove $1$
348 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 369 UUID realID;
370 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID);
349 UUID secureSession = UUID.Zero; 371 UUID secureSession = UUID.Zero;
350 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 372 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
351 { 373 {
@@ -355,6 +377,52 @@ namespace OpenSim.Services.LLLoginService
355 return LLFailedLoginResponse.UserProblem; 377 return LLFailedLoginResponse.UserProblem;
356 } 378 }
357 379
380 if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
381 {
382 // really?
383 return LLFailedLoginResponse.UserProblem;
384 }
385
386 string PrincipalIDstr = account.PrincipalID.ToString();
387 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
388
389 if(!m_allowDuplicatePresences)
390 {
391 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
392 {
393 // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost.
394 // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login.
395 // Might also need to double check if they are out hypergridding.
396
397 success = false;
398 if (m_PresenceService != null)
399 {
400 PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID);
401 if (null != pi)
402 {
403 Dictionary<string, object> pid = pi.ToKeyValuePairs();
404 if (pid["RegionID"].ToString() == UUID.Zero.ToString())
405 {
406 m_log.WarnFormat("[LLOGIN SERVICE]: Exorcising ghost avatar {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session);
407 success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString()));
408 if (success)
409 m_log.WarnFormat("[LLOGIN SERVICE]: Ghost avatar exorcised {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session);
410 else
411 m_log.ErrorFormat("[LLOGIN SERVICE]: Ghost avatar not exorcised {0} {1}, session {2}, new session {3}!", firstName, lastName, pid["SessionID"], session);
412 }
413 }
414 }
415
416 if ((!success) && SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo))
417 {
418 m_log.InfoFormat(
419 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in",
420 firstName, lastName);
421 return LLFailedLoginResponse.AlreadyLoggedInProblem;
422 }
423 }
424 }
425
358 // 426 //
359 // Get the user's inventory 427 // Get the user's inventory
360 // 428 //
@@ -391,7 +459,7 @@ namespace OpenSim.Services.LLLoginService
391 // 459 //
392 if (m_PresenceService != null) 460 if (m_PresenceService != null)
393 { 461 {
394 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 462 success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession);
395 463
396 if (!success) 464 if (!success)
397 { 465 {
@@ -406,7 +474,6 @@ namespace OpenSim.Services.LLLoginService
406 // Change Online status and get the home region 474 // Change Online status and get the home region
407 // 475 //
408 GridRegion home = null; 476 GridRegion home = null;
409 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());
410 477
411 // We are only going to complain about no home if the user actually tries to login there, to avoid 478 // We are only going to complain about no home if the user actually tries to login there, to avoid
412 // spamming the console. 479 // spamming the console.
@@ -437,7 +504,7 @@ namespace OpenSim.Services.LLLoginService
437 guinfo = new GridUserInfo(); 504 guinfo = new GridUserInfo();
438 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); 505 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
439 } 506 }
440 507
441 // 508 //
442 // Find the destination region/grid 509 // Find the destination region/grid
443 // 510 //
@@ -445,7 +512,7 @@ namespace OpenSim.Services.LLLoginService
445 Vector3 position = Vector3.Zero; 512 Vector3 position = Vector3.Zero;
446 Vector3 lookAt = Vector3.Zero; 513 Vector3 lookAt = Vector3.Zero;
447 GridRegion gatekeeper = null; 514 GridRegion gatekeeper = null;
448 TeleportFlags flags; 515 Constants.TeleportFlags flags;
449 GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags); 516 GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags);
450 if (destination == null) 517 if (destination == null)
451 { 518 {
@@ -464,7 +531,7 @@ namespace OpenSim.Services.LLLoginService
464 } 531 }
465 532
466 if (account.UserLevel >= 200) 533 if (account.UserLevel >= 200)
467 flags |= TeleportFlags.Godlike; 534 flags |= Constants.TeleportFlags.Godlike;
468 // 535 //
469 // Get the avatar 536 // Get the avatar
470 // 537 //
@@ -479,7 +546,7 @@ namespace OpenSim.Services.LLLoginService
479 // 546 //
480 string reason = string.Empty; 547 string reason = string.Empty;
481 GridRegion dest; 548 GridRegion dest;
482 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, 549 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where,
483 clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest); 550 clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest);
484 destination = dest; 551 destination = dest;
485 if (aCircuit == null) 552 if (aCircuit == null)
@@ -489,7 +556,11 @@ namespace OpenSim.Services.LLLoginService
489 return new LLFailedLoginResponse("key", reason, "false"); 556 return new LLFailedLoginResponse("key", reason, "false");
490 557
491 } 558 }
492 // Get Friends list 559
560 // only now we can assume a login
561 guinfo = m_GridUserService.LoggedIn(PrincipalIDstr);
562
563 // Get Friends list
493 FriendInfo[] friendsList = new FriendInfo[0]; 564 FriendInfo[] friendsList = new FriendInfo[0];
494 if (m_FriendsService != null) 565 if (m_FriendsService != null)
495 { 566 {
@@ -502,8 +573,8 @@ namespace OpenSim.Services.LLLoginService
502 // 573 //
503 if (m_MessageUrl != String.Empty) 574 if (m_MessageUrl != String.Empty)
504 { 575 {
505 WebClient client = new WebClient(); 576 using(WebClient client = new WebClient())
506 processedMessage = client.DownloadString(m_MessageUrl); 577 processedMessage = client.DownloadString(m_MessageUrl);
507 } 578 }
508 else 579 else
509 { 580 {
@@ -512,11 +583,11 @@ namespace OpenSim.Services.LLLoginService
512 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName); 583 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
513 584
514 LLLoginResponse response 585 LLLoginResponse response
515 = new LLLoginResponse( 586 = new LLLoginResponse(
516 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, 587 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
517 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, 588 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP,
518 m_MapTileURL, m_SearchURL, m_Currency, m_DSTZone, 589 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
519 m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee, m_MaxAgentGroups); 590 m_DestinationGuide, m_AvatarPicker, realID, m_ClassifiedFee,m_MaxAgentGroups);
520 591
521 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); 592 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
522 593
@@ -534,9 +605,9 @@ namespace OpenSim.Services.LLLoginService
534 protected GridRegion FindDestination( 605 protected GridRegion FindDestination(
535 UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, 606 UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation,
536 GridRegion home, out GridRegion gatekeeper, 607 GridRegion home, out GridRegion gatekeeper,
537 out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags) 608 out string where, out Vector3 position, out Vector3 lookAt, out Constants.TeleportFlags flags)
538 { 609 {
539 flags = TeleportFlags.ViaLogin; 610 flags = Constants.TeleportFlags.ViaLogin;
540 611
541 m_log.DebugFormat( 612 m_log.DebugFormat(
542 "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}", 613 "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}",
@@ -570,14 +641,15 @@ namespace OpenSim.Services.LLLoginService
570 641
571 position = pinfo.HomePosition; 642 position = pinfo.HomePosition;
572 lookAt = pinfo.HomeLookAt; 643 lookAt = pinfo.HomeLookAt;
573 flags |= TeleportFlags.ViaHome; 644 flags |= Constants.TeleportFlags.ViaHome;
574 } 645 }
575 646
576 if (tryDefaults) 647 if (tryDefaults)
577 { 648 {
578 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 649 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
579 if (defaults != null && defaults.Count > 0) 650 if (defaults != null && defaults.Count > 0)
580 { 651 {
652 flags |= Constants.TeleportFlags.ViaRegionID;
581 region = defaults[0]; 653 region = defaults[0];
582 where = "safe"; 654 where = "safe";
583 } 655 }
@@ -587,7 +659,10 @@ namespace OpenSim.Services.LLLoginService
587 account.FirstName, account.LastName); 659 account.FirstName, account.LastName);
588 region = FindAlternativeRegion(scopeID); 660 region = FindAlternativeRegion(scopeID);
589 if (region != null) 661 if (region != null)
662 {
663 flags |= Constants.TeleportFlags.ViaRegionID;
590 where = "safe"; 664 where = "safe";
665 }
591 } 666 }
592 } 667 }
593 668
@@ -608,6 +683,7 @@ namespace OpenSim.Services.LLLoginService
608 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 683 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
609 if (defaults != null && defaults.Count > 0) 684 if (defaults != null && defaults.Count > 0)
610 { 685 {
686 flags |= Constants.TeleportFlags.ViaRegionID;
611 region = defaults[0]; 687 region = defaults[0];
612 where = "safe"; 688 where = "safe";
613 } 689 }
@@ -616,7 +692,10 @@ namespace OpenSim.Services.LLLoginService
616 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); 692 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
617 region = FindAlternativeRegion(scopeID); 693 region = FindAlternativeRegion(scopeID);
618 if (region != null) 694 if (region != null)
695 {
696 flags |= Constants.TeleportFlags.ViaRegionID;
619 where = "safe"; 697 where = "safe";
698 }
620 } 699 }
621 700
622 } 701 }
@@ -625,12 +704,12 @@ namespace OpenSim.Services.LLLoginService
625 position = pinfo.LastPosition; 704 position = pinfo.LastPosition;
626 lookAt = pinfo.LastLookAt; 705 lookAt = pinfo.LastLookAt;
627 } 706 }
628 707
629 return region; 708 return region;
630 } 709 }
631 else 710 else
632 { 711 {
633 flags |= TeleportFlags.ViaRegionID; 712 flags |= Constants.TeleportFlags.ViaRegionID;
634 713
635 // free uri form 714 // free uri form
636 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 715 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
@@ -648,6 +727,8 @@ namespace OpenSim.Services.LLLoginService
648 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo), 727 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo),
649 float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo), 728 float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo),
650 float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); 729 float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));
730 if (0 == position.Z)
731 flags |= Constants.TeleportFlags.ViaMap;
651 732
652 string regionName = uriMatch.Groups["region"].ToString(); 733 string regionName = uriMatch.Groups["region"].ToString();
653 if (regionName != null) 734 if (regionName != null)
@@ -661,7 +742,7 @@ namespace OpenSim.Services.LLLoginService
661 regions = m_GridService.GetDefaultRegions(scopeID); 742 regions = m_GridService.GetDefaultRegions(scopeID);
662 if (regions != null && regions.Count > 0) 743 if (regions != null && regions.Count > 0)
663 { 744 {
664 where = "safe"; 745 where = "safe";
665 return regions[0]; 746 return regions[0];
666 } 747 }
667 else 748 else
@@ -696,7 +777,7 @@ namespace OpenSim.Services.LLLoginService
696 return null; 777 return null;
697 } 778 }
698 // Valid specification of a remote grid 779 // Valid specification of a remote grid
699 780
700 regionName = parts[0]; 781 regionName = parts[0];
701 string domainLocator = parts[1]; 782 string domainLocator = parts[1];
702 parts = domainLocator.Split(new char[] {':'}); 783 parts = domainLocator.Split(new char[] {':'});
@@ -714,7 +795,7 @@ namespace OpenSim.Services.LLLoginService
714 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 795 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
715 if (defaults != null && defaults.Count > 0) 796 if (defaults != null && defaults.Count > 0)
716 { 797 {
717 where = "safe"; 798 where = "safe";
718 return defaults[0]; 799 return defaults[0];
719 } 800 }
720 else 801 else
@@ -767,12 +848,15 @@ namespace OpenSim.Services.LLLoginService
767 ulong handle; 848 ulong handle;
768 string imageURL = string.Empty, reason = string.Empty; 849 string imageURL = string.Empty, reason = string.Empty;
769 string message; 850 string message;
770 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) 851 int sizeX = (int)Constants.RegionSize;
852 int sizeY = (int)Constants.RegionSize;
853
854 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason, out sizeX, out sizeY))
771 { 855 {
772 string homeURI = null; 856 string homeURI = null;
773 if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI")) 857 if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI"))
774 homeURI = (string)account.ServiceURLs["HomeURI"]; 858 homeURI = (string)account.ServiceURLs["HomeURI"];
775 859
776 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message); 860 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message);
777 return destination; 861 return destination;
778 } 862 }
@@ -799,13 +883,16 @@ namespace OpenSim.Services.LLLoginService
799 883
800 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar, 884 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
801 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, 885 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
802 IPEndPoint clientIP, TeleportFlags flags, out string where, out string reason, out GridRegion dest) 886 IPEndPoint clientIP, Constants.TeleportFlags flags, out string where, out string reason, out GridRegion dest)
803 { 887 {
804 where = currentWhere; 888 where = currentWhere;
805 ISimulationService simConnector = null; 889 ISimulationService simConnector = null;
806 reason = string.Empty; 890 reason = string.Empty;
807 uint circuitCode = 0; 891 uint circuitCode = 0;
808 AgentCircuitData aCircuit = null; 892 AgentCircuitData aCircuit = null;
893 dest = null;
894
895 bool success = false;
809 896
810 if (m_UserAgentService == null) 897 if (m_UserAgentService == null)
811 { 898 {
@@ -816,28 +903,14 @@ namespace OpenSim.Services.LLLoginService
816 simConnector = m_LocalSimulationService; 903 simConnector = m_LocalSimulationService;
817 else if (m_RemoteSimulationService != null) 904 else if (m_RemoteSimulationService != null)
818 simConnector = m_RemoteSimulationService; 905 simConnector = m_RemoteSimulationService;
819 }
820 else // User Agent Service is on
821 {
822 if (gatekeeper == null) // login to local grid
823 {
824 if (hostName == string.Empty)
825 SetHostAndPort(m_GatekeeperURL);
826
827 gatekeeper = new GridRegion(destination);
828 gatekeeper.ExternalHostName = hostName;
829 gatekeeper.HttpPort = (uint)port;
830 gatekeeper.ServerURI = m_GatekeeperURL;
831 }
832 m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL);
833 }
834 906
835 bool success = false; 907 if(simConnector == null)
908 return null;
836 909
837 if (m_UserAgentService == null && simConnector != null)
838 {
839 circuitCode = (uint)Util.RandomClass.Next(); ; 910 circuitCode = (uint)Util.RandomClass.Next(); ;
840 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 911 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
912 clientIP.Address.ToString(), viewer, channel, mac, id0);
913
841 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); 914 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason);
842 if (!success && m_GridService != null) 915 if (!success && m_GridService != null)
843 { 916 {
@@ -847,7 +920,7 @@ namespace OpenSim.Services.LLLoginService
847 { 920 {
848 foreach (GridRegion r in fallbacks) 921 foreach (GridRegion r in fallbacks)
849 { 922 {
850 success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | TeleportFlags.ViaRegionID, out reason); 923 success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | Constants.TeleportFlags.ViaRegionID | Constants.TeleportFlags.ViaMap, out reason);
851 if (success) 924 if (success)
852 { 925 {
853 where = "safe"; 926 where = "safe";
@@ -859,10 +932,22 @@ namespace OpenSim.Services.LLLoginService
859 } 932 }
860 } 933 }
861 934
862 if (m_UserAgentService != null) 935 else
863 { 936 {
937 if (gatekeeper == null) // login to local grid
938 {
939 if (hostName == string.Empty)
940 SetHostAndPort(m_GatekeeperURL);
941
942 gatekeeper = new GridRegion(destination);
943 gatekeeper.ExternalHostName = hostName;
944 gatekeeper.HttpPort = (uint)port;
945 gatekeeper.ServerURI = m_GatekeeperURL;
946 }
864 circuitCode = (uint)Util.RandomClass.Next(); ; 947 circuitCode = (uint)Util.RandomClass.Next(); ;
865 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 948 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
949 clientIP.Address.ToString(), viewer, channel, mac, id0);
950
866 aCircuit.teleportFlags |= (uint)flags; 951 aCircuit.teleportFlags |= (uint)flags;
867 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); 952 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason);
868 if (!success && m_GridService != null) 953 if (!success && m_GridService != null)
@@ -891,8 +976,8 @@ namespace OpenSim.Services.LLLoginService
891 return null; 976 return null;
892 } 977 }
893 978
894 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 979 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
895 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 980 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
896 string ipaddress, string viewer, string channel, string mac, string id0) 981 string ipaddress, string viewer, string channel, string mac, string id0)
897 { 982 {
898 AgentCircuitData aCircuit = new AgentCircuitData(); 983 AgentCircuitData aCircuit = new AgentCircuitData();
@@ -930,7 +1015,7 @@ namespace OpenSim.Services.LLLoginService
930 if (account.ServiceURLs == null) 1015 if (account.ServiceURLs == null)
931 return; 1016 return;
932 1017
933 // Old style: get the service keys from the DB 1018 // Old style: get the service keys from the DB
934 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) 1019 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
935 { 1020 {
936 if (kvp.Value != null) 1021 if (kvp.Value != null)
@@ -981,7 +1066,7 @@ namespace OpenSim.Services.LLLoginService
981 1066
982 } 1067 }
983 1068
984 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason) 1069 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, Constants.TeleportFlags flags, out string reason)
985 { 1070 {
986 EntityTransferContext ctx = new EntityTransferContext(); 1071 EntityTransferContext ctx = new EntityTransferContext();
987 1072
@@ -989,7 +1074,7 @@ namespace OpenSim.Services.LLLoginService
989 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 1074 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
990 return false; 1075 return false;
991 1076
992 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, out reason); 1077 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, ctx, out reason);
993 } 1078 }
994 1079
995 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) 1080 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
@@ -1027,7 +1112,7 @@ namespace OpenSim.Services.LLLoginService
1027 switch (subcommand) 1112 switch (subcommand)
1028 { 1113 {
1029 case "level": 1114 case "level":
1030 // Set the minimum level to allow login 1115 // Set the minimum level to allow login
1031 // Useful to allow grid update without worrying about users. 1116 // Useful to allow grid update without worrying about users.
1032 // or fixing critical issues 1117 // or fixing critical issues
1033 // 1118 //
@@ -1040,8 +1125,8 @@ namespace OpenSim.Services.LLLoginService
1040 } 1125 }
1041 break; 1126 break;
1042 1127
1043 case "reset": 1128 case "reset":
1044 m_MinLoginLevel = 0; 1129 m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0);
1045 MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel); 1130 MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel);
1046 break; 1131 break;
1047 1132
@@ -1054,6 +1139,41 @@ namespace OpenSim.Services.LLLoginService
1054 break; 1139 break;
1055 } 1140 }
1056 } 1141 }
1142
1143 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
1144 {
1145 UUID regionID = guinfo.LastRegionID;
1146 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
1147 if(regInfo == null)
1148 return false;
1149
1150 string regURL = regInfo.ServerURI;
1151 if(String.IsNullOrEmpty(regURL))
1152 return false;
1153
1154 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
1155
1156 GridInstantMessage msg = new GridInstantMessage();
1157 msg.imSessionID = UUID.Zero.Guid;
1158 msg.fromAgentID = guuid.Guid;
1159 msg.toAgentID = agentID.Guid;
1160 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
1161 msg.fromAgentName = "GRID";
1162 msg.message = string.Format("New login detected");
1163 msg.dialog = 250; // God kick
1164 msg.fromGroup = false;
1165 msg.offline = (byte)0;
1166 msg.ParentEstateID = 0;
1167 msg.Position = Vector3.Zero;
1168 msg.RegionID = scopeID.Guid;
1169 msg.binaryBucket = new byte[1] {0};
1170 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
1171
1172 m_GridUserService.LoggedOut(agentID.ToString(),
1173 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
1174
1175 return true;
1176 }
1057 } 1177 }
1058 1178
1059 #endregion 1179 #endregion