diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Services/HypergridService/GatekeeperService.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/HypergridService/GatekeeperService.cs | 121 |
1 files changed, 97 insertions, 24 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 7b84d55..8e10125 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -58,6 +58,7 @@ namespace OpenSim.Services.HypergridService | |||
58 | private static IUserAgentService m_UserAgentService; | 58 | private static IUserAgentService m_UserAgentService; |
59 | private static ISimulationService m_SimulationService; | 59 | private static ISimulationService m_SimulationService; |
60 | private static IGridUserService m_GridUserService; | 60 | private static IGridUserService m_GridUserService; |
61 | private static IBansService m_BansService; | ||
61 | 62 | ||
62 | private static string m_AllowedClients = string.Empty; | 63 | private static string m_AllowedClients = string.Empty; |
63 | private static string m_DeniedClients = string.Empty; | 64 | private static string m_DeniedClients = string.Empty; |
@@ -87,6 +88,7 @@ namespace OpenSim.Services.HypergridService | |||
87 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | 88 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); |
88 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); | 89 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); |
89 | string gridUserService = serverConfig.GetString("GridUserService", String.Empty); | 90 | string gridUserService = serverConfig.GetString("GridUserService", String.Empty); |
91 | string bansService = serverConfig.GetString("BansService", String.Empty); | ||
90 | 92 | ||
91 | // These are mandatory, the others aren't | 93 | // These are mandatory, the others aren't |
92 | if (gridService == string.Empty || presenceService == string.Empty) | 94 | if (gridService == string.Empty || presenceService == string.Empty) |
@@ -96,7 +98,9 @@ namespace OpenSim.Services.HypergridService | |||
96 | UUID.TryParse(scope, out m_ScopeID); | 98 | UUID.TryParse(scope, out m_ScopeID); |
97 | //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); | 99 | //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); |
98 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); | 100 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); |
99 | m_ExternalName = serverConfig.GetString("ExternalName", string.Empty); | 101 | m_ExternalName = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", |
102 | new string[] { "Startup", "Hypergrid", "GatekeeperService" }, String.Empty); | ||
103 | m_ExternalName = serverConfig.GetString("ExternalName", m_ExternalName); | ||
100 | if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) | 104 | if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) |
101 | m_ExternalName = m_ExternalName + "/"; | 105 | m_ExternalName = m_ExternalName + "/"; |
102 | 106 | ||
@@ -119,14 +123,19 @@ namespace OpenSim.Services.HypergridService | |||
119 | m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); | 123 | m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); |
120 | if (gridUserService != string.Empty) | 124 | if (gridUserService != string.Empty) |
121 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); | 125 | m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); |
126 | if (bansService != string.Empty) | ||
127 | m_BansService = ServerUtils.LoadPlugin<IBansService>(bansService, args); | ||
122 | 128 | ||
123 | if (simService != null) | 129 | if (simService != null) |
124 | m_SimulationService = simService; | 130 | m_SimulationService = simService; |
125 | else if (simulationService != string.Empty) | 131 | else if (simulationService != string.Empty) |
126 | m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); | 132 | m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); |
127 | 133 | ||
128 | m_AllowedClients = serverConfig.GetString("AllowedClients", string.Empty); | 134 | string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "GatekeeperService" }; |
129 | m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty); | 135 | m_AllowedClients = Util.GetConfigVarFromSections<string>( |
136 | config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); | ||
137 | m_DeniedClients = Util.GetConfigVarFromSections<string>( | ||
138 | config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); | ||
130 | m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); | 139 | m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); |
131 | 140 | ||
132 | LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); | 141 | LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); |
@@ -165,7 +174,7 @@ namespace OpenSim.Services.HypergridService | |||
165 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); | 174 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); |
166 | if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) | 175 | if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) |
167 | { | 176 | { |
168 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | 177 | List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID); |
169 | if (defs != null && defs.Count > 0) | 178 | if (defs != null && defs.Count > 0) |
170 | { | 179 | { |
171 | region = defs[0]; | 180 | region = defs[0]; |
@@ -198,41 +207,75 @@ namespace OpenSim.Services.HypergridService | |||
198 | return true; | 207 | return true; |
199 | } | 208 | } |
200 | 209 | ||
201 | public GridRegion GetHyperlinkRegion(UUID regionID) | 210 | public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHomeURI, out string message) |
202 | { | 211 | { |
203 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0}", regionID); | 212 | message = null; |
204 | 213 | ||
205 | if (!m_AllowTeleportsToAnyRegion) | 214 | if (!m_AllowTeleportsToAnyRegion) |
215 | { | ||
206 | // Don't even check the given regionID | 216 | // Don't even check the given regionID |
217 | m_log.DebugFormat( | ||
218 | "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.", | ||
219 | m_DefaultGatewayRegion.RegionName, | ||
220 | m_DefaultGatewayRegion.RegionID, | ||
221 | m_DefaultGatewayRegion.ServerURI, | ||
222 | agentID, | ||
223 | agentHomeURI == null ? "" : " @ " + agentHomeURI); | ||
224 | |||
225 | message = "Teleporting to the default region."; | ||
207 | return m_DefaultGatewayRegion; | 226 | return m_DefaultGatewayRegion; |
227 | } | ||
208 | 228 | ||
209 | GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); | 229 | GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); |
230 | |||
231 | if (region == null) | ||
232 | { | ||
233 | m_log.DebugFormat( | ||
234 | "[GATEKEEPER SERVICE]: Could not find region with ID {0} as requested by user {1}{2}. Returning null.", | ||
235 | regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI); | ||
236 | |||
237 | message = "The teleport destination could not be found."; | ||
238 | return null; | ||
239 | } | ||
240 | |||
241 | m_log.DebugFormat( | ||
242 | "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.", | ||
243 | region.RegionName, | ||
244 | region.RegionID, | ||
245 | region.ServerURI, | ||
246 | agentID, | ||
247 | agentHomeURI == null ? "" : " @ " + agentHomeURI); | ||
248 | |||
210 | return region; | 249 | return region; |
211 | } | 250 | } |
212 | 251 | ||
213 | #region Login Agent | 252 | #region Login Agent |
214 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) | 253 | public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion destination, out string reason) |
215 | { | 254 | { |
216 | reason = string.Empty; | 255 | reason = string.Empty; |
217 | 256 | ||
218 | string authURL = string.Empty; | 257 | string authURL = string.Empty; |
219 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 258 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) |
220 | authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | 259 | authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); |
221 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9} Teleport Flags {10}", | 260 | |
222 | aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName, | 261 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9}, Teleport Flags: {10}. From region {11}", |
223 | aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, aCircuit.teleportFlags.ToString()); | 262 | aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionID, |
224 | 263 | aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, (TeleportFlags)aCircuit.teleportFlags, | |
264 | (source == null) ? "Unknown" : string.Format("{0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI)); | ||
265 | |||
266 | string curViewer = Util.GetViewerName(aCircuit); | ||
267 | |||
225 | // | 268 | // |
226 | // Check client | 269 | // Check client |
227 | // | 270 | // |
228 | if (m_AllowedClients != string.Empty) | 271 | if (m_AllowedClients != string.Empty) |
229 | { | 272 | { |
230 | Regex arx = new Regex(m_AllowedClients); | 273 | Regex arx = new Regex(m_AllowedClients); |
231 | Match am = arx.Match(aCircuit.Viewer); | 274 | Match am = arx.Match(curViewer); |
232 | 275 | ||
233 | if (!am.Success) | 276 | if (!am.Success) |
234 | { | 277 | { |
235 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", aCircuit.Viewer); | 278 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); |
236 | return false; | 279 | return false; |
237 | } | 280 | } |
238 | } | 281 | } |
@@ -240,11 +283,11 @@ namespace OpenSim.Services.HypergridService | |||
240 | if (m_DeniedClients != string.Empty) | 283 | if (m_DeniedClients != string.Empty) |
241 | { | 284 | { |
242 | Regex drx = new Regex(m_DeniedClients); | 285 | Regex drx = new Regex(m_DeniedClients); |
243 | Match dm = drx.Match(aCircuit.Viewer); | 286 | Match dm = drx.Match(curViewer); |
244 | 287 | ||
245 | if (dm.Success) | 288 | if (dm.Success) |
246 | { | 289 | { |
247 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", aCircuit.Viewer); | 290 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); |
248 | return false; | 291 | return false; |
249 | } | 292 | } |
250 | } | 293 | } |
@@ -285,17 +328,16 @@ namespace OpenSim.Services.HypergridService | |||
285 | } | 328 | } |
286 | } | 329 | } |
287 | } | 330 | } |
288 | m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); | ||
289 | 331 | ||
290 | // | 332 | // |
291 | // Foreign agents allowed? Exceptions? | 333 | // Foreign agents allowed? Exceptions? |
292 | // | 334 | // |
293 | if (account == null) | 335 | if (account == null) |
294 | { | 336 | { |
295 | bool allowed = m_ForeignAgentsAllowed; | 337 | bool allowed = m_ForeignAgentsAllowed; |
296 | 338 | ||
297 | if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions)) | 339 | if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions)) |
298 | allowed = false; | 340 | allowed = false; |
299 | 341 | ||
300 | if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions)) | 342 | if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions)) |
301 | allowed = true; | 343 | allowed = true; |
@@ -309,6 +351,20 @@ namespace OpenSim.Services.HypergridService | |||
309 | } | 351 | } |
310 | } | 352 | } |
311 | 353 | ||
354 | // | ||
355 | // Is the user banned? | ||
356 | // This uses a Ban service that's more powerful than the configs | ||
357 | // | ||
358 | string uui = (account != null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit)); | ||
359 | if (m_BansService != null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL)) | ||
360 | { | ||
361 | reason = "You are banned from this world"; | ||
362 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: user {0} is banned", uui); | ||
363 | return false; | ||
364 | } | ||
365 | |||
366 | m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); | ||
367 | |||
312 | bool isFirstLogin = false; | 368 | bool isFirstLogin = false; |
313 | // | 369 | // |
314 | // Login the presence, if it's not there yet (by the login service) | 370 | // Login the presence, if it's not there yet (by the login service) |
@@ -326,7 +382,8 @@ namespace OpenSim.Services.HypergridService | |||
326 | aCircuit.firstname, aCircuit.lastname); | 382 | aCircuit.firstname, aCircuit.lastname); |
327 | return false; | 383 | return false; |
328 | } | 384 | } |
329 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); | 385 | |
386 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); | ||
330 | 387 | ||
331 | // Also login foreigners with GridUser service | 388 | // Also login foreigners with GridUser service |
332 | if (m_GridUserService != null && account == null) | 389 | if (m_GridUserService != null && account == null) |
@@ -357,7 +414,9 @@ namespace OpenSim.Services.HypergridService | |||
357 | reason = "Destination region not found"; | 414 | reason = "Destination region not found"; |
358 | return false; | 415 | return false; |
359 | } | 416 | } |
360 | m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok: {0}", destination.RegionName); | 417 | |
418 | m_log.DebugFormat( | ||
419 | "[GATEKEEPER SERVICE]: Destination {0} is ok for {1}", destination.RegionName, aCircuit.Name); | ||
361 | 420 | ||
362 | // | 421 | // |
363 | // Adjust the visible name | 422 | // Adjust the visible name |
@@ -374,7 +433,7 @@ namespace OpenSim.Services.HypergridService | |||
374 | try | 433 | try |
375 | { | 434 | { |
376 | Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); | 435 | Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); |
377 | aCircuit.lastname = "@" + uri.Host; // + ":" + uri.Port; | 436 | aCircuit.lastname = "@" + uri.Authority; |
378 | } | 437 | } |
379 | catch | 438 | catch |
380 | { | 439 | { |
@@ -391,8 +450,16 @@ namespace OpenSim.Services.HypergridService | |||
391 | // Preserve our TeleportFlags we have gathered so-far | 450 | // Preserve our TeleportFlags we have gathered so-far |
392 | loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags; | 451 | loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags; |
393 | 452 | ||
394 | m_log.DebugFormat("[GATEKEEPER SERVICE]: launching agent {0}", loginFlag); | 453 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0}, Teleport Flags: {1}", aCircuit.Name, loginFlag); |
395 | return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason); | 454 | |
455 | EntityTransferContext ctx = new EntityTransferContext(); | ||
456 | |||
457 | if (!m_SimulationService.QueryAccess( | ||
458 | destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), | ||
459 | true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) | ||
460 | return false; | ||
461 | |||
462 | return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); | ||
396 | } | 463 | } |
397 | 464 | ||
398 | protected bool Authenticate(AgentCircuitData aCircuit) | 465 | protected bool Authenticate(AgentCircuitData aCircuit) |
@@ -400,6 +467,12 @@ namespace OpenSim.Services.HypergridService | |||
400 | if (!CheckAddress(aCircuit.ServiceSessionID)) | 467 | if (!CheckAddress(aCircuit.ServiceSessionID)) |
401 | return false; | 468 | return false; |
402 | 469 | ||
470 | if (string.IsNullOrEmpty(aCircuit.IPAddress)) | ||
471 | { | ||
472 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address."); | ||
473 | return false; | ||
474 | } | ||
475 | |||
403 | string userURL = string.Empty; | 476 | string userURL = string.Empty; |
404 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 477 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) |
405 | userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | 478 | userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); |