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

794 Commits

Author SHA1 Message Date
James Yonan
17eb3bcd59 library : added async_sleep_milliseconds(), an interruptible
sleep function.
2016-05-27 22:55:20 -06:00
James Yonan
61b6646bd0 options/hexstr : refactored parse_hex_number() to allow
error detection without throwing an exception, and
extended get_num() method in Option and OptionList to
parse both decimal and hex strings, where hex strings
are prefixed with "0x".
2016-05-12 13:45:14 -06:00
James Yonan
a66058e94e client core : incremented version to 3.0.12 2016-05-10 22:44:45 -06:00
James Yonan
a2b11689e3 AsioBoundSocket : previously declared but did not define:
asio::detail::service_id<SocketService> SocketService::id;

This causes compile issues when compiling without
optimization.
2016-05-06 17:11:20 -06:00
James Yonan
458ffadc70 string : added reduce_spaces() method. 2016-05-05 00:34:33 -06:00
James Yonan
a2f31fbf75 Stop : immediately call newly-registered Stop::Scope handlers
if stop() method was already called before the Stop::Scope
handler was constructed.
2016-05-05 00:33:35 -06:00
James Yonan
8e370c16d3 runcontext : new features to support OMI requirements.
* Support log observers.

* Support asynchronous stop.

* More flexibility on choosing the RC base class of
  ServerThreadType and inherit virtually to allow
  for shared RC bases.
2016-05-05 00:31:43 -06:00
James Yonan
096a8a09fb PThreadBarrier : major refactor to use C++11
<condition_variable> header rather than pthreads directly.

Added asynchronous stop support.
2016-05-05 00:30:11 -06:00
James Yonan
67e12552cf Option : refactor get_num() to provide variants with and
without a default value.  When throwing errors, cite the
index of the parameter in addition to its name.
2016-05-05 00:29:06 -06:00
James Yonan
62645b9563 daemon : in log_setup(), added stdin_to_dev_null and
combine_out_err flags.
2016-05-05 00:28:24 -06:00
James Yonan
ab2645129f daemon: getpid() should be ::getpid(). 2016-05-05 00:27:53 -06:00
James Yonan
c6a78ee27b core : incremented OPENVPN_VERSION to 3.0.11. 2016-04-14 12:30:23 -06:00
James Yonan
dbaf26bbc9 client : support push-peer-info directive.
If either "push-peer-info" or "setenv PUSH_PEER_INFO"
directives are specified, client will push "setenv UV_x"
directives to the server via peer info data.
2016-04-14 00:30:42 -06:00
James Yonan
f59b96d0b2 hexstr : added render_hex_number() method for unsigned char. 2016-03-30 00:08:51 -06:00
James Yonan
e20a62c3c9 string : added force_eol flag (default=false) to unix2dos(). 2016-03-28 14:44:14 -06:00
James Yonan
211af3a91b string : rename methods for consistency with in-place/copy
variants of other string methods:

* rename add_trailing() -> add_trailing_copy()
* rename add_trailing_in_place() -> add_trailing()
2016-03-28 09:42:13 -06:00
James Yonan
e135add60e options : refactored get_num() so that it can be called on
either an Option or OptionList.
2016-03-28 00:02:58 -06:00
James Yonan
6ab7feff15 Make Option::err_ref() public, as it's useful when formatting
error messages that refer to a particular option.
2016-03-28 00:01:23 -06:00
James Yonan
2e06d3a367 Option : exception-proof Option::printable_directive() 2016-03-28 00:00:25 -06:00
James Yonan
5b35f09ff2 platform_string() : added app_version parameter. 2016-03-27 23:57:36 -06:00
James Yonan
8a90f0bd79 string:
* Added ends_with() method to test for trailing char.

* Added add_trailing_crlf() methods.
2016-03-27 23:49:38 -06:00
James Yonan
59c6f3d43a Added string::is_alpha() method. 2016-03-19 01:50:09 -06:00
James Yonan
ea935109b9 SplitLines: added default values for max_line_len and trim. 2016-03-19 01:48:34 -06:00
James Yonan
63f45f0dbc process: added move-aware Command(Argv) constructor. 2016-03-19 01:47:18 -06:00
James Yonan
55011e4a9d Added ActionList::to_string() method. 2016-03-19 01:46:25 -06:00
James Yonan
1a9ad56946 RedirectStd : in constructor, allow in_fn to be empty to
not redirect stdin.
2016-03-15 15:07:22 -06:00
James Yonan
6d59eea0fb Added optional title string to platform_string() method. 2016-03-15 15:06:08 -06:00
James Yonan
ec879a1a1d Added OptionList::parse_option_from_line() method. 2016-03-15 15:04:18 -06:00
James Yonan
c01506670f asiopolysock : added is_open() method. 2016-03-15 15:03:46 -06:00
James Yonan
7d4bebca25 Added string::is_ctrl() and string::contains_non_space_ctrl()
methods.
2016-03-14 17:14:24 -06:00
James Yonan
f950741131 Added read_stdin() method. 2016-03-14 17:13:19 -06:00
James Yonan
a7ba46e6f7 In PThreadBarrier, allow late-setting of limit after
construction by using using new set_limit() method.
2016-03-14 00:12:51 -06:00
James Yonan
1e907bc0e6 In file_exists(), if filename is the empty string,
return false before calling stat().
2016-03-08 12:59:09 -07:00
James Yonan
01a4dba328 Added OptionList::parse_from_argv_static() method for parsing
argv-style command-line.
2016-03-02 00:53:01 -07:00
James Yonan
ebf6713c77 Incremented OpenVPN core version to 3.0.10. 2016-03-02 00:31:18 -07:00
James Yonan
4d42ff8b0e Added wstring::pack_string_vector() method.
Also added forgotten "inline" qualifiers to
all wstring.hpp methods.
2016-02-24 23:39:41 -07:00
James Yonan
13b2945d8c Added string::join() method. 2016-02-24 23:38:55 -07:00
James Yonan
c97503c4f8 Incremented ovpn3 client core version to 3.0.9. 2016-02-22 14:36:09 -07:00
James Yonan
c05cbaf46a Fixed bug in base64 encode when std::string containing UTF-8
chars is passed to this template method:

    template <typename V>
    std::string encode(const V& data) const

The problem is that references to data[] were failing to
cast the value to unsigned char, so UTF-8 chars >= 0x80
were being interpreted as negative values.
2016-02-22 14:26:07 -07:00
James Yonan
7a17151992 Added dump_hex(const std::string&) method. 2016-02-22 14:22:14 -07:00
James Yonan
53453bd7af Incremented client API version to 3.0.8. 2016-02-05 12:20:56 -07:00
James Yonan
4a00d11a4a OptionList::extend(other, name) now returns the number
of elements processed.
2016-02-05 12:11:08 -07:00
James Yonan
93913a3479 class Option -- provide a vararg constructor. 2016-02-05 12:09:37 -07:00
James Yonan
984ec7a4c9 Incremented core version to 3.0.7. 2016-01-28 21:45:35 -07:00
James Yonan
5c85473243 Some linux platforms don't define SO_REUSEPORT, so don't
compile SockOpt::reuseport() in this case.  Since only
servers actually call it, the client should compile fine
without it.
2016-01-23 10:28:35 -08:00
James Yonan
8f63eb883c In ActionList, added add(Action* action) method. 2015-12-28 13:22:15 -07:00
James Yonan
7728ab5bc3 Extended Unicode::is_valid_utf8() to check additional string
attributes such as length and presence of control and/or
space chars.
2015-12-22 19:10:53 -07:00
James Yonan
92d4591507 Because of Android NDK issues with std::to_string, change
printfmt() to use PrintFormatted<std::ostringstream> instead
of PrintFormatted<std::string> as its underlying formatter.
2015-12-16 13:34:11 -07:00
James Yonan
42424a3b47 Apparently Android NDK doesn't support std::to_string (WTF?),
so work around it.

http://stackoverflow.com/questions/22774009/android-ndk-stdto-string-support
2015-12-16 13:20:33 -07:00
James Yonan
306f9f1951 Moved classes Argv and ArgvWrapper out of process.hpp
and into a new source file openvpn/common/argv.hpp
2015-11-25 19:41:37 -07:00
James Yonan
4ecf9594e8 ovpn3 -- support multiple compilation units by managing the
definition of mutable globals.

