aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorteravus2013-10-07 23:48:24 -0500
committerteravus2013-10-07 23:48:24 -0500
commit1df58d04b16601fb3afa408ef48e59aa68dc335b (patch)
treec19027893d939d6315d16a43b1158644359cdb89 /OpenSim
parent* Refactor (diff)
downloadopensim-SC_OLD-1df58d04b16601fb3afa408ef48e59aa68dc335b.zip
opensim-SC_OLD-1df58d04b16601fb3afa408ef48e59aa68dc335b.tar.gz
opensim-SC_OLD-1df58d04b16601fb3afa408ef48e59aa68dc335b.tar.bz2
opensim-SC_OLD-1df58d04b16601fb3afa408ef48e59aa68dc335b.tar.xz
* Move the BasicDOSProtector.cs to OpenSim.Framework (all useful classes belong there.....)
* Add an IsBlocked(string Key) method so it can be used more generically. (think.. if we want to rate limit login failures, we could have a call in the Login Service to IsBlocked(uuid.ToString()) and ignore the connection if it returns true, if IsBlocked returns false, we could run the login information and if the login fails we could run the Process method to count the login failures.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/BasicDOSProtector.cs (renamed from OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs)30
1 files changed, 29 insertions, 1 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs b/OpenSim/Framework/BasicDOSProtector.cs
index 50a4ea2..b470161 100644
--- a/OpenSim/Framework/Servers/HttpServer/BasicDOSProtector.cs
+++ b/OpenSim/Framework/BasicDOSProtector.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using log4net; 30using log4net;
31 31
32namespace OpenSim.Framework.Servers.HttpServer 32namespace OpenSim.Framework
33{ 33{
34 34
35 public class BasicDOSProtector 35 public class BasicDOSProtector
@@ -91,6 +91,27 @@ namespace OpenSim.Framework.Servers.HttpServer
91 91
92 _forgetTimer.Interval = _options.ForgetTimeSpan.TotalMilliseconds; 92 _forgetTimer.Interval = _options.ForgetTimeSpan.TotalMilliseconds;
93 } 93 }
94
95 /// <summary>
96 /// Given a string Key, Returns if that context is blocked
97 /// </summary>
98 /// <param name="key">A Key identifying the context</param>
99 /// <returns>bool Yes or No, True or False for blocked</returns>
100 public bool IsBlocked(string key)
101 {
102 bool ret = false;
103 _lockSlim.EnterReadLock();
104 ret = _tempBlocked.ContainsKey(key);
105 _lockSlim.ExitReadLock();
106 return ret;
107 }
108
109 /// <summary>
110 /// Process the velocity of this context
111 /// </summary>
112 /// <param name="key"></param>
113 /// <param name="endpoint"></param>
114 /// <returns></returns>
94 public bool Process(string key, string endpoint) 115 public bool Process(string key, string endpoint)
95 { 116 {
96 if (_options.MaxRequestsInTimeframe < 1 || _options.RequestTimeSpan.TotalMilliseconds < 1) 117 if (_options.MaxRequestsInTimeframe < 1 || _options.RequestTimeSpan.TotalMilliseconds < 1)
@@ -126,6 +147,13 @@ namespace OpenSim.Framework.Servers.HttpServer
126 } 147 }
127 return true; 148 return true;
128 } 149 }
150
151 /// <summary>
152 /// At this point, the rate limiting code needs to track 'per user' velocity.
153 /// </summary>
154 /// <param name="key">Context Key, string representing a rate limiting context</param>
155 /// <param name="endpoint"></param>
156 /// <returns></returns>
129 private bool DeeperInspection(string key, string endpoint) 157 private bool DeeperInspection(string key, string endpoint)
130 { 158 {
131 lock (_deeperInspection) 159 lock (_deeperInspection)