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

611 Commits

Author SHA1 Message Date
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
James Yonan
90ece7de04
jsonhelper : for consistency, swap the order of title and default_value in to_uint_optional(). 2020-01-09 12:23:08 +02:00
James Yonan
3154ec0f92
jsonhelper : in get_bool_optional(), convert string "true" (case insensitive) to boolean true. 2020-01-09 12:23:08 +02:00
James Yonan
5c25bb7089
jsonhelper.hpp : added new methods parse_from_file(), cast_dict(), and get_array(). 2020-01-09 12:23:08 +02:00
James Yonan
76b5f880b5
jsonhelper : added get_bool_optional(). 2020-01-09 12:23:07 +02:00
James Yonan
042c0194ac
For jsoncpp usage, rename deprecated misspelled method name:
getFormatedErrorMessages -> getFormattedErrorMessages
2020-01-09 12:23:07 +02:00
James Yonan
ba18268dfc
In class json (jsonhelper.hpp):
Added new static method parse().

Modified to_uint_optional() to make 'title' the last
parameter.

Moved to_vector() method.
2020-01-09 12:23:07 +02:00
James Yonan
1e7e8210ab
Added new file openvpn/common/jsonhelper.hpp with convenience methods for dealing with Json::Value objects. 2020-01-09 12:23:07 +02:00
Lev Stipakov
e86b3bef38
endian64.hpp: Add MSVS version of int64 byte swap
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-09 12:23:06 +02:00
James Yonan
b9b4bb8c55
Endian: use more portable method to determine machine byte order
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:06 +02:00
Arne Schwabe
c8a2405722
Add Clang specific swap 64 bit builtin macro
This fixes build on Android NDK with clang/clang++

Neither the Android libc nor the libc++ used by Android by default
have the __bswap_constant_64 macro.

The more standard include of byteswap.h and bswap_64 exists only on
Linux and Android. Mac OS X defines no function in its includes that
does a byteswap. Therefore keep the compiler internal but choose
Clang's when compiling with Clang.
2020-01-09 12:23:06 +02:00
James Yonan
02d95918e4
Endian: added missing inline
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:06 +02:00
James Yonan
db7c5613f3
HTTP layer: added Websocket support
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:05 +02:00
James Yonan
341d983734
JsonClient/AppServer: full HTTP compression support
* gzip or lz4 supported for standard HTTP.

* lz4 support for websocket.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:23:05 +02:00
James Yonan
a9f2055d07 string: added starts_with_delim() function
Signed-off-by: James Yonan <james@openvpn.net>
2019-12-26 03:44:14 -07:00
David Sommerseth
81d6e5c3c1
Update version to indicate development base version
Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-14 18:41:25 +01:00
Arne Schwabe
f6aada9577 Tempfile.hpp is unix only, add error when including it on win32
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
Arne Schwabe
54fbe7604c Fix file modifcation time retrieval stat.hpp on macOS
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
James Yonan
32b984c0ff enum_dir: use a function template
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-10 14:08:09 -06:00
James Yonan
e05fc16b20 string::indent(): try to fix all the corner cases
1. Don't emit spaces if the input string is empty.
2. Don't emit spaces after the last newline in the input string.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-09 21:01:30 -06:00
James Yonan
4e1645ea80 RunContext: mark virtual Stop* async_stop() with override attribute
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-07 00:18:00 -06:00
James Yonan
f7845578f1 RunContext: check for halt in timer closure
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:57 -06:00
James Yonan
c3c8ab7f6b string: added additional detail to split() comment
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
95ce4f22c8 string: added to_delim() method then redefined first_line() method to use it
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
448218b1e1 string: added add_leading() method
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
e3b0bf4f5c MSF iterator: allow conversion from ordinary iterator and added exists() method
Also added better comments for MSF::find().

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
7496383002 write_binary_atomic: reduce the length of the temporary filename
Linux has a filename maximum of 255 chars, but we need to
be careful about the composition of the temporary filename
so that we don't exceed this limitation on the temporary,
even when the original is within the limit.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
4fa8348689 RunContext: ASIO SIGNAL message now shows signal name rather than number
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00