diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 81af6969b7..ef73dd059b 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -27,7 +27,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Reflection; using OpenMetaverse; @@ -300,15 +299,14 @@ namespace OpenSim.Framework { if (avatarID.IsZero()) return; - if (!l_EstateAccess.Contains(avatarID) && - (l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess)) + if ((l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess) && + !l_EstateAccess.Contains(avatarID)) l_EstateAccess.Add(avatarID); } public void RemoveEstateUser(UUID avatarID) { - if (l_EstateAccess.Contains(avatarID)) - l_EstateAccess.Remove(avatarID); + _ = l_EstateAccess.Remove(avatarID); } public int EstateGroupsCount() @@ -320,15 +318,14 @@ namespace OpenSim.Framework { if (avatarID.IsZero()) return; - if (!l_EstateGroups.Contains(avatarID) && - (l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups)) + if ((l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups) && + !l_EstateGroups.Contains(avatarID)) l_EstateGroups.Add(avatarID); } public void RemoveEstateGroup(UUID avatarID) { - if (l_EstateGroups.Contains(avatarID)) - l_EstateGroups.Remove(avatarID); + _ = l_EstateGroups.Remove(avatarID); } public int EstateManagersCount() @@ -340,31 +337,24 @@ namespace OpenSim.Framework { if (avatarID.IsZero()) return; - if (!l_EstateManagers.Contains(avatarID) && - (l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers)) + if ((l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers) && + !l_EstateManagers.Contains(avatarID)) l_EstateManagers.Add(avatarID); } public void RemoveEstateManager(UUID avatarID) { - if (l_EstateManagers.Contains(avatarID)) - l_EstateManagers.Remove(avatarID); + _ = l_EstateManagers.Remove(avatarID); } public bool IsEstateManagerOrOwner(UUID avatarID) { - if (IsEstateOwner(avatarID)) - return true; - - return l_EstateManagers.Contains(avatarID); + return m_EstateOwner.Equals(avatarID) || l_EstateManagers.Contains(avatarID); } public bool IsEstateOwner(UUID avatarID) { - if (avatarID == m_EstateOwner) - return true; - - return false; + return m_EstateOwner.Equals(avatarID); } public bool IsBanned(UUID avatarID) @@ -551,10 +541,10 @@ namespace OpenSim.Framework object value = p.GetValue(this, null); if (value is String) p.SetValue(this, map[p.Name], null); - else if (value is UInt32) - p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); - else if (value is Boolean) - p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); + else if (value is uint) + p.SetValue(this, uint.Parse((string)map[p.Name]), null); + else if (value is bool) + p.SetValue(this, bool.Parse((string)map[p.Name]), null); else if (value is UUID) p.SetValue(this, UUID.Parse((string)map[p.Name]), null); } @@ -575,7 +565,7 @@ namespace OpenSim.Framework LitJson.JsonMapper.RegisterImporter((input) => new UUID(input)); bdata = LitJson.JsonMapper.ToObject>(bansmap); } - // catch(Exception e) + //catch(Exception e) catch { return; diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index fb6a9b3c1b..59d687fc1e 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -120,11 +120,11 @@ namespace OpenSim.Framework { AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.None, - ConnectTimeout = TimeSpan.FromMilliseconds(10000), + ConnectTimeout = TimeSpan.FromSeconds(120), PreAuthenticate = false, UseCookies = false, MaxConnectionsPerServer = MaxConnectionsPerServer, - PooledConnectionIdleTimeout = TimeSpan.FromMilliseconds(30000), + PooledConnectionIdleTimeout = TimeSpan.FromSeconds(31), PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shh.SslOptions.ClientCertificates = null, @@ -194,11 +194,11 @@ namespace OpenSim.Framework AllowAutoRedirect = true, MaxAutomaticRedirections = 10, AutomaticDecompression = DecompressionMethods.None, - ConnectTimeout = TimeSpan.FromMilliseconds(10000), + ConnectTimeout = TimeSpan.FromSeconds(120), PreAuthenticate = false, UseCookies = false, MaxConnectionsPerServer = MaxConnectionsPerServer, - PooledConnectionIdleTimeout = TimeSpan.FromMilliseconds(30000), + PooledConnectionIdleTimeout = TimeSpan.FromSeconds(31), PooledConnectionLifetime = TimeSpan.FromMinutes(3) }; //shh.SslOptions.ClientCertificates = null, diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index d50e4ef77b..624599cf82 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -26,13 +26,10 @@ */ using System; -using System.IO; -using System.Text; using System.Collections.Generic; using System.Collections.Concurrent; using System.Globalization; using System.Linq; -using System.Net; using System.Reflection; using System.Threading; using OpenMetaverse; @@ -1690,8 +1687,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (!secondChanceSuccess) { - message = string.Format("JsonRpcRequest for user {0} to {1} failed", properties.UserId, serverURI); - m_log.DebugFormat("[PROFILES]: {0}", message); + message = $"JsonRpcRequest for user {properties.UserId} to {serverURI} failed"; + m_log.Debug($"[PROFILES]: {message}"); return false; } } diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 8e131740f2..793e15cc43 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -33,7 +33,6 @@ using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; -using OpenSim.Region.CoreModules.Scripting.DynamicTexture; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using log4net; @@ -52,8 +51,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL private IDynamicTextureManager m_textureManager; private OutboundUrlFilter m_outboundUrlFilter; - private string m_proxyurl = ""; - private string m_proxyexcepts = ""; + WebProxy m_proxy = null; #region IDynamicTextureRender Members @@ -112,8 +110,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL public void Initialise(IConfigSource config) { m_outboundUrlFilter = new OutboundUrlFilter("Script dynamic texture image module", config); - m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); - m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + string proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + if(!string.IsNullOrEmpty(proxyurl)) + { + string proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + if (!string.IsNullOrEmpty(proxyexcepts)) + { + string[] elist = proxyexcepts.Split(';'); + m_proxy = new WebProxy(proxyurl, true, elist); + } + else + { + m_proxy = new WebProxy(proxyurl, true); + } + } } public void PostInitialise() @@ -122,9 +132,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL public void AddRegion(Scene scene) { - if (m_scene == null) - m_scene = scene; - + m_scene ??= scene; } public void RemoveRegion(Scene scene) @@ -133,13 +141,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL public void RegionLoaded(Scene scene) { - if (m_textureManager == null && m_scene == scene) + if (m_textureManager is null && m_scene == scene) { m_textureManager = m_scene.RequestModuleInterface(); - if (m_textureManager != null) - { - m_textureManager.RegisterRender(GetContentType(), this); - } + m_textureManager?.RegisterRender(GetContentType(), this); } } @@ -161,42 +166,31 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL private bool MakeHttpRequest(string url, UUID requestID) { + if (m_textureManager is null) + { + m_log.WarnFormat("[LOADIMAGEURLMODULE]: No texture manager. Can't function."); + return false; + } + if (!m_outboundUrlFilter.CheckAllowed(new Uri(url))) return false; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AllowAutoRedirect = false; - if (!string.IsNullOrEmpty(m_proxyurl)) - { - if (!string.IsNullOrEmpty(m_proxyexcepts)) - { - string[] elist = m_proxyexcepts.Split(';'); - request.Proxy = new WebProxy(m_proxyurl, true, elist); - } - else - { - request.Proxy = new WebProxy(m_proxyurl, true); - } - } + if(m_proxy is not null) + request.Proxy = m_proxy; RequestState state = new RequestState(request, requestID); // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); - request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); - - TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); - state.TimeOfRequest = (int) t.TotalSeconds; - + request.BeginGetResponse(HttpRequestReturn, state); return true; } private void HttpRequestReturn(IAsyncResult result) { if (m_textureManager == null) - { - m_log.WarnFormat("[LOADIMAGEURLMODULE]: No texture manager. Can't function."); return; - } RequestState state = (RequestState) result.AsyncState; WebRequest request = (WebRequest) state.Request; @@ -319,6 +313,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL { Request = request; RequestID = requestID; + TimeOfRequest = Util.UnixTimeSinceEpoch(); } }