Archive for the ‘Development’ Category

VPN protected use of TransmissionBT – AppleScript

février 13th, 2012

It’s been a little while that the Ananoos service exists. Very useful and easy, powerful and cheap VPN service. It works on top of OpenVPN which provides high security and encrypted connections. Besides I’m using Transmission which is a free and efficient BitTorrrent client.

The goal is to make sure the VPN connection is always up when using Transmission. When starting Transmission or when the VPN link fails, the VNP connection is restarted. And if really there is no way to get back the VPN link, the Transmission app is simple closed.

# SET HERE YOUR TUNNELBLICK
# CONNECTION NAME
# IN MY CASE: Ananoos
set VPNConnection to "Ananoos"

repeat
	# If transmission is running
	if appIsRunning("Transmission") then
		set vpn to ""

		if appIsRunning("TunnelBlick") then
			# TunnelBlick is running
			# Checking whether it is connected
			tell application "Tunnelblick"
				set vpn to get state of first configuration where name = VPNConnection
			end tell
		else
			tell application "Tunnelblick" to activate
		end if

		# VPN is connected, all fine
		if vpn = "CONNECTED" then
			#display alert "Transmission is running and protected"
		else
			# VPN is not connected, forcing reconnect
			tell application "Tunnelblick"
				connect VPNConnection
			end tell

			# Waiting for reconnection
			repeat 10 times
				tell application "Tunnelblick"
					# Is VPN connected at last?
					set vpn to get state of first configuration where name = VPNConnection
					# Yes, exiting loop
					if vpn = "CONNECTED" then exit repeat
					do shell script "sleep 3"
				end tell
			end repeat

			# Checking whether TunnelBlick has reconnected
			if vpn = "CONNECTED" then
				display alert "ATTENTION: Transmission was running without VPN protection. We have successfully forced reconnection..."
			else
				# Not reconnected, better quit Transmission
				tell application "Transmission"
					quit
				end tell
				display alert "ATTENTION: Transmission was running unprotected. We were unable to reconnect to VPN therefore we have closed it..."
			end if

		end if
	end if
	do shell script "sleep 1"
end repeat

on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

Open the Mac AppleScript Editor. Copy and paste the above code. Save as an application and make sure this app is automatically started on login.
Attention 1: this script works only with TunnelBlick which is a openVPN Mac GUI. Ananoos offers either their own VPN client or the TunnelBlick config files. Prefer 2nd option.
Attention 2: line4, I refer to the « Ananoos » connection. If your have named it differently, update the script.

Tags: , , , , ,
Posted in Development, Technology | Comments (0)

Monitolite improvement

avril 9th, 2010

Monitolite was improved today: it supports now tasks history properly. It means that Monitolite will not send 20 times the same notification for the same issue. Plus it is able to detect a recover status and to send a RECOVERY notification.

Tags: , , ,
Posted in Development, Technology | Comments (0)

Subversion pre-commit hook for PHP

mars 8th, 2010

If you are using Subversion for your development projects, you may know about hooks: these are scripts that are executed on the server at different times. For instance you may want to check that a commit message is not empty before allowing the commit. In this case, this is a pre-commit hook. Read the rest of this entry »

Tags: , , ,
Posted in Development | Comments (0)

Introducing MonitoLite

mars 4th, 2010

I am glad to introduce MonitoLite, a Perl application I’ve been developing the past days. It is a quick, powerful, easy-to-use monitoring tool.

Read the rest of this entry »

Tags: , , , ,
Posted in Development, Technology | Comments (0)

Code snippet: a PHP virus

février 25th, 2010

A quick post to share with you a tiny code sample I’ve written: this is a PHP virus.

Read the rest of this entry »

Tags: , , , ,
Posted in Development | Comments (0)