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

1957 Commits

Author SHA1 Message Date
James Yonan
fd1ed92b68
Make lambda functions mutable that benefit from using std::move() on closure vars
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:20 +02:00
James Yonan
35c0480180
AsioTimer: use expires_after() method when possible.
A common AsioTimer usage pattern is:

  expires_at(Time::now() + duration)

This is more succinctly and efficiently stated as:

  expires_after(duration).

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:20 +02:00
James Yonan
d3da69e35c
Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

This commit includes:

* Added ASIO=1 to many "go" scripts that require asio
* Renamed "asio::" to "openvpn_io::".

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:20 +02:00
James Yonan
cff607cae1
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:20 +02:00
James Yonan
658efb6232
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:19 +02:00
James Yonan
c747b20e2b
asio: deal with symbol renaming in latest github master
mutable_buffers_1 -> mutable_buffer
const_buffers_1 -> const_buffer
2020-01-09 12:23:19 +02:00
James Yonan
c0d93bbd5f
copyright : updated to 2016 2020-01-09 12:23:19 +02:00
James Yonan
4a45609b29
Updated OMI to support server-side usage. 2020-01-09 12:23:19 +02:00
James Yonan
061daa8e3c
OMI : Windows seems to lose >FATAL: notifications that are transmitted immediately before OMI socket close. Work around the issue by adding a 250ms delay between the last write to the socket and the close. 2020-01-09 12:23:19 +02:00
James Yonan
26e99b1a37
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
2020-01-09 12:23:18 +02:00
James Yonan
d0c63d3150
First working OMI wrapper for OpenVPN 3 client. Tested with OpenVPN Connect on Mac.
Could benefit from some minor modifications to
python client backend and tray app:

* Client backend and ovpn3 both implement connection timeout.
  Client backend should defer to the ovpn3 implementation.

* Client backend and ovpn3 both implement DNS server config
  and SystemConfiguration event sent to
  'Setup:/Network/Global/IPv4' for 'VPN up'.
  Client backend should defer to the ovpn3 implementation.

* Ensure that system state changes (sleep, wakeup, network
  roam, fast user switching, etc.) don't cause conflicts
  between client backend and ovpn3 core both trying to
  implement similar functionality.

* Tray app should render error detail in >FATAL: messages.
  Right now tray raises a Disconnected notification but
  loses any error detail.
2020-01-09 12:23:18 +02:00
James Yonan
e8a21acb25
Initial OMI (OpenVPN Management Interface) commit, still unfinished. 2020-01-09 12:23:18 +02:00
James Yonan
1d090e7e88
Use openvpn::strerror_str() instead of std::strerror().
std::strerror() doesn't claim to be thread-safe, so
add openvpn::strerror_str() which is thread-safe by
virtue of the fact that it backs to strerror_r().

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:18 +02:00
James Yonan
0368d32cb6
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:17 +02:00
James Yonan
6e51d02eff
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:17 +02:00
James Yonan
e6f67cedc7
copyright : updated to 2016 2020-01-09 12:23:17 +02:00
James Yonan
7dc71fa837
Added write_private() methods from core (no Windows implementation yet).
In httpcreds.hpp, use write_private() for creating creds
files rather than UMask.
2020-01-09 12:23:17 +02:00
James Yonan
0057bb7ec4
jsonhelper: allow NAME or TITLE parameters to be an array index
Also, break out json::fmt_name* methods into their own
source file.

NOTE: this code includes some SFINAE, so may need #ifdefs for
Visual Studio.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:16 +02:00
James Yonan
02b531e619
jsonhelper: extend polymorphism to allow string or numerical indices
Updated StringTempl to work with numeric types.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:16 +02:00
James Yonan
f02ea1f762
library: added BijectiveSetMapping and enhanced StringTempl::to_string()
BijectiveSetMapping is a one-to-many bijective mapping.

If K is the key and V is the value, you can:

1. add to the forward map in the form [ K : set(V) ]
2. delete K from the forward map

The BijectiveSetMapping automatically maintains the
reverse mapping where each element is the form:

  [ V: set(K) ]

Also enhanced StringTempl::to_string() with an SFINAE
variant that supports objects having a to_string() method.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:16 +02:00
James Yonan
730a57c39e
jsonhelper: allow NAME or TITLE parameters to be an array index
Also, break out json::fmt_name* methods into their own
source file.

