aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/GatekeeperService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs151
1 files changed, 118 insertions, 33 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 8e10125..5c6abd2 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,38 @@ 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 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
395 {
396 if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo))
397 {
398 if(account != null)
399 m_log.InfoFormat(
400 "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in",
401 account.FirstName, account.LastName);
402 reason = "You appear to be already logged in on the destination grid " +
403 "Please wait a a minute or two and retry. " +
404 "If this takes longer than a few minutes please contact the grid owner.";
405 return false;
406 }
407 }
408 }
409 }
410
366 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); 411 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);
367 412
368 bool isFirstLogin = false; 413 bool isFirstLogin = false;
@@ -383,26 +428,6 @@ namespace OpenSim.Services.HypergridService
383 return false; 428 return false;
384 } 429 }
385 430
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 } 431 }
407 432
408 // 433 //
@@ -455,11 +480,37 @@ namespace OpenSim.Services.HypergridService
455 EntityTransferContext ctx = new EntityTransferContext(); 480 EntityTransferContext ctx = new EntityTransferContext();
456 481
457 if (!m_SimulationService.QueryAccess( 482 if (!m_SimulationService.QueryAccess(
458 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), 483 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(),
459 true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 484 true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
460 return false; 485 return false;
461 486
462 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); 487 bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
488
489 if(didit)
490 {
491 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
492
493 if(!isFirstLogin && m_GridUserService != null && account == null)
494 {
495 // Also login foreigners with GridUser service
496 string userId = aCircuit.AgentID.ToString();
497 string first = aCircuit.firstname, last = aCircuit.lastname;
498 if (last.StartsWith("@"))
499 {
500 string[] parts = aCircuit.firstname.Split('.');
501 if (parts.Length >= 2)
502 {
503 first = parts[0];
504 last = parts[1];
505 }
506 }
507
508 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
509 m_GridUserService.LoggedIn(userId);
510 }
511 }
512
513 return didit;
463 } 514 }
464 515
465 protected bool Authenticate(AgentCircuitData aCircuit) 516 protected bool Authenticate(AgentCircuitData aCircuit)
@@ -489,7 +540,7 @@ namespace OpenSim.Services.HypergridService
489 } 540 }
490 else 541 else
491 { 542 {
492 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); 543 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL);
493 544
494 try 545 try
495 { 546 {
@@ -557,6 +608,40 @@ namespace OpenSim.Services.HypergridService
557 return exception; 608 return exception;
558 } 609 }
559 610
611 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
612 {
613 UUID regionID = guinfo.LastRegionID;
614 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
615 if(regInfo == null)
616 return false;
617
618 string regURL = regInfo.ServerURI;
619 if(String.IsNullOrEmpty(regURL))
620 return false;
621
622 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
623
624 GridInstantMessage msg = new GridInstantMessage();
625 msg.imSessionID = UUID.Zero.Guid;
626 msg.fromAgentID = guuid.Guid;
627 msg.toAgentID = agentID.Guid;
628 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
629 msg.fromAgentName = "GRID";
630 msg.message = string.Format("New login detected");
631 msg.dialog = 250; // God kick
632 msg.fromGroup = false;
633 msg.offline = (byte)0;
634 msg.ParentEstateID = 0;
635 msg.Position = Vector3.Zero;
636 msg.RegionID = scopeID.Guid;
637 msg.binaryBucket = new byte[1] {0};
638 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
639
640 m_GridUserService.LoggedOut(agentID.ToString(),
641 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
642
643 return true;
644 }
560 #endregion 645 #endregion
561 } 646 }
562} 647}