Configuring OpenVPN on PFSense for use with Android and Cyanogenmod 6 RC3

I assume you've got a working configuration for any roadwarrior such as your laptop, so I explain only small adaptions. Anyway, for a basic configuration, see http://www.scribd.com/doc/8142908/pfSense-OpenVPN-Tutorial

The setup has been tested with a nexus one running Froyo (FRF91) and Cyanogenmod 6 RC3 and PFSense 1.2.3-RELEASE nanobsd on an ALIX board

Let's start with the PFSense box:
Check LZO Compression #for a slight better performance

Under "Custom Options"

add push "redirect-gateway" #since Cyanogenmod OpenVPN integration has problems with doing this itself…

Now to the Device (all options have to match the ones chosen on your pfsense wall, i think that's self-evident):
Under "Advanced" (press the menu button) choose the following:

Device to use: tun
LZO Compression: true
Redirect Gateway: FALSE #pfsense pushes this option to us
Cipher Algorithm: AES-256-CBC #since my uplink is 1Mb/s it doesn't really matter that I use something really secure, crypting on my nexus1 will do that with ease
Size of cipher key: default

Cleaning up / Extending Timetable in LaTeX

The Class always had a “buggy” behavior for me, so I thought about some fixes for that problems and since I never discovered a better package, I made up fixes for that problems:

The snippet below is for printing the exact begin- and ending times of your lessons, since The class gives the timestring too little space, it grows slightly over the cell border. This “hack” has some exploit flavor.

...
\setprinttimestamps{2} %view also ending time
\settimestyle{\vspace{1mm}\tiny} %_HACK_ push down the Time entries
...

I also recommend adding the command below, if you haven’t already, IMHO the default value is too big.

\setbottomspace{2pt}

Android Emulator Dev Tools App on real Device

Recent Versions (>=6) of Cyanogenmod and others already include the tools mentioned below, Check that before reading.

Please setup your SDK correctly e.g. w/ this guide:Installing the SDK
There are some Apps preinstalled on the Android Emulator that comes w/ the SDK which you don’t find on the Froyo image or in the Market.

    Start an Emulator Instance and connect your phone in USB-Debugging mode.

Dev Tools” (Developer.apk) [set of tools to view network usage, connections to google servers, view packages install. locations and a whole lot more!]
Spare Parts” (SpareParts.apk) [gives you very detailed info about battery usage of specific hardware and lets you adjust the system's animations]
Custom Locale” (CustomLocale.apk) [quickly fake your locale setting]
“Speech Recorder” (SpeechRecorder.apk) [no guess...]

Ok, so here’s how to get those tools on your device:
Connect Your Android Dev phone via USB and boot the emulator;
run the following bash one-liner:

for file in "SpeechRecorder.apk" "CustomLocale.apk" "SpareParts.apk"; do adb -e pull /system/app/$file; adb -d install ./$file; done

Hex Addition function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def add_hex(arr):
    result = 0x0
    index = 0
    while True:
        print index
        try:
            result = result + int(arr[index], 16) + int(arr[index+1], 16)
        except IndexError:
            try:
                result = result + int(arr[index], 16)
            except IndexError:
                pass
            result = hex(result)
            break
        index+=2
    return result
 
print add_hex2(['0x01', '0x05', '0x04', '0x09', '0x17'])

Date subtraction SQL snippet for OpenOffice base

With this simple line condition in OpenOffice base’s hsqldb it is possible to subtract a date fragment, and in order to this, select the matching entries. My example is a query on a column containing birthdates in the german format DD-MM-YY.

It selects the entries (persons) who are under the age of 20.

SELECT “birthdate” AS “Birthdate” FROM “under20″ AS “under20″ WHERE (datediff(‘yy’, “BIRTHDATE”, CURRENT_DATE)) <= 20

Instead of  ‘yy’ it’s possible to take the following other values:

‘ms’=millisecond

‘ss’=second

‘mi’=minute

‘hh’=hour

‘dd’=day

‘mm’=month

Install additional packages on pfSense 1.2.3-RC1

There is no package manager in pfSense 1.2.3-RC1, though you can install FreeBSD ports via “Diagnostics > Command”.

Type

pkg_add URLofthePackage.tbz

in the field and press return.

the packages can be found at ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/category (BTW. there’s a complete list at the parent directory)

In most cases you will have to use a SSH or serial connection to configure the programs. Please also keep in mind that more daemons slow down the boot process significantly, especially on embedded devices !

The pkg_add(1) utility uses fetch(1) to download the precompiled package and installs it automatically. On regular (bigger) FreeBSD systems you will pull a complete directory of ports into your local ports directory from the FreeBSD servers in use of the program cvsup. Since this is method of getting new programs was not meant to be used on embedded systems on which that dump just fills up the small flash disks, the manual way of getting the packages is preferred. Another reason why it’s necessary to use precompiled packages is that most of the embedded OS’ bring no compiler with themselves.

An experience I made while setting up a ftp server that the filesystem is read-only. The developers explain it is due to the limited writecycles on flashable media, so the volume gets mounted for updating the cfg file only. You have to use the web-based cmdline for executing file-modifying commands. That also includes SSH which isn’t even with root rights able to write something.

BASH – generate a pseudo-random user agent

The following script will give you a user agent randomly out of a big list of all user agents that exist.

1
2
3
4
5
6
7
8
#!/bin/bash
 
userAgents=`curl -s http://www.user-agents.org/allagents.xml | grep -B 5 '<type>B</type>' | grep '<string>' | cut -c 9- | sed 's/..........$//'`
maxLines=`echo "$userAgents" | wc -l | tr -d ' '`
randomUserAgent=$(echo "$userAgents" | sed -n $[ ( $RANDOM % ( $[ $maxLines - 1 ] + 1 ) ) + 1 ]p)
 
echo $randomUserAgent
</string>

The script searches for a type “B” in the xml document, which stands for Browser, if you want to include other types, write the letter in place of, or with one space seperated from “B”. It’s possible to specify more than 2 types.

B = Browser
C = Link-, bookmark-, server- checking D = Downloading tool
P = Proxy server, web filtering
R = Robot, crawler, spider
S = Spam or bad bot

iTunes – Export/Copy Files from Playlist to any place on your mac

This tiny applescript lets you copy all files on any Playlist in Your iTunes Library to any folder you want. For example on an external hard drive.

If you have suggestions for features or fixes, comment.

cPlaylist.scpt (.scpt – Applescript Source)

cPlaylist.app (.app binary build)