Hi All.
I'm new with OpenVPN and possibly asking well-known things, but i could not find the solution.
I am developing database application which uses VPN connection with database server. (both running Windows)
I whish to automate VPN connetcion at application startup. When VPN connection is established i need to open connection with DB server from my application. Everything works fine except one issue: I don't want to force users to push two different buttons on app's login window (Connect VPN and Connect DB).
The issue is with understanding of established VPN connection.
When user press login button I'm calling openvpv.exe (i'm using CreateProcess function). The connection with VPN server may take unpredictable time and i don't know when i can try to start database connection. So i need to detect if VPN connection is established before trying to open DB connection in my application.
The question is - how to understand that VPN connection has been established?
I see 3 ways to do this:
1. Force OpenVPN to perform some specific action after establishing connection with server (Send any signal to my application, for example run windows batch file)
2. Loop connection testing function in application with some timeout before trying to connect database. (I tried to do this but without any result. It seems that Ws2_32.dll function gethostbyaddr fails to resolve host infomation)
3. Ask the state of OpenVPN virtual TAP interface. (But i don't know how to understand which interface is used by OpenVPN from my application)
Thanks.
Client-side detection of established connection
Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech
-
- OpenVpn Newbie
- Posts: 1
- Joined: Thu Sep 29, 2011 3:02 pm
- janjust
- Forum Team
- Posts: 2703
- Joined: Fri Aug 20, 2010 2:57 pm
- Location: Amsterdam
- Contact:
Re: Client-side detection of established connection
it would actually be easier to use the openvpn gui application for this: it can be configured to launch automatically AND it can run a script after the connection is established (<name>_up.bat)
the openvpn.exe executable can run an 'up' script during a client connect, but the link is not up at that time.
the openvpn.exe executable can run an 'up' script during a client connect, but the link is not up at that time.