How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

This forum is for general conversation and user-user networking.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
woodrock
OpenVPN User
Posts: 37
Joined: Sun Jun 04, 2017 1:59 am

How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by woodrock » Sat Jul 01, 2017 12:41 pm

How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Given that publicly downloadable openvpn files are often unreliable, my use model is to download and select a score or more of these *.ovpn files at a time, where I "RightClick > Open" them in the OpenVPN Daemon.

That initially opens up a score of OpenVPN Daemon command windows, where only two things will happen:
a. All the stale OpenVPN Daemon command windows will eventually die within minutes, and/or,
b. All the good OpenVPN Daemon command windows after the first successful connection, will also die within minutes.

In the end, after a minute or three, I will have either zero windows (which means that none were successful) or one successful window (because all subsequent successful windows will die of their own accord); but I have to keep clicking and watching to check on the progress of the "winner", if any.

More efficient would be for the OpenVPN Daemon to be told (somehow) to ring an audible when it outputs the statement:
"Initiation sequence completed"
Image
How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by TinCanTech » Sat Jul 01, 2017 5:13 pm

You could use either or all three of :
  • --up script (a batch file)
  • --route-up (a batch file)
    & --route-delay to delay for some time if required (a batch file)

woodrock
OpenVPN User
Posts: 37
Joined: Sun Jun 04, 2017 1:59 am

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by woodrock » Sat Jul 01, 2017 9:25 pm

TinCanTech wrote:You could use either or all three of :
  • --up script (a batch file)
  • --route-up (a batch file)
    & --route-delay to delay for some time if required (a batch file)
Thanks for that suggestion as those commands seem reasonable.

Apparently the specified "--up" script is called after the TUN/TAP device is opened.
Image

The "--route-up" script seems to run "after connection authentication".
Image

As you noted, the "--route-up" is subject to the "--route-delay" which is a bit more complex because it also seems to affect added routes.
Image

It seems to me the best one to test out first will be the "--route-up" which runs pretty late in the game.
Now I need to look on the Windows side for a script to ring a bell.

woodrock
OpenVPN User
Posts: 37
Joined: Sun Jun 04, 2017 1:59 am

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by woodrock » Sat Jul 01, 2017 10:41 pm

Apparently Windows 10 no longer has "sndrec32.exe" nor "SoundRecorder.exe" but it does have something called "powershell".

While "powershell" works inside a batch file to play a sound, I may need that route-delay after all, as I can't seem to get the "-up" or "--route-up" to work in this syntax in the *.ovpn config files.
--up C:\path\to\batch\file.bat
--route-up C:\path\to\batch\file.bat

Where the batch file works on its own and contains this one line:
powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();

But what happens when I doubleclick on the *.ovpn file is that a window pops up and goes down instantly, and nothing happens (not even an OpenVPN connection). If I remove the lines above, then the openvpn config file works fine - so there's a syntactical problem I need to resolve.

User avatar
Pippin
Forum Team
Posts: 1201
Joined: Wed Jul 01, 2015 8:03 am
Location: irc://irc.libera.chat:6697/openvpn

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by Pippin » Sun Jul 02, 2017 12:15 am

Correct is,

Code: Select all

up C:\path\to\batch\file.bat
route-up C:\path\to\batch\file.bat
without -- just as the rest of the directives.

There`s also <config>_up.bat that must be placed in the same directory as <config>.ovpn
<config> must match.
Runs when connection is established.
So every config can have it`s own <config>_up.bat
For OpenVPN GUI only, i use this for auto mounting SMB shares.

woodrock
OpenVPN User
Posts: 37
Joined: Sun Jun 04, 2017 1:59 am

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by woodrock » Sun Jul 02, 2017 1:07 pm

Pippin wrote:There`s also <config>_up.bat that must be placed in the same directory as <config>.ovpn
<config> must match.
Runs when connection is established.
So every config can have it`s own <config>_up.bat
This seemed so easy that I tried it first.
Image
When I doubleclick on the batch file, it works fine to make a sound all by itself.
C:\test_up.bat
When I doubleclick on the ovpn file, the OpenVPN Daemon (not the OpenVPN GUI) makes the connection just fine.
C:\test.ovpn

No error. No warning. No nothing.
It connects just fine.
But alas, no bell either.

I wonder if my registry edits are causing this to not work?
From this:
"C:\path\to\openvpn.exe" --pause-exit --config "%1"
Image
To this:
"C:\path\to\openvpn.exe" --config "%1"
Image
and also adding this one additional line to each config:
--connect-retry-max 1
Image
I wonder if the fact I don't use the OpenVPN GUI is the problem?
I'm using only the OpenVPN Daemon.

If there's only one config file, I doubleclick on it, and it opens in the OpenVPN Daemon (because I don't use the OpenVPN GUI for the reasons stated in this explanation).

Most of the time there are scores of config files, so I just select them, right click, and say "open", which opens them all in the OpenVPN Daemon, and not in the OpenVPN GUI.

Are you using the daemon or the GUI?

woodrock
OpenVPN User
Posts: 37
Joined: Sun Jun 04, 2017 1:59 am

Re: How can I get OpenVPN Daemon to ring a bell upon "Initialization sequence completed"

Post by woodrock » Sun Sep 03, 2017 10:38 am

As a long-term summary, I gave up trying to get a bell rung when OpenVPN connects, so if anyone does figure out how to add a bell to the connection notification, please let me know!

TIA

Post Reply