For all but the first compilation unit, define:

  #define OPENVPN_EXTERN extern

This will cause mutable globals to be referenced as
extern.
2015-11-25 12:11:36 -07:00
James Yonan
134ba710f2 ovpn3 core globals cleanup:
1. move all const globals into anonymous namespace
2. make sure that all non-class functions are inline
3. refactor class static data members
2015-11-25 11:34:41 -07:00
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
James Yonan
d38101d5c2 In buflist.hpp:
* Added explicit flag to turn on size=1 optimization.
* Added join() method without arguments.
* Added copy() method.
2015-09-18 10:14:03 -07:00
James Yonan
685c7601e2 In common/file.hpp, added read_binary_linear() to read a
file without seeking to determine its length.
2015-09-08 22:16:46 -07:00
James Yonan
1b913b16f1 Added PersistentFile::stat() method to return
struct stat of active file.
2015-09-08 22:14:52 -07:00
James Yonan
b4dea33463 Renamed PersistentOutputFile to PersistentFile, since class
will soon have input methods as well.
2015-09-08 11:37:55 -07:00
James Yonan
494cf8bd2d Added string::is_digit() method. 2015-09-08 05:57:51 -07:00
James Yonan
40bc68bb74 Added SockOpt::Creds::root_or_self_uid() method to test if
local socket client is root or has our own UID.
2015-09-08 05:55:08 -07:00
James Yonan
1c67469856 In AsioPolySock::Base, add boolean is_local() method to
test if socket is a unix domain socket.
2015-09-08 05:52:56 -07:00
James Yonan
af66ff434b In redir.hpp, add "::" prefix to libc methods. 2015-09-07 06:02:50 -07:00
James Yonan
03057dee0d In OptionList, touched_ private bool is now mutable AND
volatile.  The volatile qualifier is added because
OptionList const methods are often called from multiple
threads concurrently.
2015-09-06 16:42:39 -07:00
James Yonan
865176c6c6 Added HostList::Host, List, and Iterator for managing lists
of HOST::PORT pairs.
2015-09-02 12:06:24 -07:00
James Yonan
c4761ebb85 Added AutoReset class template to automatically reset
a target object when AutoReset goes out of scope.
2015-09-02 12:04:04 -07:00
James Yonan
347427b81c In string.hpp:
* Added string::trim_crlf_copy().

* Added a simplified string::split() method.
2015-09-02 03:10:12 -07:00
James Yonan
a14ca71a5f Changed all ::write() calls to use write_retry() instead.
write_retry() is a thin wrapper around ::write() that can
potentially call ::write() multiple times to fully write
the buffer.
2015-09-02 03:08:31 -07:00
James Yonan
22b9fb347f In split_host_port(), allow caller to specify a default
port and handle cases where IP address or host is bracketed,
such as "[IP]:PORT".
2015-09-02 03:06:32 -07:00
James Yonan
8d78caf733 In getpw.hpp, fixed issue where OPENVPN_PLATFORM_WIN was being used
before the source file that defines it was being included.
2015-09-02 03:04:19 -07:00
James Yonan
7826daa516 In asiopolysock.hpp and sockopt.hpp, added socket methods for
setting FD_CLOEXEC and getting the remote IP address and port.
2015-09-02 03:02:22 -07:00
James Yonan
061706ebd9 In process.hpp, use vfork() instead of fork() when possible,
such as when execve() can be executed immediately after fork()
on the child side.
2015-08-24 21:08:35 -07:00
James Yonan
00aa2f05d5 In hexstr.hpp, added parse_hex_number() method that accepts
a std::string argument.
2015-08-24 21:07:24 -07:00
James Yonan
e2e55ba6ec Forgot to specify "inline" for to_string() method
in common/format.hpp.
2015-08-24 21:06:23 -07:00
James Yonan
63233836f8 Added openvpn/common/glob.hpp, a wrapper for the unix
glob() function used for filename wildcard expansion.
2015-08-20 12:46:34 -07:00
James Yonan
50868f3e37 Fixed minor bug in rc.hpp where the rhs argument of a
move-assignment method was mistakenly declared as const.
2015-08-20 12:43:58 -07:00
James Yonan
d9f807ba50 Added close() method to AsioPolySock::Base and derived classes. 2015-07-21 05:36:15 -07:00
James Yonan
ba44de2911 In SetUserGroup (on Linux), retain core dumpability after
setgid/setuid.
2015-07-16 18:51:20 -07:00
James Yonan
3a0bd15039 runcontext.hpp changes:
* added ServerThreadWeakBase, an alternative version of
  ServerThreadBase that supports weak pointers,

* added set_exit_socket() method for triggering a mutual
  exit between two partner processes if either process
  closes their end of the socket,

* added a prefix string to distinguish between multiple
  RunContext objects, and

