30 using OpenSim.Framework;
33 namespace OpenSim.Framework.Servers.HttpServer
45 _normalMethod = normalMethod;
46 _throttledMethod = throttledMethod;
52 public XmlRpcResponse
Process(XmlRpcRequest request, IPEndPoint client)
55 XmlRpcResponse resp = null;
56 string clientstring = GetClientString(request, client);
57 string endpoint = GetEndPoint(request, client);
58 if (_dosProtector.Process(clientstring, endpoint))
59 resp = _normalMethod(request, client);
61 resp = _throttledMethod(request, client);
62 if (_options.MaxConcurrentSessions > 0)
63 _dosProtector.ProcessEnd(clientstring, endpoint);
67 private string GetClientString(XmlRpcRequest request, IPEndPoint client)
70 if (_options.AllowXForwardedFor && request.Params.Count > 3)
72 object headerstr = request.Params[3];
73 if (headerstr != null && !
string.IsNullOrEmpty(headerstr.ToString()))
74 clientstring = request.Params[3].ToString();
76 clientstring = client.Address.ToString();
79 clientstring = client.Address.ToString();
83 private string GetEndPoint(XmlRpcRequest request, IPEndPoint client)
85 return client.Address.ToString();
XmlRpcBasicDOSProtector(XmlRpcMethod normalMethod, XmlRpcMethod throttledMethod, BasicDosProtectorOptions options)
XmlRpcResponse Process(XmlRpcRequest request, IPEndPoint client)
delegate XmlRpcResponse XmlRpcMethod(XmlRpcRequest request, IPEndPoint client)