Pergunta

I'm thinking of writing a simple custom .NET OpenVPN client.
I was wondering in what different ways would it be possible to get and display the output log of the underlying openvpn executable?

(Just for the information's sake - OpenVPN service is basically a wrapper for the main executable, created to simulate transparent background execution (e.g. like Linux daemon), as well as to bypass non-admin user issues. It is written in C. It picks up its start configuration params from the registry, as decribed on this page in the Running OpenVPN as a Windows Service section.)

BTW, I was examining the clients like Viscosity and HMA, they are both .NET clients, and both have this feature for displaying the openvpn output log. HMA runs openvpnserv.exe (that is the service), and keeps the log file. Viscosity has its own service wrapper, and I didn't spot the log file on the file system (which doesn't mean it's not there somewhere)... so I can't really tell what's going on in this case.

One obvious solution is to track original log file for appended lines, e.g. something like this, which seems to work. What would be my other options here, and should I at all consider anything else?

Foi útil?

Solução

Ok, alternative (and probably desirable) solution is to use OpenVPN Management Interface and its print log capability, simply by enabling it with one of the commands (depending on the desired effect):

log on     # turn real-time logging on
log all    # show cached log history
log on all # second + first
log 30     # show most recent 30 log-history lines
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top