Browsed by
Month: January 2010

Java in the Real World vs in My Head

Java in the Real World vs in My Head

I was never a big fan of Java for a number of reasons; It was always so slow compared to my baby C++. It always generated such huge “binaries” not unlike my very much hated Visual Basic. It has automatic garbage collection while I prefer to retain an anal 100% control over my software.

Time has passed and some things have changed (plus I started using PHP religiously so there goes most of my objections both stated and otherwise). Of course it was sudden by no means and seems more of a “duh” statement that at this point in time Java is everywhere! Hell, most of my mobile devices run on the platform and since I change phones every ~six months so this is an impressive feat.

Should I give Java another look?

Tether Motorola Droid with Ubuntu Without Root

Tether Motorola Droid with Ubuntu Without Root

One of my favorite things to keep in my pocket is an Internet connection. Many, many times have I been ~1,500 miles from home in a rental car in a parking lot needing to get out an expense report (or wanting a quick deathmatch game). For this reason I search for a way to tether a mobile before I buy it as a prerequisite. My newest mobile, the Motorola Droid, was no different.

Here are the steps I took to get it working with Ubuntu 9.10 x64:

  • Grab the latest Azilink archive and extract it: http://azilink.googlecode.com/
  • Grab the latest Android SDK and extract it: http://developer.android.com/sdk/
  • Set your Droid to debugging mode: Settings -> Applications -> Development -> USB debugging
  • Install the .apk file onto your Droid. This can be done by pointing the Droid’s web browser directly to the download link or loading it onto the SD card. Either way you may need to go to Settings -> Applications -> Unknown sources to allow it to be installed.
  • Install OpenVPN: sudo apt-get install openvpn
  • Get your Droid vendor and product IDs by typing lsusb at the console. It should be easy to figure out which line is the Droid. Mine says “Motorola PCS” in it. You will see two four-digit hexadecimal numbers after the term “ID” and those are your IDs. The following is an example lsusb output:

    Bus 002 Device 005: ID XXXX:XXXX Motorola PCS

  • Enter sudo gedit /etc/udev/rules.d/50-android.rules at the console and add the line

    SUBSYSTEM=="usb",ATTRS{idVendor}=="[vendor ID]",ATTRS{idProduct}=="[product ID]",MODE="0666",OWNER="[username]"

    replacing the the appropriate fields in brackets (also removing the brackets).

  • Save the file and then reboot. [android SDK path]/tools/adb devices should show your device after this step.
  • Create a file named resolv.conf and enter into it

    domain lan
    search lan
    nameserver 192.168.56.1

  • Start up Azilink on your Droid and select Service active.
  • Enter the following into the console:

    [android SDK path]/tools/adb forward tcp:41927 tcp:41927
    sudo cp [path to file]/resolv.conf /etc/
    sudo openvpn [path to azilink]/azilink.ovpn

You might want to pack some of these things into a shell script or something to make things easier for you. If all these steps went well you should be able to access the Internet on your computer via Azilink’s tethering capabilities. Be sure to check out the About screen in the Azilink application on the Droid to see if any of that applies to you.

A few things worth mentioning: This method does not require your Droid to be rooted. I am running Ubuntu 9.10 x64, Droid firmware 2.0.1, OpenVPN 2.1 RC19, and Azilink 2.0.2.

Update 2010.05.10
These steps have also been tested to work on Ubuntu 10.04.

OpenVPN Woes: The Revenege of Nick

OpenVPN Woes: The Revenege of Nick

After one week of struggle, head ache, and a very patient girlfriend I have OpenVPN running in a bridged configuration! What follows are the steps that I had taken (minus the blood, sweat, and tears):

  • Read the OpenVPN HOWTO! Nothing will replace the knowledge of how this beast works.
  • Bridge your OpenVPN virtual network adapter with your local LAN-side adapter. Make sure to set your bridge adapter network information (IP, netmask, ect) to what your local LAN adapter information was set to. I did come across a decent guide with images in my travels for Windows.
  • Generate the certificates. Do not forget to generate the Generate Diffie Hellman keys as this was a small road block for me. (I am just going to link this one since this step is easy and is explained very well in the HOWTO.) Copy the ca.crt, client1.crt, and client1.key files to your clients. It is also a good idea to read the section on Hardening OpenVPN Security and generating a ta.key.
  • Create your configuration files using the samples as a base making sure to use your new bridge adapters IP and netmask as your server configurations IP and netmask. These samples are also included in the OpenVPN distribution. (I am including my working configurations below.)
  • Fire up the server and then the client.
  • Read the OpenVPN HOWTO!

My Configurations

Server

