skruger / Surrogate

Proxy server written in erlang. Supports reverse proxy load balancing and forward proxy with http (including CONNECT), socks4, socks5, and transparent proxy modes.
66 stars 14 forks source link

Request and response filter #9

Open bromokun opened 11 years ago

bromokun commented 11 years ago

Dear sir,

I want to use Surrogate as a proxy server in my house LAN, to filter the content of both request and response from unwanted content from my children, such as porn.

I already use a free anti porn app on my children laptop, but it doesn't stop the Google search on displaying previews of nasty pictures.

I did some Erlang codes before, but to study the way your codes works, might takes sometime, can you please point out where could I extend your code, so I can do content filtering on both request & response.

Thank you very much in advanced,

Regards, Bromo

skruger commented 11 years ago

Indeed I can.

This is one of the use cases that I had in mind when I implemented stream filters. My next task with stream filters is to validate that they still work for filtering responses and also to add buffering so you don't have to assemble the packets yourself in a filter.

This doc is a good starting point: https://github.com/skruger/Surrogate/wiki/Stream-Filters

In essence what you need to do is create a module that implements the stream_filter behaviour. This includes implementing start_instance/0 and process_hook/4.

An example of implementing authentication as a filter module: https://github.com/skruger/Surrogate/blob/master/src/filter_auth_basic.erl

Internet content filtering is something that I would like to make a first class feature and dealing with filtering things like google and facebook which run ssl all the time are the reason why I started working on uCA and the SSL spoofing feature recently. The SSL spoofing feature generates an SSL certificate from your own certificate authority and presents that certificate to the client. If the private CA is trusted by all of your computers then the cert is accepted and the traffic is decrypted and filtered just like everything else.

Let me know if you have questions about stream filters. You probably will as my work in progress refactoring has probably resulted in a little breakage, but I'll get that fixed soon enough.