<?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>RPS &#187; Researching</title>
	<atom:link href="http://www.delic.com/blog/category/researching/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.delic.com/blog</link>
	<description>The view from here</description>
	<lastBuildDate>Tue, 22 Feb 2011 12:01:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>VPN for OSX client via SSH and the tun device driver</title>
		<link>http://www.delic.com/blog/2009/05/12/vpn-for-osx-client-via-ssh-and-the-tun-device-driver/</link>
		<comments>http://www.delic.com/blog/2009/05/12/vpn-for-osx-client-via-ssh-and-the-tun-device-driver/#comments</comments>
		<pubDate>Tue, 12 May 2009 22:18:05 +0000</pubDate>
		<dc:creator>rshah21</dc:creator>
				<category><![CDATA[Researching]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tun]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.delic.com/blog/?p=82</guid>
		<description><![CDATA[For a long time, I have used SSH port forwarding to access a lot of my home files and services, but I&#8217;ve found myself hitting the limits of usefulness. So I decided to try and create a VPN. This isn&#8217;t a true VPN &#8211; it&#8217;s NAT over SSH with tun. Good enough for me. Much [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time, I have used SSH port forwarding to access a lot of my home files and services, but I&#8217;ve found myself hitting the limits of usefulness.   So I decided to try and create a VPN.  This isn&#8217;t a true VPN &#8211; it&#8217;s NAT over SSH with tun.  Good enough for me.<br />
<span id="more-82"></span></p>
<p class="alert">Much of the heavy lifting for this post was done by daleroberts at his <a href="http://wiki.daleroberts.info/doku.php?id=technical:unix:mac_os_x:vpn_with_ssh">wiki site</a>.  My only real contribution here is around the last steps of getting the routing working.</p>
<p>So, here&#8217;s what you&#8217;ll need:</p>
<ol>
<li>Two macs &#8211; one is the remote &#8220;client&#8221; and one is the home &#8220;server&#8221;.  Both should be running OS X 10.4.10+ <em>client</em>.  If you have OS X Server, I&#8217;d suggest looking around for OpenVPN. </li>
<li>Both machines connected to the network.  You&#8217;ll probably want to use a service like DynDNS so you can access the server machine via a hostname, especially if your ISP uses dynamic IP addresses </li>
<li> Your should know how to SSH to your home server</li>
<li>Your should know how to enable and use the root account on both your remote machine and home server</li>
<li>You should know how to handle yourself on the command line via Terminal. </li>
</ol>
<h3>Conventions used</h3>
<ul>
<li>The remote &#8220;client&#8221; (aka. the client) is the machine you are VPN-ing from.  It is off the target network (aka. the home network).  This is the machine you&#8217;re sitting at saying &#8220;I wish I had access to this file on my home network&#8221;</li>
<li>The home &#8220;server&#8221; (aka. the server) is the machine you are VPN-ing to.  It serves as the gateway to all the other machines on your home network. </li>
<li>For the purposes of this example, the &#8220;home network&#8221; has an IP of ranges 192.168.0.1 to 192.168.0.255 &#8211; which will be notated as 192.168.0.0/24</li>
<li>I have used en0 as the interface on both the client and server machines &#8211; this is the Ethernet inteface.  If either your client or server are connected via another mechanism (e.g. Airport), then you will need to use the appropriate interface at the appropriate time.   This is only applicable to the client and server &#8211; if machines on your home network are connected wirelessly, etc. it should not be an issue.
</ul>
<h3>Getting the Tun drivers setup</h3>
<p> Even though OS X has a tun manpage, it appears to not actually have tun installed.  The easiest way to get the tun/tap drivers is to download <a href="http://tunnelblick.net">tunnelblick</a>.  You will need it both on the client and server machines.  Once you have it, mount the disk image, and copy the application somewhere (for illustrative purposes, I put it on my Desktop).</p>
<p>At the command line, execute the following (assuming you are in your home dir):</p>
<p class="code"> sudo cp -rp Desktop/Tunnelblick.app/Contents/Resources/*kext /System/Library/Extensions/</p>
<p class="code">cd /System/Library/Extensions </p>
<p class="code">sudo chown -R root:wheel tun.kext </p>
<p class="code">sudo chmod -R go-w tun.kext </p>
<p class="code">sudo chown -R root:wheel tap.kext </p>
<p class="code">sudo chmod -R go-w tap.kext </p>
<p class="code">sudo kextload /System/Library/Extensions/tun.kext</p>
<p>Repeat the above on the server</p>
<h3>The first SSH connection</h3>
<p>Edit /private/etc/sshd_config on the server as root to permit tunnelling.  Make sure the following lines are uncommented (in a default OS X install, they should be there, but will be commented out with a &#8216;#&#8217; sign &#8211; you just need to delete the &#8216;#&#8217;)</p>
<p class="information">
PermitRootLogin yes<br />
PermitTunnel yes
</p>
<p>Then, from the client, execute:</p>
<p class="code">
sudo ssh -w 0:0 root@home while true \; do echo . \&#038;\&#038; sleep 60 \; done
</p>
<p>Replace &#8220;home&#8221; with the internet available hostname of the server.  The output should be a &#8220;period&#8221;, with a new &#8220;period&#8221; every 60 seconds.<br />
If this worked correctly, you should be able to open a new command prompt on the client and execute the following:</p>
<p class="code">ifconfig tun0</p>
<p>which should return</p>
<p class="information">
tun0: flags=8851<UP,POINTOPOINT,RUNNING,SIMPLEX,MULTICAST> mtu 1500<br />
        open (pid ABCDE)
</p>
<p>where ABCDE isn&#8217;t really relevant.  If you execute the same &#8216;ifconfig tun0&#8242; on the server, you should see something similar.</p>
<h3>Setting up the VPN</h3>
<p>Execute the following on the client:</p>
<p class="code">sudo ifconfig tun0 172.16.0.1 172.16.0.2</p>
<p class="code">ssh root@home ifconfig tun0 172.16.0.2 172.16.0.1 \&#038;\&#038; sysctl -w net.inet.ip.forwarding=1</p>
<p>Again, replacing &#8220;home&#8221; with  the internet available hostname of the server.<br />
To test this, add the route on your client</p>
<p class="code">sudo route add -net 172.16.0 -interface tun0</p>
<p>You should now be able to access your server from your client via the IP address 172.16.0.2.  Congrats, you now have a basic VPN</p>
<h3> NAT </h3>
<p>So, what if you have more machines on your home network than just your server?  You&#8217;ll need to set up NAT and some routing rules<br />
First, a route to push traffic to 172.16.0.* via the tun0 interface:</p>
<p class="code">sudo route add -net 172.16.0 -interface tun0</p>
<p>Second, a route to push traffic headed to the home network via the 172.16.0.2 gateway</p>
<p class="code">sudo route add 192.168.0 172.16.0.2</p>
<p>Finally, you need to set up NAT on the server:</p>
<p class="code">sudo /usr/sbin/natd -interface en0 -l -s -m</p>
<p class="code">sudo ipfw add 00002 allow ip from any to any via tun0</p>
<p class="code">sudo ipfw add 00003 divert 8668 ip from any to 192.168.0/24 via en0</p>
<p class="code">sudo ipfw add 00004 allow ip from any to 172.16.0.1</p>
<p>You should now be able to access any of the machines on the home network by IP address!</p>
<h3>Getting it running the next time</h3>
<p>I have setup some aliases and scripts so I don&#8217;t have to remember the exact commands to execute.  This is probably not the most efficient way to do this, but it&#8217;s better than nothing.</p>
<ol>
<li>(Optional) If NAT is not running on the server, you will need to get it setup.  I have dumped the server commands from above into a shell script and just ssh into the box, and execute the script</li>
<li>Execute the first ssh tunnel on the client: &#8220;sudo ssh -w 0:0 root@home while true \; do echo . \&#038;\&#038; sleep 60 \; done&#8221;  Leave it running</li>
<li>Execute the second ssh tunnel on the client: &#8220;sudo ifconfig tun0 172.16.0.1 172.16.0.2; sudo ssh root@home ifconfig tun0 172.16.0.2 172.16.0.1 \&#038;\&#038; sysctl -w net.inet.ip.forwarding=1&#8243;  If successful, this will return the prompt to you</li>
<li>Setup the routes on the client: &#8220;sudo route add -net 172.16.0 -interface tun0; sudo route add 192.168.0 172.16.0.2&#8243;  The VPN is running</li>
</ol>
<ol> When you&#8217;re done</p>
<li>Remove the routes on the client: &#8220;sudo route delete 172.16.0; sudo route delete 192.168.0&#8243;</li>
<li>Kill the running ssh client with a Control-C</li>
<p>That&#8217;s it.  I&#8217;m sure some people will comment on how this could be made better, but it&#8217;s meant to be quick and dirty but work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.delic.com/blog/2009/05/12/vpn-for-osx-client-via-ssh-and-the-tun-device-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes, you can move your own files onto the iPhone Kindle Reader</title>
		<link>http://www.delic.com/blog/2009/03/04/yes-you-can-move-your-own-files-onto-the-iphone-kindle-reader/</link>
		<comments>http://www.delic.com/blog/2009/03/04/yes-you-can-move-your-own-files-onto-the-iphone-kindle-reader/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 19:17:52 +0000</pubDate>
		<dc:creator>rshah21</dc:creator>
				<category><![CDATA[Researching]]></category>
		<category><![CDATA[iPhone Kindle]]></category>

		<guid isPermaLink="false">http://www.delic.com/blog/?p=63</guid>
		<description><![CDATA[If you have a jailbroken iPhone, you can move files onto the iPhone for use in the Kindle reader. The reader stores data in /User/Applications/[App ID]/Documents/eBooks. You&#8217;ll need to figure out the correct App ID for the Kindle app on your phone (you can probably figure it out by looking at the date associated with [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a jailbroken iPhone, you can move files onto the iPhone for use in the Kindle reader.  The reader stores data in /User/Applications/[App ID]/Documents/eBooks.  You&#8217;ll need to figure out the correct App ID for the Kindle app on your phone (you can probably figure it out by looking at the date associated with the directory).  </p>
<p>I have tested this with an unsecured .prc file (similar to what I have loaded onto my Kindle via USB) and the reader opens the document just fine.  You may need to relaunch the application to get it to update the available books on the Home screen.  Whispernet syncing will obviously not work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.delic.com/blog/2009/03/04/yes-you-can-move-your-own-files-onto-the-iphone-kindle-reader/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Building your own Alltop or PopURLs*</title>
		<link>http://www.delic.com/blog/2008/04/11/building-your-own-alltop-or-popurls/</link>
		<comments>http://www.delic.com/blog/2008/04/11/building-your-own-alltop-or-popurls/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 13:21:09 +0000</pubDate>
		<dc:creator>rshah21</dc:creator>
				<category><![CDATA[Researching]]></category>
		<category><![CDATA[popurls alltop simplepie php]]></category>

		<guid isPermaLink="false">http://www.delic.com/blog/?p=55</guid>
		<description><![CDATA[For a while, I have been using PopURLs as a quick and dirty way of scanning interesting websites for what&#8217;s new. It is not a RSS reader substitute, but if I have a couple of minutes and just want to see something new, it&#8217;s a good spot to stop. A few weeks ago, with a [...]]]></description>
			<content:encoded><![CDATA[<p>For a while, I have been using <a href="http://www.popurls.com">PopURLs</a> as a quick and dirty way of scanning interesting websites for what&#8217;s new.  It is not a RSS reader substitute, but if I have a couple of minutes and just want to see something new, it&#8217;s a good spot to stop.  A few weeks ago, with a few free cycles, I wondered just how difficult it would be to roll my own.  Nothing as pretty, but something that would give me some exposure to what&#8217;s under the covers.></p>
<p>A couple of days ago, buzz started to build around <a href-"http://www.alltop.com">Alltop</a> which was built by Guy Kawasaki&#8217;s Nononina, also behind the site <a href="http://www.truemors.com">Truemors</a>.  Alltop is a very pretty site with a wide variety of content, but it too is based on the same content (and looking at the page sources, potentially the same code base).</p>
<p>If you want to build your own, I offer you my findings, code and lessons learned<br />
<!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/php" rel="tag">php</a>, <a href="http://www.technorati.com/tag/popurls" rel="tag">popurls</a>, <a href="http://www.technorati.com/tag/alltop" rel="tag">alltop</a></p>
<p><!-- technorati tags end --><br />
<span id="more-55"></span></p>
<h2>The source code:</h2>
<p>As this is a quick and dirty implementation, I apologize if the code base contains some minor bad practices.  In most cases, I&#8217;ve adhered to standards that should allow you to unzip and deploy, but if something doesn&#8217;t quite work, take a look at the code.  It was intended to be deployed on the URL <a href="http://news.delic.com">news.delic.com</a> so take a look for any part of that string if paths don&#8217;t work.</p>
<p class="alert">Please leave all of the GPL, BSD, CC and other licenses in the code intact, if you publish this.  Any changes I have made to the code are extensions of these licenses. You are free to reuse any code I have written, but if there&#8217;s a license embedded in there, you should leave it there.</p>
<p class="download"><a href="/static/delic_news_source.zip">News aggregation source code</a> (zip format, 490Kb)
</p>
<h2>System components (aka. &#8220;the credits&#8221;) and requirements</h2>
<p>If you are interested in rolling your own version of the <a href="http://news.delic.com" title="Delic News Aggregator">aggregator</a>, I have listed the components below, along with links to some of the relevant installation instructions and documentation</p>
<h3>PHP:</h3>
<ul><strong>PHP core components &#8211; minimum</strong></p>
<li> <a href="http://php.net/" title="http://php.net/"  rel="nofollow">PHP</a> 4.3 or higher (including <acronym title="Hypertext Preprocessor">PHP</acronym> 5)</li>
<li> <acronym title="Hypertext Preprocessor">PHP</acronym>&#8216;s <a href="http://php.net/xml" title="http://php.net/xml"  rel="nofollow">XML extension</a> (enabled by default)</li>
<li> <acronym title="Hypertext Preprocessor">PHP</acronym>&#8216;s <a href="http://php.net/pcre" title="http://php.net/pcre"  rel="nofollow">PCRE extension</a> (enabled by default)</li>
<li> Either <acronym title="Hypertext Preprocessor">PHP</acronym's <a href="http://php.net/mbstring" title="http://php.net/mbstring"  rel="nofollow">multibyte string extension</a> OR <a href="http://php.net/iconv"title="http://php.net/iconv"  rel="nofollow">iconv extension</a>. There is a bug in the current version of SimplePie one or the other.</li>
</ul>
<ul><strong>PHP core components &#8211; recommended</strong></p>
<li> Ability to change file/folder permissions (dependent on how much access your host provides)</li>
<li> Both <acronym title="Hypertext Preprocessor">PHP</acronym>&#8216;s <a href="http://php.net/mbstring" title="http://php.net/mbstring"  rel="nofollow">multibyte string extension</a> AND <a href="http://php.net/iconv" title="http://php.net/iconv"  rel="nofollow">iconv extension</a>.</li>
<li> <acronym title="Hypertext Preprocessor">PHP</acronym>&#8216;s <a href="http://php.net/curl" title="http://php.net/curl"  rel="nofollow">cURL extension</a> (disabled by default)</li>
<li> <acronym title="Hypertext Preprocessor">PHP</acronym>&#8216;s <a href="http://php.net/zlib" title="http://php.net/zlib"  rel="nofollow">Zlib extension</a> (disabled by default)</li>
</ul>
<p class="information">If you are hosted on <A href="http://www.dreamhost.com">Dreamhost</a> and running PHP 5+, you will have all of the minimum and recommended components listed above available to you via the php5 default install.</p>
<ul><strong><a href="http://simplepie.org/" title="SimplePie RSS Aggregator">SimplePie</a></strong></p>
<li>The <acronym title="Hypertext Preprocessor">PHP</acronym> <a href="http://simplepie.org/downloads/" title="SimplePie Download">install</a>for SimplePie.  Installation instructions (if you are rolling your own from scratch) begin <a href="http://simplepie.org/wiki/setup/start" title="SimplePie Install Instructions">here</a></li>
<li>The SimplePie <a href="http://simplepie.org/mint/pepper/orderedlist/downloads/download.php?file=http%3A//simplepie.org/downloads/newsblocks_demo.zip" title="Newsblocks Demo Source">Newsblocks Demo Source</a>.  The documentation for the demo is also <a href="http://simplepie.org/wiki/tutorial/how_to_replicate_popurls" title="Newsblocks Demo Documentation">available</a></li>
</ul>
<h3> Javascript </h3>
<ul>
<li>The SimplePie Newsblocks Demo contains <a href="http://www.prototypejs.org/" title="Prototype Javascript Library">Prototype</a>, <a href="http://script.aculo.us/" title="Script.aculo.us Javascript Library">Script.aculo.us</a>, and <a href="http://www.bennolan.com/behaviour/" title="Behaviour Javascript Library">Behaviour.js</a>, along with <a href="http://www.dustindiaz.com/sweet-titles-finalized/" title="Dustin Diaz's SweetTitles Javascript Library">SweetTitles</a>.  I have replaced SweetTitles with the jQuery based ClueTip (see below) due to some text flicker issues on <a href="http://www.mozilla.com" title="Firefox">Firefox</a>. </li>
<li><a href="http://plugins.learningjquery.com/cluetip/" title="Cluetip - a jQuery based tooltip plugin">Cluetip</a>, which is a<a href="http://jquery.com/" title="jQuery Javascript Library">jQuery</a> based tooltip replacement.  The Cluetip <a href="http://plugins.jquery.com/project/cluetip/" title="Cluetip download">download</a> has all of the jQuery libraries needed (jquery 1.2.2 minimized, dimensions, hoverIntent and cluetip).  Since both prototype and jQuery are being used, you will need to run jQuery in noConflict mode. </li>
</ul>
<h3><acronym title="Cascading Style Sheets">CSS</acronym>/Theme</h3>
<ul>
<li> The theme used for the <a href="http://news.delic.com" title="Delic News Aggregator">aggregator</a> is based on the black style of the <a href="http://www.plaintxt.org/themes/simplr/" title="Simplr WordPress Theme">Simplr</a> theme for <a href="http://wordpress.org/" title="Wordpress blogging system">WordPress</a>, although the <a href="http://news.delic.com" title="Delic News Aggregator">aggregator</a> is not actually running WordPress. The <acronym title="Cascading Style Sheets">CSS</acronym> for the theme has been modified to work with the SimplePie scripts, and can be found <a href="http://news.delic.com/css/styleb.css" title="CSS for news.delic.com">here</a>.</li>
</ul>
<h2>Tips and tricks</h2>
<ol> Some lessons learned in using the SimplePie library:</p>
<li> Setting up feeds in index.php is extremely easy.  For most feeds, the following code will work flawlessly:</br>
<p class="code">&lt;?php echo newsblocks::render (&#8216;http://digg.com/rss/index.xml&#8217;); ?&gt;</p>
<p>The SimplePie <a href="http://simplepie.org/wiki/" title="SimplePie Documentation Wiki">Documentation</a> has all of the options one might need to increase the number of articles pulled from the feed, the cache periods, etc. </li>
<li> If you need to modify the output of the SimplePie parser (for example, to just pull the image out a feed), you need to work in the /php/includes/newsblocks.inc file.  Included in the newsblocks demo file is a function called render_wide which will return any images in the thumbnail enclosure.  If that does not work, you may need to familiarize yourself with the <acronym title="Hypertext Preprocessor">PHP</acronym> function <a href="http://us.php.net/preg_match_all" title="preg_match_all PHP function">preg_match_all</a> and <acronym title="Perl-compatible regular expressions"><a href="http://us.php.net/manual/en/book.pcre.php" title="Perl-compatible regular expressions">PCRE</a></acronym>.</li>
<p>   To get Cluetip to work, there are two necessary steps:</p>
<li> run jQuery in noConflict mode.  In the code below, the class &#8220;ctip&#8221; has been assigned to all links that have associated tips we want to show in Cluetip:
<p class="code">
	&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
     jQuery.noConflict(); </br><br />
     // Put all your code in your document ready area<br />
     jQuery(document).ready(function($){<br />
       // Do jQuery stuff using $ </br><br />
       $(&#8220;a.ctip&#8221;).cluetip({ </br><br />
	    splitTitle: &#8216;|&#8217;, // use the invoking element&#8217;s title attribute to populate the clueTip&#8230;<br />
	                     // &#8230;and split the contents into separate divs where there is a &#8220;|&#8221;<br />
	    showTitle: false // hide the clueTip&#8217;s heading<br />
	  });<br />
     });<br />
   &lt;/script&gt;
</p>
</li>
<li>Modify newsblocks.inc so that the html output for each link for each item in the rss feed contains the &#8220;ctip&#8221; class as well as the &#8220;|&#8221; delimiters for the title and body of the tooltip.  Look for the code:
<p class="code">
      $html .= &#8216;&lt;li class=&#8221;&#8216; . $class . &#8216;&#8221;&gt;&lt;a href=&#8221;&#8216; . $item->get_permalink() . &#8216;&#8221; title=&#8221;&#8216; . newsblocks::cleanup ($item->get_description(), $length) . &#8216;&#8221;&gt;&#8217; . $item->get_title() . &#8216;&lt;/a&gt; &lt;/li&gt;&#8217; . &#8220;\n&#8221;;
      </p>
<p>and change it to:</p>
<p class="code">
       $html .= &#8216;&lt;li class=&#8221;&#8216; . $class . &#8216;&#8221;&gt;&lt;a class=&#8221;ctip&#8221; href=&#8221;&#8216; . $item->get_permalink() . &#8216;&#8221; title=&#8221;|&#8217; . newsblocks::cleanup ($item->get_description(), $length) . &#8216;&#8221;&gt;&#8217; . $item->get_title() . &#8216;&lt;/a&gt; &lt;/li&gt;&#8217; . &#8220;\n&#8221;;
      </p>
</li>
</ol>
<p class="information">* = <a href="http://www.alltop.com">Alltop</a> and <a href="http://www.popurls.com">PopURLs</a> are registered trademarks and/or servicemarks of Nononina and <A href="http://thomasmarban.com/">Thomas Marban</a> respectively.  This site is not affiliated with them in any way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.delic.com/blog/2008/04/11/building-your-own-alltop-or-popurls/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.446 seconds -->

