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>
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>
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.
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>
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>
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>
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>
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>
* 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>
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>
* 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>
* 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.