
<?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>Codex</title>
	<atom:link href="http://www.codexsoftware.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codexsoftware.co.uk/blog</link>
	<description>Computer topics and random rants!</description>
	<lastBuildDate>Wed, 07 Dec 2011 22:18:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>BT Infinity with Linux Router</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/bt-infinity-with-linux-router/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/bt-infinity-with-linux-router/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 21:57:37 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[BT Infinity]]></category>
		<category><![CDATA[Modem]]></category>
		<category><![CDATA[PPPoE]]></category>
		<category><![CDATA[pppoeconf]]></category>
		<category><![CDATA[Router]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=523</guid>
		<description><![CDATA[BT just enabled Infinity in my residential area, so I quickly contacted my ISP to see if they could upgrade me.  They said they were still working on their fibre rollout and couldn&#8217;t estimate when they might be able to provide a fibre to the cabinet connection.  Obviously I dropped them like a shitty stick, [...]]]></description>
			<content:encoded><![CDATA[<p>BT just enabled <a href="http://www.bt.com/infinity" title="BT Infinity" target="_blank">Infinity</a> in my residential area, so I quickly contacted my ISP to see if they could upgrade me.  They said they were still working on their fibre rollout and couldn&#8217;t estimate when they might be able to provide a fibre to the cabinet connection.  Obviously I dropped them like a shitty stick, and put my order in with BT immediately.</p>
<p><img class="alignleft" title="BT Infinity Line Speed" src="http://www.speedtest.net/result/1610181904.png" alt="" width="300" height="135" />My old connection with <a href="http://www.bethere.co.uk/" title="BE Broadband" target="_blank">Bethere</a> would let me download at about 6Mb and upload at well under 1Mb over ADSL2+.  After the BT engineer upgraded my connection, I almost <a href="http://www.youtube.com/watch?v=scOPfElE61A" target="_blank">squealed with glee</a> to see it was almost 37Mb downstream and 8.6Mb upstream.  That&#8217;s a <a href="http://3.bp.blogspot.com/-8o2YHE4SoZE/TjwoTnhoafI/AAAAAAAAAAQ/Czs7_tfF5Mg/s1600/serious-face%255B1%255D.jpg" title="Serious" target="_blank">serious</a> upgrade!</p>
<p>The engineer installed a new modem and the BT HomeHub router.  Of course I don&#8217;t want to use a generic router so I unplugged it and began figuring out how I could plug my trusty Linux Acer Revo 3600 back in.  The modem has 2 ethernet ports on the back, but one is <a href="http://www.youtube.com/watch?v=LksPRwPzvgQ">masked off</a>.  Plugging in to that was the easy part.  What I wasn&#8217;t sure of was what the modem really was &#8211; Was it a real modem or was it like my old BeBox which maintained the connection for me and acted as an invisible bridge?</p>
<p><span id="more-523"></span>I spent hours <a href="http://www.youtube.com/watch?v=BwveTeK0FKs" target="_blank">messing around</a> with /etc/network/interfaces and trying various settings.  As it turns out it is a real modem and my Revo needed to treat it as a PPPoE device.  I eventually got it connected but then found that certain web sites weren&#8217;t loading or were partially loading from other machines on my network.  That&#8217;s a very big indication of an <a href="http://en.wikipedia.org/wiki/Maximum_transmission_unit" title="MTU" target="_blank">MTU</a> problem.</p>
<p>If you get BT Infinity and decide you want to hook a Linux router up to the modem then do yourself a favour and use pppoeconf.  I didn&#8217;t know the program existed until I&#8217;d already been messing around for hours.  It has nice prompts which ask you for your login information, the device, and even tells you that you will likely have an MTU problem and that it can fix it for you!  Apparently this is because many PPPoE modems have a maximum MTU of 1460 and there&#8217;s another 4 overhead for machines that you&#8217;re <a href="http://en.wikipedia.org/wiki/Network_address_translation">masquerading</a> on your network.  So your max MTU must be clamped at 1454.  pppoeconf does this by creating a ppp ip-up script which uses <a href="http://en.wikipedia.org/wiki/Iptables">iptables</a>.</p>
<pre class="brush: plain; title: ; notranslate">iptables -t mangle -o &quot;$PPP_IFACE&quot; --insert FORWARD 1 -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1400:65495 -j TCPMSS --clamp-mss-to-pmtu</pre>
<p>Unless you have a good reason not to use pppoeconf, save yourself some time and just run it.</p>
<p>That said, I&#8217;d already been configuring my system manually and only needed to add the MTU tweak so that&#8217;s what I did.  Below you&#8217;ll find the configuration that I use.  Bear in mind my little Revo is running Ubuntu.</p>
<p>/etc/ppp/peers/bt</p>
<pre class="brush: plain; title: ; notranslate">
# Load rp-ppoe.so for kernel mode interface naming compatibility (ie, ppp0, ppp1)
plugin rp-pppoe.so eth1

# Every BT Infinity user uses the same login information.  Don't use
# your personal one - that's just for e-mail.
user &quot;bthomehub@btbroadband.com&quot;

# The device to which the Infinity modem is connected
eth1

#Bind this connection to ppp99
unit 99

# Assumes that your IP address is allocated dynamically by the ISP.
noipdefault

# Try to get the name server addresses from the ISP.
# I have commented this because I run my own full DNS
# server locally.  Most people will want this enabled.
#usepeerdns

# Use this connection as the default route.
defaultroute
replacedefaultroute
hide-password

# Makes pppd &quot;dial again&quot; when the connection is lost.
persist

# Do not ask the remote to authenticate.
noauth
</pre>
<p>I added this to the end of /etc/ppp/chap-secrets. BT don&#8217;t actually require a password but I&#8217;ve read that sometimes PPP connections can fail if they&#8217;re not provided so I added one anyway.</p>
<pre class="brush: plain; title: ; notranslate">
&quot;bthomehub@btbroadband.com&quot; * &quot;BT&quot;
</pre>
<p>/etc/ppp/ip-up.d/0clampmss</p>
<pre class="brush: plain; title: ; notranslate">
#!/bin/sh
# Enable MSS clamping (autogenerated by pppoeconf)

iptables -t mangle -o &quot;$PPP_IFACE&quot; --insert FORWARD 1 -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1400:65495 -j TCPMSS --clamp-mss-to-pmtu
</pre>
<p>And I added this to my /etc/network/interfaces. The pre-up makes eth1 (the port my modem is connected to) available before PPP dials. The provider line tells it to use the details in the &#8220;/etc/ppp/peers/bt&#8221; file above. eth1 itself is configured as a manual device so that we don&#8217;t have to give it an ip address at this stage.</p>
<pre class="brush: plain; title: ; notranslate">
auto bt
iface bt inet ppp
	pre-up /sbin/ip link set dev eth1 up
	provider bt

iface eth1 inet manual
</pre>
<p>I faced one more &#8220;gotcha&#8221;. I had to reconfigure my iptables to allow certain connections through my new ppp99 device rather than eth1. I use webmin for a lot of common administration and it uses iptables-restore and iptables-save and of course when I updated my iptables, it removed the MTU clamping rule. To make sure that didn&#8217;t happen again, I configured iptables how I wanted it and then re-added the MTU clamping rule. Then I ran iptables-save.</p>
<pre class="brush: plain; title: ; notranslate">
iptables-save &gt; /etc/iptables.up.rules
</pre>
<p>That&#8217;ll ensure the rule doesn&#8217;t get accidentally removed again the next time I&#8217;m reconfiguring iptables in webmin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/bt-infinity-with-linux-router/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Server, New Desktop Computer :)</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/new-server-new-desktop-computer/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/new-server-new-desktop-computer/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 21:00:44 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[1and1]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Apple iMac]]></category>
		<category><![CDATA[AppleCare]]></category>
		<category><![CDATA[Easyspace]]></category>
		<category><![CDATA[virtualservers.com]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=487</guid>
		<description><![CDATA[Over the past month, I've experienced truly wonderful customer service from Apple and the complete opposite from Easyspace / virtualservers.com.]]></description>
			<content:encoded><![CDATA[<p>Over the past month, I&#8217;ve experienced truly wonderful customer service from Apple and the complete opposite from <a href="http://www.virtualservers.com" target="_blank">Easyspace / virtualservers.com</a>.</p>
<p>I instructed <a href="http://www.1and1.co.uk" target="_blank">1and1</a> to transfer my codexsoftware.co.uk domain to <a title="Daily Internet Services" href="http://www.daily.co.uk" target="_blank">Daily</a> so that I could have cheaper renewals, and because that&#8217;s where I have most of my other domains.  Unfortunately rather than just change the <a href="http://en.wikipedia.org/wiki/Internet_Provider_Security" target="_blank">IPS tag</a> and leave everything else as it was, 1and1 decided to also delete my web site and all my mail too&#8230; <span id="more-487"></span>Well, ok then.</p>
<p>Rather than have to deal with another &#8216;user friendly&#8217; web site to manage my net services, I decided to get a <a href="http://en.wikipedia.org/wiki/Virtual_private_server" target="_blank">virtual private server</a> and manage it myself.  All good in theory, but I made the mistake of choosing <a title="Wankers" href="http://www.virtualservers.com/" target="_blank">virtualservers.com</a>, without first realising they were actually an Easyspace company.  It soon became apparent that they weren&#8217;t offering proper <a href="http://en.wikipedia.org/wiki/Hypervisor" target="_blank">hypervisors</a> and I tried to cancel my order literally within about 10 minutes of placing it.</p>
<p>Not only would they not cancel it, but apparently in some small print amongst the reams of legal wording in their terms and conditions, and despite the only price shown being the monthly price, I had actually signed up for a 3 month contract.  They wouldn&#8217;t cancel it.  I told them I wanted to cancel it under the UK Distance Selling Regulations, but apparently that wasn&#8217;t going to fly either as I&#8217;d clicked the &#8216;business&#8217; box instead of the &#8216;retail customer&#8217; box and therefore wasn&#8217;t eligible.  And so there was the good ol&#8217; Easyspace customer service.</p>
<p>Wankers.</p>
<p>With no confidence in their promise to cancel my account after 3 months, I decided to get the server banned instead to ensure that it happened.</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;

void main()
{
	printf(&quot;I really wish you'd cancelled my order instead of being bitches...\n&quot;);
	while (1);
}
</pre>
<p>Apparently consuming 100% of the processing time I was paying for was abusing their system, which I guessed would be the case.  Luckily for them I didn&#8217;t also decide to make full usage of their advertised &#8216;unlimited bandwidth&#8217; with a nice spider saving all of its downloads to /dev/null (unlimited disk space wasn&#8217;t part of the deal).</p>
<p>After that I decided to try out <a href="http://aws.amazon.com/" target="_blank">Amazon Web Services</a> and got a proper virtual server in the EC2 &#8220;cloud&#8221;, and made sure to make decent backups this time as well.  The server has been very reliable and I&#8217;m very pleased with it.  No hassle at all.</p>
<h3>An Example of Good Customer Service</h3>
<p>Early in December, my 2 year old  iMac&#8217;s 24&#8243; screen started intermittently turning black for random periods of time.  The problem got worse and worse.  Luckily for me I had taken out an <a href="http://www.apple.com/uk/support/products/" target="_blank">AppleCare</a> agreement for it and was covered.  I dropped the iMac in at the store and they told me it would take about 5 days to replace the screen.  I really didn&#8217;t like the thought of being without it at all, but I have a Macbook Pro and a fast PC as well, so it wasn&#8217;t really a huge problem to do without it for a while.</p>
<p>After 10 days I was beginning to lose patience, so I chased them up to find out what was going on.  They informed me that they&#8217;d been waiting for parts but that they&#8217;d now arrived and I should expect a call soon.</p>
<p>The next day I woke up to my phone ringing and I answered it.  It was the Apple store.</p>
<p>&#8220;Hello Mr Stiles.  It&#8217;s Simon from the Apple store here at the Trafford Centre.  We&#8217;ve finished replacing the screen on your iMac,&#8221; said the voice on the telephone.</p>
<p>&#8220;Oh, right.  Good,&#8221; I replied, while rubbing my eyes and trying to get both of my mental pistons firing.</p>
<p>&#8220;Yes, but I&#8217;m afraid it still isn&#8217;t working,&#8221; he continued.  I groaned.  That was just my luck.  &#8221;So, we&#8217;ve decided to give you a brand new one.&#8221;</p>
<p>&#8220;What?&#8221; I asked.  I thought I must still be dreaming.  I was still in bed afterall.  &#8221;Really?&#8221; I asked in disbelief.</p>
<p>&#8220;Yes, a new one free of charge.  Your old one had a 24 inch screen and this new one has a 27 inch.  Your old processor was a dual core 3.06GHz and this new one is an Intel i3 3.2GHz dual core.  Your old one had 2GB of RAM**, this new one has 4GB and is upgradable to 16GB.  You also had 500GB of disk space and this one has 1TB.  Does that sound, ok?&#8221; he asked, sounding slightly resigned.</p>
<p>&#8220;Umm, yes&#8230;&#8221;</p>
<p>&#8220;Right.  I&#8217;ll process that now then.  Can you get over here this afternoon?&#8221;</p>
<p>&#8220;Damn right, I can.&#8221;</p>
<p>I got myself ready and rushed over there as quickly as I could, to find the nice, brand new iMac waiting for me in its unopened box.  Not only did they give me a whole new machine, but they completely refreshed my AppleCare for a further 3 years.  At this rate I&#8217;ll never been to buy a new one again!</p>
<p>Now that&#8217;s customer service! &lt;3 Apple</p>
<p style="padding-left: 30px;">* I can&#8217;t remember who called me but I&#8217;m going to call him Simon.  In fact these weren&#8217;t even fictional Simon&#8217;s actual words but you get the idea.<br />
** Actually it had 4GB because I&#8217;d upgraded it, but I wasn&#8217;t going to argue with the nice man.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/new-server-new-desktop-computer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What a cock up!</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/what-a-cock-up/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/what-a-cock-up/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 22:49:48 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=454</guid>
		<description><![CDATA[Well after a monumental cock-up by 1and1, I&#8217;ve found myself trying to cobble my site back together. I have most of it except some blog images that I didn&#8217;t back up. Doh!]]></description>
			<content:encoded><![CDATA[<p>Well after a monumental cock-up by 1and1, I&#8217;ve found myself trying to cobble my site back together.  I have most of it except some blog images that I didn&#8217;t back up.  Doh!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/what-a-cock-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iptables: PPTP Passthrough and UPnP for Xbox 360</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/iptables-pptp-passthrough-and-upnp-for-xbox-360/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/iptables-pptp-passthrough-and-upnp-for-xbox-360/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 20:06:45 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[PPTP Passthrough]]></category>
		<category><![CDATA[UPnP]]></category>
		<category><![CDATA[Xbox 360]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=447</guid>
		<description><![CDATA[iptables: PPTP Passthrough and UPnP for XBox 360 I recently decided to replace my nice Draytek 2820 with a Linux box for purely geeky reasons. Since then I&#8217;ve come across a couple of little &#8216;gotchas&#8217;. Firstly I found that I couldn&#8217;t open any PPTP connections from computers on my network, despite GRE being allowed to [...]]]></description>
			<content:encoded><![CDATA[<p>iptables: PPTP Passthrough and UPnP for XBox 360</p>
<p>I recently decided to replace my nice Draytek 2820 with a Linux box for purely geeky reasons.  Since then I&#8217;ve come across a couple of little &#8216;gotchas&#8217;.</p>
<p>Firstly I found that I couldn&#8217;t open any PPTP connections from computers on my network, despite GRE being allowed to pass through my firewall.  The solution was to simply load some extra kernel modules.</p>
<pre class="brush: plain; title: ; notranslate">
/sbin/modprobe nf_conntrack_proto_gre
/sbin/modprobe nf_nat_proto_gre
/sbin/modprobe nf_conntrack_pptp
/sbin/modprobe nf_nat_pptp
</pre>
<p>To do this at boot time, just append the module names to your /etc/modules file. i.e. mine now looks like this:</p>
<pre class="brush: plain; title: ; notranslate">
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with &quot;#&quot; are ignored.

loop
lp
nf_conntrack_proto_gre
nf_nat_proto_gre
nf_conntrack_pptp
nf_nat_pptp
</pre>
<p>The other thing I noticed was that when playing on my Xbox 360, I&#8217;d get a warning about some of the features not being available on Xbox Live.  At first I thought it was a temporary problem with their service but I got a bit suspicious after a few days and decided to investigate further.</p>
<p>I ran a connection test from the Xbox and it suggested that I should enable a UPnP server on my router if possible.  I installed linux-igd with the usual command.</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install linux-igd
</pre>
<p>Then I edited the /etc/default/linux-igd file to let it know about my interfaces.</p>
<pre class="brush: plain; title: ; notranslate">
# External interface name.  If undefined then upnpd will not be started.
EXTIFACE=eth1

# Internal interface name.  If undefined then upnpd will not be started.
INTIFACE=eth0
</pre>
<p>Then I restarted the linux-igd service</p>
<pre class="brush: plain; title: ; notranslate">
sudo service linux-igd restart
</pre>
<p>The Xbox is now happy.  Easy peasy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/iptables-pptp-passthrough-and-upnp-for-xbox-360/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac OS X Lion Sneak Peek</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/mac-os-x-lion-sneak-peek/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/mac-os-x-lion-sneak-peek/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 14:21:50 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=434</guid>
		<description><![CDATA[Gah! No! OS X Lion looks naff. Why would I want my computer to behave like an iPhone? An iPhone has limited screen space and you poke with a finger. My computer has a huge monitor and a proper keyboard and mouse instead because&#8230; it&#8217;s a computer! I hate the idea of all those icons [...]]]></description>
			<content:encoded><![CDATA[<p>Gah! No! OS X Lion looks naff. Why would I want my computer to behave like an iPhone? An iPhone has limited screen space and you poke with a finger. My computer has a huge monitor and a proper keyboard and mouse instead because&#8230; it&#8217;s a computer!</p>
<p>I hate the idea of all those icons displayed over the desktop too.  I realize it only does that when you use the Launchpad but desktops should be tidy!  It even does that ugly thing that iPhones do with folders.  Blech!</p>
<p>Perhaps this is mostly because they want to cash in and put the App Store on the Mac <img src='http://www.codexsoftware.co.uk/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><a href="http://www.apple.com/macosx/lion/" target="_blank">http://www.apple.com/macosx/lion/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/mac-os-x-lion-sneak-peek/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dealing with Image Hotlinks &amp; Bandwidth Bandits</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/programming/dealing-with-hotlinks-bandwidth-bandits/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/programming/dealing-with-hotlinks-bandwidth-bandits/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 21:34:23 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bandwidth bandits]]></category>
		<category><![CDATA[hotlinking]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[referrer]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=405</guid>
		<description><![CDATA[How to deal with other sites hotlinking your images and making you pay for their bandwidth.]]></description>
			<content:encoded><![CDATA[<p>Ever found one of your images on someone else&#8217;s site? Then to add insult to injury you find that they&#8217;ve actually linked your image directly from their page so you&#8217;re paying for the bandwidth for them to display your image on their own page? Bandwidth bandits!</p>
<p>Well here&#8217;s a way to write a message across the centre of the image, if the image has been loaded from any site but your own. To do this we need to create 2 files. One is an .htaccess file for use in Apache and the other is a PHP script. Apache must have the mod_rewrite module enabled and PHP must have been compiled with the GD library for this to work.</p>
<p>The following .htaccess file should be dropped in to the root docs folder of your web site. It contains rules that tells Apache to check the referring domain on any file that contains a jpg, gif or png extension. If the referrer is codexsoftware.co.uk, friendlysite.com, google.com or Google&#8217;s cache then it&#8217;ll serve the image as normal. If it isn&#8217;t then it&#8217;ll redirect the request to imagehotlink.php in the document root. You should edit these domains for your own site. Remember to put the backslash before all dots in your domain names.</p>
<pre class="brush: plain; title: ; notranslate">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !codexsoftware\.co\.uk [NC]
RewriteCond %{HTTP_REFERER} !friendlysite\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /imagehotlink.php?pic=$1
</pre>
<p>Then all we need to do is drop the following imagehotlink.php file in to your document root. It will load the requested image and write the contents of the $text variable across the centre of the image in as large a font as it can &#8211; adjust the text to your amusement <img src='http://www.codexsoftware.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$pic = strip_tags( $_GET['pic'] );
if (!$pic)
	trigger_error(&quot;No picture specified.&quot;, E_USER_ERROR);
$path_info = pathinfo($pic);
switch ($path_info['extension']) {
    case 'gif':
        $image = imagecreatefromgif($pic);
        break;
    case 'png':
        $image = imagecreatefrompng($pic);
        break;
    case 'jpg':
    case 'jpeg':
        $image = imagecreatefromjpeg($pic);
        break;
}
if (!$image) {
    header(&quot;HTTP/1.0 404 Not Found&quot;);
    exit;
}
header(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot;);
header(&quot;Cache-Control: no-store, no-cache, must-revalidate&quot;);
header(&quot;Cache-Control: post-check=0, pre-check=0&quot;, false);
header(&quot;Pragma: no-cache&quot;);
header(&quot;Content-type: image/png&quot;);
$color_text = imagecolorallocate($image, 255, 255, 0);
$color_shadow = imagecolorallocate($image, 0, 0, 0);
$color_bg = imagecolorallocate($image, 0, 0, 50);
$text = &quot;http://www.codexsoftware.co.uk/ pwns this site&quot;;
$ypos = imagesy($image) /2;
$font_size = 5;
$text_width = imagefontwidth($font_size)*strlen($text);
while (($text_width &gt; imagesx($image)) &amp;&amp; ($font_size &gt; 2)) {
    $font_size--;
    $text_width = imagefontwidth($font_size)*strlen($text);
}
$xpos = ceil(imagesx($image)/2) - ceil($text_width/2);
imagefilledrectangle($image, 0, $ypos,iagesx($image), $ypos + imagefontheight($font_size), $color_bg);
imagestring($image, $font_size, $xpos+1, $ypos+1, $text, $color_shadow);
imagestring($image, $font_size, $xpos, $ypos, $text, $color_text);
imagepng($image);
imagecolordeallocate($image, $color_text);
imagecolordeallocate($image, $color_shadow);
imagecolordeallocate($image, $color_bg);
imagedestroy($image);
?&gt;
</pre>
<p>This code was inspired by this excellent article http://www.alistapart.com/articles/hotlinking/ It has a good explanation of the .htaccess rules and how referrers work, but I liked the idea of returning a modified image rather than an HTML block as it allows me to write amusing messages across bandits&#8217; web pages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/programming/dealing-with-hotlinks-bandwidth-bandits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting your Ubuntu server to show up in Finder on OS X</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/getting-your-ubuntu-server-to-show-up-in-finder-on-os-x/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/getting-your-ubuntu-server-to-show-up-in-finder-on-os-x/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 22:42:32 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[afp]]></category>
		<category><![CDATA[Avahi]]></category>
		<category><![CDATA[Bonjour]]></category>
		<category><![CDATA[Finder]]></category>
		<category><![CDATA[Netatalk]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=384</guid>
		<description><![CDATA[An easy guide to get your Ubuntu machine to show up in the Network window in Finder on your Mac without using Windows File Sharing.]]></description>
			<content:encoded><![CDATA[<p>I just found this easy guide to get my Ubuntu to show up in the Network window in Finder on my Mac.</p>
<p><a title="Permanent Link to How to get your Linux-based AFP server to show up correctly in Leopard’s new Finder" rel="bookmark" href="http://www.disgruntled-dutch.com/2007/general/how-to-get-your-linux-based-afp-server-to-show-up-correctly-in-leopards-new-finder">How to get your Linux-based AFP server to show up correctly in Leopard’s new Finder</a></p>
<p>My Linux server is running Ubuntu 10.10 and the steps I needed to get it working were slightly different, but generally easier since Netatalk seems to have come a long way since that blog post.</p>
<pre class="brush: plain; title: ; notranslate">
sudo -i
apt-get install netatalk
apt-get install avahi-daemon
cd /etc/avahi/services
wget http://www.disgruntled-dutch.com/media/afpd.service
service netatalk restart
service avahi-daemon restart
</pre>
<p>Worked for me <img src='http://www.codexsoftware.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Apparently you can even use the new Netatalk as a server for Time Machine!</p>
<p>If you&#8217;re on an older version of Ubuntu then you might get an error after installing netatalk like this<br />
<pre><pre>Starting Netatalk services (this will take a while): nbp_rgstr: Connection timed out
Can&#039;t register cctv:Workstation@*</pre></pre><br />
This can happen if you have any virtual network interfaces configured.  The solution is to tell netatalk which interface to use.  Just edit /etc/netatalk/atalkd.conf  to do so and add the network interface on a line by itself.  In my case I only want it to use eth0.</p>
<p>Unfortunately at this stage the system considers the netatalk installation to have failed.  I found that in order to make aptitude happy, I had to do this:</p>
<pre class="brush: plain; title: ; notranslate">
apt-get remove netatalk
apt-get install netatalk
</pre>
<p>The remove instruction still leaves your edited /etc/netatalk/atalkd.conf in place which netatalk uses upon installation.  Everything should work fine and aptitude should now stop moaning every time you use it.</p>
<p>Additionally you may want to disable AppleTalk, which (I think) only older Mac OS versions use.</p>
<pre class="brush: plain; title: ; notranslate">
ATALKD_RUN=no
PAPD_RUN=no
</pre>
<p>Then restart netatalk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/getting-your-ubuntu-server-to-show-up-in-finder-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Openswan LAN to LAN IPSEC Tunnel to Draytek 2820</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/openswan-lan-to-lan-ipsec-tunnel-to-draytek-2820/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/openswan-lan-to-lan-ipsec-tunnel-to-draytek-2820/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 21:44:07 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Draytek]]></category>
		<category><![CDATA[IPSEC]]></category>
		<category><![CDATA[LAN to LAN]]></category>
		<category><![CDATA[Openswan]]></category>
		<category><![CDATA[Tunnel]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=365</guid>
		<description><![CDATA[My Openswan to Draytek 2820 LAN to LAN IPSEC tunnel config.]]></description>
			<content:encoded><![CDATA[<p>So I was feeling all geeky and I decided to replace my Draytek 2820 with a little Aspire Revo 3600 running Linux.  The Revo only has 1 ethernet interface so I bought a little USB ethernet adapter for the interface to the WAN bridge.  It&#8217;s gone pretty well but one of the biggest challenges I had was sorting out a LAN to LAN IPSEC tunnel to my co-workers.  The Draytek used to magically handle all that for me.</p>
<p>OpenVPN wasn&#8217;t an option since the Draytek doesn&#8217;t support it so I decided to go with Openswan.  It took me a while to figure out but I now seem to have a rock solid link to my co-workers.  I thought I&#8217;d paste my /etc/ipsec.conf file below in case it&#8217;s of use to anyone else looking to do something similar.</p>
<p><span id="more-365"></span>The Draytek at the other end has its call direction set to &#8220;Dial-in&#8221; so it&#8217;s my router&#8217;s responsibility to open the connection.  They use an IKE Pre-Shared-Key to authenticate.  I&#8217;ve changed IP addresses below to fictional ones.</p>
<pre class="brush: plain; title: ; notranslate">version	2.0	# conforms to second version of ipsec.conf specification

# basic configuration
config setup
	interfaces=%defaultroute
	myid=200.200.200.100
	nat_traversal=yes
	oe=no
	protostack=netkey
	syslog=syslog.debug
	virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12%,v4:!192.168.1.0/24

conn net-to-net
	type=tunnel
	connaddrfamily=ipv4
	authby=secret
	auto=start
	compress=no
	ike=3des-sha1,des-md5
	phase2alg=3des-sha1,des-md5
	phase2=esp
	ikelifetime=3600s
	keyexchange=ike
	keylife=28800s
	keyingtries=%forever
	left=%defaultroute
	leftsourceip=192.168.2.1
	leftid=200.200.200.100
	leftsubnet=192.168.2.0/24
	pfs=yes
	dpdaction=restart
	right=200.200.200.200
	rightid=200.200.200.200
	rightsourceip=192.168.1.1
	rightsubnet=192.168.1.0/24</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/openswan-lan-to-lan-ipsec-tunnel-to-draytek-2820/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Battle.net security is a wipe-fest</title>
		<link>http://www.codexsoftware.co.uk/blog/rants/battle-net-security-is-a-wipe-fest/</link>
		<comments>http://www.codexsoftware.co.uk/blog/rants/battle-net-security-is-a-wipe-fest/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 16:03:48 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Battle.net]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile Authenticator]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[world of warcraft]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=339</guid>
		<description><![CDATA[A while ago, World of Warcraft players were forced to merge their accounts in to new Battle.net accounts.  These Battle.net accounts can hold several Blizzard accounts.  In my case I now have 5 different WoW accounts merged in to one login, including a mix of US and EU accounts. My StarCraft II beta code came [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, World of Warcraft players were forced to merge their accounts in to new Battle.net accounts.  These Battle.net accounts can hold several Blizzard accounts.  In my case I now have 5 different WoW accounts merged in to one login, including a mix of US and EU accounts.<span id="more-339"></span></p>
<p><a href="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/862897.jpg"><img class="alignleft size-medium wp-image-346" title="Mobile Authenticator" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/862897-200x300.jpg" alt="Battle.net Mobile Authenticator" width="200" height="300" /></a>My StarCraft II beta code came through a few months ago so I decided to log in to my Battle.net account to add the code.  As I tried to log in, the site unexpectedly asked me for an authenticator code.  Blizzard authenticators are devices that are associated with a Battle.net account that produce a code that you have to type in to the web site in order to log in &#8211; you may use a similar device for logging in to your online bank account.  As I hadn&#8217;t associated an authenticator I was very confused.</p>
<p>I rang Blizzard Europe and discovered that my account had been hacked and that the hackers had associated their own authenticator with my account, preventing me from accessing it.  After they were happy with my identity, they removed the authenticator from my account and advised I associate my own.  They then also advised me that one of my US accounts had been banned and that I had to ring Blizzard US to explain the situation.</p>
<p>To protect my account from further security problems, I decided to download the official Blizzard Mobile Authenticator to my iPhone and used that.  Problem solved, right?</p>
<p>Nope&#8230; There has since been a software update for this little iPhone application that has caused it to wipe it&#8217;s settings.  This has basically once again left me locked out of my account.  I&#8217;ve tried contacting Blizzard Europe by e-mail but I&#8217;ve had no response yet.  I&#8217;ve tried by telephone and they&#8217;re so busy that they&#8217;re not even accepting new calls in to their queuing system!</p>
<p>The most annoying thing of all is that the login name for Battle.net accounts are e-mail addresses.  So if you tend to use the same password for various things, such as forums, and someone gets hold of that data then they can look at your e-mail address and the password you used and just use that info to log in to your Battle.net account.</p>
<p>If I can&#8217;t rely on the authenticator to work properly then the best idea is going to be to change the password to something I don&#8217;t use for anything else at all, and also make it relatively complex since the username doesn&#8217;t need to be guessed at all!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/rants/battle-net-security-is-a-wipe-fest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R.I.P. Mynx and Marvel</title>
		<link>http://www.codexsoftware.co.uk/blog/uncategorized/r-i-p-mynx-and-marvel/</link>
		<comments>http://www.codexsoftware.co.uk/blog/uncategorized/r-i-p-mynx-and-marvel/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 22:24:04 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cat killed hollin way rawtenstall]]></category>
		<category><![CDATA[Cat run over]]></category>
		<category><![CDATA[hollin way rawtenstall]]></category>
		<category><![CDATA[Marvel]]></category>
		<category><![CDATA[Mynx]]></category>
		<category><![CDATA[rossendale]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=325</guid>
		<description><![CDATA[On Monday my baby boy, Xander, was playing outside in the back garden with our cat, Marvel, while my wife was hanging out the washing.  The weather was lovely.  My son has only been walking for a couple of weeks and it was great to see him toddling around with the cat.  &#8221;Marvel&#8221; is one [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-460" title="marvel-bigcat" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/12/marvel-bigcat.jpeg" alt="" width="259" height="194" />On Monday my baby boy, Xander, was playing outside in the back garden with our cat, Marvel, while my wife was hanging out the washing.  The weather was lovely.  My son has only been walking for a couple of weeks and it was great to see him toddling around with the cat.  &#8221;Marvel&#8221; is one of the few words he can say.  Sometimes he says &#8220;Muh-vuh&#8221; but usually he just shortens in to &#8220;Muh&#8221;.  In fact Marvel has had such a big influence on him that he generally refers to all animals as &#8220;Muh&#8221;.</p>
<p><span id="more-325"></span>After my wife, Becki, had finished hanging out the washing to dry, she came in with Xander.  Marvel followed them around to the side of the house but then decided to hop over the fence and stroll across the park towards the road.  He loved being outside in nice weather and would disappear for days at a time in summer.</p>
<p>Fifteen minutes later a friend from around the corner knocked on our door to tell us that a cat had been run down on the road at the top of my street and that she thought he was ours.  She identified him because of his very large size and distinctive colouring.  I came with her and there lying at the side of the very quiet road is Marvel, surrounded by kids.  Thankfully he was dead, as his injuries were horrific and not something I want to detail here in case my family read my blog.  I can only hope he died instantly.</p>
<p><a href="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/Marvel-Kitten.jpg"><img class="alignright size-full wp-image-331" title="Marvel-Kitten" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/Marvel-Kitten.jpg" alt="Marvel as a kitten" width="217" height="211" /></a>I didn&#8217;t let anyone else in my family see his body because I want them to remember him for who he was and not what became of him.  We have many happy memories of him as we&#8217;d raised him since he was a kitten. Xander still calls for him.  He calls &#8220;Muh-uh?&#8221; while pointing around at the top of the kitchen units to where he&#8217;d usually spot him.  I explain to him that Marvel&#8217;s gone.  He understands &#8220;Marvel&#8221; and &#8220;gone&#8221; but doesn&#8217;t understand how Marvel can be gone so keeps calling for him.  It&#8217;s heart-breaking.  I&#8217;m sure he&#8217;ll forget soon as he&#8217;s so young but the rest of us won&#8217;t.</p>
<p>We live on a very quiet modern housing estate and there are no busy roads around us.  In fact the road that Marvel died on isn&#8217;t even properly surfaced yet as the builders are still putting up houses.  The motorist that ran him down didn&#8217;t have the humanity to stop.  Instead they left it up to children to find Marvel and take it upon themselves to find his owner.  Eventually the kids knocked on our friend&#8217;s door who then identified him.</p>
<p><img class="alignleft size-full wp-image-465" title="Marvel_and_Xander" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/12/Marvel_and_Xander.png" alt="" width="240" height="320" />The law in the UK states that that motorists have to stop if they run over a dog, but cats are not entitled to the same privilege.  I find that ridiculous.  Marvel was a marble Bengal pedigree cat and was bigger than some dogs.  If the law is based on size then they should stop.  If it&#8217;s based on the expense of the animal then they should stop.  It makes no sense at all.</p>
<p>We&#8217;re all hurting because we don&#8217;t know how he died.  It seems unlikely that he just walked in front of a car as he was 4 and a half years old and healthily fearful of cars.  We don&#8217;t know if he suffered.  We don&#8217;t know because the asshole in the car didn&#8217;t stop.  We all miss him and so does his brother, Mynx.</p>
<p>Accidents happen but if you run over a cat or any domestic animal then please stop, because they belong to a family and that family deserves to know what happened.</p>
<p><strong><img class="alignright size-full wp-image-468" title="Mynx2" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/Mynx2.png" alt="" width="240" height="320" />Update:</strong> Just 5 weeks later, our other cat Mynx was hit by a car and killed on the same section of road.  The girl that found him and came to tell us is actually the daughter of our friend that found Marvel.  Mynx and Marvel were brothers of the same age.  I can&#8217;t really understand how or why this has happened to them both on such a quiet road within such a short time frame, after having both lived here for 4 and a half years.  I wouldn&#8217;t like to calculate the odds on that.</p>
<p>I even considered the possibility that someone had done it on purpose but Marvel was killed in the late afternoon and Mynx was killed in the early morning, and it would be almost impossible to predict when to find a cat in the road.</p>
<p>After Marvel was killed, Mynx didn&#8217;t seem to know what to do with himself.  We gave him as much attention as we could to comfort him and every evening he&#8217;d cuddle up to our daughter, Brianne, on the sofa.</p>
<p>Usually I&#8217;d put the cats in the kitchen before going to bed, but I started letting him sleep on the sofa since he was comfortable.  Mostly because I felt sorry for him.</p>
<p><img class="alignleft size-full wp-image-467" title="Mynx" src="http://www.codexsoftware.co.uk/blog/wp-content/uploads/2010/04/Mynx.png" alt="" width="320" height="240" />Once again, Xander doesn&#8217;t know what&#8217;s happened.  He knows he&#8217;s &#8220;gone&#8221;.  If I say the word &#8220;Mynx&#8221;, he&#8217;ll say &#8220;gone all gone&#8221;.  Now he looks out of the window for neighbours&#8217; cats in our garden and shouts excitedly when he sees them.</p>
<p>We&#8217;ll miss you Mynx and Marvel.  I&#8217;m sorry we couldn&#8217;t prevent what happened.  It was cruel and unnecessary.  I doubt the motorist on each occasion even saved themselves 30 seconds by speeding along that road.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/uncategorized/r-i-p-mynx-and-marvel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

