mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 10:46:00 +08:00
robust: add login block by ID0. Note that like by mac this may even block wrong users; cosmetics
This commit is contained in:
@@ -46,9 +46,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
public class GatekeeperService : IGatekeeperService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static bool m_Initialized = false;
|
||||
|
||||
@@ -60,12 +58,13 @@ namespace OpenSim.Services.HypergridService
|
||||
private static IGridUserService m_GridUserService;
|
||||
private static IBansService m_BansService;
|
||||
|
||||
private static string m_AllowedClients = string.Empty;
|
||||
private static string m_DeniedClients = string.Empty;
|
||||
private static Regex m_AllowedClientsRegex = null;
|
||||
private static Regex m_DeniedClientsRegex = null;
|
||||
private static string m_DeniedMacs = string.Empty;
|
||||
private static string m_DeniedID0s = string.Empty;
|
||||
private static bool m_ForeignAgentsAllowed = true;
|
||||
private static List<string> m_ForeignsAllowedExceptions = new List<string>();
|
||||
private static List<string> m_ForeignsDisallowedExceptions = new List<string>();
|
||||
private static readonly List<string> m_ForeignsAllowedExceptions = new();
|
||||
private static readonly List<string> m_ForeignsDisallowedExceptions = new();
|
||||
|
||||
private static UUID m_ScopeID;
|
||||
private static bool m_AllowTeleportsToAnyRegion;
|
||||
@@ -85,7 +84,7 @@ namespace OpenSim.Services.HypergridService
|
||||
m_Initialized = true;
|
||||
|
||||
IConfig serverConfig = config.Configs["GatekeeperService"];
|
||||
if (serverConfig == null)
|
||||
if (serverConfig is null)
|
||||
throw new Exception(String.Format("No section GatekeeperService in config file"));
|
||||
|
||||
string accountService = serverConfig.GetString("UserAccountService", string.Empty);
|
||||
@@ -124,11 +123,10 @@ namespace OpenSim.Services.HypergridService
|
||||
string[] alias = gatekeeperURIAlias.Split(',');
|
||||
for (int i = 0; i < alias.Length; ++i)
|
||||
{
|
||||
OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false);
|
||||
OSHHTPHost tmp = new(alias[i].Trim(), false);
|
||||
if (tmp.IsValidHost)
|
||||
{
|
||||
if (m_gateKeeperAlias == null)
|
||||
m_gateKeeperAlias = new HashSet<OSHHTPHost>();
|
||||
m_gateKeeperAlias ??= new HashSet<OSHHTPHost>();
|
||||
m_gateKeeperAlias.Add(tmp);
|
||||
}
|
||||
}
|
||||
@@ -138,43 +136,68 @@ namespace OpenSim.Services.HypergridService
|
||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
||||
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
|
||||
|
||||
if (accountService != string.Empty)
|
||||
if (!string.IsNullOrEmpty(accountService))
|
||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
|
||||
if (homeUsersService != string.Empty)
|
||||
if (!string.IsNullOrEmpty(homeUsersService))
|
||||
m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
|
||||
if (gridUserService != string.Empty)
|
||||
if (!string.IsNullOrEmpty(gridUserService))
|
||||
m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
|
||||
if (bansService != string.Empty)
|
||||
if (!string.IsNullOrEmpty(bansService))
|
||||
m_BansService = ServerUtils.LoadPlugin<IBansService>(bansService, args);
|
||||
|
||||
if (simService != null)
|
||||
if (simService is not null)
|
||||
m_SimulationService = simService;
|
||||
else if (simulationService != string.Empty)
|
||||
m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
|
||||
|
||||
string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "GatekeeperService" };
|
||||
m_AllowedClients = Util.GetConfigVarFromSections<string>(
|
||||
config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
m_DeniedClients = Util.GetConfigVarFromSections<string>(
|
||||
config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
m_DeniedMacs = Util.GetConfigVarFromSections<string>(
|
||||
config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
|
||||
string AllowedClients = Util.GetConfigVarFromSections<string>(config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
if (!string.IsNullOrEmpty(AllowedClients))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_AllowedClientsRegex = new Regex(AllowedClients, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_AllowedClientsRegex = null;
|
||||
m_log.Error("[GATEKEEPER SERVICE]: failed to parse AllowedClients");
|
||||
}
|
||||
}
|
||||
|
||||
string DeniedClients = Util.GetConfigVarFromSections<string>(config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
if (!string.IsNullOrEmpty(DeniedClients))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_DeniedClientsRegex = new Regex(DeniedClients, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_DeniedClientsRegex = null;
|
||||
m_log.Error("[GATEKEEPER SERVICE]: failed to parse DeniedClients");
|
||||
}
|
||||
}
|
||||
|
||||
m_DeniedMacs = Util.GetConfigVarFromSections<string>(config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
|
||||
m_DeniedID0s = Util.GetConfigVarFromSections<string>(config, "DeniedID0s", possibleAccessControlConfigSections, string.Empty);
|
||||
|
||||
m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
|
||||
|
||||
LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
|
||||
LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);
|
||||
|
||||
if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
|
||||
if (m_GridService is null || m_PresenceService is null || m_SimulationService is null)
|
||||
throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
|
||||
|
||||
IConfig presenceConfig = config.Configs["PresenceService"];
|
||||
if (presenceConfig != null)
|
||||
if (presenceConfig is not null)
|
||||
{
|
||||
m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
|
||||
}
|
||||
|
||||
IConfig messagingConfig = config.Configs["Messaging"];
|
||||
if (messagingConfig != null)
|
||||
if (messagingConfig is not null)
|
||||
m_messageKey = messagingConfig.GetString("MessageKey", String.Empty);
|
||||
m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
|
||||
}
|
||||
@@ -190,8 +213,13 @@ namespace OpenSim.Services.HypergridService
|
||||
string value = config.GetString(variable, string.Empty);
|
||||
string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (string s in parts)
|
||||
exceptions.Add(s.Trim());
|
||||
foreach (string ps in parts)
|
||||
{
|
||||
string s = ps.Trim();
|
||||
if(!s.EndsWith("/"))
|
||||
s += '/';
|
||||
exceptions.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -203,13 +231,13 @@ namespace OpenSim.Services.HypergridService
|
||||
externalName = m_gatekeeperURL + ((regionName != string.Empty) ? " " + regionName : "");
|
||||
imageURL = string.Empty;
|
||||
reason = string.Empty;
|
||||
GridRegion region = null;
|
||||
GridRegion region;
|
||||
|
||||
//m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName.Length == 0)? "default region" : regionName);
|
||||
if (!m_AllowTeleportsToAnyRegion || regionName.Length == 0)
|
||||
{
|
||||
List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID);
|
||||
if (defs != null && defs.Count > 0)
|
||||
if (defs is not null && defs.Count > 0)
|
||||
{
|
||||
region = defs[0];
|
||||
m_DefaultGatewayRegion = region;
|
||||
@@ -224,7 +252,7 @@ namespace OpenSim.Services.HypergridService
|
||||
else
|
||||
{
|
||||
region = m_GridService.GetRegionByName(m_ScopeID, regionName);
|
||||
if (region == null)
|
||||
if (region is null)
|
||||
{
|
||||
reason = "Region not found";
|
||||
return false;
|
||||
@@ -256,7 +284,7 @@ namespace OpenSim.Services.HypergridService
|
||||
m_DefaultGatewayRegion.RegionID,
|
||||
m_DefaultGatewayRegion.ServerURI,
|
||||
agentID,
|
||||
agentHomeURI == null ? "" : " @ " + agentHomeURI);
|
||||
agentHomeURI is null ? "" : " @ " + agentHomeURI);
|
||||
|
||||
message = "Teleporting to the default region.";
|
||||
return m_DefaultGatewayRegion;
|
||||
@@ -268,7 +296,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[GATEKEEPER SERVICE]: Could not find region with ID {0} as requested by user {1}{2}. Returning null.",
|
||||
regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI);
|
||||
regionID, agentID, (agentHomeURI is null) ? "" : " @ " + agentHomeURI);
|
||||
|
||||
message = "The teleport destination could not be found.";
|
||||
return null;
|
||||
@@ -280,7 +308,7 @@ namespace OpenSim.Services.HypergridService
|
||||
region.RegionID,
|
||||
region.ServerURI,
|
||||
agentID,
|
||||
agentHomeURI == null ? "" : " @ " + agentHomeURI);
|
||||
agentHomeURI is null ? "" : " @ " + agentHomeURI);
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -306,35 +334,39 @@ namespace OpenSim.Services.HypergridService
|
||||
//
|
||||
// Check client
|
||||
//
|
||||
if (!String.IsNullOrWhiteSpace(m_AllowedClients))
|
||||
if (m_AllowedClientsRegex is not null)
|
||||
{
|
||||
Regex arx = new Regex(m_AllowedClients);
|
||||
Match am = arx.Match(curViewer);
|
||||
|
||||
if (!am.Success)
|
||||
lock(m_AllowedClientsRegex)
|
||||
{
|
||||
reason = "Login failed: client " + curViewer + " is not allowed";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
|
||||
return false;
|
||||
Match am = m_AllowedClientsRegex.Match(curViewer);
|
||||
|
||||
if (!am.Success)
|
||||
{
|
||||
reason = "Login failed: client " + curViewer + " is not allowed";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(m_DeniedClients))
|
||||
if (m_DeniedClientsRegex is not null)
|
||||
{
|
||||
Regex drx = new Regex(m_DeniedClients);
|
||||
Match dm = drx.Match(curViewer);
|
||||
|
||||
if (dm.Success)
|
||||
lock(m_DeniedClientsRegex)
|
||||
{
|
||||
reason = "Login failed: client " + curViewer + " is denied";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
|
||||
return false;
|
||||
Match dm = m_DeniedClientsRegex.Match(curViewer);
|
||||
|
||||
if (dm.Success)
|
||||
{
|
||||
reason = "Login failed: client " + curViewer + " is denied";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(m_DeniedMacs))
|
||||
{
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
//m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
if (m_DeniedMacs.Contains(curMac))
|
||||
{
|
||||
reason = "Login failed: client with Mac " + curMac + " is denied";
|
||||
@@ -343,6 +375,17 @@ namespace OpenSim.Services.HypergridService
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_DeniedID0s))
|
||||
{
|
||||
//m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
if (m_DeniedID0s.Contains(aCircuit.Id0))
|
||||
{
|
||||
reason = "Login failed: client with id0 " + aCircuit.Id0 + " is denied";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client with mac {0} is denied", aCircuit.Id0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Authenticate the user
|
||||
//
|
||||
@@ -358,14 +401,14 @@ namespace OpenSim.Services.HypergridService
|
||||
// Check for impersonations
|
||||
//
|
||||
UserAccount account = null;
|
||||
if (m_UserAccountService != null)
|
||||
if (m_UserAccountService is not null)
|
||||
{
|
||||
// Check to see if we have a local user with that UUID
|
||||
account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
|
||||
if (account != null)
|
||||
if (account is not null)
|
||||
{
|
||||
// Make sure this is the user coming home, and not a foreign user with same UUID as a local user
|
||||
if (m_UserAgentService != null)
|
||||
if (m_UserAgentService is not null)
|
||||
{
|
||||
if (!m_UserAgentService.IsAgentComingHome(aCircuit.SessionID, m_gatekeeperURL))
|
||||
{
|
||||
@@ -383,7 +426,7 @@ namespace OpenSim.Services.HypergridService
|
||||
//
|
||||
// Foreign agents allowed? Exceptions?
|
||||
//
|
||||
if (account == null)
|
||||
if (account is null)
|
||||
{
|
||||
bool allowed = m_ForeignAgentsAllowed;
|
||||
|
||||
@@ -406,8 +449,8 @@ namespace OpenSim.Services.HypergridService
|
||||
// Is the user banned?
|
||||
// This uses a Ban service that's more powerful than the configs
|
||||
//
|
||||
string uui = (account != null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit));
|
||||
if (m_BansService != null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL))
|
||||
string uui = (account is not null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit));
|
||||
if (m_BansService is not null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL))
|
||||
{
|
||||
reason = "You are banned from this world";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: user {0} is banned", uui);
|
||||
@@ -415,32 +458,33 @@ namespace OpenSim.Services.HypergridService
|
||||
}
|
||||
|
||||
UUID agentID = aCircuit.AgentID;
|
||||
if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
|
||||
if(agentID.Equals(Constants.servicesGodAgentID))
|
||||
{
|
||||
// really?
|
||||
reason = "Invalid account ID";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_GridUserService != null)
|
||||
if(m_GridUserService is not null)
|
||||
{
|
||||
string PrincipalIDstr = agentID.ToString();
|
||||
GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
|
||||
|
||||
if(!m_allowDuplicatePresences)
|
||||
GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(uui);
|
||||
if (guinfo is not null)
|
||||
{
|
||||
if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
|
||||
if (!m_allowDuplicatePresences)
|
||||
{
|
||||
if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo))
|
||||
if (guinfo.Online && !guinfo.LastRegionID.IsZero())
|
||||
{
|
||||
if(account != null)
|
||||
m_log.InfoFormat(
|
||||
"[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in",
|
||||
account.FirstName, account.LastName);
|
||||
reason = "You appear to be already logged in on the destination grid " +
|
||||
"Please wait a a minute or two and retry. " +
|
||||
"If this takes longer than a few minutes please contact the grid owner.";
|
||||
return false;
|
||||
if (SendAgentGodKillToRegion(UUID.Zero, agentID, uui, guinfo))
|
||||
{
|
||||
if (account is not null)
|
||||
m_log.InfoFormat(
|
||||
"[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in",
|
||||
account.FirstName, account.LastName);
|
||||
reason = "You appear to be already logged in on the destination grid " +
|
||||
"Please wait a a minute or two and retry. " +
|
||||
"If this takes longer than a few minutes please contact the grid owner.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,7 +497,7 @@ namespace OpenSim.Services.HypergridService
|
||||
// Login the presence, if it's not there yet (by the login service)
|
||||
//
|
||||
PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID);
|
||||
if (presence != null) // it has been placed there by the login service
|
||||
if (presence is not null) // it has been placed there by the login service
|
||||
isFirstLogin = true;
|
||||
|
||||
else
|
||||
@@ -472,7 +516,7 @@ namespace OpenSim.Services.HypergridService
|
||||
// Get the region
|
||||
//
|
||||
destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID);
|
||||
if (destination == null)
|
||||
if (destination is null)
|
||||
{
|
||||
reason = "Destination region not found";
|
||||
return false;
|
||||
@@ -484,18 +528,18 @@ namespace OpenSim.Services.HypergridService
|
||||
//
|
||||
// Adjust the visible name
|
||||
//
|
||||
if (account != null)
|
||||
if (account is not null)
|
||||
{
|
||||
aCircuit.firstname = account.FirstName;
|
||||
aCircuit.lastname = account.LastName;
|
||||
}
|
||||
if (account == null)
|
||||
if (account is null)
|
||||
{
|
||||
if (!aCircuit.lastname.StartsWith("@"))
|
||||
aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname;
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString());
|
||||
Uri uri = new(aCircuit.ServiceURLs["HomeURI"].ToString());
|
||||
aCircuit.lastname = "@" + uri.Authority;
|
||||
}
|
||||
catch
|
||||
@@ -515,7 +559,7 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0}, Teleport Flags: {1}", aCircuit.Name, loginFlag);
|
||||
|
||||
EntityTransferContext ctx = new EntityTransferContext();
|
||||
EntityTransferContext ctx = new();
|
||||
|
||||
if (!m_SimulationService.QueryAccess(
|
||||
destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(),
|
||||
@@ -528,7 +572,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
|
||||
|
||||
if(!isFirstLogin && m_GridUserService != null && account == null)
|
||||
if(!isFirstLogin && m_GridUserService is not null && account is null)
|
||||
{
|
||||
// Also login foreigners with GridUser service
|
||||
string userId = aCircuit.AgentID.ToString();
|
||||
@@ -566,7 +610,7 @@ namespace OpenSim.Services.HypergridService
|
||||
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
|
||||
userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
|
||||
|
||||
OSHHTPHost userHomeHost = new OSHHTPHost(userURL, true);
|
||||
OSHHTPHost userHomeHost = new(userURL, true);
|
||||
if(!userHomeHost.IsResolvedHost)
|
||||
{
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL");
|
||||
@@ -601,7 +645,7 @@ namespace OpenSim.Services.HypergridService
|
||||
if (parts.Length < 2)
|
||||
return false;
|
||||
|
||||
OSHHTPHost reqGrid = new OSHHTPHost(parts[0], false);
|
||||
OSHHTPHost reqGrid = new(parts[0], false);
|
||||
if(!reqGrid.IsValidHost)
|
||||
{
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Visitor provided malformed gird address {0}", parts[0]);
|
||||
@@ -624,31 +668,30 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
private bool IsException(AgentCircuitData aCircuit, List<string> exceptions)
|
||||
{
|
||||
bool exception = false;
|
||||
if (exceptions.Count > 0) // we have exceptions
|
||||
{
|
||||
// Retrieve the visitor's origin
|
||||
string userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
|
||||
string userURL = aCircuit.ServiceURLs["HomeURI"].ToString().Trim();
|
||||
if (string.IsNullOrEmpty(userURL))
|
||||
return false;
|
||||
|
||||
if (!userURL.EndsWith("/"))
|
||||
userURL += "/";
|
||||
|
||||
if (exceptions.Find(delegate(string s)
|
||||
{
|
||||
if (!s.EndsWith("/"))
|
||||
s += "/";
|
||||
return s == userURL;
|
||||
}) != null)
|
||||
exception = true;
|
||||
if(userURL.Equals(s))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return exception;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
|
||||
private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID, string uui, GridUserInfo guinfo)
|
||||
{
|
||||
UUID regionID = guinfo.LastRegionID;
|
||||
GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
if(regInfo == null)
|
||||
if(regInfo is null)
|
||||
return false;
|
||||
|
||||
string regURL = regInfo.ServerURI;
|
||||
@@ -671,7 +714,7 @@ namespace OpenSim.Services.HypergridService
|
||||
msg.binaryBucket = new byte[1] {0};
|
||||
InstantMessageServiceConnector.SendInstantMessage(regURL,msg, m_messageKey);
|
||||
|
||||
m_GridUserService.LoggedOut(agentID.ToString(),
|
||||
m_GridUserService.LoggedOut(uui,
|
||||
UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -53,9 +53,7 @@ namespace OpenSim.Services.HypergridService
|
||||
/// </summary>
|
||||
public class UserAgentService : UserAgentServiceBase, IUserAgentService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// This will need to go into a DB table
|
||||
//static Dictionary<UUID, TravelingAgentInfo> m_Database = new Dictionary<UUID, TravelingAgentInfo>();
|
||||
@@ -80,9 +78,9 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
protected static bool m_BypassClientVerification;
|
||||
|
||||
private static Dictionary<int, bool> m_ForeignTripsAllowed = new Dictionary<int, bool>();
|
||||
private static Dictionary<int, List<string>> m_TripsAllowedExceptions = new Dictionary<int, List<string>>();
|
||||
private static Dictionary<int, List<string>> m_TripsDisallowedExceptions = new Dictionary<int, List<string>>();
|
||||
private static readonly Dictionary<int, bool> m_ForeignTripsAllowed = new();
|
||||
private static readonly Dictionary<int, List<string>> m_TripsAllowedExceptions = new();
|
||||
private static readonly Dictionary<int, List<string>> m_TripsDisallowedExceptions = new();
|
||||
|
||||
public UserAgentService(IConfigSource config) : this(config, null)
|
||||
{
|
||||
@@ -93,7 +91,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
// Let's set this always, because we don't know the sequence
|
||||
// of instantiations
|
||||
if (friendsConnector != null)
|
||||
if (friendsConnector is not null)
|
||||
m_FriendsLocalSimConnector = friendsConnector;
|
||||
|
||||
if (!m_Initialized)
|
||||
@@ -105,7 +103,7 @@ namespace OpenSim.Services.HypergridService
|
||||
m_FriendsSimConnector = new FriendsSimConnector();
|
||||
|
||||
IConfig serverConfig = config.Configs["UserAgentService"];
|
||||
if (serverConfig == null)
|
||||
if (serverConfig is null)
|
||||
throw new Exception(String.Format("No section UserAgentService in config file"));
|
||||
|
||||
string gridService = serverConfig.GetString("GridService", String.Empty);
|
||||
@@ -152,13 +150,12 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
m_GridName = m_GridName.ToLowerInvariant();
|
||||
if (!m_GridName.EndsWith("/"))
|
||||
m_GridName = m_GridName + "/";
|
||||
Uri gateURI;
|
||||
if(!Uri.TryCreate(m_GridName, UriKind.Absolute, out gateURI))
|
||||
m_GridName += "/";
|
||||
if (!Uri.TryCreate(m_GridName, UriKind.Absolute, out Uri gateURI))
|
||||
throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri"));
|
||||
string host = gateURI.DnsSafeHost;
|
||||
IPAddress ip = Util.GetHostFromDNS(host);
|
||||
if(ip == null)
|
||||
if(ip is null)
|
||||
throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host"));
|
||||
m_MyExternalIP = ip.ToString();
|
||||
}
|
||||
@@ -174,8 +171,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
if (keyName.StartsWith(variable + "_Level_"))
|
||||
{
|
||||
int level = 0;
|
||||
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level))
|
||||
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level))
|
||||
m_ForeignTripsAllowed.Add(level, config.GetBoolean(keyName, true));
|
||||
}
|
||||
}
|
||||
@@ -187,15 +183,19 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
if (keyName.StartsWith(variable + "_Level_"))
|
||||
{
|
||||
int level = 0;
|
||||
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level) && !exceptions.ContainsKey(level))
|
||||
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level) && !exceptions.ContainsKey(level))
|
||||
{
|
||||
exceptions.Add(level, new List<string>());
|
||||
string value = config.GetString(keyName, string.Empty);
|
||||
string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (string s in parts)
|
||||
exceptions[level].Add(s.Trim());
|
||||
{
|
||||
string ss = s.Trim();
|
||||
if(!ss.EndsWith("/"))
|
||||
ss += '/';
|
||||
exceptions[level].Add(ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,18 +209,18 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
GridRegion home = null;
|
||||
GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
|
||||
if (uinfo != null)
|
||||
if (uinfo is not null)
|
||||
{
|
||||
if (!uinfo.HomeRegionID.IsZero())
|
||||
if (uinfo.HomeRegionID.IsNotZero())
|
||||
{
|
||||
home = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
|
||||
position = uinfo.HomePosition;
|
||||
lookAt = uinfo.HomeLookAt;
|
||||
}
|
||||
if (home == null)
|
||||
if (home is null)
|
||||
{
|
||||
List<GridRegion> defs = m_GridService.GetDefaultRegions(UUID.Zero);
|
||||
if (defs != null && defs.Count > 0)
|
||||
if (defs is not null && defs.Count > 0)
|
||||
home = defs[0];
|
||||
}
|
||||
}
|
||||
@@ -236,7 +236,7 @@ namespace OpenSim.Services.HypergridService
|
||||
string gridName = gatekeeper.ServerURI.ToLowerInvariant();
|
||||
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID);
|
||||
if (account == null)
|
||||
if (account is null)
|
||||
{
|
||||
m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname);
|
||||
reason = "Forbidden to launch your agents from here";
|
||||
@@ -266,27 +266,28 @@ namespace OpenSim.Services.HypergridService
|
||||
}
|
||||
|
||||
// Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
|
||||
GridRegion region = new GridRegion(gatekeeper);
|
||||
region.ServerURI = gatekeeper.ServerURI;
|
||||
region.ExternalHostName = finalDestination.ExternalHostName;
|
||||
region.InternalEndPoint = finalDestination.InternalEndPoint;
|
||||
region.RegionName = finalDestination.RegionName;
|
||||
region.RegionID = finalDestination.RegionID;
|
||||
region.RegionLocX = finalDestination.RegionLocX;
|
||||
region.RegionLocY = finalDestination.RegionLocY;
|
||||
GridRegion region = new(gatekeeper)
|
||||
{
|
||||
ServerURI = gatekeeper.ServerURI,
|
||||
ExternalHostName = finalDestination.ExternalHostName,
|
||||
InternalEndPoint = finalDestination.InternalEndPoint,
|
||||
RegionName = finalDestination.RegionName,
|
||||
RegionID = finalDestination.RegionID,
|
||||
RegionLocX = finalDestination.RegionLocX,
|
||||
RegionLocY = finalDestination.RegionLocY
|
||||
};
|
||||
|
||||
// Generate a new service session
|
||||
agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
|
||||
TravelingAgentInfo old = null;
|
||||
TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
|
||||
TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out TravelingAgentInfo old);
|
||||
|
||||
if(!fromLogin && old != null && !string.IsNullOrEmpty(old.ClientIPAddress))
|
||||
if(!fromLogin && old is not null && !string.IsNullOrEmpty(old.ClientIPAddress))
|
||||
{
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: stored IP = {0}. Old circuit IP: {1}", old.ClientIPAddress, agentCircuit.IPAddress);
|
||||
agentCircuit.IPAddress = old.ClientIPAddress;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
bool success;
|
||||
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
|
||||
|
||||
@@ -297,7 +298,7 @@ namespace OpenSim.Services.HypergridService
|
||||
else
|
||||
{
|
||||
//TODO: Should there not be a call to QueryAccess here?
|
||||
EntityTransferContext ctx = new EntityTransferContext();
|
||||
EntityTransferContext ctx = new();
|
||||
success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out reason);
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ namespace OpenSim.Services.HypergridService
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
|
||||
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
|
||||
|
||||
if (old != null)
|
||||
if (old is not null)
|
||||
StoreTravelInfo(old);
|
||||
else
|
||||
m_Database.Delete(agentCircuit.SessionID);
|
||||
@@ -323,7 +324,6 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return LoginAgentToGrid(source, agentCircuit, gatekeeper, finalDestination, false, out reason);
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace OpenSim.Services.HypergridService
|
||||
HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID);
|
||||
existing = null;
|
||||
|
||||
if (hgt != null)
|
||||
if (hgt is not null)
|
||||
{
|
||||
// Very important! Override whatever this agent comes with.
|
||||
// UserAgentService always sets the IP for every new agent
|
||||
@@ -341,11 +341,13 @@ namespace OpenSim.Services.HypergridService
|
||||
agentCircuit.IPAddress = existing.ClientIPAddress;
|
||||
}
|
||||
|
||||
TravelingAgentInfo travel = new TravelingAgentInfo(existing);
|
||||
travel.SessionID = agentCircuit.SessionID;
|
||||
travel.UserID = agentCircuit.AgentID;
|
||||
travel.GridExternalName = region.ServerURI;
|
||||
travel.ServiceToken = agentCircuit.ServiceSessionID;
|
||||
TravelingAgentInfo travel = new(existing)
|
||||
{
|
||||
SessionID = agentCircuit.SessionID,
|
||||
UserID = agentCircuit.AgentID,
|
||||
GridExternalName = region.ServerURI,
|
||||
ServiceToken = agentCircuit.ServiceSessionID
|
||||
};
|
||||
|
||||
if (fromLogin)
|
||||
travel.ClientIPAddress = agentCircuit.IPAddress;
|
||||
@@ -362,7 +364,7 @@ namespace OpenSim.Services.HypergridService
|
||||
m_Database.Delete(sessionID);
|
||||
|
||||
GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
|
||||
if (guinfo != null)
|
||||
if (guinfo is not null)
|
||||
m_GridUserService.LoggedOut(userID.ToString(), sessionID, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
|
||||
}
|
||||
|
||||
@@ -370,12 +372,11 @@ namespace OpenSim.Services.HypergridService
|
||||
public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
|
||||
{
|
||||
HGTravelingData hgt = m_Database.Get(sessionID);
|
||||
if (hgt == null)
|
||||
if (hgt is null || hgt.Data is null)
|
||||
return false;
|
||||
|
||||
TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
|
||||
|
||||
return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower();
|
||||
if(!hgt.Data.TryGetValue("GridExternalName", out string htgGrid))
|
||||
return false;
|
||||
return htgGrid.Equals(thisGridExternalName, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool VerifyClient(UUID sessionID, string reportedIP)
|
||||
@@ -387,10 +388,10 @@ namespace OpenSim.Services.HypergridService
|
||||
sessionID, reportedIP);
|
||||
|
||||
HGTravelingData hgt = m_Database.Get(sessionID);
|
||||
if (hgt == null)
|
||||
if (hgt is null)
|
||||
return false;
|
||||
|
||||
TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
|
||||
TravelingAgentInfo travel = new(hgt);
|
||||
|
||||
bool result = travel.ClientIPAddress == reportedIP;
|
||||
if(!result && !string.IsNullOrEmpty(m_MyExternalIP))
|
||||
@@ -405,7 +406,7 @@ namespace OpenSim.Services.HypergridService
|
||||
public bool VerifyAgent(UUID sessionID, string token)
|
||||
{
|
||||
HGTravelingData hgt = m_Database.Get(sessionID);
|
||||
if (hgt == null)
|
||||
if (hgt is null)
|
||||
{
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
|
||||
return false;
|
||||
@@ -425,18 +426,16 @@ namespace OpenSim.Services.HypergridService
|
||||
return new List<UUID>();
|
||||
}
|
||||
|
||||
List<UUID> localFriendsOnline = new List<UUID>();
|
||||
List<UUID> localFriendsOnline = new();
|
||||
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
|
||||
|
||||
// First, let's double check that the reported friends are, indeed, friends of that user
|
||||
// And let's check that the secret matches
|
||||
List<string> usersToBeNotified = new List<string>();
|
||||
List<string> usersToBeNotified = new();
|
||||
foreach (string uui in friends)
|
||||
{
|
||||
UUID localUserID;
|
||||
string secret = string.Empty, tmp = string.Empty;
|
||||
if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
|
||||
if (Util.ParseUniversalUserIdentifier(uui, out UUID localUserID, out _, out _, out _, out string secret))
|
||||
{
|
||||
FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
|
||||
foreach (FriendInfo finfo in friendInfos)
|
||||
@@ -459,18 +458,18 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
PresenceInfo friendSession = null;
|
||||
foreach (PresenceInfo pinfo in friendSessions)
|
||||
if (!pinfo.RegionID.IsZero()) // let's guard against traveling agents
|
||||
{
|
||||
if (pinfo.RegionID.IsNotZero()) // let's guard against traveling agents
|
||||
{
|
||||
friendSession = pinfo;
|
||||
break;
|
||||
}
|
||||
|
||||
if (friendSession != null)
|
||||
}
|
||||
if (friendSession is not null)
|
||||
{
|
||||
ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online);
|
||||
usersToBeNotified.Remove(friendSession.UserID.ToString());
|
||||
UUID id;
|
||||
if (UUID.TryParse(friendSession.UserID, out id))
|
||||
if (UUID.TryParse(friendSession.UserID, out UUID id))
|
||||
localFriendsOnline.Add(id);
|
||||
|
||||
}
|
||||
@@ -500,10 +499,9 @@ namespace OpenSim.Services.HypergridService
|
||||
[Obsolete]
|
||||
protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online)
|
||||
{
|
||||
UUID userID;
|
||||
if (UUID.TryParse(user, out userID))
|
||||
if (UUID.TryParse(user, out UUID userID))
|
||||
{
|
||||
if (m_FriendsLocalSimConnector != null)
|
||||
if (m_FriendsLocalSimConnector is not null)
|
||||
{
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
|
||||
m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
|
||||
@@ -511,7 +509,7 @@ namespace OpenSim.Services.HypergridService
|
||||
else
|
||||
{
|
||||
GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
{
|
||||
m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
|
||||
m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online);
|
||||
@@ -522,9 +520,9 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public List<UUID> GetOnlineFriends(UUID foreignUserID, List<string> friends)
|
||||
{
|
||||
List<UUID> online = new List<UUID>();
|
||||
List<UUID> online = new();
|
||||
|
||||
if (m_FriendsService == null || m_PresenceService == null)
|
||||
if (m_FriendsService is null || m_PresenceService is null)
|
||||
{
|
||||
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing");
|
||||
return online;
|
||||
@@ -534,12 +532,10 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
// First, let's double check that the reported friends are, indeed, friends of that user
|
||||
// And let's check that the secret matches and the rights
|
||||
List<string> usersToBeNotified = new List<string>();
|
||||
List<string> usersToBeNotified = new();
|
||||
foreach (string uui in friends)
|
||||
{
|
||||
UUID localUserID;
|
||||
string secret = string.Empty, tmp = string.Empty;
|
||||
if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
|
||||
if (Util.ParseUniversalUserIdentifier(uui, out UUID localUserID, out _, out _, out _, out string secret))
|
||||
{
|
||||
FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
|
||||
foreach (FriendInfo finfo in friendInfos)
|
||||
@@ -559,12 +555,11 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
// First, let's send notifications to local users who are online in the home grid
|
||||
PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
foreach (PresenceInfo pi in friendSessions)
|
||||
{
|
||||
UUID presenceID;
|
||||
if (UUID.TryParse(pi.UserID, out presenceID))
|
||||
if (UUID.TryParse(pi.UserID, out UUID presenceID))
|
||||
online.Add(presenceID);
|
||||
}
|
||||
}
|
||||
@@ -574,9 +569,9 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public Dictionary<string, object> GetUserInfo(UUID userID)
|
||||
{
|
||||
Dictionary<string, object> info = new Dictionary<string, object>();
|
||||
Dictionary<string, object> info = new();
|
||||
|
||||
if (m_UserAccountService == null)
|
||||
if (m_UserAccountService is null)
|
||||
{
|
||||
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get user flags because user account service is missing");
|
||||
info["result"] = "fail";
|
||||
@@ -611,7 +606,7 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public Dictionary<string, object> GetServerURLs(UUID userID)
|
||||
{
|
||||
if (m_UserAccountService == null)
|
||||
if (m_UserAccountService is null)
|
||||
{
|
||||
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing");
|
||||
return new Dictionary<string, object>();
|
||||
@@ -640,21 +635,21 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
// Let's see if it's a local user
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID);
|
||||
if (account != null)
|
||||
if (account is not null)
|
||||
return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ;
|
||||
|
||||
// Let's try the list of friends
|
||||
if(m_FriendsService != null)
|
||||
if(m_FriendsService is not null)
|
||||
{
|
||||
FriendInfo[] friends = m_FriendsService.GetFriends(userID);
|
||||
if (friends != null && friends.Length > 0)
|
||||
if (friends is not null && friends.Length > 0)
|
||||
{
|
||||
foreach (FriendInfo f in friends)
|
||||
if (f.Friend.StartsWith(targetUserID.ToString()))
|
||||
{
|
||||
// Let's remove the secret
|
||||
UUID id; string tmp = string.Empty, secret = string.Empty;
|
||||
if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret))
|
||||
if (Util.ParseUniversalUserIdentifier(f.Friend, out _,
|
||||
out _, out _, out _, out string secret))
|
||||
return f.Friend.Replace(secret, "0");
|
||||
}
|
||||
}
|
||||
@@ -666,7 +661,7 @@ namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
// Let's see if it's a local user
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last);
|
||||
if (account != null)
|
||||
if (account is not null)
|
||||
{
|
||||
// check user level
|
||||
if (account.UserLevel < m_LevelOutsideContacts)
|
||||
@@ -682,40 +677,37 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
private bool IsException(string dest, int level, Dictionary<int, List<string>> exceptions)
|
||||
{
|
||||
if (!exceptions.ContainsKey(level))
|
||||
if (string.IsNullOrEmpty(dest))
|
||||
return false;
|
||||
if (!exceptions.TryGetValue(level, out List<string> excep) || excep.Count == 0)
|
||||
return false;
|
||||
|
||||
bool exception = false;
|
||||
if (exceptions[level].Count > 0) // we have exceptions
|
||||
{
|
||||
string destination = dest;
|
||||
if (!destination.EndsWith("/"))
|
||||
destination += "/";
|
||||
|
||||
if (exceptions[level].Find(delegate(string s)
|
||||
{
|
||||
if (!s.EndsWith("/"))
|
||||
s += "/";
|
||||
return s == destination;
|
||||
}) != null)
|
||||
exception = true;
|
||||
if (destination.Equals(s))
|
||||
return true;
|
||||
}
|
||||
|
||||
return exception;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void StoreTravelInfo(TravelingAgentInfo travel)
|
||||
{
|
||||
if (travel == null)
|
||||
if (travel is null)
|
||||
return;
|
||||
|
||||
HGTravelingData hgt = new HGTravelingData();
|
||||
hgt.SessionID = travel.SessionID;
|
||||
hgt.UserID = travel.UserID;
|
||||
hgt.Data = new Dictionary<string, string>();
|
||||
hgt.Data["GridExternalName"] = travel.GridExternalName;
|
||||
hgt.Data["ServiceToken"] = travel.ServiceToken;
|
||||
hgt.Data["ClientIPAddress"] = travel.ClientIPAddress;
|
||||
HGTravelingData hgt = new()
|
||||
{
|
||||
SessionID = travel.SessionID,
|
||||
UserID = travel.UserID,
|
||||
Data = new Dictionary<string, string>
|
||||
{
|
||||
["GridExternalName"] = travel.GridExternalName,
|
||||
["ServiceToken"] = travel.ServiceToken,
|
||||
["ClientIPAddress"] = travel.ClientIPAddress
|
||||
}
|
||||
};
|
||||
|
||||
m_Database.Store(hgt);
|
||||
}
|
||||
@@ -733,7 +725,7 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public TravelingAgentInfo(HGTravelingData t)
|
||||
{
|
||||
if (t.Data != null)
|
||||
if (t.Data is not null)
|
||||
{
|
||||
SessionID = new UUID(t.SessionID);
|
||||
UserID = new UUID(t.UserID);
|
||||
@@ -745,7 +737,7 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
public TravelingAgentInfo(TravelingAgentInfo old)
|
||||
{
|
||||
if (old != null)
|
||||
if (old is not null)
|
||||
{
|
||||
SessionID = old.SessionID;
|
||||
UserID = old.UserID;
|
||||
|
||||
@@ -26,11 +26,8 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.Base;
|
||||
|
||||
namespace OpenSim.Services.HypergridService
|
||||
@@ -50,7 +47,7 @@ namespace OpenSim.Services.HypergridService
|
||||
// Try reading the [DatabaseService] section, if it exists
|
||||
//
|
||||
IConfig dbConfig = config.Configs["DatabaseService"];
|
||||
if (dbConfig != null)
|
||||
if (dbConfig is not null)
|
||||
{
|
||||
if (dllName.Length == 0)
|
||||
dllName = dbConfig.GetString("StorageProvider", String.Empty);
|
||||
@@ -62,7 +59,7 @@ namespace OpenSim.Services.HypergridService
|
||||
// [UserAgentService] section overrides [DatabaseService], if it exists
|
||||
//
|
||||
IConfig gridConfig = config.Configs["UserAgentService"];
|
||||
if (gridConfig != null)
|
||||
if (gridConfig is not null)
|
||||
{
|
||||
dllName = gridConfig.GetString("StorageProvider", dllName);
|
||||
connString = gridConfig.GetString("ConnectionString", connString);
|
||||
@@ -76,7 +73,7 @@ namespace OpenSim.Services.HypergridService
|
||||
throw new Exception("No StorageProvider configured");
|
||||
|
||||
m_Database = LoadPlugin<IHGTravelingData>(dllName, new Object[] { connString, realm });
|
||||
if (m_Database == null)
|
||||
if (m_Database is null)
|
||||
throw new Exception("Could not find a storage interface in the given module");
|
||||
|
||||
}
|
||||
|
||||
@@ -84,9 +84,10 @@ namespace OpenSim.Services.LLLoginService
|
||||
protected int m_MaxAgentGroups = 42;
|
||||
protected string m_DestinationGuide;
|
||||
protected string m_AvatarPicker;
|
||||
protected string m_AllowedClients;
|
||||
protected string m_DeniedClients;
|
||||
protected Regex m_AllowedClientsRegex;
|
||||
protected Regex m_DeniedClientsRegex;
|
||||
protected string m_DeniedMacs;
|
||||
protected string m_DeniedID0s;
|
||||
protected string m_MessageUrl;
|
||||
protected string m_DSTZone;
|
||||
protected bool m_allowDuplicatePresences = false;
|
||||
@@ -94,13 +95,13 @@ namespace OpenSim.Services.LLLoginService
|
||||
protected bool m_allowLoginFallbackToAnyRegion = true; // if login requested region if not found and there are no Default or fallback regions,
|
||||
// try any online. This is legacy behaviour
|
||||
|
||||
IConfig m_LoginServerConfig;
|
||||
readonly IConfig m_LoginServerConfig;
|
||||
// IConfig m_ClientsConfig;
|
||||
|
||||
public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService)
|
||||
{
|
||||
m_LoginServerConfig = config.Configs["LoginService"];
|
||||
if (m_LoginServerConfig == null)
|
||||
if (m_LoginServerConfig is null)
|
||||
throw new Exception(string.Format("No section LoginService in config file"));
|
||||
|
||||
string accountService = m_LoginServerConfig.GetString("UserAccountService", string.Empty);
|
||||
@@ -132,23 +133,47 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
m_allowLoginFallbackToAnyRegion = m_LoginServerConfig.GetBoolean("AllowLoginFallbackToAnyRegion", m_allowLoginFallbackToAnyRegion);
|
||||
|
||||
string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "LoginService" };
|
||||
m_AllowedClients = Util.GetConfigVarFromSections<string>(
|
||||
config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
m_DeniedClients = Util.GetConfigVarFromSections<string>(
|
||||
config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
|
||||
m_DeniedMacs = Util.GetConfigVarFromSections<string>(
|
||||
config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
|
||||
string[] accessControlConfigSections = new string[] { "AccessControl", "LoginService" };
|
||||
string AllowedClients = Util.GetConfigVarFromSections<string>(config, "AllowedClients", accessControlConfigSections, string.Empty);
|
||||
if (!string.IsNullOrEmpty(AllowedClients))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_AllowedClientsRegex = new Regex(AllowedClients, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_AllowedClientsRegex = null;
|
||||
m_log.Error("[GATEKEEPER SERVICE]: failed to parse AllowedClients");
|
||||
}
|
||||
}
|
||||
|
||||
string DeniedClients = Util.GetConfigVarFromSections<string>(config, "DeniedClients", accessControlConfigSections, string.Empty);
|
||||
if (!string.IsNullOrEmpty(DeniedClients))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_DeniedClientsRegex = new Regex(DeniedClients, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_DeniedClientsRegex = null;
|
||||
m_log.Error("[GATEKEEPER SERVICE]: failed to parse DeniedClients");
|
||||
}
|
||||
}
|
||||
|
||||
m_DeniedMacs = Util.GetConfigVarFromSections<string>(config, "DeniedMacs", accessControlConfigSections, string.Empty);
|
||||
m_DeniedID0s = Util.GetConfigVarFromSections<string>(config, "DeniedID0s", accessControlConfigSections, string.Empty);
|
||||
|
||||
m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
|
||||
m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
|
||||
|
||||
IConfig groupConfig = config.Configs["Groups"];
|
||||
if (groupConfig != null)
|
||||
if (groupConfig is not null)
|
||||
m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
|
||||
|
||||
IConfig presenceConfig = config.Configs["PresenceService"];
|
||||
if (presenceConfig != null)
|
||||
if (presenceConfig is not null)
|
||||
{
|
||||
m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
|
||||
}
|
||||
@@ -158,11 +183,11 @@ namespace OpenSim.Services.LLLoginService
|
||||
{
|
||||
m_MapTileURL = m_MapTileURL.Trim();
|
||||
if (!m_MapTileURL.EndsWith("/"))
|
||||
m_MapTileURL = m_MapTileURL + "/";
|
||||
m_MapTileURL += "/";
|
||||
}
|
||||
|
||||
IConfig messagingConfig = config.Configs["Messaging"];
|
||||
if (messagingConfig != null)
|
||||
if (messagingConfig is not null)
|
||||
m_messageKey = messagingConfig.GetString("MessageKey", string.Empty);
|
||||
// These are required; the others aren't
|
||||
if (accountService.Length == 0 || authService.Length == 0)
|
||||
@@ -207,7 +232,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
// deal with the services given as argument
|
||||
//
|
||||
m_LocalSimulationService = simService;
|
||||
if (libraryService != null)
|
||||
if (libraryService is not null)
|
||||
{
|
||||
m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument");
|
||||
m_LibraryService = libraryService;
|
||||
@@ -236,8 +261,10 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
public Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP)
|
||||
{
|
||||
Hashtable response = new Hashtable();
|
||||
response["success"] = "false";
|
||||
Hashtable response = new()
|
||||
{
|
||||
["success"] = "false"
|
||||
};
|
||||
|
||||
if (!m_AllowRemoteSetLoginLevel)
|
||||
return response;
|
||||
@@ -245,7 +272,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
try
|
||||
{
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
|
||||
if (account == null)
|
||||
if (account is null)
|
||||
{
|
||||
m_log.InfoFormat("[LLOGIN SERVICE]: Set Level failed, user {0} {1} not found", firstName, lastName);
|
||||
return response;
|
||||
@@ -286,7 +313,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
|
||||
string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP)
|
||||
{
|
||||
bool success = false;
|
||||
bool success;
|
||||
UUID session = UUID.Random();
|
||||
|
||||
string processedMessage;
|
||||
@@ -302,42 +329,46 @@ namespace OpenSim.Services.LLLoginService
|
||||
// Check client
|
||||
//
|
||||
string clientNameToCheck;
|
||||
if(clientVersion.Contains(" "))
|
||||
if(clientVersion.Contains(' '))
|
||||
clientNameToCheck = clientVersion;
|
||||
else
|
||||
clientNameToCheck = channel + " " + clientVersion;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_AllowedClients))
|
||||
if (m_AllowedClientsRegex is not null)
|
||||
{
|
||||
Regex arx = new Regex(m_AllowedClients);
|
||||
Match am = arx.Match(clientNameToCheck);
|
||||
|
||||
if (!am.Success)
|
||||
lock(m_AllowedClientsRegex)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is not allowed",
|
||||
firstName, lastName, clientNameToCheck);
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
Match am = m_AllowedClientsRegex.Match(clientNameToCheck);
|
||||
|
||||
if (!am.Success)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is not allowed",
|
||||
firstName, lastName, clientNameToCheck);
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_DeniedClients))
|
||||
if (m_DeniedClientsRegex is not null)
|
||||
{
|
||||
Regex drx = new Regex(m_DeniedClients);
|
||||
Match dm = drx.Match(clientNameToCheck);
|
||||
|
||||
if (dm.Success)
|
||||
lock(m_DeniedClientsRegex)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is denied",
|
||||
firstName, lastName, clientNameToCheck);
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
Match dm = m_DeniedClientsRegex.Match(clientNameToCheck);
|
||||
|
||||
if (dm.Success)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is denied",
|
||||
firstName, lastName, clientNameToCheck);
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_DeniedMacs))
|
||||
{
|
||||
m_log.InfoFormat("[LLOGIN SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
//m_log.InfoFormat("[LLOGIN SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
if (m_DeniedMacs.Contains(curMac))
|
||||
{
|
||||
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: client with mac {0} is denied", curMac);
|
||||
@@ -345,11 +376,21 @@ namespace OpenSim.Services.LLLoginService
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_DeniedID0s))
|
||||
{
|
||||
//m_log.InfoFormat("[LLOGIN SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
|
||||
if (m_DeniedID0s.Contains(id0))
|
||||
{
|
||||
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: client with ido {0} is denied", id0);
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get the account and check that it exists
|
||||
//
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName);
|
||||
if (account == null)
|
||||
if (account is null)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user not found", firstName, lastName);
|
||||
@@ -364,7 +405,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
return LLFailedLoginResponse.LoginBlockedProblem;
|
||||
}
|
||||
|
||||
if (account.PrincipalID == Constants.servicesGodAgentID)
|
||||
if (account.PrincipalID.Equals(Constants.servicesGodAgentID))
|
||||
{
|
||||
// really?
|
||||
return LLFailedLoginResponse.UserProblem;
|
||||
@@ -393,8 +434,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
if (!passwd.StartsWith("$1$"))
|
||||
passwd = "$1$" + Util.Md5Hash(passwd);
|
||||
passwd = passwd.Remove(0, 3); //remove $1$
|
||||
UUID realID;
|
||||
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID);
|
||||
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out UUID realID);
|
||||
UUID secureSession = UUID.Zero;
|
||||
if (string.IsNullOrWhiteSpace(token) || !UUID.TryParse(token, out secureSession))
|
||||
{
|
||||
@@ -409,7 +449,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
if(!m_allowDuplicatePresences)
|
||||
{
|
||||
if(guinfo != null && guinfo.Online && !guinfo.LastRegionID.IsZero())
|
||||
if(guinfo is not null && guinfo.Online && !guinfo.LastRegionID.IsZero())
|
||||
{
|
||||
if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo))
|
||||
{
|
||||
@@ -433,15 +473,12 @@ namespace OpenSim.Services.LLLoginService
|
||||
return LLFailedLoginResponse.InventoryProblem;
|
||||
}
|
||||
|
||||
if (m_HGInventoryService != null)
|
||||
{
|
||||
// Give the Suitcase service a chance to create the suitcase folder.
|
||||
// (If we're not using the Suitcase inventory service then this won't do anything.)
|
||||
m_HGInventoryService.GetRootFolder(account.PrincipalID);
|
||||
}
|
||||
// Give the Suitcase service a chance to create the suitcase folder.
|
||||
// (If we're not using the Suitcase inventory service then this won't do anything.)
|
||||
m_HGInventoryService?.GetRootFolder(account.PrincipalID);
|
||||
|
||||
List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
|
||||
if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
|
||||
if (m_RequireInventory && ((inventorySkel is null) || (inventorySkel is not null && inventorySkel.Count == 0)))
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LLOGIN SERVICE]: Login failed, for {0} {1}, reason: unable to retrieve user inventory",
|
||||
@@ -456,7 +493,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
//
|
||||
// Login the presence
|
||||
//
|
||||
if (m_PresenceService != null)
|
||||
if (m_PresenceService is not null)
|
||||
{
|
||||
success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession);
|
||||
|
||||
@@ -476,7 +513,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
// We are only going to complain about no home if the user actually tries to login there, to avoid
|
||||
// spamming the console.
|
||||
if (guinfo != null)
|
||||
if (guinfo is not null)
|
||||
{
|
||||
if (guinfo.HomeRegionID.IsZero())
|
||||
{
|
||||
@@ -485,12 +522,12 @@ namespace OpenSim.Services.LLLoginService
|
||||
"[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location but they have none set",
|
||||
account.Name);
|
||||
}
|
||||
else if (m_GridService != null)
|
||||
else if (m_GridService is not null)
|
||||
{
|
||||
home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);
|
||||
if (home == null)
|
||||
if (home is null)
|
||||
{
|
||||
if (startLocation == "home")
|
||||
if (startLocation.Equals("home"))
|
||||
m_log.WarnFormat(
|
||||
"[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location with ID {1} but this was not found.",
|
||||
account.Name, guinfo.HomeRegionID);
|
||||
@@ -511,10 +548,8 @@ namespace OpenSim.Services.LLLoginService
|
||||
string where = string.Empty;
|
||||
Vector3 position = Vector3.Zero;
|
||||
Vector3 lookAt = Vector3.Zero;
|
||||
GridRegion gatekeeper = null;
|
||||
TeleportFlags flags;
|
||||
GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags);
|
||||
if (destination == null)
|
||||
GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out GridRegion gatekeeper, out where, out position, out lookAt, out TeleportFlags flags);
|
||||
if (destination is null)
|
||||
{
|
||||
m_PresenceService.LogoutAgent(session);
|
||||
|
||||
@@ -536,7 +571,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
// Get the avatar
|
||||
//
|
||||
AvatarAppearance avatar = null;
|
||||
if (m_AvatarService != null)
|
||||
if (m_AvatarService is not null)
|
||||
{
|
||||
avatar = m_AvatarService.GetAppearance(account.PrincipalID);
|
||||
}
|
||||
@@ -545,9 +580,8 @@ namespace OpenSim.Services.LLLoginService
|
||||
// Instantiate/get the simulation interface and launch an agent at the destination
|
||||
//
|
||||
string reason = string.Empty;
|
||||
GridRegion dest;
|
||||
AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where,
|
||||
clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest);
|
||||
clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out GridRegion dest);
|
||||
destination = dest;
|
||||
if (aCircuit == null)
|
||||
{
|
||||
@@ -561,8 +595,8 @@ namespace OpenSim.Services.LLLoginService
|
||||
guinfo = m_GridUserService.LoggedIn(PrincipalIDstr);
|
||||
|
||||
// Get Friends list
|
||||
FriendInfo[] friendsList = new FriendInfo[0];
|
||||
if (m_FriendsService != null)
|
||||
FriendInfo[] friendsList = Array.Empty<FriendInfo>();
|
||||
if (m_FriendsService is not null)
|
||||
{
|
||||
friendsList = m_FriendsService.GetFriends(account.PrincipalID);
|
||||
// m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length);
|
||||
@@ -573,7 +607,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
//
|
||||
if (m_MessageUrl != string.Empty)
|
||||
{
|
||||
using(WebClient client = new WebClient())
|
||||
using(WebClient client = new())
|
||||
processedMessage = client.DownloadString(m_MessageUrl);
|
||||
}
|
||||
else
|
||||
@@ -582,8 +616,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
}
|
||||
processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
|
||||
|
||||
LLLoginResponse response
|
||||
= new LLLoginResponse(
|
||||
LLLoginResponse response = new(
|
||||
account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
|
||||
where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP,
|
||||
m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
|
||||
@@ -596,12 +629,13 @@ namespace OpenSim.Services.LLLoginService
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace);
|
||||
if (m_PresenceService != null)
|
||||
m_PresenceService.LogoutAgent(session);
|
||||
m_PresenceService?.LogoutAgent(session);
|
||||
return LLFailedLoginResponse.InternalError;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Regex URIRegex = new(@"^uri:(?<region>[^&]+)&(?<x>\d+[.]?\d*)&(?<y>\d+[.]?\d*)&(?<z>\d+[.]?\d*)$", RegexOptions.Compiled);
|
||||
|
||||
protected GridRegion FindDestination(
|
||||
UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation,
|
||||
GridRegion home, out GridRegion gatekeeper,
|
||||
@@ -618,16 +652,16 @@ namespace OpenSim.Services.LLLoginService
|
||||
position = new Vector3(128, 128, 0);
|
||||
lookAt = new Vector3(0, 1, 0);
|
||||
|
||||
if (m_GridService == null)
|
||||
if (m_GridService is null)
|
||||
return null;
|
||||
|
||||
if (startLocation.Equals("home"))
|
||||
{
|
||||
// logging into home region
|
||||
if (pinfo == null)
|
||||
if (pinfo is null)
|
||||
return null;
|
||||
|
||||
if(home != null)
|
||||
if(home is not null)
|
||||
{
|
||||
position = pinfo.HomePosition;
|
||||
lookAt = pinfo.HomeLookAt;
|
||||
@@ -636,7 +670,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
}
|
||||
|
||||
List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
|
||||
if (defaults != null && defaults.Count > 0)
|
||||
if (defaults is not null && defaults.Count > 0)
|
||||
{
|
||||
flags |= TeleportFlags.ViaRegionID;
|
||||
where = "safe";
|
||||
@@ -646,7 +680,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
|
||||
account.FirstName, account.LastName);
|
||||
GridRegion region = FindAlternativeRegion(scopeID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
{
|
||||
flags |= TeleportFlags.ViaRegionID;
|
||||
where = "safe";
|
||||
@@ -659,15 +693,15 @@ namespace OpenSim.Services.LLLoginService
|
||||
// logging into last visited region
|
||||
where = "last";
|
||||
|
||||
if (pinfo == null)
|
||||
if (pinfo is null)
|
||||
return null;
|
||||
|
||||
GridRegion region = null;
|
||||
GridRegion region;
|
||||
|
||||
if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null)
|
||||
{
|
||||
List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
|
||||
if (defaults != null && defaults.Count > 0)
|
||||
if (defaults is not null && defaults.Count > 0)
|
||||
{
|
||||
flags |= TeleportFlags.ViaRegionID;
|
||||
region = defaults[0];
|
||||
@@ -677,7 +711,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
{
|
||||
m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
|
||||
region = FindAlternativeRegion(scopeID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
{
|
||||
flags |= TeleportFlags.ViaRegionID;
|
||||
where = "safe";
|
||||
@@ -699,10 +733,11 @@ namespace OpenSim.Services.LLLoginService
|
||||
// free uri form
|
||||
// e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
|
||||
where = "url";
|
||||
GridRegion region = null;
|
||||
Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+[.]?\d*)&(?<y>\d+[.]?\d*)&(?<z>\d+[.]?\d*)$");
|
||||
Match uriMatch = reURI.Match(startLocation);
|
||||
if (uriMatch == null)
|
||||
GridRegion region;
|
||||
Match uriMatch;
|
||||
lock (URIRegex)
|
||||
uriMatch = URIRegex.Match(startLocation);
|
||||
if (uriMatch is null)
|
||||
{
|
||||
m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation);
|
||||
return null;
|
||||
@@ -714,17 +749,17 @@ namespace OpenSim.Services.LLLoginService
|
||||
float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));
|
||||
|
||||
string regionName = uriMatch.Groups["region"].ToString();
|
||||
if (regionName != null)
|
||||
if (regionName is not null)
|
||||
{
|
||||
if (!regionName.Contains("@"))
|
||||
if (!regionName.Contains('@'))
|
||||
{
|
||||
region = m_GridService.GetRegionByName (scopeID, regionName);
|
||||
if(region != null)
|
||||
if(region is not null)
|
||||
return region;
|
||||
|
||||
m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName);
|
||||
List<GridRegion> regions = m_GridService.GetDefaultRegions(scopeID);
|
||||
if (regions != null && regions.Count > 0)
|
||||
if (regions is not null && regions.Count > 0)
|
||||
{
|
||||
where = "safe";
|
||||
return regions[0];
|
||||
@@ -733,7 +768,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
{
|
||||
m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
|
||||
region = FindAlternativeRegion(scopeID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
{
|
||||
where = "safe";
|
||||
return region;
|
||||
@@ -782,7 +817,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
else
|
||||
{
|
||||
List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
|
||||
if (defaults != null && defaults.Count > 0)
|
||||
if (defaults is not null && defaults.Count > 0)
|
||||
{
|
||||
where = "safe";
|
||||
return defaults[0];
|
||||
@@ -801,13 +836,13 @@ namespace OpenSim.Services.LLLoginService
|
||||
private GridRegion FindAlternativeRegion(UUID scopeID)
|
||||
{
|
||||
List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
|
||||
if (regions != null && regions.Count > 0 )
|
||||
if (regions is not null && regions.Count > 0 )
|
||||
return regions[0];
|
||||
|
||||
if(m_allowLoginFallbackToAnyRegion)
|
||||
{
|
||||
regions = m_GridService.GetOnlineRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000), 10);
|
||||
if (regions != null && regions.Count > 0)
|
||||
if (regions is not null && regions.Count > 0)
|
||||
return regions[0];
|
||||
}
|
||||
|
||||
@@ -852,7 +887,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
{
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(url);
|
||||
Uri uri = new(url);
|
||||
hostName = uri.Host;
|
||||
port = uri.Port;
|
||||
}
|
||||
@@ -869,23 +904,23 @@ namespace OpenSim.Services.LLLoginService
|
||||
where = currentWhere;
|
||||
ISimulationService simConnector = null;
|
||||
reason = string.Empty;
|
||||
uint circuitCode = 0;
|
||||
AgentCircuitData aCircuit = null;
|
||||
uint circuitCode;
|
||||
AgentCircuitData aCircuit;
|
||||
dest = null;
|
||||
|
||||
bool success = false;
|
||||
bool success;
|
||||
|
||||
if (m_UserAgentService == null)
|
||||
if (m_UserAgentService is null)
|
||||
{
|
||||
// HG standalones have both a localSimulatonDll and a remoteSimulationDll
|
||||
// non-HG standalones have just a localSimulationDll
|
||||
// independent login servers have just a remoteSimulationDll
|
||||
if (m_LocalSimulationService != null)
|
||||
if (m_LocalSimulationService is not null)
|
||||
simConnector = m_LocalSimulationService;
|
||||
else if (m_RemoteSimulationService != null)
|
||||
else if (m_RemoteSimulationService is not null)
|
||||
simConnector = m_RemoteSimulationService;
|
||||
|
||||
if(simConnector == null)
|
||||
if(simConnector is null)
|
||||
return null;
|
||||
|
||||
circuitCode = (uint)Random.Shared.Next();
|
||||
@@ -893,11 +928,11 @@ namespace OpenSim.Services.LLLoginService
|
||||
clientIP.Address.ToString(), viewer, channel, mac, id0);
|
||||
|
||||
success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason);
|
||||
if (!success && m_GridService != null)
|
||||
if (!success && m_GridService is not null)
|
||||
{
|
||||
// Try the fallback regions
|
||||
List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
|
||||
if (fallbacks != null)
|
||||
if (fallbacks is not null)
|
||||
{
|
||||
foreach (GridRegion r in fallbacks)
|
||||
{
|
||||
@@ -915,15 +950,17 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
else
|
||||
{
|
||||
if (gatekeeper == null) // login to local grid
|
||||
if (gatekeeper is null) // login to local grid
|
||||
{
|
||||
if (hostName.Length == 0)
|
||||
SetHostAndPort(m_GatekeeperURL);
|
||||
|
||||
gatekeeper = new GridRegion(destination);
|
||||
gatekeeper.ExternalHostName = hostName;
|
||||
gatekeeper.HttpPort = (uint)port;
|
||||
gatekeeper.ServerURI = m_GatekeeperURL;
|
||||
gatekeeper = new GridRegion(destination)
|
||||
{
|
||||
ExternalHostName = hostName,
|
||||
HttpPort = (uint)port,
|
||||
ServerURI = m_GatekeeperURL
|
||||
};
|
||||
}
|
||||
circuitCode = (uint)Random.Shared.Next();
|
||||
aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
|
||||
@@ -931,11 +968,11 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
aCircuit.teleportFlags |= (uint)flags;
|
||||
success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason);
|
||||
if (!success && m_GridService != null)
|
||||
if (!success && m_GridService is not null)
|
||||
{
|
||||
// Try the fallback regions
|
||||
List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
|
||||
if (fallbacks != null)
|
||||
if (fallbacks is not null)
|
||||
{
|
||||
foreach (GridRegion r in fallbacks)
|
||||
{
|
||||
@@ -961,10 +998,12 @@ namespace OpenSim.Services.LLLoginService
|
||||
AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
|
||||
string ipaddress, string viewer, string channel, string mac, string id0)
|
||||
{
|
||||
AgentCircuitData aCircuit = new AgentCircuitData();
|
||||
AgentCircuitData aCircuit = new()
|
||||
{
|
||||
AgentID = account.PrincipalID
|
||||
};
|
||||
|
||||
aCircuit.AgentID = account.PrincipalID;
|
||||
if (avatar != null)
|
||||
if (avatar is not null)
|
||||
aCircuit.Appearance = new AvatarAppearance(avatar);
|
||||
else
|
||||
aCircuit.Appearance = new AvatarAppearance();
|
||||
@@ -993,13 +1032,13 @@ namespace OpenSim.Services.LLLoginService
|
||||
private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account)
|
||||
{
|
||||
aCircuit.ServiceURLs = new Dictionary<string, object>();
|
||||
if (account.ServiceURLs == null)
|
||||
if (account.ServiceURLs is null)
|
||||
return;
|
||||
|
||||
// Old style: get the service keys from the DB
|
||||
foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
|
||||
{
|
||||
if (kvp.Value != null)
|
||||
if (kvp.Value is not null)
|
||||
{
|
||||
aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
|
||||
|
||||
@@ -1020,7 +1059,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
string keyName = serviceKey.Replace("SRV_", "");
|
||||
string keyValue = m_LoginServerConfig.GetString(serviceKey, string.Empty);
|
||||
if (!keyValue.EndsWith("/"))
|
||||
keyValue = keyValue + "/";
|
||||
keyValue += "/";
|
||||
|
||||
if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && (string)account.ServiceURLs[keyName] != keyValue))
|
||||
{
|
||||
@@ -1049,7 +1088,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
|
||||
private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason)
|
||||
{
|
||||
EntityTransferContext ctx = new EntityTransferContext();
|
||||
EntityTransferContext ctx = new();
|
||||
|
||||
if (!simConnector.QueryAccess(
|
||||
region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
|
||||
@@ -1125,7 +1164,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
{
|
||||
UUID regionID = guinfo.LastRegionID;
|
||||
GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
if(regInfo == null)
|
||||
if(regInfo is null)
|
||||
return false;
|
||||
|
||||
string regURL = regInfo.ServerURI;
|
||||
@@ -1133,20 +1172,22 @@ namespace OpenSim.Services.LLLoginService
|
||||
return false;
|
||||
|
||||
|
||||
GridInstantMessage msg = new GridInstantMessage();
|
||||
msg.imSessionID = UUID.Zero.Guid;
|
||||
msg.fromAgentID = Constants.servicesGodAgentID.Guid;
|
||||
msg.toAgentID = agentID.Guid;
|
||||
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
|
||||
msg.fromAgentName = "GRID";
|
||||
msg.message = string.Format("New login detected");
|
||||
msg.dialog = 250; // God kick
|
||||
msg.fromGroup = false;
|
||||
msg.offline = (byte)0;
|
||||
msg.ParentEstateID = 0;
|
||||
msg.Position = Vector3.Zero;
|
||||
msg.RegionID = scopeID.Guid;
|
||||
msg.binaryBucket = new byte[1] {0};
|
||||
GridInstantMessage msg = new()
|
||||
{
|
||||
imSessionID = UUID.Zero.Guid,
|
||||
fromAgentID = Constants.servicesGodAgentID.Guid,
|
||||
toAgentID = agentID.Guid,
|
||||
timestamp = (uint)Util.UnixTimeSinceEpoch(),
|
||||
fromAgentName = "GRID",
|
||||
message = string.Format("New login detected"),
|
||||
dialog = 250, // God kick
|
||||
fromGroup = false,
|
||||
offline = (byte)0,
|
||||
ParentEstateID = 0,
|
||||
Position = Vector3.Zero,
|
||||
RegionID = scopeID.Guid,
|
||||
binaryBucket = new byte[1] { 0 }
|
||||
};
|
||||
InstantMessageServiceConnector.SendInstantMessage(regURL,msg, m_messageKey);
|
||||
|
||||
m_GridUserService.LoggedOut(agentID.ToString(),
|
||||
|
||||
Reference in New Issue
Block a user