Indy TIdHTTPProxyServer: how to filter requests?

I use TIdHTTPProxyServer to implement a simple HTTP proxy, but now I want to block some connections if they match specific URLs. What event and / or component is best to do this? Indy's documentation is not too explanatory. :(

Thank!

+3
source share
2 answers

As the main filter, you can use the OnHTTPBeforeCommand event handler (which runs before sending the command to the HTTP server).

Inspect the properties of the Context parameter, you will find it useful:

Context.Command
Context.OutboundClient.Host
Context.OutboundClient.Port
Context.Document
Context.Headers

I have never tried to stop PassTrough at this time, but I am sure you can do this by simply throwing an exception at this point if you define a matching block rule there.

+3

"OnConnect", :

if AContext.Connection.Socket.Binding.PeerIP = '127.0.0.1' then
  AContext.Connection.Disconnect;

127.0.0.1 , " ", Indy, "OnConnect".

+1

Source: https://habr.com/ru/post/1784907/


All Articles