aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/GatekeeperService.cs
diff options
context:
space:
mode:
authoronefang2019-09-11 16:36:50 +1000
committeronefang2019-09-11 16:36:50 +1000
commit50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch)
tree52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Services/HypergridService/GatekeeperService.cs
parentRenamed branch to SledjChisl. (diff)
parentBump to release flavour, build 0. (diff)
downloadopensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs177
1 files changed, 144 insertions, 33 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 8e10125..24979be 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -35,8 +35,8 @@ using OpenSim.Framework;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Services.Connectors.InstantMessage;
38using OpenSim.Services.Connectors.Hypergrid; 39using OpenSim.Services.Connectors.Hypergrid;
39
40using OpenMetaverse; 40using OpenMetaverse;
41 41
42using Nini.Config; 42using Nini.Config;
@@ -71,6 +71,7 @@ namespace OpenSim.Services.HypergridService
71 private static string m_ExternalName; 71 private static string m_ExternalName;
72 private static Uri m_Uri; 72 private static Uri m_Uri;
73 private static GridRegion m_DefaultGatewayRegion; 73 private static GridRegion m_DefaultGatewayRegion;
74 private bool m_allowDuplicatePresences = false;
74 75
75 public GatekeeperService(IConfigSource config, ISimulationService simService) 76 public GatekeeperService(IConfigSource config, ISimulationService simService)
76 { 77 {
@@ -93,7 +94,7 @@ namespace OpenSim.Services.HypergridService
93 // These are mandatory, the others aren't 94 // These are mandatory, the others aren't
94 if (gridService == string.Empty || presenceService == string.Empty) 95 if (gridService == string.Empty || presenceService == string.Empty)
95 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 96 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
96 97
97 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); 98 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
98 UUID.TryParse(scope, out m_ScopeID); 99 UUID.TryParse(scope, out m_ScopeID);
99 //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); 100 //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
@@ -135,7 +136,7 @@ namespace OpenSim.Services.HypergridService
135 m_AllowedClients = Util.GetConfigVarFromSections<string>( 136 m_AllowedClients = Util.GetConfigVarFromSections<string>(
136 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 137 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
137 m_DeniedClients = Util.GetConfigVarFromSections<string>( 138 m_DeniedClients = Util.GetConfigVarFromSections<string>(
138 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 139 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
139 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 140 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
140 141
141 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); 142 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
@@ -144,6 +145,12 @@ namespace OpenSim.Services.HypergridService
144 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 145 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
145 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 146 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
146 147
148 IConfig presenceConfig = config.Configs["PresenceService"];
149 if (presenceConfig != null)
150 {
151 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
152 }
153
147 m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); 154 m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
148 } 155 }
149 } 156 }
@@ -162,10 +169,12 @@ namespace OpenSim.Services.HypergridService
162 exceptions.Add(s.Trim()); 169 exceptions.Add(s.Trim());
163 } 170 }
164 171
165 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 172 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY)
166 { 173 {
167 regionID = UUID.Zero; 174 regionID = UUID.Zero;
168 regionHandle = 0; 175 regionHandle = 0;
176 sizeX = (int)Constants.RegionSize;
177 sizeY = (int)Constants.RegionSize;
169 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); 178 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : "");
170 imageURL = string.Empty; 179 imageURL = string.Empty;
171 reason = string.Empty; 180 reason = string.Empty;
@@ -199,6 +208,8 @@ namespace OpenSim.Services.HypergridService
199 208
200 regionID = region.RegionID; 209 regionID = region.RegionID;
201 regionHandle = region.RegionHandle; 210 regionHandle = region.RegionHandle;
211 sizeX = region.RegionSizeX;
212 sizeY = region.RegionSizeY;
202 213
203 string regionimage = "regionImage" + regionID.ToString(); 214 string regionimage = "regionImage" + regionID.ToString();
204 regionimage = regionimage.Replace("-", ""); 215 regionimage = regionimage.Replace("-", "");
@@ -215,11 +226,11 @@ namespace OpenSim.Services.HypergridService
215 { 226 {
216 // Don't even check the given regionID 227 // Don't even check the given regionID
217 m_log.DebugFormat( 228 m_log.DebugFormat(
218 "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.", 229 "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.",
219 m_DefaultGatewayRegion.RegionName, 230 m_DefaultGatewayRegion.RegionName,
220 m_DefaultGatewayRegion.RegionID, 231 m_DefaultGatewayRegion.RegionID,
221 m_DefaultGatewayRegion.ServerURI, 232 m_DefaultGatewayRegion.ServerURI,
222 agentID, 233 agentID,
223 agentHomeURI == null ? "" : " @ " + agentHomeURI); 234 agentHomeURI == null ? "" : " @ " + agentHomeURI);
224 235
225 message = "Teleporting to the default region."; 236 message = "Teleporting to the default region.";
@@ -240,10 +251,10 @@ namespace OpenSim.Services.HypergridService
240 251
241 m_log.DebugFormat( 252 m_log.DebugFormat(
242 "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.", 253 "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.",
243 region.RegionName, 254 region.RegionName,
244 region.RegionID, 255 region.RegionID,
245 region.ServerURI, 256 region.ServerURI,
246 agentID, 257 agentID,
247 agentHomeURI == null ? "" : " @ " + agentHomeURI); 258 agentHomeURI == null ? "" : " @ " + agentHomeURI);
248 259
249 return region; 260 return region;
@@ -275,6 +286,7 @@ namespace OpenSim.Services.HypergridService
275 286
276 if (!am.Success) 287 if (!am.Success)
277 { 288 {
289 reason = "Login failed: client " + curViewer + " is not allowed";
278 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); 290 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
279 return false; 291 return false;
280 } 292 }
@@ -287,6 +299,7 @@ namespace OpenSim.Services.HypergridService
287 299
288 if (dm.Success) 300 if (dm.Success)
289 { 301 {
302 reason = "Login failed: client " + curViewer + " is denied";
290 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); 303 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
291 return false; 304 return false;
292 } 305 }
@@ -302,7 +315,7 @@ namespace OpenSim.Services.HypergridService
302 return false; 315 return false;
303 } 316 }
304 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); 317 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL);
305 318
306 // 319 //
307 // Check for impersonations 320 // Check for impersonations
308 // 321 //
@@ -363,6 +376,64 @@ namespace OpenSim.Services.HypergridService
363 return false; 376 return false;
364 } 377 }
365 378
379 UUID agentID = aCircuit.AgentID;
380 if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
381 {
382 // really?
383 reason = "Invalid account ID";
384 return false;
385 }
386
387 if(m_GridUserService != null)
388 {
389 string PrincipalIDstr = agentID.ToString();
390 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
391
392 if(!m_allowDuplicatePresences)
393 {
394//// TODO - Should also check Presence.UserID if RegionID == UUID.Zero, they are a ghost. Maybe.
395//// NOTE - this is a person hypergridding in, or returning home, or just logging in and it's duplicating effort in OpenSim/Services/LLLoginService/LLLoginService.cs.
396 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
397 {
398 // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost.
399 // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login.
400 // Might also need to double check if they are out hypergridding.
401
402 bool success = false;
403 if (m_PresenceService != null)
404 {
405 PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID);
406 if (null != pi)
407 {
408 Dictionary<string, object> pid = pi.ToKeyValuePairs();
409 if ((pid["RegionID"].ToString() == UUID.Zero.ToString()) && (0 != String.Compare(pid["SessionID"].ToString(), aCircuit.SessionID.ToString())))
410 {
411 m_log.WarnFormat("[GATEKEEPER SERVICE]: Exorcising ghost avatar {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
412m_log.WarnFormat("[GATEKEEPER SERVICE]: NOT REALLY.");
413//// Don't do this until after more checking.
414//// success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString()));
415//// if (success)
416//// m_log.WarnFormat("[GATEKEEPER SERVICE]: Ghost avatar exorcised {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
417//// else
418//// m_log.ErrorFormat("[GATEKEEPER SERVICE]: Ghost avatar not exorcised {0}, session {1}, new session {2}!", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
419 }
420 }
421 }
422 if ((!success) && SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo))
423 {
424 if(account != null)
425 m_log.InfoFormat(
426 "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in. This may be bogus if a ghost avatar was exorcised above.",
427 account.FirstName, account.LastName);
428 reason = "You appear to be already logged in on the destination grid " +
429 "Please wait a a minute or two and retry. " +
430 "If this takes longer than a few minutes please contact the grid owner.";
431 return false;
432 }
433 }
434 }
435 }
436
366 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); 437 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);
367 438
368 bool isFirstLogin = false; 439 bool isFirstLogin = false;
@@ -383,26 +454,6 @@ namespace OpenSim.Services.HypergridService
383 return false; 454 return false;
384 } 455 }
385 456
386 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
387
388 // Also login foreigners with GridUser service
389 if (m_GridUserService != null && account == null)
390 {
391 string userId = aCircuit.AgentID.ToString();
392 string first = aCircuit.firstname, last = aCircuit.lastname;
393 if (last.StartsWith("@"))
394 {
395 string[] parts = aCircuit.firstname.Split('.');
396 if (parts.Length >= 2)
397 {
398 first = parts[0];
399 last = parts[1];
400 }
401 }
402
403 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
404 m_GridUserService.LoggedIn(userId);
405 }
406 } 457 }
407 458
408 // 459 //
@@ -455,11 +506,37 @@ namespace OpenSim.Services.HypergridService
455 EntityTransferContext ctx = new EntityTransferContext(); 506 EntityTransferContext ctx = new EntityTransferContext();
456 507
457 if (!m_SimulationService.QueryAccess( 508 if (!m_SimulationService.QueryAccess(
458 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), 509 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(),
459 true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 510 true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
460 return false; 511 return false;
461 512
462 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); 513 bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
514
515 if(didit)
516 {
517 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
518
519 if(!isFirstLogin && m_GridUserService != null && account == null)
520 {
521 // Also login foreigners with GridUser service
522 string userId = aCircuit.AgentID.ToString();
523 string first = aCircuit.firstname, last = aCircuit.lastname;
524 if (last.StartsWith("@"))
525 {
526 string[] parts = aCircuit.firstname.Split('.');
527 if (parts.Length >= 2)
528 {
529 first = parts[0];
530 last = parts[1];
531 }
532 }
533
534 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
535 m_GridUserService.LoggedIn(userId);
536 }
537 }
538
539 return didit;
463 } 540 }
464 541
465 protected bool Authenticate(AgentCircuitData aCircuit) 542 protected bool Authenticate(AgentCircuitData aCircuit)
@@ -489,7 +566,7 @@ namespace OpenSim.Services.HypergridService
489 } 566 }
490 else 567 else
491 { 568 {
492 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); 569 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL);
493 570
494 try 571 try
495 { 572 {
@@ -557,6 +634,40 @@ namespace OpenSim.Services.HypergridService
557 return exception; 634 return exception;
558 } 635 }
559 636
637 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
638 {
639 UUID regionID = guinfo.LastRegionID;
640 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
641 if(regInfo == null)
642 return false;
643
644 string regURL = regInfo.ServerURI;
645 if(String.IsNullOrEmpty(regURL))
646 return false;
647
648 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
649
650 GridInstantMessage msg = new GridInstantMessage();
651 msg.imSessionID = UUID.Zero.Guid;
652 msg.fromAgentID = guuid.Guid;
653 msg.toAgentID = agentID.Guid;
654 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
655 msg.fromAgentName = "GRID";
656 msg.message = string.Format("New login detected");
657 msg.dialog = 250; // God kick
658 msg.fromGroup = false;
659 msg.offline = (byte)0;
660 msg.ParentEstateID = 0;
661 msg.Position = Vector3.Zero;
662 msg.RegionID = scopeID.Guid;
663 msg.binaryBucket = new byte[1] {0};
664 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
665
666 m_GridUserService.LoggedOut(agentID.ToString(),
667 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
668
669 return true;
670 }
560 #endregion 671 #endregion
561 } 672 }
562} 673}