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

60 Commits

Author SHA1 Message Date
James Yonan
71e825761c
mbedTLS: Port from polarssl-1.3 to mbedtls-2.3
This patch is mostly about polarssl -> mbedtls symbol renaming.
2020-01-09 12:23:46 +02:00
James Yonan
f0eb518b77
relay : added relay functionality and tests. 2020-01-09 12:23:46 +02:00
James Yonan
12866f4d0a
HTTP client : status argument to WS::Client::Status::error_str() should be an int because -1 is one of the possible values. 2020-01-09 12:23:46 +02:00
James Yonan
3b8a5595fb
copyright : updated to 2016 2020-01-09 12:23:46 +02:00
James Yonan
7059606bae
keepalive : added HTTPCore::is_keepalive_enabled() stub method to comply with TransportClientParent requirements. 2020-01-09 12:23:45 +02:00
James Yonan
2f56fb9fbd
httpcli.hpp : added Request::creds_defined() method. 2020-01-09 12:23:45 +02:00
James Yonan
d4cf3b75d7
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:45 +02:00
James Yonan
fee78ccfe4
In HTTP client and server, enable TCP_NODELAY on socket. 2020-01-09 12:23:45 +02:00
James Yonan
438ad6f4db
In WS::Client::Status::error_str(), handle cases where status == -1. Also, show the numerical status value for unknown errors. 2020-01-09 12:23:44 +02:00
James Yonan
3df9f988e3
Apparently Android NDK doesn't support std::to_string (WTF?), so work around it.
http://stackoverflow.com/questions/22774009/android-ndk-stdto-string-support
2020-01-09 12:23:44 +02:00
James Yonan
21ad74202e
In httpcli.hpp, need to rename E_ABORT to E_ABORTED to avoid a Windows symbol conflict. 2020-01-09 12:23:44 +02:00
James Yonan
a29b91760d
In HTTP client:
Added get_socket() method to WS::Client to return the
underlying HTTP AsioPolySock::Base object.

Added unix_fd() method to WS::ClientSet which depends on
get_socket() above and will return the fd of HTTP socket
if it's a unix domain socket.
2020-01-09 12:23:44 +02:00
James Yonan
3637c2976e
In httpcli.hpp, use C++11 member initialization in class ContentInfo. 2020-01-09 12:23:43 +02:00
James Yonan
eb6971b972
In HTTP client, added abort() method to both WS::Client and WS::ClientSet. 2020-01-09 12:23:43 +02:00
James Yonan
d3b5f1b186
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.
2020-01-09 12:23:43 +02:00
James Yonan
3175805174
In WS::Client::Config, use C++11 member initializers. 2020-01-09 12:23:43 +02:00
James Yonan
fa513773c0
In HTTP client, added http_post_connect() virtual callback method to allow user to verify server socket immediately after connect. This is useful when the server is local via a unix domain socket or windows named pipe.
In WS::ClientSet, exposed the callback as a std::function
in TransactionSet::post_connect.
2020-01-09 12:23:42 +02:00
James Yonan
56736bb90d
Minor simplification in HTTP client Windows-specific code for opening a named pipe. Use Win::LastError instead of asio::error_code... 2020-01-09 12:23:42 +02:00
James Yonan
fab921f714
Added Windows named pipe support to HTTP client/server library. 2020-01-09 12:23:42 +02:00
James Yonan
f811dfd42c
In HTTP client (httpcli.hpp):
* Added Request::set_creds() method.

* In HTTPCore, added a virtual destructor that calls stop().

* Added is_alive() method.

* In HTTPDelegate class template, detach() method now accepts
  a keepalive parameter.

* Added HTTPDelegate::attach() method.
2020-01-09 12:23:42 +02:00
James Yonan
dd5b4980ff
Asio async_wait lambdas should always check error status. 2020-01-09 12:23:41 +02:00
James Yonan
6b599f158c
In HTTP client/server, added msg_overhead_bytes member to Config class to allow for accounting of message overhead.
This is to prevent attacks where a large number of very
small messages (such as 1 byte each) are sent to the
server to force it to consume more memory than the
max_content_bytes limit would normally allow.
2020-01-09 12:23:41 +02:00
James Yonan
e49d4adae3
Added AGPL license header to HTTP, Java, and common code. 2020-01-09 12:23:41 +02:00
James Yonan
5087ea6a36
HTTP changes.
Both Client/Server side:

1. Support asynchronous sending of content via
   set_async_out() and http_content_out_finish()
   methods and http_content_out_needed() callback.

2. Added ContentInfo::extra_headers for caller-defined
   extra HTTP headers.

3. Made ContentInfo::CHUNKED into a constexpr
   type to match ContentInfo::length member var.

4. Set FD_CLOEXEC on socket.

5. Added remote_ip_port() method to allow remote IP
   address and port of socket to be obtained.

Client side:

1. In Host, added hint string to override transport host
   when a specific IP address should be used for host
   instead of resolving host via DNS.

2. Added Host::host_port_str() method.

3. Make general_timeout work like a true timeout, where
   traffic resets the timer (this is how server-side
   already works).

4. Added new method remote_endpoint_str() to match
   the same method on server-side.

5. Added new method host_hint() to return the current Host
   object, but set the hint/port fields to the live
   remote IP address/port of the connection.

6. Added new callback http_mutate_resolver_results() to
   allow user to modify the order of endpoint list returned
   by resolver.

Server side:

1. Make content_len_t into a 64-bit signed int since one
   of its possible values is -1 for CHUNKED.

