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

342 Commits

Author SHA1 Message Date
James Yonan
20cba09579 In runcontext.hpp, use "<< std::flush" instead
of std::cout.flush();
2015-11-24 19:22:17 -07:00
James Yonan
331827fd06 In SockOpt::Creds, added root_uid() method. 2015-11-20 19:02:37 -07:00
James Yonan
693909ae42 Restructured class Cleanup to no longer depend on
std::function.
2015-11-20 19:00:45 -07:00
James Yonan
59f0c72674 Added classes Stop and AsioStopScope for terminating a
nested asio::io_context.
2015-11-20 18:58:13 -07:00
James Yonan
34410f6721 In openvpn/common/hostport.hpp, added is_valid_port()
and validate_port() methods.
2015-11-10 23:07:43 -07:00
James Yonan
054946ca5f Minor mod to openvpn/common/abort.hpp for C++11. 2015-11-10 23:04:05 -07:00
James Yonan
2f40c52fbc Change to calls of Windows API methods:
* Where unicode/ansi versions of a method exist, always
  explicitly call one of unicode or ansi methods by
  appending a 'W' or 'A' to the end of the method name.
  Never omit the 'W' or 'A' because that will cause the
  default method to be used which may vary according to
  build flags.

* Prepend all Windows API method references with "::" to
  indicate that the method names should be resolved from
  the top-level namespace.
2015-11-09 14:56:08 -07:00
James Yonan
2c7bfc37ed Added new file openvpn/common/sleep.hpp with
portable sleep_milliseconds() function.
2015-11-05 16:11:49 -08:00
James Yonan
c859a46187 Added class Cleanup (openvpn/common/cleanup.hpp), a
general model for executing a std::function in the
destructor.
2015-11-02 20:10:46 -07:00
James Yonan
dcebf7b559 Added sort parameter (bool) to enum_dir() to sort results. 2015-10-30 16:41:18 -06:00
James Yonan
4b1379e919 In hexstr.hpp, extended dump_hex() to show both hex and ascii. 2015-10-30 16:39:38 -06:00
James Yonan
d4be16c109 Added string::is_printable() methods for char and unsigned char. 2015-10-30 16:38:41 -06:00
James Yonan
4c7f7af10d In process.hpp, added new system_cmd() variant that uses pipes
to communicate with subprocess and provides std::strings for
input/output/error.

Updated Command class with new execute() signature.

Added RedirectPipe (redir.hpp) to deal with handling
input/output/error pipes for a subprocess.
2015-10-28 22:40:15 -06:00
James Yonan
27061e01b1 In openvpn/common/signal.hpp, added SIGPIPE support. 2015-10-28 22:38:14 -06:00
James Yonan
0cb18b6084 Created new ActionListFactory abstraction, to allow client tun
implementations to provide custom ActionList handlers.
This can be used, for example, to forward tun configuration
commands requiring higher privileges to a remote daemon.
2015-10-27 18:34:13 -06:00
James Yonan
aa4f2773f3 Added openvpn/common/wstring.hpp for classes that deal
with wchar_t and std::wstring types.
2015-10-27 18:30:57 -06:00
James Yonan
5e1a706c67 Added string::remove_blanks() method. 2015-10-27 18:19:32 -06:00
James Yonan
5f6989465a Fixed recent regression in userpass.hpp where parse()
method was failing to identify auth-user-pass directive
when given without parameters.
2015-10-19 08:07:17 -07:00
James Yonan
a35ed0375f Removed write_private() as it's no longer used on this branch. 2015-10-18 15:21:25 -07:00
James Yonan
ee6882725b Added comment that class UMask is not thread-safe. 2015-10-18 15:07:17 -07:00
James Yonan
32b6912931 Added Windows named-pipe support to RemoteList,
Listen::List, Protocol, and AsioPolySock.
2015-10-16 21:00:51 -06:00
James Yonan
d0dcfe759c In file.hpp, added write_binary_list() method. 2015-10-15 23:37:00 -07:00
James Yonan
508d6858ac Ported runcontext.hpp to Windows. 2015-10-08 21:54:22 -06:00
James Yonan
b2769db93a In format.hpp, work around a Windows symbol conflict
by renaming template var OUT to OUTPUT.
2015-10-08 21:52:59 -06:00
James Yonan
0268d210dd Added Windows implementation for n_cores(). 2015-10-08 21:51:29 -06:00
James Yonan
c90eb0b74b Made n_cores() portable between Linux and Mac OS X and
moved it to new file openvpn/common/core.hpp
2015-10-08 00:30:35 -07:00
James Yonan
c26f8d7375 Make PThreadCondBase portable between Linux and Mac OS X. 2015-10-08 00:25:06 -07:00
James Yonan
6b92002fde Make peercreds() portable between Linux or Mac OS X. 2015-10-08 00:23:19 -07:00
James Yonan
97c967be57 In unicode.hpp, added Unicode::UTF8Iterator. 2015-10-01 17:34:13 -07:00
James Yonan
8b6b2015a0 Fixed issue where utf8_length() was not properly reducing
the length passed to isLegalUTF8() for characters near the
end of the string.
2015-10-01 16:35:45 -07:00
James Yonan
0710d1f327 Added string::is_empty() method that returns true if
passed string is empty or contains only space chars.
2015-10-01 16:33:19 -07:00
James Yonan
07bcab9ab3 Extend is_close_tag() in options.hpp to search for
wildcard close tag if tag string is empty.
2015-10-01 16:29:38 -07:00
James Yonan
2df4f44711 Added/changed printfmt() format specifiers:
* %r formats any argument regardless of type
     and single-quotes it.
