diff --git a/OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs b/OpenSim/Framework/BasicDOSProtector.cs similarity index 88% rename from OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs rename to OpenSim/Framework/BasicDOSProtector.cs index 50a4ea2f71..b470161a0e 100644 --- a/OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs +++ b/OpenSim/Framework/BasicDOSProtector.cs @@ -29,7 +29,7 @@ using System.Collections.Generic; using System.Reflection; using log4net; -namespace OpenSim.Framework.Servers.HttpServer +namespace OpenSim.Framework { public class BasicDOSProtector @@ -91,6 +91,27 @@ namespace OpenSim.Framework.Servers.HttpServer _forgetTimer.Interval = _options.ForgetTimeSpan.TotalMilliseconds; } + + /// + /// Given a string Key, Returns if that context is blocked + /// + /// A Key identifying the context + /// bool Yes or No, True or False for blocked + public bool IsBlocked(string key) + { + bool ret = false; + _lockSlim.EnterReadLock(); + ret = _tempBlocked.ContainsKey(key); + _lockSlim.ExitReadLock(); + return ret; + } + + /// + /// Process the velocity of this context + /// + /// + /// + /// public bool Process(string key, string endpoint) { if (_options.MaxRequestsInTimeframe < 1 || _options.RequestTimeSpan.TotalMilliseconds < 1) @@ -126,6 +147,13 @@ namespace OpenSim.Framework.Servers.HttpServer } return true; } + + /// + /// At this point, the rate limiting code needs to track 'per user' velocity. + /// + /// Context Key, string representing a rate limiting context + /// + /// private bool DeeperInspection(string key, string endpoint) { lock (_deeperInspection)