0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

Ported OpenVPN 3 OMI to Windows

* Added build script buildomi.py

* Implemented logging using Win::LogUtil

* Still an issue with External PKI that is documented in
  omi/doc/omi.log
This commit is contained in:
James Yonan 2016-03-28 14:52:18 -06:00 committed by Lev Stipakov
parent d0c63d3150
commit 26e99b1a37
No known key found for this signature in database
GPG Key ID: 88670BE258B9C258

View File

@ -38,6 +38,7 @@
#include <openvpn/common/hostport.hpp> #include <openvpn/common/hostport.hpp>
#include <openvpn/common/options.hpp> #include <openvpn/common/options.hpp>
#include <openvpn/buffer/bufstr.hpp> #include <openvpn/buffer/bufstr.hpp>
#include <openvpn/time/timestr.hpp>
// include acceptors for different protocols // include acceptors for different protocols
#include <openvpn/acceptor/base.hpp> #include <openvpn/acceptor/base.hpp>
@ -46,6 +47,12 @@
#include <openvpn/acceptor/unix.hpp> #include <openvpn/acceptor/unix.hpp>
#endif #endif
#if defined(OPENVPN_PLATFORM_WIN)
#include <openvpn/win/logutil.hpp>
#else
#include <openvpn/common/redir.hpp>
#endif
namespace openvpn { namespace openvpn {
class OMICore : public Acceptor::ListenerBase class OMICore : public Acceptor::ListenerBase
{ {
@ -290,7 +297,20 @@ namespace openvpn {
send(buf_from_string(str)); send(buf_from_string(str));
} }
void log_line(const std::string& line) void log_full(const std::string& text) // logs to OMI buffer and log file
{
const time_t now = ::time(NULL);
const std::string textcrlf = string::unix2dos(text, true);
log_line(openvpn::to_string(now) + ",," + textcrlf);
#if defined(OPENVPN_PLATFORM_WIN)
if (log_handle.defined())
Win::LogUtil::log(log_handle(), date_time(now) + ' ' + textcrlf);
else
#endif
std::cout << date_time(now) << ' ' << text << std::flush;
}
void log_line(const std::string& line) // logs to OMI buffer only
{ {
if (!stop_called) if (!stop_called)
send(hist_log.notify(line)); send(hist_log.notify(line));
@ -588,7 +608,7 @@ namespace openvpn {
void log_setup(const std::string& log_fn, const bool append) void log_setup(const std::string& log_fn, const bool append)
{ {
#if defined(OPENVPN_PLATFORM_WIN) #if defined(OPENVPN_PLATFORM_WIN)
// fixme -- code for Windows log_handle = Win::LogUtil::create_file(log_fn, "", append);
#else #else
RedirectStd redir("", RedirectStd redir("",
log_fn, log_fn,
@ -855,6 +875,10 @@ namespace openvpn {
History hist_log {"log", 100}; History hist_log {"log", 100};
History hist_state {"state", 100}; History hist_state {"state", 100};
History hist_echo {"echo", 100}; History hist_echo {"echo", 100};
#if defined(OPENVPN_PLATFORM_WIN)
Win::ScopedHANDLE log_handle;
#endif
}; };
} }