How to blacklist an IP on TIdHTTPServer

2019-08-20 05:56发布

In a TIdHTTPServer component, I'd like to enable a blacklist of IP addresses to block. I'd like to make sure this is on the lowest level possible to prevent any unnecessary data streaming in from a blacklisted client. How should I intercept this server component to block an IP on the lowest level possible? This applies to both IP v4 and v6

1条回答
2楼-- · 2019-08-20 06:06

On Indy 9, there was an event for refusing a connection before it was actually accepted. On Indy 10, it's still not implemented.

If you look at IdCustomTCPServer.pas, in procedure TIdListenerThread.Run there is a comment in there about exposing an event to the user to let them decide whether the connection should be accepted.

I would modify the source and implement it there.

If that's not for you, then you can disconnect them in the OnConnect event.

查看更多
登录 后发表回答