RTC Forums

Subscription => Support => Topic started by: craigism on October 12, 2015, 11:48:32 PM



Title: How to best block selective IP access (TRtcHttpServer)?
Post by: craigism on October 12, 2015, 11:48:32 PM
I have a TRtcHttpServer with a number of TRtcDataProviders.  I can block access with a 403 message in each of the TRtcDataProviders.  Is there a easy way to do it in the TRtcHttpServer's events to make coding easier?  I would like to return a 403 message and then disconnect the client.

Any ideas?

Thanks.

Craig.


Title: Re: How to best block selective IP access (TRtcHttpServer)?
Post by: D.Tkalcec (RTC) on October 13, 2015, 08:30:10 AM
TRtcDataProvider, TRtcServerModule, TRtcDataServerLink and TRtcDualDataServerLink components have a CheckOrder property, which defines the order of executing OnCheckRequest events across all components connected to the same Server or ServerLink component. Once a component executing the "OnCheckRequest" event calls the "Sender.Accept" method, no other components will receive any events related to that request and the component will be responsible for process it. Using this mechanism, you can attach a new "TRtcDataProvider" component with a low "CheckOrder" value (negative values are allowed) to your Server component to filter requests and close connections from unwanted IP addresses.

PS. Events on the Server component (TRtcHttpServer, TRtcISAPIServer and TRtcMessageServer) will be called last, allowing you to handle requests which have NOT been accepted by any other connected component. As an alternative, you can use a TRtcDataProvider component with a high "CheckOrder" value to handle requests which weren't "accepted" by any other component.

Best Regards,
Danijel Tkalcec