diff options
author | teravus | 2013-10-07 21:35:55 -0500 |
---|---|---|
committer | teravus | 2013-10-07 21:35:55 -0500 |
commit | f76cc6036ebf446553ee5201321879538dafe3b2 (patch) | |
tree | 7e33eee605c3baf04a16422f06ac3986f0f27eaa /OpenSim/Region/CoreModules | |
parent | * Added a unique and interesting WebSocket grid login processor by hijacking ... (diff) | |
download | opensim-SC_OLD-f76cc6036ebf446553ee5201321879538dafe3b2.zip opensim-SC_OLD-f76cc6036ebf446553ee5201321879538dafe3b2.tar.gz opensim-SC_OLD-f76cc6036ebf446553ee5201321879538dafe3b2.tar.bz2 opensim-SC_OLD-f76cc6036ebf446553ee5201321879538dafe3b2.tar.xz |
* Added a Basic DOS protection container/base object for the most common HTTP Server handlers. XMLRPC Handler, GenericHttpHandler and <Various>StreamHandler
* Applied the XmlRpcBasicDOSProtector.cs to the login service as both an example, and good practice.
* Applied the BaseStreamHandlerBasicDOSProtector.cs to the friends service as an example of the DOS Protector on StreamHandlers
* Added CircularBuffer, used for CPU and Memory friendly rate monitoring.
* DosProtector has 2 states, 1. Just Check for blocked users and check general velocity, 2. Track velocity per user, It only jumps to 2 if it's getting a lot of requests, and state 1 is about as resource friendly as if it wasn't even there.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 21 |
2 files changed, 30 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index 2116605..ed4b205 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -42,14 +42,22 @@ using log4net; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 43 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
44 | { | 44 | { |
45 | public class FriendsRequestHandler : BaseStreamHandler | 45 | public class FriendsRequestHandler : BaseStreamHandlerBasicDOSProtector |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private FriendsModule m_FriendsModule; | 49 | private FriendsModule m_FriendsModule; |
50 | 50 | ||
51 | public FriendsRequestHandler(FriendsModule fmodule) | 51 | public FriendsRequestHandler(FriendsModule fmodule) |
52 | : base("POST", "/friends") | 52 | : base("POST", "/friends", new BasicDosProtectorOptions() |
53 | { | ||
54 | AllowXForwardedFor = true, | ||
55 | ForgetTimeSpan = TimeSpan.FromMinutes(2), | ||
56 | MaxRequestsInTimeframe = 5, | ||
57 | ReportingName = "FRIENDSDOSPROTECTOR", | ||
58 | RequestTimeSpan = TimeSpan.FromSeconds(5), | ||
59 | ThrottledAction = ThrottleAction.DoThrottledMethod | ||
60 | }) | ||
53 | { | 61 | { |
54 | m_FriendsModule = fmodule; | 62 | m_FriendsModule = fmodule; |
55 | } | 63 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index a26a5f0..0f05e07 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -165,7 +165,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
165 | regionimage = regionimage.Replace("-", ""); | 165 | regionimage = regionimage.Replace("-", ""); |
166 | m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage); | 166 | m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage); |
167 | 167 | ||
168 | MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage); | 168 | MainServer.Instance.AddHTTPHandler(regionimage, |
169 | new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions() | ||
170 | { | ||
171 | AllowXForwardedFor = false, | ||
172 | ForgetTimeSpan = TimeSpan.FromMinutes(2), | ||
173 | MaxRequestsInTimeframe = 4, | ||
174 | ReportingName = "MAPDOSPROTECTOR", | ||
175 | RequestTimeSpan = TimeSpan.FromSeconds(10), | ||
176 | ThrottledAction = ThrottleAction.DoThrottledMethod | ||
177 | }).Process); | ||
169 | MainServer.Instance.AddLLSDHandler( | 178 | MainServer.Instance.AddLLSDHandler( |
170 | "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); | 179 | "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); |
171 | 180 | ||
@@ -1081,6 +1090,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1081 | block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); | 1090 | block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); |
1082 | } | 1091 | } |
1083 | 1092 | ||
1093 | public Hashtable OnHTTPThrottled(Hashtable keysvals) | ||
1094 | { | ||
1095 | Hashtable reply = new Hashtable(); | ||
1096 | int statuscode = 500; | ||
1097 | reply["str_response_string"] = "I blocked you! HAHAHAHAHAHAHHAHAH"; | ||
1098 | reply["int_response_code"] = statuscode; | ||
1099 | reply["content_type"] = "text/plain"; | ||
1100 | return reply; | ||
1101 | } | ||
1102 | |||
1084 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) | 1103 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) |
1085 | { | 1104 | { |
1086 | m_log.Debug("[WORLD MAP]: Sending map image jpeg"); | 1105 | m_log.Debug("[WORLD MAP]: Sending map image jpeg"); |