2. Added ContentInfo::no_cache member var to trigger headers
   telling clients to not cache the content.

3. Added Factory::stop() virtual method for users to
   optionally override.

4. Made get_client_id() method public.

5. Fixed issue where code that allocates a client_id
   wasn't actually calling new_client_id().
2020-01-09 12:23:41 +02:00
James Yonan
30c4c2f37f
HTTP client/server -- now that socket is a smart pointer, make sure to check it is defined before calling close() method. 2020-01-09 12:23:40 +02:00
James Yonan
bbf84f1db1
In HTTP client/server stop() methods, do socket->close() instead of socket.reset(), as the latter may free the underlying socket while asio still holds dangling pointers to it. 2020-01-09 12:23:40 +02:00
James Yonan
10a0bfb6a7
Minor changes to httpcli.hpp:
* Check for empty DNS resolve results.
* Fix some debugging names passed to asio_error_handler,
  after functions were renamed for tcp vs. unix domain
  sockets.
2020-01-09 12:23:40 +02:00
James Yonan
135e2436bf
HTTP client/server changes:
* HTTP client and server now support unix domain sockets
  via AsioPolySock abstraction.

* HTTP server now supports Basic auth credentials.

* HTTP server now supports peercred authentication
  over unix domain sockets.

* HTTP server now supports file creation permission
  bits on unix domain socket.

* Added udstest tool to test HTTP client over unix domain
  sockets.
2020-01-09 12:23:40 +02:00
James Yonan
acfb70ab8a
Don't use deprecated asio features. 2020-01-09 12:23:40 +02:00
James Yonan
c0dcbae82f
Obsoleted asiodispatch in favor of C++11 lambdas. 2020-01-09 12:23:39 +02:00
James Yonan
ab72082bd4
Made protocol type a template parameter to TCPTransport::Link, so we can work with protocols other than TCP such as unix domain sockets. 2020-01-09 12:23:39 +02:00
James Yonan
12e4cfb4a4
Method signature changes for DCO (Data Channel Offload). 2020-01-09 12:23:39 +02:00
James Yonan
038b02fb2a
Boost dependency elimination -- final removal of Boost dependency. Asio is now included as a standalone, header-only dependency. 2020-01-09 12:23:39 +02:00
James Yonan
3ab7739fed
HTTP server:
* Fixed issue where HTTP server did not detect
  mid-session client disconnect.

* Implement parent_handoff (for proxies).

* Improved handling of residual content, allowing
  HTTP 1.1 pipelining to be supported.
2020-01-09 12:23:38 +02:00
James Yonan
8cabba1665
OPENVPN_HTTP_SERV_RC may be defined to override WS::Server::Listener::Client RC root class. 2020-01-09 12:23:38 +02:00
James Yonan
e608ee6db4
Renamed boost::intrusive_ptr<T> usage to RCPtr<T>. 2020-01-09 12:23:38 +02:00
James Yonan
686968992d
Moved array_size() function to its own header file. 2020-01-09 12:23:38 +02:00
James Yonan
47ffbe7401
C++11 : rename NULL to nullptr 2020-01-09 12:23:37 +02:00
James Yonan
8dbf685a25
Extended WS::Client to allow the use of any OpenVPN client transport driver for the HTTP/S transport layer. This enables use of HTTP CONNECT and OBFS proxy drivers. To enable, set the WS::Client::Config::transcli member to any TransportClientFactory instance. 2020-01-09 12:23:37 +02:00
James Yonan
c5d3fdad87
Added pgproxy, an HTTP proxy supporting both CONNECT and OBFS. 2020-01-09 12:23:37 +02:00
James Yonan
84b234b68b
Refactored web services classes (openvpn/ws) to support HTTP/S servers. 2020-01-09 12:23:37 +02:00
James Yonan
16a69d0325
In HTTPCore (httpcli.hpp), factor out code into httpcommon.hpp that is common to both HTTP clients and servers, so upcoming HTTP server implementation can leverage on the same code currently used by the client. 2020-01-09 12:23:36 +02:00
James Yonan
80c63cd93e
Refactored WS::Client status codes from WS::Client::E_x to WS::Client::Status::E_x. 2020-01-09 12:23:36 +02:00
James Yonan
1aebd88dc7
Factored out web services get_content_length() method into openvpn/ws/httpcommon.hpp which is intended for code that is common between HTTP clients and servers. 2020-01-09 12:23:36 +02:00
James Yonan
45b5d3bf69
Refactored WS::HTTPCore::ChunkedHelper into its own source file in preparation for HTTP server implementation. 2020-01-09 12:23:36 +02:00
James Yonan
937082b80d
Added minimal Content-Encoding support to HTTP client. 2020-01-09 12:23:35 +02:00
James Yonan
5d2a05cf8e
In HTTP client, added the ability to separately specify:
* hostname for TCP transport
* hostname for CN verification
* hostname sent as HTTP Host header
2020-01-09 12:23:35 +02:00
James Yonan
3175a9c9dd
Extended WS::Client:
* Added WS::Client:error_str() for formatting
  error codes.

* Added reset() method.

* When calling start_request(), set ready=false immediately
  to avoid race.

* Added http_headers_sent() and http_keepalive_close()
  callbacks.

* Added HTTPDelegate class.
2020-01-09 12:23:35 +02:00
James Yonan
93f10d74e2
Updated web services client classes to use SSLConfigAPI, and to support PolarSSL or OpenSSL. 2020-01-09 12:23:35 +02:00
James Yonan
51fbf93a93
Updated copyright to 2015. 2020-01-09 12:23:34 +02:00