content filter

require ‘webrick/httpproxy’

def handle_request(req, res)
puts “[REQUEST] ” + req.request_line

if req.host == “ted.com” || req.host == “www.ted.com”
res.header[‘content-type’] = ‘text/html’
res.header.delete(‘content-encoding’)
res.body = “Access is denied.”
elsif req.host == “googleads.g.doubleclick.net:443”
res.body = “Access is denied.”
res.header[‘content-type’] = ‘text/html’
res.header.delete(‘content-encoding’)
res.body = “Access is denied.”

elsif req.host == “http://pancake.apple.com/cmremoteconfig/2/default”
res.body = “Access is denied.”
res.header[‘content-type’] = ‘text/html’
res.header.delete(‘content-encoding’)
res.body = “Access is denied.”

end
end

if $0 == __FILE__ then
server = WEBrick::HTTPProxyServer.new(
:Port => 80,
:DoNotReverseLookup => true,
:AccessLog => [],
:ProxyContentHandler => method(:handle_request))
trap “INT” do server.shutdown end
server.start
end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s