Hi On Tue, Sep 21, 2021 at 8:42 AM Bo Berglund <bo.bergl...@gmail.com> wrote:
> On Fri, 18 Jun 2021 11:15:00 -0400, Selva Nair <selva.n...@gmail.com> > wrote: > > >Hi, > > > >On Fri, Jun 18, 2021 at 3:36 AM Bo Berglund <bo.bergl...@gmail.com> > wrote: > > > >> On Sat, 12 Jun 2021 14:01:51 -0400, Selva Nair <selva.n...@gmail.com> > >> wrote: > >> > >> >> I wonder if there is some way (on Windows) to start the tunnel > >> connection > >> >> from > >> >> the special comm program and then close it down when the comm > session is > >> >> over > >> >> and the program closes. > >> >> I have written the comm program and I could add such a feature if it > is > >> >> possible > >> >> to accoplish. > >> >> > >> >> OpenVPN-GUI is sort of a GUI program so I suspect it does not have > any > >> >> useful > >> >> hooks... > >> >> > >> > > >> >We have some support for sending commands to the GUI to > >> >connect, disconnect etc.. See > >> > > >> > > >> > https://github.com/OpenVPN/openvpn-gui#send-commands-to-a-running-instance-of-openvpn-gui > >> > > >> >Selva > >> > >> I have now tested the individual commands to connect and disconnect > using a > >> small program just for testing this interaction. It seems to work very > >> well. > >> > >> But when I integrated it into the main client application I found that > what > >> happens on the connect call > >> > >> openvpn-gui.exe --command connect serverconfig > >> > >> is that the connection dialog pops up showing all of the progress > messages > >> while > >> connecting, but at this time the call to openvpn-client returns *before* > >> the > >> connection is established so my following actions are errored out > because > >> there > >> is not yet a connection. > >> When I traced this in the debugger with a breakpoint directly following > >> the call > >> it reaches the breakpoint before the dialog has finished... > >> > >> So now I am wondering if the connect call just *triggers* openvpn-gui to > >> start > >> the connect process but it does so in its main thread so it exits the > user > >> call? > >> > >> > >That is correct. It uses Windows messages and returns as soon as the > >message is delivered. You will have to do some checks like ping the remote > >through the tunnel to determine the connection has started up. The status > >window popup can be avoided by toggling silent-connection (see the > >supported commands in README). > > > >Selva > > I am returning to this issue after the summer, when I had to make a pause, > so I > have a follow-up question: > > I implemented the GUIO call to start a connection and I made it hide the > dialog > window. So now I need to cover all bases so to speak... > > Since ping is not really working well to detect a connection I figured > that I > could invoke the Windows command: > > ipconfig /all > > and examine the result to check that an adapter with the correct starting 3 > octets of the tunnel IPv4 address appears (or is already present). I have > noted > that it is present when connected but not when unconnected. > > What I don't understand is for how long I should wait until giving up after > commanding a connection? > Depending on your network, about 30 seconds max, probably. But it also depends on whether you want it to try the next remote if one fails, how many times to retry etc. > > I have noted that the OpenVPN GUI application runs a *very long time* > (maybe > forever) if there is no connection to the server, seems to restart every > minute... > > Is there a way to make it stop if it does not connect within a certain > (short) > time? > If you want to stop using the "send commands to running GUI" feature, send the disconnect command. openvpn-gui.exe --command disconnect profilename See the readme in GUI repo. Or, add "connect-retry-max 1" to the config file. See OpenVPN manpage. Which is better depends on the use case. Selva
_______________________________________________ Openvpn-users mailing list Openvpn-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-users