port 1194
proto udp
dev tap
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
ifconfig-pool-persist ipp.txt
server-bridge [Server IP] [Server Netmask] [OpenVPN DHCP Range Start] [OpenVPN DHCP Range End]
client-config-dir ccd
client-to-client
keepalive 10 120
tls-auth ta.key 0
tls-cipher DHE-RSA-AES256-SHA
replay-persist persist.txt
cipher AES-256-CBC
comp-lzo
max-clients 16
persist-key
persist-tun
status openvpn-status.log
log openvpn.log
verb 4
mute 20

Client

client
dev tap
proto udp
remote [VPN IP] [VPN Port]
resolv-retry infinite
nobind
persist-key
persist-tun
mute-replay-warnings
ca ca.crt
cert client1.crt
key client1.key
ns-cert-type server
tls-remote [Server Common Name]
tls-auth ta.key 1
cipher AES-256-CBC
comp-lzo
verb 4
mute 20


Notes

  • All my testing was done with OpenVPN v2.1.1.
  • A bridge configuration will give your VPN clients IPs on your local LAN. Make sure you choose a free range of IPs that does not conflict with anything (including an existing DHCP server).
  • Make sure to disable any firewalls on the bridged adapter if you can. If that is a problem– say your bridged adapter is plugged directly into a WAN connection– you will need to experiment since I did not have to go that far in my setup.
  • I have done most of my testing on Windows XP Professional SP3 and Ubuntu 9.10. These configurations should work for any support platform.
  • I have chosen to allow OpenVPN to dish out the IPs instead of my local DHCP server. The reason for this is some clients will not allow this functionally based on client OS. Since I was already using most of my IPs for DHCP I just lowered the number of available DHCP addresses and set OpenVPN to use those as it wished.
  • Some versions of Windows have an issue bridging the adapter properly. It will say it worked but there is still another step you need to take. Check out this article for more information.
  • If you are unfamiliar with networking and subnetting Wikipedia may be a good place to start.

With the OpenVPN HOWTO and this information you should be able to avoid the headache I went through.

I would very, very, very much like to thank #openvpn on the freenode IRC servers! Without them I would still be at this thing. You guys helped me so much and I appreciate it so much.

Edit 2010.12.23
I have done a lot of experimentation since I originally wrote this. I have updated this article with my current configs.

My Robotic Apartment

My Robotic Apartment

I recently purchased a Synology DS409 (more on that another time). This has prompted me to restart work on something I have wanted to do since I moved into my apartment three years ago: build an infrastructure to house my e-mail, web, various media, and other content all in one place, all under my direct control. I also want these technologies to allow me to access everything as if I were home. This is not a difficult goal to accomplish– given the right equipment– but does require a number of moving parts that all need to work together. For example, the DS409 will now contain the web root for my web server which will run on a separate box. This not only unifies everything but also allows for RAID protection and backup of a single entity instead of worrying about monitoring several scripts on several boxes.

The following are the products/projects I am looking to employ:

  • Synology (DS409): For a while I was looking at Openfiler but the Synology OS offers more functionally for roughly the same price plus free, fast tech support if needed.
  • Linux (Ubuntu): This will be the platform most services will on. It is efficient with its resources and has a huge, active community.
  • OpenVPN: This is provide direct access to everything while I am away as if I were not.
  • TrueCrypt: For data at rest that that requires absolute secrecy.
  • Apache 2.2 + PHP 5: Between the various Apache web servers and PHP I have gotten so much work done these are now staples in my environment.
  • MySQL and SQLite: My tried and true database software for nearly as long as I have been working with SQL.
  • Orb: An oddity in the Microsoft world, this server will stream my media to nearly any device while dynamically adjusting its bandwidth usage.

Most of these are open-source and free.

Robot Traverses Maze

Robot Traverses Maze

At the Singapore Robotic Games where “automation is a key factor towards advancement… to a technologically sophisticated country” some people have built a maze for robots to run through.

This is very similar to something I had done in high school except my maze and robots were virtual. With the introduction of the LEGO Mindstorms things that were the domain of nerds in academic labs before are now accessible to a wider audience. This audience includes people of a younger age than was commonly seen before. I often wonder what technology that I drooled over a year ago will soon be inexpensive enough for me to buy and screw around with.

[youtube]bproY7G2t4o[/youtube]
2009 Singapore Robotic Games MicroMouse Robot Competition



This post represents a paradigm shift.

What was once a repository for the everyday crap floating around in my brain is no more. This blog is now a repository for B- everyday crap floating around in my head.

Most posts before this point– minus one or two decent posts– are to be ignored.

No, that subject is not a mistake. I was being clever, doink.