28 using System.Collections;
30 namespace OpenSim.Framework.Servers.HttpServer
42 _normalMethod = normalMethod;
43 _throttledMethod = throttledMethod;
48 public Hashtable
Process(Hashtable request)
50 Hashtable process = null;
51 string clientstring= GetClientString(request);
52 string endpoint = GetRemoteAddr(request);
53 if (_dosProtector.Process(clientstring, endpoint))
54 process = _normalMethod(request);
56 process = _throttledMethod(request);
58 if (_options.MaxConcurrentSessions>0)
59 _dosProtector.ProcessEnd(clientstring, endpoint);
64 private string GetRemoteAddr(Hashtable request)
66 string remoteaddr =
"";
67 if (!request.ContainsKey(
"headers"))
69 Hashtable requestinfo = (Hashtable)request[
"headers"];
70 if (!requestinfo.ContainsKey(
"remote_addr"))
72 object remote_addrobj = requestinfo[
"remote_addr"];
73 if (remote_addrobj != null)
75 if (!
string.IsNullOrEmpty(remote_addrobj.ToString()))
77 remoteaddr = remote_addrobj.ToString();
84 private string GetClientString(Hashtable request)
86 string clientstring =
"";
87 if (!request.ContainsKey(
"headers"))
90 Hashtable requestinfo = (Hashtable)request[
"headers"];
91 if (_options.AllowXForwardedFor && requestinfo.ContainsKey(
"x-forwarded-for"))
93 object str = requestinfo[
"x-forwarded-for"];
96 if (!
string.IsNullOrEmpty(str.ToString()))
98 return str.ToString();
102 if (!requestinfo.ContainsKey(
"remote_addr"))
105 object remote_addrobj = requestinfo[
"remote_addr"];
106 if (remote_addrobj != null)
108 if (!
string.IsNullOrEmpty(remote_addrobj.ToString()))
110 clientstring = remote_addrobj.ToString();
GenericHTTPDOSProtector(GenericHTTPMethod normalMethod, GenericHTTPMethod throttledMethod, BasicDosProtectorOptions options)
Hashtable Process(Hashtable request)
delegate Hashtable GenericHTTPMethod(Hashtable request)