<div dir="ltr"><div>Hello again...<br><br>Here's what I've come up with. It uses tinyproxy, dansguardian, and iptables to do the dirty work. Any comments appreciated. It can sometimes take a long time for https connections to be disallowed. I've briefly looked into using tcpkill and cutter to kill the connections but not got far...<br>
<br>Thanks, James.<br><br><br>My instructions:<br><br><br>how to block your internet distraction for all but ten minutes in every hour in linux.<br><br>Follow instructions "Setup DansGuardian" at:<br>(ignoring "Setup Firefox" instructions)<br>
<br><a href="http://tinyapps.org/docs/ubuntu_whitelist_blacklist_websites.html">http://tinyapps.org/docs/ubuntu_whitelist_blacklist_websites.html</a><br><br>(obvious note: users of distros not based on Debian/Ubuntu will need to adjust the above instructions accordingly.)<br>
<br>Copy the code below (begining #!/bin/bash and ending #EOF) into a text<br>editor and saves as "iptables_block_rule" (minus quotes of course).<br><br>#!/bin/bash<br><br># the rule, redirects tcp traffic to dansguardian:<br>
RULE="OUTPUT -p tcp -m owner ! --uid-owner proxy -m multiport --dports<br>http,https -j REDIRECT --to-port 8080"<br><br># check for existing (duplicate) rules and delete them:<br># the check:<br>iptables -t nat -C $RULE 2> /dev/null<br>
while [ $? -eq 0 ]; do<br>    # the deletion:<br>    iptables -t nat -D $RULE<br>    # check for duplicates:<br>    iptables -t nat -C $RULE 2> /dev/null<br>done<br><br><br># only add rule if any arguments were passed to script:<br>
if [[ $# -gt 0 ]]; then<br>    iptables -t nat -A $RULE<br>fi<br><br><br># list rules:<br># iptables -t nat -L<br><br>#EOF<br><br>Limit the file permissions on the file you saved:<br>chmod -v 0754 iptables_block_rule<br><br>
Change ownership to root:<br>sudo chown -v root:root iptables_block_rule<br><br>Move file to root's home directory:<br>sudo mv -v iptables_block_rule /root/<br><br>Ok everything is now in place to setup the cron job which will run the script to turn the internet on at eleven minutes to the hour before turning it off again at 1 minute to the hour.<br>
<br>To do that:<br>sudo crontab -e<br><br>and add the following lines at the end of the file:<br>49 * * * * /root/iptables_block_rule<br>59 * * * * /root/iptables_block_rule deny<br><br><br></div><div>PS this was supposed to take five minutes and then I'd be able to get on with my programming without distraction - THIS has been tonights distraction!<br>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 4 November 2013 18:55, James Morris <span dir="ltr"><<a href="mailto:jwm.art.net@gmail.com" target="_blank">jwm.art.net@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>uh sorry looks like google is a good place to start.</p><span class="HOEnZb"><font color="#888888">
<p>James</p></font></span><div class="HOEnZb"><div class="h5">
<p>On Nov 4, 2013 6:29 PM, "James Morris" <<a href="mailto:jwm.art.net@gmail.com" target="_blank">jwm.art.net@gmail.com</a>> wrote:<br>
><br>
> hi I came across the leech block plugin for Firefox the other day but it isn't quite what I want.<br>
><br>
> was wondering if you guys had any suggestions for blocking all websites except for a few white listed for  50 minutes in every hour (for example).<br>
><br>
> am not really sure where to start, any suggestions for where to look appreciated, thanks.<br>
><br>
> James</p>
</div></div></blockquote></div><br></div>