* refactored cancel() method to better leverage on asio::post.
2015-07-04 16:36:15 -06:00
James Yonan
d014f2ebb6 Added class PersistentOutputFile, an object that holds
a file descriptor to a writable file, and keeps the
file open over multiple write cycles to the file.
Useful for updating a file after privilege downgrade.
2015-07-04 16:19:58 -06:00
James Yonan
014c53d005 Added UMask helper class to manage umask using RAII pattern. 2015-07-04 16:17:08 -06:00
James Yonan
570a1642ad Added SockOpt::peercreds(), to get credentials of process on
other end of unix domain socket using SO_PEERCRED socket op.
2015-07-04 16:14:33 -06:00
James Yonan
23cfbd2c2a Added Asio polymorphic socket object for handling TCP
and unix domain sockets.
2015-07-04 16:12:40 -06:00
James Yonan
006bf0d838 Added class AsioContextStore, a container for asio::io_context
objects from different threads.
2015-07-04 16:09:39 -06:00
James Yonan
56c07b1152 In class SetUserGroup, added invalidate() method.
Also added leading :: to some global functions.
2015-07-04 15:58:47 -06:00
James Yonan
35c920626b Added convenience method next() in class SplitLines. 2015-07-04 15:57:31 -06:00
James Yonan
833d731894 In redir.hpp, added new RedirectTemp constructor with
separate tempfiles for stdout and stderr.
2015-07-04 15:56:20 -06:00
James Yonan
e36d7b2bf0 Reordered classes in rc.hpp so that RCPtr and RCWeakPtr
can have Ptr and WPtr typedefs.
2015-07-04 15:54:00 -06:00
James Yonan
16bde170c0 Don't use deprecated asio features. 2015-06-30 00:05:37 -06:00
James Yonan
9e2b2f72aa In rc.hpp, don't include notify release code unless
OPENVPN_RC_NOTIFY is defined.
2015-06-27 16:26:17 -06:00
James Yonan
1acc33feaf Obsoleted asiodispatch in favor of C++11 lambdas. 2015-06-25 13:59:12 -06:00
James Yonan
9c9addf75f Minor formatting change to asiodispatch.hpp. 2015-06-25 01:32:10 -06:00
James Yonan
4add0c9bdc Added a high-performance, general-purpose functor type
with move-only semantics.
2015-06-24 16:25:30 -06:00
James Yonan
66f79ae817 Increased core version to 3.0.5 after revamp of replay
detection code.
2015-06-18 13:45:20 -06:00
James Yonan
d2ddc82bca Move errinfo() method out of exception.hpp and into its own
file, so that exception.hpp doesn't have to depend on Asio
headers.
2015-06-16 22:39:28 -06:00
James Yonan
a6c611651c Added string::is_multiline() method. 2015-06-11 12:14:24 -06:00
James Yonan
c4a9cea3e1 Updated Windows client for VS 2015. 2015-06-09 11:21:41 -06:00
James Yonan
ee381e73f1 Incremented core version to 3.0.4. 2015-06-07 00:53:26 -06:00
James Yonan
c6a21c827b Boost dependency elimination -- final removal of Boost
dependency.  Asio is now included as a standalone,
header-only dependency.
2015-06-06 10:59:18 -06:00
James Yonan
61972d2d40 Boost dependency elimination -- removed dependency on
boost::intrusive_ptr.
2015-06-05 00:16:07 -06:00
James Yonan
6cd32888fe Boost dependency elimination -- removed include of
<boost/detail/endian.hpp>
2015-06-04 22:15:03 -06:00
James Yonan
b28fe08e09 Boost dependency elimination -- removed references to
<boost/functional/hash.hpp> in favor of std::hash.
2015-06-04 21:31:01 -06:00
James Yonan
88518335c4 Boost dependency elimination -- change boost::algorithm
usage (for string algorithms) to use methods of our own
implementation in openvpn/common/string.hpp.
2015-06-04 19:22:59 -06:00
James Yonan
ba957e45cc In class RCWeak, added release notification callables. 2015-06-04 13:55:37 -06:00
James Yonan
597c2837f4 In class Option, change storage class of "bool touched_" to
mutable so we can set it without having to resort to const_cast.
2015-06-03 23:50:34 -06:00
James Yonan
da5927761c In split.hpp, use std::move where possible. 2015-06-03 23:48:36 -06:00
James Yonan
87a2a684ce Allow callers of split_host_port() to get the actual
integer port number.
2015-06-03 23:46:11 -06:00
James Yonan
94260d47c2 In rc.hpp, add debugging mode enabled by OPENVPN_RC_DEBUG that
will log info about objects being managed.
2015-06-01 23:35:03 -06:00
James Yonan
803b91724b In asiodispatch.hpp, added class AsioDispatchResolveArg. 2015-06-01 23:31:36 -06:00
James Yonan
bceb5be362 Add noexcept to some methods in process.hpp and redir.hpp
that need to run in an async-signal context, i.e. between
fork on the child side, and execve.
2015-05-27 13:54:10 -06:00
James Yonan
16bb7df1d2 Added support for weak pointers to rc.hpp. 2015-05-26 22:45:24 -06:00
James Yonan
adb617c40a Refactored daemon.hpp and process.hpp, adding a more
general-purpose stdin/stdout/stderr redirection
class.
2015-05-26 15:22:22 -06:00
James Yonan
be2922de39 Refactored methods for parsing/validating hosts/ports
into openvpn/common/hostport.hpp
2015-05-19 15:01:53 -06:00
James Yonan
e609e318ca Renamed openvpn/common/port.hpp -> openvpn/common/hostport.hpp 2015-05-19 13:33:29 -06:00
James Yonan
b75c780cab Renamed boost::intrusive_ptr<T> usage to RCPtr<T>. 2015-05-17 21:26:53 -06:00
James Yonan
35ac9f6229 Renamed types.hpp to size.hpp since it now only defines
size_t and ssize_t.
2015-05-17 13:27:34 -06:00
James Yonan
e494846f7d Moved count_t to its own header file. 2015-05-17 13:17:24 -06:00
James Yonan
5d1bc1c952 Moved array_size() function to its own header file. 2015-05-17 12:57:23 -06:00
James Yonan
fe6fcefa61 C++11 : rename NULL to nullptr 2015-05-17 02:53:37 -06:00
James Yonan
68b8f12b25 Refactored ScopedPtr usage to std::unique_ptr.
Removed ScopedPtr.
2015-05-17 01:41:16 -06:00
James Yonan
fd6892f8fa Added AsioBoundSocket -- an Asio TCP socket that can be configured
so that open() method always prebinds the socket to a given local
address.  Useful for TCP clients.
2015-05-15 13:33:56 -06:00
James Yonan
53e6af884a In OptionList, added get_optional_relaxed() and
get_default_relaxed() methods.
2015-05-13 21:55:32 -06:00
James Yonan
970a41757d Modified OPENVPN_OSTREAM() macro to not require data
type to be convertible to std::string.
2015-05-10 20:05:00 -06:00
James Yonan
3bcf8743c1 More conversions of threads/mutexes from boost to C++11 std.
As part of this work, removed openvpn/common/thread.hpp
2015-05-10 20:04:22 -06:00
James Yonan
7a6053f4b5 class RC: redefined thread_safe_refcount in a C++11 way. 2015-05-10 15:33:06 -06:00
James Yonan
e7b3af3e01 class Base64: added encode() method that accepts a raw unsigned
char * buffer.
2015-05-10 15:30:30 -06:00
James Yonan
6baf23462f Added render_hex_sep() method that allows a separator between
each byte.
2015-05-01 13:41:25 -06:00
James Yonan
d441693725 Added a second SetUserGroup constructor that accepts std::string
arguments instead of const char *.  Made both constructors
explicit.
2015-04-30 10:34:07 -06:00
James Yonan
36576a26c5 Break up existing daemonize() method into two methods:
1. log_setup -- redirect stdin/stdout/stderr
2. daemonize -- actually call daemon()

