Closed pickfire closed 9 years ago
Sounds good. You could even add this line of code to your hostsblock.conf's "postprocess" subroutine, e.g.
postprocess() {
sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden
}
I changed ">>" to ">" so that your /etc/polipo/forbidden doesn't keep getting bigger and bigger each time hostsblock runs.
Is it a better way to use hostblock in this way:
hostsblock -e sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden`
Instead of editing the source file with
sed -i '/postprocess() {/a sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden' ~/.hostsblock.conf
There is no need to edit the source file. The configuration option postprocess () {}
in /etc/hostsblock/hostsblock.conf
can handle this without manual intervention (assuming that you would use the systemd service or a cronjob.
What do you mean? I am using polipo
as an advertistment blocker I don't think it will route through hosts.conf (I have tried it) because I use polipo as an advertistment blocker.
I'm not sure what you mean. hostsblock
cannot be used as you have it in this command:
hostsblock -e sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden
nor
sed -i '/postprocess() {/a sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden' ~/.hostsblock.conf
Moreover, to the substance of your issue:
If you want to use polipo
with hostsblock
, you can have hostsblock
overwrite the /etc/polipo/forbidden
file using the postprocess() {}
parameter in /etc/hostsblock/hostsblock.conf
as stated above. This will have hostsblock
create the /etc/hosts.block
or whatever target file you have configured in /etc/hostsblock/hostsblock.conf
and then, after creating it, overwrite /etc/polipo/forbidden
with the same blocking information. There is no need for an extra step or to modify the source code or the like.
Sorry, if hostsblock
overwrite /etc/hosts, it should be:
sed 's/127.0.0.1 //g' /etc/hosts > /etc/polipo/forbidden
This is because polipo
does not need the 127.0.0.1
in each line.
I hope you can add it to the README.md to show how to use
hostsblock
in polipo by converting /etc/hosts