* %R formats any argument regardless of type
     and double-quotes it.
2015-10-01 16:21:21 -07:00
James Yonan
f3e9dbde86 Added OPENVPN_FMT(...) macro. 2015-10-01 16:20:15 -07:00
James Yonan
e6d27bc57e In format.hpp, added specializations for bool. 2015-10-01 16:18:45 -07:00
James Yonan
96866ac7e1 format.hpp:
* Added static polymorphic sink for print formatting in
  print_formatted_detail::Output<T> where T can be
  std::string or std::ostringstream

* By default printfmt() uses:

  PrintFormatted<std::string> pf(fmt, 256);

* prune openvpn::to_string() methods prior to removal
  (obsoleted by C++11 std::to_string())
2015-09-25 11:39:12 -07:00
James Yonan
d0b570bd7e In userpass.hpp:
* Added new parse method that parses creds out
  of a file.

* Added dedicated exception creds_error.
2015-09-24 14:28:15 -07:00
James Yonan
5885b35731 In format.hpp:
(1) Create new versions of to_string() method:
    (a) for numeric types, dispatch to std::to_string()
    (b) for string, char, and nullptr_t types, handle directly
    (c) for other types, use std::ostringstream

(2) Create vararg methods prints, print, and printd
    for printing argument lists.

(3) Create method printfmt() with string formatting
    similar to sprintf but fully type-safe.
    usage: printfmt(<format_string>, args...)
    options:
      %s formats any argument regardless of type.
      %r formats any argument regardless of type and quotes it.
      %% formats '%'
2015-09-24 13:52:24 -07:00
James Yonan
6378339776 Changes to hash.hpp and users:
1. Hash code is now compatible with VS 2015, so
   HAVE_HASH_COMBINE can be removed.

2. Added OPENVPN_HASH_METHOD macro for defining std::hash<>
   classes.

3. Make Hash::combine() into a varargs method.
2015-09-24 13:43:38 -07:00
James Yonan
29e427241b In exception.hpp, optimize Exception() constructor for
string move.

Also added noexcept qualifier to most Exception methods.
2015-09-23 23:26:30 -07:00
James Yonan
415dc9067b In splitlines.hpp, rename S_OK to S_OKAY due to Windows symbol
conflict.
2015-09-23 23:11:55 -07:00
James Yonan
a9ed9d47f2 ovpn3 client API now supports adding user-defined peer-info
data to the OpenVPN handshake (peer-info is a client -> server
key/value list that is part of the OpenVPN protocol).  To
add peer-info key/value pairs, use ClientAPI::Config::peerInfo.

Incremented core OPENVPN_VERSION to "3.0.6".
2015-09-21 19:42:24 -07:00
James Yonan
ba91532554 In merge.hpp, detect multiline breakout attempt. 2015-09-18 21:25:40 -07:00
James Yonan
d3d45937dc Added write_private() method, for writing a string to a file
that is created with access bits limited to owner access.
2015-09-18 10:26:21 -07:00
James Yonan
9c2fa0a6e5 In namespace string::, added new methods:
* ends_with_newline()
* spaces()
* indent()
* is_empty()
2015-09-18 10:23:18 -07:00
James Yonan
a8e8881510 In splitlines.hpp, added a const line_ref() method. 2015-09-18 10:22:47 -07:00
James Yonan
8dcf7dc828 Asio async_wait() lambdas should always check error status. 2015-09-18 10:22:11 -07:00
James Yonan
48a9d237d7 In options.hpp, added detect_multiline_breakout() method as
a security check to ensure that untrusted content pasted into
multiline config file directives such as:

<cert>
. . .
</cert>

doesn't try to break out of the pseudo-XML block
by inserting its own </cert>.
2015-09-18 10:19:38 -07:00
James Yonan
ecfd16e432 In hostport.hpp, when validating host/port, include the bad
host/port string in the thrown exception by sanitizing it
with Unicode::utf8_printable().
2015-09-18 10:18:22 -07:00
James Yonan
50118b0444 Extended UserPass methods with new flags:
OPT_REQUIRED
  USERNAME_REQUIRED
  PASSWORD_REQUIRED
  TRY_FILE
2015-09-18 10:16:37 -07:00