For compatibility, the old daemonize() method is still
available and is now internally composed using the new
methods.
2015-04-30 10:29:51 -06:00
James Yonan
6b8d51e5d9 Added event_loop_wait_barrier(). 2015-04-25 10:09:08 -06:00
James Yonan
46498b6bbf Refactored RunContext to eliminate possibility of race between
set_thread and set_server.
2015-04-25 10:03:33 -06:00
James Yonan
709486cd1a Added some extra logging to RunContext::do_cancel() to show
number of threads we called thread_safe_stop() on compared
to the total number of threads.
2015-04-24 01:26:42 -06:00
James Yonan
c7bc3aff22 Don't use #include <cassert>, instead throw Exception()
instead of assert().
2015-04-24 01:24:48 -06:00
James Yonan
0fde33173a C++11 update: mass replace of boost::uint/int to std::uint/int. 2015-04-23 17:55:07 -06:00
James Yonan
a51c0bf0bf Mostly complete transition from boost::thread to std::thread. 2015-04-23 17:07:56 -06:00
James Yonan
89cf6bb369 Changed BOOST_ASSERT usage to assert() (#include <cassert>). 2015-04-23 15:42:12 -06:00
James Yonan
36550cd35e Update to C++11 noncopyable semantics.
Instead of inheriting from boost::noncopyable,
use the C++11 delete qualifier:

    Class(const Class&) = delete;
    Class& operator=(const Class&) = delete;
2015-04-23 15:10:43 -06:00
James Yonan
f12c2ab7eb C++11 update -- in rc.hpp, change boost::detail::atomic_count
to std::atomic<long>.
2015-04-23 14:37:28 -06:00
James Yonan
9d9c51d6f4 C++11 update -- converted boost::unordered_map usage to
std::unordered_map.
2015-04-23 14:08:54 -06:00
James Yonan
4b02f237eb minor C++11 update: Changed BOOST_STATIC_ASSERT to static_assert. 2015-04-23 13:03:09 -06:00
James Yonan
069de90ffd minor C++11 updates:
* rename BOOST_NOEXCEPT to noexcept

* verify that certain classes are noexcept move constructable
  including Option, Buffer, BufferAllocated, RunContext::Thread
2015-04-23 12:49:25 -06:00
James Yonan
95e11e9172 Added openvpn/common/stat.hpp with file_exists() method. 2015-04-22 17:53:12 -06:00
James Yonan
b27ce6ad93 New string methods:
string::unix2dos()         -- convert \n to \r\n
string::split_host_port()  -- split host:port
2015-04-22 01:51:57 -06:00
James Yonan
d6fa2307b1 Use a switch in string::is_space(). 2015-04-22 01:51:07 -06:00
James Yonan
664b276716 render_hex() methods now take an optional caps argument to
control whether hex chars a-f are rendered as lowercase or
uppercase.

Renamed the template form of render_hex() to render_hex_generic(),
to avoid ambiguity from new caps parameter.
2015-04-21 00:42:15 -06:00
James Yonan
1e54bba2bc Added ServerThreadBase to runcontext.hpp. 2015-04-19 11:20:47 -06:00
James Yonan
7b4d98d1eb Added missing include to asiodispatch.hpp. 2015-04-15 22:18:32 -06:00
James Yonan
d1bd2d8d3c Added operator[] to ScopedPtr. 2015-04-12 10:52:59 -06:00
James Yonan
6f35bbd9d1 Extend daemonize() to do initial log rotate. 2015-04-09 21:45:19 -06:00
James Yonan
f2d03f292a Added string::replace_spaces method. 2015-04-09 15:22:38 -06:00
James Yonan
a206d08820 Added OptionList::get_optional_noexcept method. 2015-04-09 15:21:56 -06:00
James Yonan
1d6096609b Added additional parse_user_pass() convenience method. 2015-03-27 01:20:30 -06:00
James Yonan
688588bd12 Added sockopt.hpp with common setsockopt functions
(reuseport, reuseaddr, tcp_nodelay).
2015-03-19 14:04:31 -06:00
James Yonan
f683eca1d7 Added SignalBlockerDefault to handle common usage case. 2015-03-19 13:58:31 -06:00
James Yonan
987867082c Use C++11 std::thread (instead of boost::thread) if USE_STD_THREAD
if defined.
2015-03-19 13:56:38 -06:00
James Yonan
d1072035b3 Added openvpn/common/inotify.hpp.
Created initial method INotify::mask_to_string() to convert
an inotify mask to a human-readable string for debugging.
2015-02-10 15:58:58 -07:00
James Yonan
c8ffeea283 Added string::len_without_trailing_nulls method. 2015-02-10 15:57:42 -07:00
James Yonan
26b792436a Added ScopedFD::reset() method. 2015-02-10 15:57:09 -07:00
James Yonan
58031408d7 ScopedFD::close() should not be virtual. 2015-02-10 15:56:49 -07:00
James Yonan
01a381ef44 Added nondigit_term bool to parse_number() to allow parsing
of numbers that are terminated by non-number chars.  Previously
only '\0' could terminate a number.
2015-02-10 15:55:32 -07:00
James Yonan
2226a34850 In asiodispatch.hpp, added dispatcher for asio async_read
without argument: asio_dispatch_read_noarg().
2015-02-10 15:54:34 -07:00
James Yonan
90d98c8fac class OptionList now inherits from RCCopyable. 2015-02-03 17:34:13 -07:00
James Yonan
d5f249b3a4 Added class RunContext for managing threads in a
multi-threaded server.
2015-02-01 01:48:18 -07:00
James Yonan
169612f842 Add virtual void post_close() method to ScopedFD so derived
classes can do post-close actions.
2015-01-24 20:07:36 -07:00
James Yonan
79b9deb2bc Added SIGUSR1/SIGUSR2 to class ASIOSignals.
Also added register_signals_all() method.
2015-01-16 01:52:59 -07:00
James Yonan
69d0a9cefb Added SetUserGroup class for downgrading UID/GID. 2015-01-14 23:50:40 -07:00
James Yonan
fbfc84f460 Refactored PThreadCond and added PThreadBarrier for cases
where all threads need to reach a known point before
executing some action.
2015-01-14 23:17:20 -07:00
James Yonan
8d61382731 Core version number updated to 3.0.3. 2015-01-14 12:12:34 -07:00
James Yonan
915d0220a4 Added methods for daemonization and redirecting stdout/stderr
to a log file.
2015-01-13 23:18:57 -07:00
James Yonan
e0910bf6c4 Added PolarSSL AuthCert support (server-side only). 2015-01-12 23:20:23 -07:00
James Yonan
e817a9dc0b Added dump_hex methods. 2015-01-12 23:16:51 -07:00
James Yonan
9004e8cbea Added PThreadCond, a wrapper for pthread conditions. 2015-01-12 18:39:32 -07:00
James Yonan
58de6a371d Added class OptionList convenience method get_num()
with range checking.
2015-01-12 18:35:53 -07:00
James Yonan
9965704558 Added write_string() method to write a std::string to a file. 2015-01-12 18:34:10 -07:00
James Yonan
2f65d5b550 Added enum_dir() function to return filenames in a directory
as a vector of strings.
2015-01-08 15:18:55 -07:00
James Yonan
93ced6f8d9 Added string::root() function to return the
non-extension part of the filename.
2015-01-08 15:16:51 -07:00
James Yonan
d51c6c6dc4 Added render_hex_number() function to hexstr.hpp. 2015-01-08 15:16:11 -07:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
47236d5ab5 Updated OPENVPN_VERSION to "3.0.2". 2015-01-05 19:25:18 -07:00
James Yonan
0acb038808 Added class OptionList convenience methods get_default()
and get_num().

Also, get_optional() should return a std::string, not a
const std::string.
2014-12-29 21:54:23 -07:00
James Yonan
464690aa6b Added class ServerPushList for keeping track of
push "..." directives on the server.
2014-12-29 21:51:08 -07:00
James Yonan
1789443603 Updated core version to 3.0.1. 2014-12-21 11:03:09 -07:00
James Yonan
ea29858135 Added Option::get_default method. 2014-12-13 21:20:29 -07:00
James Yonan
81a7f2ad75 In asiodispatch.hpp, added dispatcher for asio
async_accept with argument.
2014-12-13 21:19:18 -07:00
James Yonan
f5ff65562e OptionList, Option:
* Make use of C++11 move semantics for optimization, especially
  where std::vector<Option> is pushed onto OptionList.

* Fixed bug in Option::render() where arguments would be
  printed without any delimiter if RENDER_BRACKET flag was
  absent.

* Added parse_from_peer_info() method, for parsing peer info
  string received from client.
2014-10-30 10:36:33 -06:00
James Yonan
758ac9daa0 Templatized UTF-8 methods such as Unicode::utf8_printable to
work on arbitrary string types (such as upcoming SafeString).
2014-10-30 10:18:30 -06:00
James Yonan
43f0a6a636 Added a more human-readable render_hex method: render_hex_pretty. 2014-10-25 22:25:11 -06:00
James Yonan
0c91391bae Added C++11 array_size method that is constexpr so it can be used
for compile-time asserts.

Use C++11 static_assert and array_size to verify size consistency
of tables in openvpn/error/error.hpp.
2014-10-23 13:44:52 -06:00
James Yonan
5826910bbe Refactored server-side client instance object (ServerProto::Session)
to use Link abstraction (openvpn/common/link.hpp) to link with
transport layer (and other layers such as routing and management
as development progresses).
2014-08-19 15:41:59 -06:00
James Yonan
1531189578 class BackRef is no longer used. Move it to unused directory. 2014-08-19 09:20:39 -06:00
James Yonan
ea406b83c8 Added flag OPENVPN_RC_USERDEF to allow for debug implementations
of intrusive_ptr_add_ref and intrusive_ptr_release.
2014-08-19 00:57:38 -06:00
James Yonan
170fc59508 Refer to abort() as std::abort(). 2014-08-18 02:55:30 -06:00
James Yonan
516cd89a76 Added class SignalBlocker for selective blocking of posix signals. 2014-08-17 22:35:51 -06:00
James Yonan
4e39a533e9 Added new constant-time memory comparison function crypto::memneq
to replace memcmp_secure.  crypto::memneq benefits from insights
gained during the development of crypto_memneq for the Linux kernel.
2014-08-17 22:09:12 -06:00
James Yonan
6e5e84d2d6 Added new function hash_combine_data. 2014-08-15 22:19:17 -06:00
James Yonan
03d74ed507 Annotate RC and RCCopyable methods with BOOST_NOEXCEPT
to play well with std::function small object optimization.
2014-08-15 22:05:25 -06:00
James Yonan
08fff1b640 For class String (RC-inheriting version of std::string), forgot
to make the inheritance of RC<thread_unsafe_refcount> public.
2014-08-14 11:24:07 -06:00
James Yonan
aeba511846 Added parse_port function. 2014-08-14 11:22:33 -06:00
James Yonan
03dd9aa766 Added write_binary method to file.hpp. 2014-08-11 18:02:21 -06:00
James Yonan
b3245b4590 Simplified class BackRef and added test code. 2014-08-10 20:59:21 -06:00
James Yonan
4b5cbc4cc6 Added AsioDispatchComposedConnect for dispatch/callback
to an Asio ComposedConnectHandler.
2014-08-10 17:17:11 -06:00
James Yonan
564dcdc2cf Added C++11 move construction/assignment to CF::Wrap,
BufferAllocatedType, ScopedPtr, and ScopedFD.
2014-08-10 16:53:39 -06:00
James Yonan
2c6d972ad6 Added AGPL copyright/licensing language. 2014-07-20 21:22:06 -06:00
James Yonan
820b0720ff Core: Fixed issue in base64.hpp with typo in expression that
terminates loop through char array.

This is functionally a no-op because the
(*p == equal || is_base64_char(*p)) term will effectively
terminate the loop when *p != '\0' because is_base64_char(0)
returns 0.
2014-07-07 14:46:44 -06:00
James Yonan
5c009430bb New implementation of tunPersist for Mac OS X based on FailsafeBlock
strategy, where the default route and DNS client are redirected to
localhost during pause/reconnect.
2014-03-30 23:21:28 -06:00
James Yonan
40a1842502 Implemented non-echoed console prompt for password in cli wrapper
(Unix platforms only).
2014-03-28 18:53:15 -06:00
James Yonan
91f82f1276 cli wrapper now handles SIGUSR1/SIGUSR2:
SIGUSR1: print stats
SIGUSR2: toggle pause/resume state
2014-03-24 16:53:19 -06:00
James Yonan
c1cf0d7375 In ActionList::execute(), catch exceptions and log them. 2014-03-06 00:27:41 -07:00
James Yonan
9e35e41fb4 Added ActionThread class to allow Action objects to be
executed asynchronously in a worker thread.

Needed to make some changes to logthread as well
to allow log context to be made available to
the worker thread.
2014-03-06 00:27:41 -07:00
James Yonan
074dbafa27 Ported minicrypto lib to OS X for PolarSSL optimization.
These scripts

  scripts/mac/build-minicrypto
  scripts/mac/build-polarssl

will now build PolarSSL (on OSX) with libminicrypto linkage.
Currently, only SHA1/256/512 implementations from OpenSSL are
built in libminicrypto.  We leave the current PolarSSL AES
implementation as-is since it now implements AES-NI.

Also added portable openssl/build-openssl script.
2014-03-04 17:42:00 -07:00
James Yonan
6900658a39 Fixed issue where OPENVPN_SIMPLE_EXCEPTION_INHERIT
instantiation was failing due to lack of a default constructor.
2014-02-27 21:21:54 -07:00
James Yonan
28bf9b2a15 Added full support for OpenVPN 3 on Mac OS X (10.6 and higher)
including DNS and IPv6 support.
2014-02-27 18:34:17 -07:00
James Yonan
33f6153f34 Added ScopedPtr<T>::ref() method. 2014-02-20 17:10:57 -07:00
James Yonan
e8be2d6956 Added operator()() convenience method to ScopedPtr to return
raw pointer.
2014-02-16 00:44:49 -07:00
James Yonan
c91beca441 Moved OPENVPN_STRINGIZE(x), a macro that puts double-quotes
around x, into its own source file in common.  Modified
exception.hpp to reference it.
2014-02-16 00:37:50 -07:00
James Yonan
4f4571ee30 More additions to TunPersist for Windows:
* Allow DestructorBase object to be bound to TunPersist-owned
  SCOPED_OBJ object, so that DestructorBase::destroy() is guaranteed
  to be called before SCOPED_OBJ destruction.  This is used as a
  mechanism to remove routes and other properties of the Windows
  TAP adapter that must be unwound when the TAP adapter is closed.

* Added ScopedAsioStream to allow an Asio stream object to
  be managed by a TunPersist object.

* Added TunPersistAsioStream which supports that subset of the Asio
  stream interface required by TunIO, and is intended to wrap a
  ScopedAsioStream embedded in a TunPersist object.
  It is used primarily on Windows to wrap the TAP interface HANDLE
  in way that plays well with Windows I/O completion ports (once
  a HANDLE is bound to an I/O completion port it cannot be unbound).
2014-02-16 00:14:36 -07:00
James Yonan
a9a60a2283 ScopedFD::close() should return a standard status independent of the
underlying implementation.  So return boolean true on successful
close (or no-op) and false on error.
2014-02-11 19:55:12 -07:00
James Yonan
09681f9aea Added ScopedFD::defined_static method. 2014-02-11 00:24:40 -07:00
James Yonan
279c6d5994 Added static ScopedFD::undefined() method to return the undefined
base_type value, i.e. -1.  This is intended to smooth out the
differences between ScopedFD and (upcoming) ScopedHANDLE APIs,
so that they can be used as template types.
2014-02-10 22:59:02 -07:00
James Yonan
0255621670 Added a getopt_long implementation for Windows, since MSVC does
not provide one.
2014-02-08 00:13:23 -07:00
James Yonan
ecc122feed In cli.cpp, avoid compiling signal stuff when on Windows. 2014-02-08 00:13:23 -07:00
James Yonan
03cf311f75 Windows: fix some MSVC compiler warnings. 2014-02-08 00:13:23 -07:00
James Yonan
ea4e95bf24 Refactored find_first_set and find_last_set for both
Unix and Windows support.
2014-02-07 21:22:29 -07:00
James Yonan
7ce7b73940 Added opportunistic long typedefs (olong and oulong) that are
32 bits on 32-bit machines and 64 bits on 64-bit machines.

This is needed because on Windows (MSVC), long is 32 bits
even when building in x64 mode.
2014-02-07 21:11:32 -07:00
James Yonan
b80e4af571 core: recognize backslash as a directory separator char on all
platforms, including Unix.  This is necessary to allow ProfileMerge
to operate correctly when Windows profiles are merged on Unix.
2014-01-30 12:31:32 -07:00
James Yonan
d20fb9a47f core: added platform info method to OpenVPN 3 API:
// Returns platform description string
  static std::string platform();
2014-01-14 16:28:29 -07:00
James Yonan
baca5e05d5 Core proxy changes:
Added support for "http-proxy" and "http-proxy-option" directives
in the main section of the config file, outside of <connection>
blocks.

Added <http-proxy-user-pass> multiline directive for inlining
proxy creds:

  <http-proxy-user-pass>
  user
  pass
  </http-proxy-user-pass>

Merge class now knows how to expand creds file inline.
For example,

  http-proxy ntlm.yonan.net 3128 auth.txt

is converted to:

  http-proxy ntlm.yonan.net 3128 auto
  <http-proxy-user-pass>
  user
  pass
  </http-proxy-user-pass>
2013-12-30 16:17:22 -07:00
James Yonan
b6d17ba69e Added Option::escape() method.
Minor string/option refactoring.
2013-12-28 20:20:21 -07:00
James Yonan
2cbe310f35 OpenVPN 1.0.4 build 114 (iOS)
Dusted off LZ4 implementation and enabled in iOS
and cli.cpp builds.

Tested LZ4 as well with OpenVPN 3 acting as the client,
with a hacked AS and OpenVPN 2.3 (JY) acting as the server
(see lz4hack patches).
2013-12-27 22:21:22 -07:00
James Yonan
1481327d72 OpenVPN 1.0.2 build 98 (iOS)
Ported iOS client and OpenVPN 3 core to ARM-64.
Now building a "fat binary" with Xcode 5.0.1 that
targets arm7, arm7s, and arm64.

Outstanding issues:

* IPv6 doesn't route through tunnel on iOS7
* Client doesn't install on iOS 5.1.1.
2013-11-11 12:33:35 -07:00
James Yonan
f290f9feee Extended IP.Addr class to handle extents as IP.Addr objects. This
extends the IP.Addr class to act more-or-less as a generic 128-bit
unsigned integer class.
2013-07-29 05:48:03 +00:00
James Yonan
a5210ce061 In ipv6-vps.ovpn, use the setenv opt form of the
tls-version-min directive:

  setenv opt tls-version-min 1.2 or-highest

In 3.0 core, properly set OPENVPN_VERSION to 3.0.

Updated make-community to automatically push at
end of build.
2013-06-11 02:04:07 +00:00
James Yonan
cf39be0516 Log unused options, i.e. options specified in config file that were
unrecognized, ignored, or unused.

This behavior is somewhat different (by design) to 2.x branch, which
will raise a fatal exception if an unrecognized option is
encountered.
2013-06-10 00:42:19 +00:00
James Yonan
906584ba3b Support "setenv opt" prefix before directives, where
its presence indicates that the directive is optional,
i.e. if a client doesn't understand the directive, it
should simply ignore it.
2013-06-08 16:10:35 +00:00
James Yonan
e92899c490 Relax options parser a bit and follow OpenVPN 2.x behavior
where if more than one instance of an option exists, and
a single instance of the option is required, use the last
instance.  Previously we would raise an exception in this case.
2013-06-03 06:31:22 +00:00
James Yonan
bbaaf65b0a Fixed options parsing issue if non-aggregate option was
specified in profile as well as pushed by server
(the pushed version should win).
2013-05-25 01:13:11 +00:00
James Yonan
d3c592c991 For iOS (and other platforms in the future), added the capability
for server to push proxy options, e.g.:

  push "dhcp-option PROXY_HTTP 10.144.5.14 3128"
  push "dhcp-option PROXY_HTTPS 10.144.5.14 3128"
  push "dhcp-option PROXY_BYPASS www.yonan.net staging.openvpn.net"
  push "dhcp-option PROXY_AUTO_CONFIG_URL http://www.yonan.net/proxy.pac"
2013-05-24 20:04:37 +00:00
James Yonan
ffe53114ab Copy ProtoConfig for each connection within a client session so that
modifications due to server push will not persist across client
instantiations.

Added RCCopyable object, a variation on RC that allows copying and
assignment.
2013-04-21 20:29:14 +00:00
James Yonan
964e9553b5 Added more functionality to IP:Addr classes so that they can be
wrapped by swig and used in the Access Server to represent IPv4
and IPv6 addresses.
2013-04-04 00:51:25 +00:00
James Yonan
82d2dfb280 OpenVPN 1.0.1 build 79 (iOS)
OpenVPN 1.1.10 build 42 (Android)

Change to memcmp_secure: declare memory regions as volatile
to avoid potential compiler optimizations from leaking
timing info.
2013-03-22 18:02:45 +00:00
James Yonan
cebc610e8e Implemented route-nopull (second attempt). 2013-03-14 02:54:58 +00:00
James Yonan
be3a573f66 Core change: provide logic for tunPerist that works with iOS-style
tun semantics, however this code has not been enabled yet on iOS
because it breaks in several ways:

1. network available/unavailable detection appears to break when
   tun interface is kept alive across transport connection sessions.

2. plugin session persistence appears to fail when these lines are not
   executed immediately after transport pause/resume:

     VPNTunnelSetStatus(tunnelRef, kVPNTunnelStatusReasserting, 0);
     VPNTunnelClearConfiguration(tunnelRef)

iOS Core change: change pause/reconnect delay to 3 seconds (from 2)
to reduce flapping.
2013-02-19 06:38:10 +00:00
James Yonan
13db8d94ca Core: modified read_text_utf8 to remove the Windows UTF-8 BOM,
if present.
2013-01-30 13:36:53 +00:00
James Yonan
6c0be1e1c0 iOS: 1.0.1 build 55
Android: 1.1.9 build 31

* Reverted key-direction back to a default of 1.

* Raise fatal error if "fragment" option is used.

* Made TunBuilderCapture more useful as a base class for
  tun construction on various platforms.

* Added disableClientCert flag at ovpncli.hpp API.

* Updated help FAQ with more details on how to
  properly set key-direction, and notes about
  possible network disconnect during voice calls.
2013-01-24 13:34:17 +00:00
James Yonan
3b8ede216d Core: on PolarSSL, try to do string rendition of X509 subject
just like OpenSSL, so that tls-remote equality matches with the
X509 subject will be compatible.
2013-01-20 08:44:49 +00:00
James Yonan
5055dedbfc Core: fixed issue with parsing time period options (such as
"reneg-sec"), where if period is 0, we must treat it as essentially
infinite.  This fixes the issue where "reneg-sec 0" was causing an
infinite connect loop.

Refactored number.hpp to provide all reasonable number-parsing
functionality, so that typeinfo.hpp can be retired.
2013-01-20 06:34:49 +00:00
James Yonan
400b7324da In Android client, added a custom error dialog for
TAP-based tunnels not supported.
2012-12-12 02:19:07 +00:00
James Yonan
e51e5421cf Updated OpenSSL driver to feature equivalance with
PolarSSL driver.

Updated Linux build.

Added badcert.ovpn test profile to trigger certificate
verification error.
2012-11-26 07:46:09 +00:00
James Yonan
d5874f4684 Misc client and pre-server cleanup. 2012-11-26 01:51:24 +00:00
James Yonan
3a16bc0248 Move unused files out of source tree. 2012-11-23 06:33:27 +00:00
James Yonan
4d9a751af2 Added head comments to all source files.
Minor reorganization of unicode code.
2012-11-23 06:18:43 +00:00
James Yonan
5047d251a0 Fixed iOS regression caused by addition of support for non-unified
profile merge, where profiles that succeeded in the merge phase
but failed in the options parse phase would crash the UI.
2012-11-15 16:17:46 +00:00
James Yonan
0d16acd0bb Minor exception code cleanup. 2012-11-14 16:41:33 +00:00
James Yonan
daa97ededd Added support for <connection> blocks in profile. 2012-11-14 05:12:48 +00:00
James Yonan
31d87f09a4 Extend config file parser to recognize end-of-line comments
that start with # or ;

To pass these chars as part of an argument, make sure to quote
them.
2012-11-14 03:25:59 +00:00
James Yonan
32a117242e More profile validation. 2012-11-14 02:35:50 +00:00
James Yonan
05aed22147 Allow multi-cert directives like ca and extra-certs to be specified
multiple times in the config file.
2012-11-12 16:17:25 +00:00
James Yonan
df51e2bfc3 Minor SplitLines changes. 2012-11-12 02:33:20 +00:00
James Yonan
5a5a18942a Added parser size validation constants in
openvpn/client/cliconstants.hpp
2012-11-12 01:52:03 +00:00
James Yonan
065b83263c Initial Apple VPN-On-Demand implementation:
* VoD profiles can be defined using the iPhone Configuration utility:

  1. Connection Type should be set to Custom SSL
  2. Identifier should be set to net.openvpn.OpenVPN-Connect.vpnplugin
  3. Server can be set to a hostname, or "DEFAULT" to use the
     hostname(s) from the OpenVPN configuration.
  4. User Authentication should be set to Certificate, and the client
     certificate+key should be attached as a PKCS#12 file.
  5. VPN On Demand should be enabled and match entries should be
     defined.

  In addition, the OpenVPN client configuration file may be defined
  via key/value pairs:

  1. VoD requires an autologin profile.
  2. Define each OpenVPN directive as a key, with arguments
     specified as the value.
  3. For Access server meta-directives such as
     OVPN_ACCESS_SERVER_USERNAME, remove the "OVPN_ACCESS_SERVER_"
     prefix, giving USERNAME as the directive.
  4. If no arguments are present, use "NOARGS" as the value.
  5. If multiple instances of the same directive are present,
     number the directives in the order they should be processed by
     appending .<n> to the directive, where n is an integer,
     such as remote.1 or remote.2
  6. For multi-line directives such as <ca> and <tls-auth>, you must
     convert the multi-line argument to a single line by specifying
     line breaks as \n -- also note that because of
     this escaping model, you must use \\ to pass backslash itself.

* VoD profiles are recognized and listed by the app.

* The app can disconnect but not connect a VoD profile.

* Most app-level functionality such as logging and preferences
  work correctly for VoD profiles.

Core changes:

* Added support for key-direction parameter in core.
2012-11-06 17:50:30 +00:00
James Yonan
f72aab4b40 Added support to new core for remote-cert-tls, remote-cert-ku,
and remote-cert-eku directives.
2012-10-31 14:46:40 +00:00
James Yonan
1c7f9e2577 Completed HTTP proxy backend implementation
in new client core:

* Added NTLMv2 authentication
2012-10-28 10:07:32 +00:00
James Yonan
9c6d783134 Added HTTP Proxy Digest Auth support. 2012-10-26 12:36:40 +00:00
James Yonan
3ca3a857bd Initial HTTP proxy implementation in core, with support for
non-authenticated proxies and Basic Auth.

Includes new PROXY_ERROR and PROXY_NEED_CREDS events.

Still to do: Digest and NTLM auth.
2012-10-24 06:38:20 +00:00
James Yonan
cded2ca49e Android 1.1.1 build 9
* Fix attempt for java.lang.NullPointerException in
  net.openvpn.openvpn.OpenVPNService.onStartCommand(OpenVPNService.java:838)

* Allow non-unified profiles (i.e. profiles containing directives that
  reference other files) to be imported from SD card, as long
  as all referenced files are present in the same directory on the
  SD card as the profile.

* Relaxed parsing of "remote" directive to allow the port and/or
  protocol parameters to be omitted.  The port defaults to 1194
  and the protocol to UDP.  Either defaults can be changed with
  the "port" or "proto" directive.

* Fixed issue where profile parser was choking on files containing
  Windows-style line-endings.
2012-10-18 12:24:14 +00:00
James Yonan
3a126349f1 Added strcasecmp methods to operate on std::string. 2012-10-18 06:17:46 +00:00
James Yonan
4445ba1e76 OpenVPN 1.0 Beta 21 (iOS)
Implemented IPv6 in iOS client.

Added new flags to redirect-gateway to control whether redirection
occurs at IPv4 or IPv6 levels (or both):

* ipv4 (default)
* !ipv4
* ipv6
* !ipv6

Added new directive "redirect-dns yes|no".  If yes, all DNS requests
will be forwarded through pushed DNS servers.  If no, only DNS
requests that match domains enumerated in "dhcp-option DOMAIN"
directives will be forwarded.  If redirect-dns is omitted, it will
default to yes if redirect-gateway is specified at the IPv4 level
(this is the normal pre-existing behavior).

Allow the following aggregated options that are normally pushed by
the server to be defined in the config file as well.  These options
will be combined with server-pushed options:

* route
* route-ipv6
* redirect-gateway
* redirect-private
* dhcp-option

Allow the following singleton options (i.e. options that don't
aggregate), that are normally pushed, to be defined in the config
file (note that server-pushed singleton options will override the
config file setting):

* redirect-dns

The Connection Details section of the UI now displays VPN IP
addresses for IPv4 and IPv6.

Added new pushable option "client-ip IP_ADDR" that can be pushed
by the server with the client's IP address as seen by the server.
The client will then show the address in the Connection Details
section of the UI.
2012-10-03 09:03:02 +00:00
James Yonan
48ab9cbbe9 Added our own system() implementation to allow args to be passed as
array instead of concatenated string, and to resolve issue on OS X
where signals were being ignored after system() was called.

C++ iterators incremented in a for statement should usually use
a preincrement syntax.
2012-09-12 04:24:05 +00:00
James Yonan
54a534d347 Fixed build script to work again on OS X.
Implement our own wrapper around ::system().
2012-09-11 23:51:37 +00:00
James Yonan
a6b6d487ef Global edit to add copyright notice at head of each source file. 2012-08-24 21:13:42 +00:00
James Yonan
582c8f3977 OpenVPN 1.0 Beta 13 (iOS)
* Fixed issue with non-pushed "comp-lzo" statically declared in
  config file.

* Show Peer info in log.

* Increment core version number to 1.0.
2012-08-23 14:25:50 +00:00
James Yonan
b37eb264d3 iOS client changes:
OpenVPN 1.0 Beta 4

* Fixed issue where large profiles were hitting against a limitation
  in Apple VPN API (configd[14] <Error>: VPN Controller: failed to
  write to VPN control socket - msgtype: 2050).  The fix is to pass the
  profile to the plugin via a temporary file rather than putting the
  file content into the plist.

* Added Help section toggle button.

* Added Private Tunnel import.

* Added anti-race sequencing to prevent connection request processing
  until after callbacks and event stream subscriptions have been
  set up.
2012-08-12 00:32:15 +00:00
James Yonan
f91339e739 First working iOS build. 2012-07-01 15:37:46 +00:00
James Yonan
3bacaf84c3 Added Blowfish support for iOS. 2012-05-25 20:28:14 +00:00
James Yonan
40ada7a7db cli tool builds without errors for iOS (arm). 2012-05-22 19:18:41 +00:00
James Yonan
53fa94260f Added clang/LLVM support. 2012-05-22 12:25:33 +00:00
James Yonan
452b19b787 Checkpoint for new core server implementation
(not yet complete).
2012-05-06 00:39:39 +00:00
James Yonan
3c99b8976b C++ core fixes for Windows. 2012-04-21 04:47:30 +00:00
James Yonan
d6be1cf2ee Android 4 client:
* Added OpenVPN log file page view in advanced preferences.

* Added OpenSSL verify_callback.

* Support ns-cert-type

* Sanitize logged data to remove Session ID.
2012-03-08 10:30:43 +00:00
James Yonan
fe76cd990d Allow delete method for ScopedPtr to be overriden via
a template argument.
2012-03-08 08:27:21 +00:00
James Yonan
deffceea7e Android 4 -- Implemented External PKI. 2012-03-06 06:06:54 +00:00
James Yonan
d77865d0a5 Android 4 -- Interim checkpoint for External PKI development. 2012-03-04 23:05:26 +00:00
James Yonan
3a04648684 Android 4 client -- Implemented dynamic challenge/response. 2012-03-03 02:56:58 +00:00
James Yonan
efd1139571 Implemented base64 so static challenge/response now works.
Refactored some of the base Activity stuff into
OpenVPNClientBase.java.

Clients sending intents to OpenVPNService should use
OpenVPNService.INTENT_PREFIX as a key prefix when
calling putExtra.
2012-03-01 22:50:57 +00:00
James Yonan
0d36ec4d10 Fixed bug in lex/split that occurs on processors
such as ARM where char is unsigned by default.
2012-02-29 02:13:39 +00:00
James Yonan
71c5d1a35f Added meta option parsing capability to options parser. 2012-02-29 01:59:01 +00:00
James Yonan
f094241aa8 Android 4 client port is almost working (need to get an Android
build that includes tun driver to test further).
2012-02-19 01:36:50 +00:00
James Yonan
9f5cfc465a Implement error handling if socket_protect() call fails. 2012-02-17 20:30:08 +00:00
James Yonan
da248a8fbd Search/replace of:
std::exception& e

to:

  const std::exception& e
2012-02-17 19:28:44 +00:00
James Yonan
9c9a159895 Added SocketProtect abstraction for Android. 2012-02-17 02:10:24 +00:00
James Yonan
dec744c870 Fixes to multi-threaded cli.cpp to allow signals to work
properly.
2012-02-13 23:11:37 +00:00
James Yonan
f13ed3e7a8 Implemented Java client using Swig. 2012-02-11 14:02:51 +00:00
James Yonan
aa35d332ff Initialize OpenSSL "auto" engine in InitProcess::init().
Workaround bug in OpenSSL <= 0.9.8 that caused class DH
compile fail.
2012-02-10 14:25:52 +00:00
James Yonan
adbc10fb5e Bug fixes:
* raise default headroom/tailroom to 512 for worst-case compression
  expansion

* for TCP connections use async_connect instead of connect

* for Time and Time::Duration, handle subtraction reasonably with
  infinite values

* handle possible infinite duration in to_posix_duration

* fix overflow in Time::Duration::to_milliseconds

* call Base::update_now() in ClientProto::start
2012-02-07 20:52:40 +00:00
James Yonan
6674709aba Added ClientConnect class which implements an "always-try-to-reconnect"
approach, with remote list rotation.  Only gives up on auth failure.
2012-02-07 11:37:35 +00:00
James Yonan
231bd0f21a Top-level client refactoring, to move configuration functionality
from cli.cpp to ClientOptions in openvpn/client/cliopt.hpp.
2012-02-06 20:39:10 +00:00
James Yonan
f9ae757e1a Added "remote" option list handling.
Added ClientProtoTerminateCallback abstraction to ClientProto.

Added ClientProto::Config for configuration parameters, rather than
passing parameters individually to ClientProto constructor.
2012-02-06 08:28:05 +00:00
James Yonan
e7a5d9f55b Start process of moving client logic out of cli.cpp into
general-purpose classes.

Rename ProtoStats to SessionStats and make it more flexible
by using an abstract base class model.

Add a client event queue for the beginnings of a client-backend
API.

Added logic to ProtoContext to invalidate session on certain
kinds of errors in TCP that would be normally be okay in UDP
such as HMAC_ERROR, DECRYPT_ERROR, etc.

Add some alignment adjustment logic for READ_LINK_TCP (3 bytes)
and READ_LINK_UDP (1 byte).
2012-02-04 10:24:54 +00:00
James Yonan
94cdd50aee Added support for pushed option continuations. 2012-01-31 23:30:19 +00:00
James Yonan
d9e8a028c8 Ported core to Windows except for TAP driver support. 2012-01-25 08:32:27 +00:00
James Yonan
f7067d817c Added constant-time memcmp. 2012-01-24 01:54:35 +00:00
James Yonan
29bc40bf09 Added TCP transport support.
Disable retransmission of control channel packets
when running in TCP mode.
2012-01-20 23:13:48 +00:00
James Yonan
bd4673c60f Added IP address classes for IPv4/v6.
Implemented get_default_gateway() for Mac OS X.
2012-01-11 06:15:32 +00:00
James Yonan
e5c2791c65 Ported cli.cpp to Mac. Still a couple fixmes to address. 2012-01-05 07:47:24 +00:00
James Yonan
648298d17a Completed client refactoring to make polymorphic abstraction
layer for transport and tun objects.
2012-01-04 15:58:31 +00:00
James Yonan
d7039586dd Made client transport layer polymorphic. 2012-01-03 08:04:41 +00:00
James Yonan
a20651efbf Make DNS resolution asynchronous. 2012-01-02 01:58:00 +00:00
James Yonan
cd13bb745f Minor file reorg/cleanup:
* link renamed to transport
* moved common/addr.hpp and common/iostats.hpp to unused
2011-12-31 19:49:43 +00:00
James Yonan
a13f44199e minor changes to platform.hpp. 2011-12-31 19:44:50 +00:00
James Yonan
161bbb241d Added BidirObjBase + test code. 2011-12-30 02:05:07 +00:00
James Yonan
7371bd8e14 First working version of cli that can be entirely driven from config
file.  Currently limited to UDP, runs only on Linux, and supports
pushed redirect-gateway but not route directives.
2011-12-18 10:50:08 +00:00
James Yonan
e0b96357fb First working version of core (testcli.cpp). 2011-12-16 17:20:46 +00:00
James Yonan
990231b226 First successful negotiation with AS.
Still need to parse and apply PUSH_REPLY options.
2011-12-16 10:02:15 +00:00
James Yonan
44ee74f374 Added compression framework.
Implemented LZO_STUB compressor.

Added methods to generate options and peer info strings.
2011-12-14 11:34:33 +00:00
James Yonan
3f73d56afb Added some string parsing classes/functions for parsing OpenVPN options
given as a comma-separated list.
2011-12-13 19:51:29 +00:00
James Yonan
1aa65c259b Implemented soft reset in proto.hpp. 2011-12-13 04:46:56 +00:00
James Yonan
f3e9239d80 Full-protocol unit test using ProtoContext, w/o soft resets.
Test in test/ssl/proto.cpp.
2011-12-11 08:28:55 +00:00
James Yonan
3c57bf9b05 ProtoStack with Apple SSL client and OpenSSL server
successfully tested by test/reliable/ssl.cpp.
2011-12-02 22:00:56 +00:00
James Yonan
67304fc671 Initial implementation of class ProtoStackBase.
Compiles, but not yet tested.
2011-11-30 19:47:30 +00:00
James Yonan
fc0635e657 Read PKCS#12 file using Apple crypto. 2011-11-26 11:33:39 +00:00
James Yonan
e56f1c6b11 Added OpenSSLContext data transfer test. 2011-11-24 10:47:11 +00:00
James Yonan
71eaaaac9d Started process of abstracting SSL Context object to be independent
of the underlying crypto library.
2011-11-24 02:09:11 +00:00
James Yonan
d05decf3a9 Added OpenSSL-like EVP API (for digests only) and random
API using Apple CommonCrypto and Security/SecRandom APIs
as backend.
2011-11-21 22:39:33 +00:00
James Yonan
7dd61393ab Move crypto random number headers out of openvpn/openssl
into openvpn/random.  Also move boostrand.hpp into
openvpn/random.
2011-11-21 06:11:06 +00:00
James Yonan
f09b9ae12a Added reltest.cpp for testing ReliableRecv and ReliableSend
objects by simulating an unreliable packet stream.

Modified packet_id code so that current time (now) is passed
via function calls rather than accessed as a global.

Added integer random number support via boost::random.
2011-11-09 05:52:52 +00:00
James Yonan
52c42fb5d2 Moved time source files to openvpn/time.
Added search/replace tool smod.
2011-11-05 17:02:16 +00:00
James Yonan
b1b313ec28 Implemented new time system based on Time and Time::Duration,
with Asio integration using boost::asio::time_traits<openvpn::Time>.

Started reliable receive class (ReliableRecv).
2011-11-01 13:00:49 +00:00
James Yonan
1fcf65fbda Started PKI tree for wrapping OpenSSL PKI objects.
Started SSL Context class.

Implemented dgram & stream buffer queues that can operate as
OpenSSL BIOs.

Reworked Frame class to make it more flexible.
2011-10-25 17:32:26 +00:00
James Yonan
e5b9f303bc Developed openvpn::time abstraction. 2011-10-16 07:51:07 +00:00
James Yonan
11be943cbb Added MessageWindow class and test. 2011-10-10 07:27:20 +00:00
James Yonan
ab4c6ee28e Added NowUpdater class to update "now" variable once per second.
Currently being used in static key tunnel (st.cpp).
2011-10-08 06:20:49 +00:00
James Yonan
918caca206 First working static key implementation.
Tested interoperability with OpenVPN in static key mode.
2011-10-07 05:47:49 +00:00
James Yonan
422cd204af Added CryptoContext wrapper struct for Encrypt and Decrypt objects.
Modified build scripts to use -fwhole-program.

Added read_text function to read a text file into a string.
2011-10-06 17:22:37 +00:00
James Yonan
e3422bd755 Encrypt and Decrypt classes implemented for OpenVPN data channel protocol. 2011-10-06 00:18:46 +00:00
James Yonan
7822e9e298 Make Buffer/BufferAllocated into BufferType/BufferAllocatedType
templates.

Obsolete SimpleArray (all SimpleArray functionality is now
supported by BufferAllocatedType).
2011-10-02 18:55:55 +00:00
James Yonan
f2423aad9d Misc fixes:
* Changes to make library more properly "header only".
* Make Allocator argument to SimpleArray a template parameter.
2011-09-30 23:20:30 +00:00
James Yonan
bba84f1692 Minor fix. 2011-09-30 16:47:28 +00:00
James Yonan
e4f9d20a0f Added OpenVPN Static Key parser/renderer. 2011-09-30 15:25:38 +00:00
James Yonan
45cd55cb4d Added allocators to SimpleArray to allow for a secure
allocator that zeros data before deallocation.
2011-09-30 01:01:01 +00:00
James Yonan
4d66859513 Added PRNG. 2011-09-29 22:42:37 +00:00
James Yonan
f25c9b37ef Added SimpleArray class template.
Misc cleanup.
2011-09-29 06:35:23 +00:00
James Yonan
931a4b1a07 In Cleartun, revert to single-threaded mode only regardless of whether
Boost/Asio built in single-threaded mode.  This is done due to the
revelation that Asio socket objects are not thread-safe.

Break out IOStats into two classes:

* IOStatsSingleThread
* IOStatsMultiThread
2011-09-29 03:01:36 +00:00
James Yonan
ff23d78fa9 Implemented OpenVPN Packet ID code. 2011-09-28 23:12:37 +00:00
James Yonan
fed617b613 Added cleartun optimizations:
* reuse buffer for next queue
* do 8 async_read_somes in parallel
* use hand-rolled function object instead of boost::bind
2011-09-26 21:02:13 +00:00
James Yonan
c90ba6937d Added cleartun benchmark to demonstrate cleartext
tun-based VPN implemented in C++/Asio/Boost.

See test/cleartun/notes.txt.
2011-09-24 22:51:28 +00:00
James Yonan
f11af8460f Commit of misc C/C++ code:
* test/cascli -- call AS client API from C++ by embedding python
* test/embed -- misc test code for embedding python
* test/dtls -- DTLS proof-of-concept code
* test/tunflood -- test boost::asio wrapper around linux tun/tap device
2010-09-23 09:01:19 +00:00
James Yonan
24a4eb3267 Initial checkin for OpenVPN 3 rewrite.
This very basic proof-of-concept implements a
boost::asio wrapper around the linux tun/tap device.
2010-09-13 08:52:18 +00:00