<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>delx &#187; Technical</title>
	<atom:link href="http://delx.net.au/blog/category/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://delx.net.au/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 01 Jul 2010 11:59:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Australian Internet Filter (again)</title>
		<link>http://delx.net.au/blog/2010/07/australian-internet-filter-again/</link>
		<comments>http://delx.net.au/blog/2010/07/australian-internet-filter-again/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 11:49:35 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[australia]]></category>
		<category><![CDATA[censorship]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=202</guid>
		<description><![CDATA[I just realised that my previous post on this was 18 months ago. That&#8217;s depressing. Well, the situation has mostly stayed the same since then. It&#8217;s good that it has not become worse! This post is a slightly edited version of an email I sent to my local representative about the matter. See my previous [...]]]></description>
			<content:encoded><![CDATA[<p>I just realised that my previous post on this was 18 months ago. That&#8217;s depressing. Well, the situation has mostly stayed the same since then. It&#8217;s good that it has not become worse!<br />
This post is a slightly edited version of an email I sent to my local representative about the matter.<br />
<span id="more-202"></span></p>
<p>See my <a href="/blog/2008/11/internet-censorship-in-australia">previous post</a> from November 2008. Oh, and if you plan to write your own letter to somebody about this matter, feel free to use my references, but please write your own content. I doubt it&#8217;s effective to spam busy politicians with duplicates that waste their time.</p>
<p>Firstly, I resent Stephen Conroy&#8217;s repeated assertion that those who oppose his plan to filter the internet are interested in &#8220;opting in to child porn&#8221; <a href="http://www.itwire.com/opinion-and-analysis/whiskey-tango-foxtrot/40057-senator-conroy-says-qim-not-into-opting-into-child-pornq?start=1">[1]</a>. There have been many other occasions where Stephen Conroy has made such remarks. For example: &#8220;If people equate freedom of speech with watching child pornography, then the Rudd-Labor Government is going to disagree.&#8221; <a href="http://www.abc.net.au/news/stories/2007/12/31/2129471.htm">[2]</a>. Nobody is trying to suggest that child pornography is acceptable, these kind of statements are inflammatory, and framing the debate in such a way is offensive and unhelpful.</p>
<p>It is also disturbing to see him outright mislead the public in so many respects, just one example was claiming that most ISPs support his filter plan <a href="http://www.smh.com.au/technology/technology-news/filter-goes-ahead-regardless-20100529-wmg7.html">[3]</a>, both iiNet<a href="http://www.iinet.net.au/customers/iinews/internet-filtering.html">[4]</a> and Telstra<a href="http://www.theaustralian.com.au/business/news/isp-filtering-a-pipe-dream-telstra/story-e6frg90f-1111118234565">[5]</a> have been on record in the past as saying that the filter plan is a bad idea, so this was an outright falsehood that he definitely should have been aware of the facts before making such a statement. This is particularly irritating because he on so many occasions accuses others of misleading the public.</p>
<p>For the record, the rest of the industry is also against the plan, including Google, Yahoo, the US government <a href="http://www.smh.com.au/technology/technology-news/toxic-net-filters-shelved-until-after-election-20100618-ykvj.html">[6]</a> and even the &#8220;Save the Children&#8221; organisation <a href="http://www.computerworld.com.au/article/330087/child_groups_slam_conroy_isp_filtering_plans/">[7]</a>. There are good reasons why there is such widespread disapproval, which I will now cover.</p>
<p>The filter plan seems to have no concrete goals:</p>
<ul>
<li>Clearly it cannot protect those children who are actually suffering child abuse. Hiding the problem does not make it go away.</li>
<li>Will it protect ordinary law abiding citizens browsing the internet at home? Considering the goal is to have a blacklist of less than 10,000 of the 1,000,000,000,000+ websites on the internet, I think it&#8217;s easy to see that it cannot possibly hope to make much of a difference to the chance of you coming across a website that may offend you. If Australians were interested in such things, they already have the option of signing up to an ISP like WebShield that offers this service at a small premium to anybody who can get ADSL through the Telstra wholesale network (that&#8217;s everybody who can get ADSL)</li>
<li>It will not stop people trading this content via email, peer 2 peer file sharing networks, instant messaging chat software and private encrypted websites, or using virtual private networks. This means it will be trivial for anybody who desires to bypass the filter. The report that Stephen Conroy published on the filter testing acknowledged this.</li>
</ul>
<p>So the filter will not help abused children, protect casual internet users, or reduce criminal activity. What exactly will it do? Here are some negatives that it will do:</p>
<ul>
<li>Add cost to ISPs, that will be passed on to all users</li>
<li>Become an extra point of failure that will make our internet connections are less reliable <a href="http://apcmag.com/internet_filter_stuffup_cuts_off_wikipedia.htm">[8]</a></li>
<li>Noticeably slow down access to high traffic websites if it is used to block any pages on them</li>
<li>Provide a false sense of security to the Australian public, due to Stephen Conroy advertising that it will protect children online</li>
<li>Introduces a sinister secret censorship blacklist that is not subject to review by the Australian public</li>
</ul>
<p>All these negatives, all this time and money spent on it, and no positives to show? All it allows is for the government to say &#8220;We tried!&#8221;. If your best try will have no positive effect and many negatives, then perhaps a better option would be to do nothing. After all, is there really a huge outcry in the public for the government to protect us from the big bad internet? For those who are interested in such protection, options do exist, such as WebShield at the ISP level and countless more downloadable packages.</p>
<p>Thanks for reading :)</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2010/07/australian-internet-filter-again/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nokia N97 and Apple iSync</title>
		<link>http://delx.net.au/blog/2009/11/nokia-n97-and-apple-isync/</link>
		<comments>http://delx.net.au/blog/2009/11/nokia-n97-and-apple-isync/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 23:09:08 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=189</guid>
		<description><![CDATA[I bought my Nokia N97 early July, just a few days after the Australia release. I&#8217;ve been enjoying this great device since then desspite its bugs. The most notable of which was that unlike my previous Nokia S60 it would not cooperate with iSync. Thankfully the recently released firmware update (V20.0.019) fixes this problem. After [...]]]></description>
			<content:encoded><![CDATA[<p>I bought my Nokia N97 early July, just a few days after the Australia release. I&#8217;ve been enjoying this great device since then desspite its bugs. The most notable of which was that unlike my previous Nokia S60 it would not cooperate with iSync. Thankfully the recently released firmware update (V20.0.019) fixes this problem.</p>
<p><span id="more-189"></span></p>
<p>After hacking the Nokia 5800 phoneplugin and turning off contact sync in iSync I got older firmware versions (V10, V11 and V12) to sync my calendars. This was the most important thing for me, but still very annoying.</p>
<p>First download <a href="http://delx.net.au/files/Nokia-N97.phoneplugin.zip">Nokia-N97.phoneplugin.zip</a>. Extract to <tt>~/Library/PhonePlugins/</tt> as usual. Now pair your phone with bluetooth and select the option to enable iSync. Open iSync and turn off contacts sync. It should now sync calendars properly. This is where I&#8217;d been up to V20.</p>
<p>To get contacts to sync you need to reset the contacts database. Insert a MicroSD card into your phone and do a backup of your contacts from the phone&#8217;s &#8220;File Mgr&#8221; app. Now immediately restore just the contacts, the phone will reboot. Turn on contacts sync in iSync and it should work great =)</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/11/nokia-n97-and-apple-isync/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Encrypted file systems on Debian/Ubuntu Linux</title>
		<link>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/</link>
		<comments>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 15:06:57 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=179</guid>
		<description><![CDATA[Recently I set up an encrypted file system so I could do rsync backups to a secured location. What you end up with is a mountable file system that you can use to securely store data. Debian offers an easy way to set up encrypted file systems using the LUKS standard with the cryptsetup package. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I set up an encrypted file system so I could do rsync backups to a secured location. What you end up with is a mountable file system that you can use to securely store data. Debian offers an easy way to set up encrypted file systems using the LUKS standard with the cryptsetup package. You&#8217;ll need to enter a decryption passphrase to mount the volume whenever the system boots.</p>
<p><span id="more-179"></span></p>
<h4>Package installation</h4>
<p>Install the required packages:</p>
<pre># aptitude install e2fsprogs cryptsetup</pre>
<h4>Partitioning</h4>
<p>Use your favourite partitioning tool, for example <tt>fdisk</tt> or <tt>cfdisk</tt> to set aside a whole partition with enough space to store your data.</p>
<h4>Erase</h4>
<p>This step is optional. For complete security you want the contents of the disk to be random before you start using it. Use the <tt>badblocks</tt> tool to do this.</p>
<pre>
# badblocks -c 10240 -s -w -t random -v /dev/sdX9
</pre>
<h4>Format</h4>
<p>The <tt>luksformat</tt> tool will format a partition to be used with LUKS (Linux Unified Key Setup) and then create a filesystem on it.</p>
<pre># luksformat -t ext3 /dev/sdX9</pre>
<h4>crypttab and fstab</h4>
<p>Now all that remains is to a line in each of these config files.</p>
<p>Add this line to <tt>/etc/crypttab</tt>:</p>
<pre>myname /dev/sdX9 none luks</pre>
<p>The <tt>crypttab</tt> file is examined by the system during boot. Each line maps a real encrypted device file (<tt>/dev/sdX9</tt>) to a virtual decrypted device file (<tt>/dev/mapper/myname</tt>). Once you&#8217;ve added done this run the following command to actually set up the mapping:</p>
<pre># /etc/init.d/cryptdisks restart</pre>
<p>Now you can set up that virtual device file to be mounted like any other. For example, the following command would mount your filesystem:</p>
<pre># mount /dev/mapper/myname /mnt</pre>
<p>Note that you should probably use partition UUIDs (<tt>UUID=XXXXX</tt>) in place of device file names (<tt>/dev/sdX9</tt>) in your <tt>crypttab</tt> for a more robust system. The easiest way to find these is by running:</p>
<pre># ls -l /dev/disks/by-uuid</pre>
<p>Add a line like this to <tt>/etc/fstab</tt></p>
<pre>/dev/mapper/myname /path/to/mountpoint ext3 defaults 0 2</pre>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fink for Mac OS X package management</title>
		<link>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/</link>
		<comments>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 00:34:31 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[fink]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=170</guid>
		<description><![CDATA[Fink is a package management system for Mac OS X. If you&#8217;re new to Fink read on for a description of how it works. The Fink project has two components. First, the port of Debian&#8217;s apt-get tools to Mac OS X combined with a binary package repository for the stable distribution. Second, the &#8216;fink&#8217; command [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.finkproject.org">Fink</a> is a package management system for Mac OS X. If you&#8217;re new to Fink read on for a description of how it works.</p>
<p><span id="more-170"></span></p>
<p>The Fink project has two components. First, the port of <a href="http://www.debian.org">Debian&#8217;s</a> apt-get tools to Mac OS X combined with a binary package repository for the stable distribution.</p>
<p>Second, the &#8216;fink&#8217; command line tool. It generates <tt>.deb</tt> packages from a source package description (located in <tt>/sw/fink/dists</tt>). Once generated you can move these packages between machines and install them with apt-get or dpkg as you would in Debian. This can save rebuilding from source.</p>
<p>Next the infamous stable vs unstable distributions. Unstable in Fink has the same meaning as it does with Debian. Don&#8217;t be too scared of using unstable. It won&#8217;t make your system crash. What it will do is have up to date packages (in most cases). It will get more frequent updates, meaning you&#8217;ll have more to recompile more often. Because of this, if you&#8217;re using the unstable distribution there tends not to be any prebuilt binaries so installation can take longer than in Debian. Also note these more recent packages may have had less testing, so sometimes they may not install.</p>
<p>One other thing you should know about is a neat package called &#8216;debfoster&#8217;. It&#8217;ll help you clean out unused packages and libraries. One of the consequences of Fink unstable building from source is that you often get lots of development packages installed that you don&#8217;t need anymore.</p>
<p>Just install debfoster and run it as root, then answer either y(es), n(o) or p(rune) to keep a package and its deps, not keep, or remove a package and all it&#8217;s deps. It&#8217;s quite clever. Give it a shot.</p>
<p>Finally, remember Fink is a volunteer project that you can contribute to. If you find a missing or out of date package, feel free to dig in to the <tt>.info</tt> file and update it. This is often as easy as just changing the version number. See the <a href="http://www.finkproject.org">Fink</a> website for a good packaging tutorial and reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Keyboard on Linux</title>
		<link>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/</link>
		<comments>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 06:20:11 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=159</guid>
		<description><![CDATA[The Apple aluminium keyboards are very nice. I recently bought one for an Ubuntu Linux machine, and it requires some special configuration to work as expected. This post describes how to fix the function keys and swap command (windows or &#8216;super&#8217;) keys with the alt (or option) keys. This command will fix the function keys, [...]]]></description>
			<content:encoded><![CDATA[<p>The Apple aluminium keyboards are very nice. I recently bought one for an Ubuntu Linux machine, and it requires some special configuration to work as expected.</p>
<p>This post describes how to fix the function keys and swap command (windows or &#8216;super&#8217;) keys with the alt (or option) keys.</p>
<p><span id="more-159"></span></p>
<p><img src="http://delx.net.au/blog/wp-content/wp-uploads/2009/04/apple_aluminium_keyboardcompare.jpg" alt="Apple Aluminium Keyboard" width="400" height="292" class="size-full wp-image-160" /></p>
<p>This command will fix the function keys, it saves you pressing fn-F1 whenever you want F1. The first command is for older kernels, the second is for version 2.6.28 or later.</p>
<pre>
# echo 2 > /sys/module/hid/parameters/pb_fnmode
# echo 2 > /sys/module/hid_apple/parameters/fnmode
</pre>
<p>Then add that line to your <tt>/etc/rc.local</tt> file, somewhere before the <tt>exit 0</tt> at the end, so that it gets run on startup.</p>
<p>Next to swap the Command/Alt keys using xmodmap. I&#8217;m aware you can do this from the Gnome Keyboard Settings panel, but I&#8217;ve found this method works better. Particularly when combined with <a href="http://synergy2.sf.net">synergy</a>.</p>
<p>Create a file called <tt>~/.xmodmaprc</tt> with this inside:</p>
<pre>
clear mod1
keycode 115 = Alt_L
keycode 116 = Alt_R
keycode 64 = Super_L
keycode 113 = Super_R
add mod1 = Alt_L Alt_R
</pre>
<p>On another computer I&#8217;ve found this worked:</p>
<pre>
clear mod1
keycode 133 = Alt_L
keycode 134 = Alt_R
keycode 64 = Super_L
keycode 108 = Super_R
add mod1 = Alt_L Alt_R
</pre>
<p>Now run to activate the new keys, run:</p>
<pre>$ xmodmap ~/.xmodmaprc</pre>
<p>Don&#8217;t forget to add it to your list of startup programs. If you&#8217;re using Gnome, look at System->Preferences->Startup Applications<br />
Otherwise you can just add it to <tt>~/.xsession</tt></p>
<p>To find the keycodes above I used the <tt>xev</tt> program. Try running it from a console. It shows you all X11 events that the xev window receives, including key presses/releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Who wants Hulu?</title>
		<link>http://delx.net.au/blog/2009/03/who-wants-hulu/</link>
		<comments>http://delx.net.au/blog/2009/03/who-wants-hulu/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 13:15:37 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[censorship]]></category>
		<category><![CDATA[hulu]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=128</guid>
		<description><![CDATA[Update: Improved proxying of RTMP Update: Compatibility with unmetered and local content Update: Automatic /etc/hosts update Hulu is a website that offers commercial-supported streaming video of TV shows and movies from NBC, Fox and many other networks and studios. Currently Hulu is only available from within the United States of America. If you want to [...]]]></description>
			<content:encoded><![CDATA[<p><i>Update: Improved proxying of RTMP</i><br />
<i>Update: Compatibility with unmetered and local content</i><br />
<i>Update: Automatic /etc/hosts update</i></p>
<p>Hulu is a website that offers commercial-supported streaming video of TV shows and movies from NBC, Fox and many other networks and studios. Currently Hulu is only available from within the United States of America.</p>
<p>If you want to be notified of updates to this post, subscribe to the <a href="feed">comments feed</a>.</p>
<p><span id="more-128"></span></p>
<p>This is kind of lame. One of the fundamental principles of the internet is global access. That&#8217;s why we have the <i>world wide</i> web, not the America-web.</p>
<p>So, in that spirit, here&#8217;s how to make Hulu fully functional on your local network and accessible from any ordinary web browser.</p>
<h4>Requirements</h4>
<ul>
<li>A machine in the US that you can run programs and serve web pages from.</li>
<li>A Linux machine at home that shares your net connection</li>
</ul>
<h4>For my friends</h4>
<p>You can skip the USA proxy configuration and just use <tt>72.232.203.84</tt> everywhere you would put that server&#8217;s IP.<br />
Make sure you email me and I&#8217;ll add your local IP address to the allow list for the RTMP proxy.</p>
<h4>USA Proxy Configuration</h4>
<p>First we need to set up your US server to forward some selected HTTP sites as well as the Flash RTMP video streams. Do these steps on the server in the US:</p>
<ul>
<li>Create a file, hulu_proxy.ini with these contents:
<pre>
[proxy]
mode = proxy
listen_port = 9997

[allowed]
host1 = YOUR_LOCAL_IP_OR_DOMAIN
</pre>
<li>Download <a href="http://delx.net.au/hg/jamesstuff/raw-file/tip/scripts/proxy.py">proxy.py</a> and run this command to start forwarding requests on port 9997 from the allowed hosts.
<pre>proxy.py -d hulu_proxy.ini</pre>
</li>
<li>Create an HTTP virtual server for these domains: <tt>releasegeo.hulu.com</tt></li>
<li>Download <a href="http://delx.net.au/hg/cgiproxy/raw-file/tip/ruby/proxy.rb">proxy.rb</a> and <a href="http://delx.net.au/hg/cgiproxy/raw-file/tip/ruby/path.cgi">path.cgi</a> to these virtual hosts.</li>
<li>Edit path.cgi to end with
<pre>proxyTo "http://" + ENV["HTTP_HOST"], False</pre>
</li>
<li>
<li>Now set up a rewrite rule to forward <tt>/</tt> to <tt>/path.cgi</tt> for each of these virtual hosts.</li>
</ul>
<h4>Local network</h4>
<p>If you have a Linux router you can configure it to forward all packets destined for Hulu from inside your network to your US server.<br />
Follow these steps on your LAN&#8217;s router or your on any Linux computer:</p>
<ul>
<li>Add this to your <tt>/etc/hosts</tt> file (these addresses may be out of date, see the last section in this blog):
<pre>
XXX.YYY.ZZZ.AAA releasegeo.hulu.com
205.241.224.55 cp41752.edgefcs.net # HULU
205.241.224.45 cp39465.edgefcs.net # HULU
205.241.224.158 cp51756.edgefcs.net # HULU
205.241.224.37 cp47346.edgefcs.net # HULU
</pre>
<p>where <tt>XXX.YYY.ZZZ.AAA</tt> is the IP address of your US server.</li>
<li>If you&#8217;re using dnsmasq for your LAN&#8217;s DNS server ensure that it reads these addresses from your and resolves them for hosts on your network.</li>
<li>Add this to your firewall config for Linux:
<pre>
grep 'HULU$' /etc/hosts | awk '{print $1;}' | while read huluip; do
    iptables -t nat -A PREROUTING -i eth0 -p tcp \
        --destination "$huluip"  --dport 1935 -j REDIRECT --to-ports 9997
    iptables -t nat -A OUTPUT -p tcp \
        --destination "$huluip" --dport 1935 -j REDIRECT --to-ports 9997
done
</pre>
</li>
<li>Add this to your firewall config for OSX:
<pre>
grep 'HULU$' /etc/hosts | awk '{print $1;}' | while read huluip; do
    ipfw add 50000 fwd 127.0.0.1,9997 \
        tcp from any to "$huluip" dst-port 1935
done
</pre>
</li>
<li>Create a file, hulu_interceptor.ini with these contents:
<pre>
[proxy]
mode = interceptor
listen_port = 9997
host = XXX.YYY.ZZZ.XXX
port = 9997
</pre>
</li>
<li>Download <a href="http://delx.net.au/hg/jamesstuff/raw-file/tip/scripts/proxy.py">proxy.py</a> and run this command to start capturing and forwarding the Flash RTMP port to your US server.
<pre>proxy.py -d hulu_interceptor.ini</pre>
</li>
</ul>
<p>Some ISPs in Australia (Internode, iiNet and others) override the DNS entries for Akamai servers. This is why the modification to <tt>/etc/hosts</tt> is needed. Note that using the rules above, only traffic to specific Akamai Flash RTMP servers will go through your US server. So unmetered ABC iView content will remain unmetered. However, if Hulu adds new servers to this list, or if I&#8217;ve missed some, then some videos may not work and the hosts file will need updating.</p>
<p>If you are having difficulty viewing videos and you suspect that this is the issue, try running this tcpdump command to see whether your connections are being sent to a server within your ISPs address range:</p>
<pre># tcpdump -i INTERFACE port 1935</pre>
<p>You&#8217;ll then need to find the corresponding domain name and the &#8216;correct&#8217; IP to add to <tt>/etc/hosts</tt></p>
<h4>Automatic <tt>/etc/hosts</tt> updating</h4>
<p>The <tt>/etc/hosts</tt> file is used to know which IP addresses to route over the tunnel to USA. My USA server resolves the Hulu video hosts that I know about and makes them available at this URL: <a href="http://delx.net.au/files/huluhosts.txt">http://delx.net.au/files/huluhosts.txt</a>. This is automatically updated every hour.</p>
<p>I use a daily cronjob on my client machines in order to keep their hosts file up to date. Adapt this to your needs.</p>
<pre>
#!/bin/bash

cp /etc/hosts /etc/hosts.hulubak &#038;&#038;
grep -v HULU /etc/hosts > /etc/_hosts.new &#038;&#038;
curl -s http://delx.net.au/files/huluhosts.txt >> /etc/_hosts.new &#038;&#038;
chmod 0644 /etc/_hosts.new &#038;&#038;
mv /etc/_hosts.new /etc/hosts &#038;&#038;

# Ensure you clear the previous Hulu firewall rules and restart your
# DNS server (if you use one)
/root/hulutables
/etc/init.d/dnsmasq restart > /dev/null
</pre>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/03/who-wants-hulu/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Mercurial remote repository names</title>
		<link>http://delx.net.au/blog/2009/02/mercurial-remote-repository-names/</link>
		<comments>http://delx.net.au/blog/2009/02/mercurial-remote-repository-names/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 08:39:09 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=120</guid>
		<description><![CDATA[I just discovered that Mercurial supports named shortcuts for repositories. This is great for when you want to be pushing and pulling from several repository URLs without typing their full locations. I was aware you could set a default and default-push repository in .hg/hgrc, in fact whenever you clone a repository a default remote path [...]]]></description>
			<content:encoded><![CDATA[<p>I just discovered that Mercurial supports named shortcuts for repositories. This is great for when you want to be pushing and pulling from several repository URLs without typing their full locations.</p>
<p><span id="more-120"></span></p>
<p>I was aware you could set a default and default-push repository in <tt>.hg/hgrc</tt>, in fact whenever you clone a repository a default remote path is created for you.</p>
<p>You can actually put arbitrary names in there. For example, I have a repository &#8220;chatbots&#8221; that I cloned from Katie&#8217;s repository: <tt>http://katharos.id.au/hg/chatbots"</tt>. I want to be able to push and pull changes from my repository as well as pull from her&#8217;s without typing the full path out at any time.</p>
<p><code><br />
[paths]<br />
default = ssh://hg@delx.net.au/chatbots<br />
katie = http://katharos.id.au/hg/chatbots<br />
</code></p>
<p>The above snippet goes in the repositories <tt>.hg/hgrc</tt>, and I can now run commands like this:<br />
<code><br />
$ hg pull katie<br />
$ hg push<br />
</code><br />
This pulls any new changes in from Katie&#8217;s repository and pushes them to the default, mine.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/02/mercurial-remote-repository-names/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OfflineIMAP IDLE support</title>
		<link>http://delx.net.au/blog/2009/02/offlineimap-idle-support/</link>
		<comments>http://delx.net.au/blog/2009/02/offlineimap-idle-support/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:36:45 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[offlineimap]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=112</guid>
		<description><![CDATA[I&#8217;ve implemented IDLE support into OfflineIMAP. For the last day or two I&#8217;ve been using this and I&#8217;m loving the instant email notifications. I emailed the original author and plan to work with him to get the code included into an official OfflineIMAP release. There&#8217;s a Git repository with the patch included here: http://delx.net.au/git/offlineimap I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve implemented IDLE support into OfflineIMAP. For the last day or two I&#8217;ve been using this and I&#8217;m loving the instant email notifications. I emailed the original author and plan to work with him to get the code included into an official OfflineIMAP release.</p>
<p><span id="more-112"></span></p>
<p>There&#8217;s a Git repository with the patch included here:<br />
<a href="http://delx.net.au/git/offlineimap">http://delx.net.au/git/offlineimap</a></p>
<p>I followed the plan John Goerzen suggested in <a href="http://software.complete.org/software/issues/show/18">offlineimap ticket 18</a>. Here&#8217;s an overview of the changes.</p>
<ul>
<li>Use <a href="http://www.cs.usyd.edu.au/~piers/python/imaplib2">imaplib2</a> as it implements the IDLE command and a few other nice things. This is written by Piers Lauder, the author Python&#8217;s standard imaplib.</li>
<li>Some small changes to the OfflineIMAP code were needed for it to work with imaplib2.</li>
<li>Added a config parameter &#8216;idlefolders&#8217; to specify a list of mailboxes to monitor. This parameter forces holdconnectionopen, keepalive and maxconnections to be sane values.</li>
<li>Hijack the keepalive thread. Use the available connections for IDLE, one on each of the given mailboxes. If there are leftover connections we send NOOP as before.</li>
<li>Added documentation to the sample offlineimap.conf</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/02/offlineimap-idle-support/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux Traffic Control &#8211; QoS</title>
		<link>http://delx.net.au/blog/2008/12/linux-traffic-control-qos/</link>
		<comments>http://delx.net.au/blog/2008/12/linux-traffic-control-qos/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 17:30:59 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[shaping]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=17</guid>
		<description><![CDATA[I recently started using VoIP, using NodePhone with Internode. This post describes how I implemented QoS on my router to make VoIP work well. It also allows me to prioritise some traffic on my network, such as SSH, while deprioritising others, such as BitTorrent and SFTP. Background You may want to skip this section initially [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started using <acronym title="Voice over Internet Protocol">VoIP</acronym>, using <a href="http://www.internode.on.net/residential/nodephone">NodePhone</a> with <a href="http://www.internode.on.net">Internode</a>. This post describes how I implemented <acronym title="Quality of Service">QoS</acronym> on my router to make VoIP work well. It also allows me to prioritise some traffic on my network, such as SSH, while deprioritising others, such as BitTorrent and SFTP.</p>
<p><span id="more-17"></span></p>
<h3>Background</h3>
<p>You may want to skip this section initially and refer back to it if you come across a concept that you do not fully understand later in the document.</p>
<p>I assume that you have a working understanding of networking. This means you must know what an IP address is, what TCP is, and what the relationship of these to application level protocols HTTP and SSH is. IPv6 is not covered here but probably will be in the future.</p>
<p>QoS, or Quality of Service, is any mechanism for guaranteeing a particular amount of throughput or latency for some type of traffic.</p>
<p>VoIP is basically about making phone calls over your internet connection. NodePhone uses the SIP standard for this. It supports incoming and outgoing calls to the PSTN by giving you an extra phone number. Internode recommends getting a QoS equipped router, but I use a Linux PC as my router and was unwilling to switch for various reasons. Using VoIP without QoS is much like talking on a mobile phone while going through a subway. The call is jittery with frequent voice dropouts.</p>
<p>IP packets have a Type-Of-Service (TOS) field in them. Applications can set this field to values such as Minimise-Delay, or Maximise-Throughput. This allows applications such as BitTorrent to signal that they are more interested in throughput than latency, while an interactive SSH session (think typing at a shell) could signal the opposite. The default is for normal service.</p>
<p>Shaping is when we prioritise outgoing traffic. It is possible to do this really well because our router is in full control of what data is sent out onto the internet. It is possible to specify what rate packets should be sent at and in what order. Eg, VoIP packets before BitTorrent is a sensible rule.</p>
<p>Policing is attempting to enforce rules upon incoming data. This is not possible because we cannot directly influence how much data other computers will send our way. Instead what we do is drop packets that are coming in too fast in the hope that the sender will slow down. Thankfully this is exactly what TCP is designed to do, so this strategy works reasonably well. The aim here is to make your router into a bottleneck that is slightly slower than your internet connection so you influence over the rate at which different classes of packets come in.</p>
<h3>Goal</h3>
<p>I needed to set up QoS to prioritise the VoIP traffic on my network. The existing documentation is not exactly plentiful and while it was invaluable, I found it difficult to understand. There don&#8217;t seem to be any turnkey solutions that do QoS for Linux in the way that I wanted.</p>
<p>I have four categories of traffic.</p>
<ol>
<li>VoIP traffic &#8211; guaranteed 64Kbit, highest priority</li>
<li>High priority &#8211; interactive SSH sessions (not SFTP)</li>
<li>Normal priority &#8211; the default</li>
<li>Low priority &#8211; bulk data transfers like SFTP or BitTorrent</li>
</ol>
<p>If I&#8217;m on a phone call, that traffic absolutely needs priority over everything else. The packets from the VoIP phone call should never be dropped or delayed.</p>
<p>Immediately after that comes other high priority traffic. This is anything with the Minimise-Delay TOS bit set in the IP header. SSH sets Minimise-Delay for interactive shells, but not for SFTP/SCP. Very convenient. Be aware that if you use ControlMaster to piggyback SFTP on an existing SSH connection that the TOS bits are set per TCP connection. I also put ACK packets in here; one of these is sent for every packet that you download. If you&#8217;re doing a large upload then these tiny packets can get delayed, causing your download to slow down. I find it works well to give them a high priority.</p>
<p>Next priority is general traffic, this is the default bucket. By default all traffic goes in here. This includes web traffic, instant messaging, email, etc</p>
<p>Finally we have the data that we don&#8217;t care about at all. I&#8217;m a little nasty and dump any traffic with the Maximise-Throughput TOS bit set in here. That includes my BitTorrents (using <a href="http://libtorrent.rakshasa.no">rtorrent</a>) and SFTP/SCP traffic. This means that the traffic doesn&#8217;t really get it&#8217;s throughput maximised at all, but it works well for my purposes.</p>
<h3>Linux Traffic Control</h3>
<p>This is all done using the Linux Traffic Control system. It&#8217;s made up of a tree of queues, each with a specific algorithm for dequeuing packets.</p>
<p>Have a look at the <a href="http://delx.net.au/hg/jamesstuff/file/b005ac01417d/scripts/shaper">shaper script</a>. All of the rates in this file are specified in Kilobits/sec. You may need to read this text more than once.</p>
<p>I&#8217;m using the Hierarchical Token Bucket (HTB) for each of the four categories mentioned above. Each bucket has an associated rate, maximum rate and priority. The available outgoing bandwidth is measured and divided up amongst the different categories of traffic. The bucket gets a minimum throughput specified by &#8216;rate&#8217;, and a maximum specified by &#8216;ceil&#8217;. This maximum could be reached if one of the other buckets is not using its allowance. For example, while there is no VoIP traffic other buckets can use that 64Kbit allowance. Packets are dequeued from the buckets in order of the priority that each is given. Lower priorities first.</p>
<p>Next we add a Stochastical Fairness Queue (SFQ) to each bucket. The SFQ organises all packets it receives into sessions, like TCP connections, using a hashing algorithm. It dequeues packets from these sessions in a round-robin fashion. This means that if you have two connections they each receive an equal share of the available resources.</p>
<p>Packets are assigned to a particular queue/bucket by inspecting their header for source/dest addresses/ports as well as the TOS field.</p>
<p>Finally, some basic policing is applied to incoming traffic. Incoming VoIP traffic is never policed, but all other incoming traffic is policed at slightly less than the link&#8217;s maximum throughput. This forces the router to be the bottleneck and encourages the sender of any traffic that has been dropped to slow down.</p>
<p>QoS on incoming traffic really needs to be handled by your ISP, and while Internode claims that they do this, I found that I needed these policing rules for VoIP to work while large downloads were occurring. I suspect this is due to Internode not being able to provide proper QoS for my ADSL1 connection on a 1.5Mbit Telstra port.</p>
<h3>References</h3>
<ol>
<li><a href="http://delx.net.au/hg/jamesstuff/raw-file/tip/scripts/shaper">Shaper script</a> &#8211; latest version</li>
<li><a href="http://delx.net.au/hg/jamesstuff/file/b005ac01417d/scripts/shaper">Shaper script</a> &#8211; original version</li>
<li><a href="http://lartc.org/howto/">Linux Advanced Routing &amp; Traffic Control HOWTO</a></li>
<li><a href="http://rfc.sunsite.dk/rfc/rfc1349.html">RFC1349 &#8211; Type of Service in the Internet Protocol Suite</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2008/12/linux-traffic-control-qos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HFS+ auto defragmentation of files under Mac OS X</title>
		<link>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/</link>
		<comments>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 02:14:17 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[defrag]]></category>
		<category><![CDATA[hfs]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=13</guid>
		<description><![CDATA[HFS+ automatically defragments files as they are used. When a fragmented file is opened, if the system has been up for 3 minutes, the file is not busy and is under 20MiB in size then it will be relocated to be in a contiguous section of the disk So I was having a discussion with [...]]]></description>
			<content:encoded><![CDATA[<p>HFS+ automatically defragments files as they are used. When a fragmented file is opened, if the system has been up for 3 minutes, the file is not busy and is under 20MiB in size then it will be relocated to be in a contiguous section of the disk</p>
<p><span id="more-13"></span></p>
<p>So I was having a discussion with Greg yesterday about file systems and I claimed the above. I have actually made this claim, that OS X automatically defragments files, many times in the past. However this time Greg decided to call me on it. He told me: <i>Citation needed</i>.</p>
<p>I knew I&#8217;d read this somewhere, but couldn&#8217;t track my original source. So I did a little bit of research and found there wasn&#8217;t an easily accessible authoritative source anywhere.</p>
<p><a href="http://support.apple.com/kb/HT1375">Apple Technote HT1375</a> was one of the first pages I found. However it only talks about the Hot-File-Adaptive-Clustering, which is a completely different technique.</p>
<p>A little more searching and I found this Ars Technica article, a <a href="http://arstechnica.com/reviews/os/macosx-10-3.ars/5">review of Mac OS X 10.3</a>. This actually contains some solid details on the auto defragmentation feature. The reference for this information is only a <a href="http://article.gmane.org/gmane.comp.macosx.general/22906">newsgroup post</a> on comp.macosx.general, not exactly definitive.</p>
<p>So I decided to go to the source. Apple publishes the source code for large components of Mac OS X in the <a href="http://www.opensource.apple.com/darwinsource/Current/">Darwin Source Code</a> repository. In this case we needed to look at the HFS+ driver, which is part of XNU &#8211; the OS X kernel.<br />
Incidentally, thanks go to Apple for making this code available to everybody for random research like this.</p>
<p>Before long I&#8217;d narrowed it down to this file: <a href="http://www.opensource.apple.com/darwinsource/10.5.5/xnu-1228.7.58/bsd/hfs/hfs_vnops.c">xnu-1228.7.58/bsd/hfs/hfs_vnops.c</a>. The function that we&#8217;re interested in is <tt>hfs_vnop_open()</tt>, which is called whenever the system needs to open a file or directory on disk for reading or writing. The last two comments in that function explain the conditions under which defragmentation occurs. Nicely written and well commented code.</p>
<p>Since you need a free Apple developer account to view the above link, here&#8217;s the relevant section of the source code:</p>
<pre>
/*
 * Open a file/directory.
 */
static int
hfs_vnop_open(struct vnop_open_args *ap)
{
  struct vnode *vp = ap-&gt;a_vp;
  struct filefork *fp;
  struct timeval tv;
  int error;

  /*
   * Files marked append-only must be opened for appending.
   */
  if ((VTOC(vp)-&gt;c_flags &amp; APPEND) &amp;&amp; !vnode_isdir(vp) &amp;&amp;
      (ap-&gt;a_mode &amp; (FWRITE | O_APPEND)) == FWRITE)
    return (EPERM);

  if (vnode_isreg(vp) &amp;&amp; !UBCINFOEXISTS(vp))
    return (EBUSY);  /* file is in use by the kernel */

  /* Don't allow journal file to be opened externally. */
  if (VTOC(vp)-&gt;c_fileid == VTOHFS(vp)-&gt;hfs_jnlfileid)
    return (EPERM);
  /*
   * On the first (non-busy) open of a fragmented
   * file attempt to de-frag it (if its less than 20MB).
   */
  if ((VTOHFS(vp)-&gt;hfs_flags &amp; HFS_READ_ONLY) ||
      (VTOHFS(vp)-&gt;jnl == NULL) ||
#if NAMEDSTREAMS
      !vnode_isreg(vp) || vnode_isinuse(vp, 0) ||
      vnode_isnamedstream(vp)) {
#else
      !vnode_isreg(vp) || vnode_isinuse(vp, 0)) {
#endif
    return (0);
  }

  if ((error = hfs_lock(VTOC(vp), HFS_EXCLUSIVE_LOCK)))
    return (error);
  fp = VTOF(vp);
  if (fp-&gt;ff_blocks &amp;&amp;
      fp-&gt;ff_extents[7].blockCount != 0 &amp;&amp;
      fp-&gt;ff_size &lt;= (20 * 1024 * 1024)) {
    struct timeval now;
    struct cnode *cp = VTOC(vp);
    /*
     * Wait until system bootup is done (3 min).
     * And don't relocate a file that's been modified
     * within the past minute -- this can lead to
     * system thrashing.
     */
    microuptime(&amp;tv);
    microtime(&amp;now);
    if (tv.tv_sec &gt; (60 * 3) &amp;&amp;
       ((now.tv_sec - cp-&gt;c_mtime) &gt; 60)) {
      (void) hfs_relocate(vp, VTOVCB(vp)-&gt;nextAllocation + 4096,
                          vfs_context_ucred(ap-&gt;a_context),
                          vfs_context_proc(ap-&gt;a_context));
    }
  }
  hfs_unlock(VTOC(vp));

  return (0);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