NOTE: this code includes some SFINAE, so may need #ifdefs for
Visual Studio.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:16 +02:00
Arne Schwabe
ec7d4746b3
Update jsonhelper to current JSONcpp library
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-01-09 12:23:15 +02:00
James Yonan
e79add27a8
jsonhelper: C++ standard appears to indicate no need to do explicit std::move on return value
This edit also silences a warning in clang.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:15 +02:00
James Yonan
b0669ab4e3
jsonhelper: added dict_result() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:15 +02:00
James Yonan
6e242ee555
jsonhelper: added error() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:15 +02:00
James Yonan
0c61d0dfa8
jsonhelper: minor fix: typo in exception string
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:14 +02:00
James Yonan
201e0e68a2
jsonhelper: added cast() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:14 +02:00
James Yonan
9f3afbae91
Json: support parsing from ConstBuffer
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:14 +02:00
James Yonan
e13f1f3859
JSON: added #ifdef OPENVPN_JSON_INTERNAL around code requiring internal JSON lib
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:14 +02:00
James Yonan
d30c6f4e8f
jsonhelper: added get_string_ref() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:13 +02:00
James Yonan
121d647fe2
jsonhelper: added get_bool_tristate() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:13 +02:00
James Yonan
df1695dc74
jsonhelper: get_bool_optional: removed string interpretation
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:13 +02:00
James Yonan
580bbb9bf0
jsonhelper: allow NAME or TITLE parameters to be an array index
Also, break out json::fmt_name* methods into their own
source file.

NOTE: this code includes some SFINAE, so may need #ifdefs for
Visual Studio.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:13 +02:00
James Yonan
819cc56962
jsonhelper: minor changes
* Added simple parse() method that only requires
  JSON string to be parsed.

* Added get_string_from_array() method that doesn't
  require title parameter.

* Added cast_array() method that doesn't require
  title parameter.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:13 +02:00
James Yonan
550d308480
jsonhelper: extend polymorphism to allow string or numerical indices
Updated StringTempl to work with numeric types.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:12 +02:00
James Yonan
672e07f210
jsonhelper: trivial indentation change
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:12 +02:00
James Yonan
372eb97457
jsonhelper: Use new JSON library implementation.
Also:

* break up some long lines in source code

* added get_uint_optional_via_string() and
  get_uint64_optional_via_string()

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:12 +02:00
James Yonan
04c3aa9b0a
jsonhelper: added format() method outputting to Buffer.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:11 +02:00
James Yonan
407b83e529
jsonhelper: added get_array() method without title argument.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:11 +02:00
James Yonan
a01d34deaa
jsonhelper: exists() method should return false if argument is not a JSON object.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:11 +02:00
James Yonan
3d0d9de34e
jsonhelper.hpp misc changes
* use namespace json instead of class json so that other
  source files can also add stuff to namespace json

* make fmt_name() method public

* added get_string_from_array() method

* added get_(int|uint|uint64)_optional() methods

* added get_(uint|uint64)_via_string() methods

* added some title-free method variants such as get_dict()
  and cast_dict()

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:11 +02:00
James Yonan
cb6914e6a4
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:10 +02:00
James Yonan
b8f64a02b7
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:10 +02:00
James Yonan
6e33ef89c0
jsonhelper: major refactor
* Templatize name and title parameters.
* String construct the json_parse exceptions instead of
  using OPENVPN_THROW.
* Refactor to_x() methods to derive from get_x() methods
  instead of the other way around.
* Added get_uint64() method.
* Added cast_array() method.
* Added format() method.
2020-01-09 12:23:10 +02:00
James Yonan
bfb9833354
jsonhelper : added default_value parameter to get_bool_optional() 2020-01-09 12:23:10 +02:00
James Yonan
6e5b04fd01
jsonhelper : added parse_from_buffer() 2020-01-09 12:23:09 +02:00
James Yonan
760ae4a5f1
jsonhelper : added json::format_compact() methods for formatting JSON into a compact representation without extraneous whitespace. 2020-01-09 12:23:09 +02:00
James Yonan
ff804f93f0
copyright : updated to 2016 2020-01-09 12:23:09 +02:00
James Yonan
b850f4875c
jsonhelper : added json::get_string_optional() method. 2020-01-09 12:23:09 +02:00
James Yonan
8831925837
jsonhelper : added json::exists() method. 2020-01-09 12:23:08 +02:00