Monitoring VPN connection

Sometimes you really need to make sure VPN connection is alive when you are running some applications. I didn’t find any easy way to do this in Win7 (I don’t want to installing new firewalls just because of this) so I made this small application called “vpncheck 1.1″:

http://code.vn720.com/files/2011/07/vpncheck-2011-06-07.zip

Old “vpncheck 1.0″ is still available at http://code.vn720.com/files/2010/11/vpncheck-2010-27-11.zip

It does following:

Checks every 0.3s that VPN connection is active and kills listed processes if not.
If later VPN becomes active, the processes are re-started.

Reads config file (vpncheck.cfg) which has following format:
<name of VPN connection, e.g. Anonine>
<full absolute path filename of exe 1>
<full absolute path filename of exe 2>

Example of valid config file:
Anonine
C:\Program Files (x86)\uTorrent\uTorrent.exe
C:\Program Files (x86)\Skype\Phone\Skype.exe

Tested on Windows 7.

Provided as is, no guarantees of any kind.
This is a bit hacky application so don’t take it as example of good software engineering, but it should work.

Feedback, bugs, comments, welcome: jani@kajala.com

The application comes with full source code and build files (Visual Studio 2008) if you are interested to take a look. However, it does have executable as well.

Cheers,

Jani

Tags: , , , ,

22 Responses to “Monitoring VPN connection”

  1. Usif says:

    I’ve been looking for an easy solution to this and so far yours seems the easiest and it looks like it works.

    Just wanted to thank you for the effort since it seems that the other solutions (which indeed probably do work but require another software/firewall or a slew of other setups that may bog down my connection) are just a bit too much for me.

    THANKS!

  2. kajala says:

    Thanks for your comments, nice to hear the application been useful for someone besides me. :)

  3. Hamlet says:

    Hello!
    Thanks for this great little program.

    There is only one thing that tends to cut into its usefulness:
    Let’s say I want to close µtorrent on purpose, but VPNcheck is running in the background. So I close µtorrent, but it get immediately re-opened by VPNcheck.

    So I try it a second time, only this time I quickly close µtorrent and VPNcheck as well, but this leads to a hard shutdown of µtorrent, which means that all my downloads have to be checked again.

    –> Please integrate an option to make a smooth, controlled shutdown of the supervised program and VPNcheck.

    Also some (more or less useful) suggestions:
    - let VPNcheck run in the tray. Right now it always opens a huge window with nothing but blank space in it
    - give it a nice symbol :)

    Would like to hear your opinions about those.

    Regards,
    Hamlet

  4. Hamlet says:

    Oh, and one more thing:
    I’m using Win7 64-bit and VPNcheck runs just fine.

  5. Olof says:

    Thanks alot for publishing this! You found a clever solution to a common problem, and it’s really appreciated that you are actually sharing it aswell!

  6. iJon says:

    I also stumbled upon this app after dealing with VPN issues and just wanted something that worked… this has been the absolute perfect solution and I thank you for putting out there for the rest of us.

    Cheers!

  7. d says:

    thanks man, love your app. Very useful.

  8. O says:

    Works a treat. Many thanks!

  9. kajala says:

    Thank for the feedback and suggestions! Yep, I agree it would better be in tray instead of big empty window. Lazy programmer, lets see if “v2″ comes out some day. :)

  10. admin says:

    Uploaded v1.1: Otherwise same as before but added minimizing to tray. Download @ http://code.vn720.com/files/2011/07/vpncheck-2011-06-07.zip

  11. sfx says:

    Where do I find my VPN name? My VPN connection shows up as an unidentified network in the Network and Sharing Center. I looked at ipconfig and tried using what was listed under Description, Physical Address, Link-local IPv6 Address, IPv4 Address and DHCP Server as the name but none worked.

    Does this work with OpenVPN?

    -Thanks

  12. sfx says:

    Hmm I left a question here earlier but it has been removed? I noticed the email address I used was wrong, should I repost?

  13. admin says:

    No wasn’t deleted, I’ve been just out of Internet for a few days. Time Warner Cable: “Oops sorry, we connected your Internet in the transfer to wrong house!” :P

  14. admin says:

    The application uses Windows API to detect VPN, so it most likely doesn’t work with anything which requires a dedicated client software to connect.

    By the way: Would be nice if the VPN providers would make their systems Windows-compatible as well. At least I don’t like installing extra software on my PC just to connect to network.

  15. SimWin says:

    Thx for making something like this possible. When I try to run the app it says: File missing:C:\programm files (x86)\utorrent\utorrent.exe. I have utorrent installed in C:\program files. Can you tell me whats wrong by any chance? thank you

  16. kajala says:

    maybe just wrong path? the text file vpncheck.cfg has the paths. The first line is name of the VPN network, and the rest of the lines are paths to the executables, e.g. c:\Program Files\uTorrent\uTorrent.exe or something similar

  17. smg says:

    Just wanted to say THANKS Was dealing with firewalls and this is simple and it works!

  18. zum says:

    Looks like a really useful utility. Do you know of anything similar that will run on a DD-WRT router? IE it will block p2p traffic if it finds the vpn has gone down.

  19. Mellow says:

    This is wonderful. Works perfectly.
    I decided to set it to run at start up; However, when executed it opens the program window. Do you/will you plan to add settings in the .cfg to start minimized to tray?

  20. admin says:

    You could make a shortcut/bat and start vpncheck like this:

    start /min vpncheck.exe

    That should minimize the window. Works for me at least.

  21. vpnftw says:

    Do you know how long it takes once the vpn connection drops for the regular network connection to take over? In other words how can you be sure this won’t leak your within the time it takes to kill any process it is monitoring?

  22. kajala says:

    Not sure, but I’d be very surprised if p2p connection can be established and re-routed that fast. If you are worried you can always lower the VPN_CHECK_INTERVAL constant (default 300ms) and re-compile the sources. However, I’d not worry too much. Besides, even if you’d somehow manage to establish connection, certainly you wouldn’t have time to download/upload anything in that time. :)

Leave a Reply