Active Topics

 



Notices


Reply
Thread Tools
Posts: 422 | Thanked: 244 times | Joined on Feb 2008
#1
This is adapted from http://rightfootin.blogspot.com/2009...th-polipo.html, and is aimed at Maemo 5. For Maemo 4, the main things you need to consider are auto-starting the app (upstart is not available), and if the polipo package is available, the default configuration may be different.

Setup Polipo

Polipo isn't available from app manager, it only seems to exist as a dependency for tor.. so:

Code:
apt-get install polipo
Not sure which repository you'll need, and heed the "at your own risk" disclaimers mentioned a million times.

The polipo app comes ready configured to work with tor. This post assumes you don't want to use tor, so we need to change the polipo config. Use leafpad or vi:

Code:
vi /etc/polipo/config
Look for:

Code:
socksParentProxy = "localhost:9050"
socksProxyType = socks5
And comment:

Code:
#socksParentProxy = "localhost:9050"
#socksProxyType = socks5
Now we want polipo to begin at boot time, so create

Code:
/etc/event.d/polipo
Like this:

Code:
start on stopped rcS
console output
respawn
exec /usr/bin/polipo
(any comments on how this should really be for this type of app, please let me know, I am new to upstart).

Set Up Blocking

Polipo uses a "forbidden" list in
Code:
/etc/polipo/forbidden
What we are going to do is download the standard adblock list, and convert it to something polipo understands.

First, get adblocktopolipo.py and save to /usr/bin

Then
Code:
chmod +x /usr/bin/adblock2polipo.py
Create a backup copy of the default forbidden.list (not entirely necessary, but the script below expects it. Also, you can use this file to keep any custom blocks you want:

Code:
cp /etc/polipo/forbidden /etc/polipo/forbidden.dist
Then save this script somewhere sensible. Mine is in /etc/polipo/update which is not sensible:

Code:
#!/bin/bash
wget http://easylist.adblockplus.org/easylist.txt \
   --no-check-certificate -O /etc/polipo/easylist.txt
cp /etc/polipo/forbidden.dist /etc/polipo/forbidden
/usr/bin/adblock2polipo.py  /etc/polipo/easylist.txt >> /etc/polipo/forbidden
stop polipo
start polipo
Enable execute:

Code:
chmod +x /etc/polipo/update
Now you can run the script as root to get a fresh copy of the block list, install into polipo and restart it.

Code:
/etc/polipo/update
Using Polipo AdBlocking

To use it, all you need do is point the proxy settings for each internet connection to polipo. Open Internet Connections in Settings. You will need to modify each connection you want ad blocking for.

Open the connection and hit Next until you see Advanced. Click that, and go to the Proxy tab. Change the http proxy to:

Code:
ip: 127.0.0.1
port: 8118
Make it Better

Now Polipo will return a 403 error for any blocked connection, and these are displayed in place of blocked ads. Which isn't cool. Unless you are happy with that, we need to make some more changes. The idea here is that instead of the 403 error, we return a small empty gif which is displayed in its place.

Edit the /etc/polipo/config file again, and look for
Code:
localDocumentRoot
Make sure it says:

Code:
localDocumentRoot = /usr/share/polipo/www
Then add:

Code:
forbiddenUrl = http://127.0.0.1:8118/empty.gif
Now all we need is the gif image file:

Code:
wget -O /usr/share/polipo/www/empty.gif \
     http://upload.wikimedia.org/wikipedia/commons/4/4b/Empty.gif
Restart polipo:

Code:
stop polipo
start polipo
Caveats

The easylist.txt download and conversion had a line beginning with

Code:
+adverts/
The initial + should be escaped, and polipo ignores the entire forbidden list because it fails to parse.

Edit forbidden and change the line to:

Code:
\+adverts/
Or just delete it.

The conversion script needs to be updated to account for this, but until then, this works as a workaround. You can run polipo from the command line to see if everything is happy:

Bad:

Code:
# polipo
Couldn't compile regex: 13.
Established listening socket on port 8118.
Good:

Code:
# polipo
Established listening socket on port 8118.
Cheers,

Paul

Last edited by paulkoan; 2010-03-28 at 22:59.
 

The Following 3 Users Say Thank You to paulkoan For This Useful Post:
Posts: 1,950 | Thanked: 1,174 times | Joined on Jan 2008 @ Seattle, USA
#2
Thanks for going through the effort to post all that.

Couple questions:

Do you find it much more helpful than just relying on a hosts file?

Are all your instructions equally applicable for Maemo 4 and Maemo 5?
 
Posts: 422 | Thanked: 244 times | Joined on Feb 2008
#3
Originally Posted by GeraldKo View Post
Thanks for going through the effort to post all that.
Funny, when I started typing it seems like it would be brief...

Do you find it much more helpful than just relying on a hosts file?
I haven't tried the hosts file method, so I am not sure how the pros and cons play out. WIth a proxy server, you have more granular control over what is blocked, and what matches. Ie, 'adverts' blocks any url containing the word adverts. A hosts file only blocks at the domain level. Because it does this, a hosts file may be smaller (the block list in this case is 2000 entries). With a proxy server method, you can for example, hide non-advert images from the site you are visiting. Some sites will put a huge stonking image right in the middle of the page, and this may not be a good thing from a small form-factor screen perspective. So block it.

A hosts file will have the edge over perfomance I think. Though marginal I reckon. It may be that polipo does better caching than microb, so would confer some performance advantage on slow links.

Not sure!


Are all your instructions equally applicable for Maemo 4 and Maemo 5?
I have added a couple of comments at the beginning of the post. The auto-start of the app part is maemo 5 specific, and I never did get around to figuring it out on my n810.
 

The Following User Says Thank You to paulkoan For This Useful Post:
Posts: 422 | Thanked: 244 times | Joined on Feb 2008
#4
Obviously one of the clear benefits is so you can have conversations like:

Them: "Damn, surfing on my phone is awful with all the damn ads"
You: "Yeah, I know what you mean. I was using a hosts file originally, but now I use a local polipo proxy server so I get finer control over blocking. What do you do?"
Them: "You did what and what now?"
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:37.