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

187 Commits

Author SHA1 Message Date
James Yonan
4ebd66bfbb
httpcreds : redefined WS::Creds::load_from_options() to pass through the UserPass flags value. 2020-01-09 12:24:18 +02:00
James Yonan
c86fd2a5de
Added write_private() methods from core (no Windows implementation yet).
In httpcreds.hpp, use write_private() for creating creds
files rather than UMask.
2020-01-09 12:24:17 +02:00
James Yonan
3b20b9bf6a
Fix to httpcreds.hpp for Windows: #ifdef out umask functionality. 2020-01-09 12:24:17 +02:00
James Yonan
94419fd21c
Update httpcreds.hpp with SplitLines change where S_OK was renamed to S_OKAY due to Windows symbol conflict. 2020-01-09 12:24:17 +02:00
James Yonan
8ca935bcd4
In httpcreds.hpp, added WS::Creds::load_from_options() method. 2020-01-09 12:24:17 +02:00
James Yonan
5965e046ed
Added AGPL license header to HTTP, Java, and common code. 2020-01-09 12:24:16 +02:00
James Yonan
75acd76f40
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:24:16 +02:00
Arne Schwabe
99dbc6848b
Fix adding int to a string
Compiler warning:

openvpn/ws/httpcommon.hpp:157:135: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
2020-01-09 12:24:16 +02:00
James Yonan
f1546d6b8b
WS::HTTPBase: added more detail to http_content_out_finish() exception on unexpected state
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:16 +02:00
James Yonan
7b6d4cf6cb
AppServer, WS::HTTPBase: added support for ssl_did_full_handshake() method added to SSL layer
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:15 +02:00
James Yonan
73f8525f9e
Implemented TLS session ticket support in the HTTP layers.
Added support for PGDB server and clients, and the chat test.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:15 +02:00
James Yonan
9e7470c37d
AppServer, WS::HTTPBase: change update_max_content_bytes() to reduce_max_content_bytes()
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:15 +02:00
James Yonan
77f7e06786
Change to commit "httpcommon: fixed race that can occur on high-speed persistent connections"
The original commit has some unintended side effects
that break server-side code.

This commit tries a different approach: do an early
return from http_in() when buffer size is zero.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:15 +02:00
James Yonan
8e6e8e759d
httpcommon: fixed race that can occur on high-speed persistent connections
I observed a case where http_in() (running as a client) called
parent().base_http_done_handler() twice for the same transaction!
Normally the 'ready' var blocks this sort of behavior, but with
a high-speed persistent session, the 'ready' var can transition
so quickly as to create a window for a double-done race.

The fix is to use a more robust filter against unsolicited input
after base_http_done_handler() is called by setting rr_status to
REQUEST_REPLY::Parser::undefined.  This value is never matched
in httpcommon, so it effectively turns http_in() into a no-op when
set.

There is also the question of whether unsolicited input should
be considered a fatal error on a persistent session.  It probably
should, but this fix focuses on a corner case where http_in()
is called with a zero-length buffer, presumably from the SSL/TLS
layer.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:14 +02:00
James Yonan
fa37101597
httpcommon: minor comment addition
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:14 +02:00
James Yonan
111cabd518
AppServer: minor debug logging change of E_GENERAL_TIMEOUT
At debug_level 1, only show timeouts if they occur
within a request/reply transaction, not if they
are triggered outside of a transaction by the
expiration of keepalive.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:14 +02:00
James Yonan
f7e8719852
websocket: don't debit websocket stream traffic to max content size limit
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:14 +02:00
James Yonan
b8886e0482
httpcommon: make is_deferred() public
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:13 +02:00
James Yonan
4e8dffd02b
HTTP layer: added Websocket support
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:13 +02:00
James Yonan
2136c62a35
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:13 +02:00
James Yonan
0d62ae1fb0
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:13 +02:00
James Yonan
d48c197d01
HTTP library : extended debug flag OPENVPN_DEBUG_HTTP to log incoming as well as outgoing network data. 2020-01-09 12:24:12 +02:00
James Yonan
54b91242d3
copyright : updated to 2016 2020-01-09 12:24:12 +02:00
James Yonan
8c341d7d11
Fixed a bug in update_max_content_bytes() in the HTTP common code, where the code was modifying max_content_bytes in the global configuration instead of the specific HTTP instance.
Because pgapi and ccds use this method as an anti-DoS measure,
it means that POSTS of > 4096 bytes that fail authentication
would permanently lower the future max POST size to 4096 bytes
until server restart.
2020-01-09 12:24:12 +02:00
James Yonan
017571afad
In httpcommon.hpp, added a static_assert() to ensure that CONTENT_LENGTH_TYPE type is signed. 2020-01-09 12:24:12 +02:00
James Yonan
a095cd1237
Fixed a minor issue in httpcommon.hpp -- SSL read was not respecting reserved tailroom. 2020-01-09 12:24:11 +02:00
James Yonan
36a2a401e7
Added new HTTP common method update_max_content_bytes() to allow the configuration limit max_content_bytes to be modified mid-session. This can be useful to dial-down the limit on unauthenticated sessions. 2020-01-09 12:24:11 +02:00
James Yonan
f0aea806e3
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:24:11 +02:00
James Yonan
1eb31f13e6
In httpcommon.hpp, added HTTPBase::http_config() method. 2020-01-09 12:24:11 +02:00
James Yonan
0e31ffa928
Added AGPL license header to HTTP, Java, and common code. 2020-01-09 12:24:10 +02:00
James Yonan
d9173907e2
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:24:10 +02:00
James Yonan
18c3789943
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:24:10 +02:00
James Yonan
7925880b7f
OPENVPN_HTTP_SERV_RC may be defined to override WS::Server::Listener::Client RC root class. 2020-01-09 12:24:10 +02:00
James Yonan
24070412f3
Renamed types.hpp to size.hpp since it now only defines size_t and ssize_t. 2020-01-09 12:24:09 +02:00
James Yonan
51603baee6
Refactored ScopedPtr usage to std::unique_ptr. Removed ScopedPtr (moved to test/unused). 2020-01-09 12:24:09 +02:00
James Yonan
2343e0aff0
Added pgproxy, an HTTP proxy supporting both CONNECT and OBFS. 2020-01-09 12:24:09 +02:00
James Yonan
2af25cca08
Minor readability/comments update to httpcommon.hpp. 2020-01-09 12:24:09 +02:00
James Yonan
8f535eb76e
Refactored web services classes (openvpn/ws) to support HTTP/S servers. 2020-01-09 12:24:08 +02:00
James Yonan
a22d7c3d7d
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:24:08 +02:00
James Yonan
c61a41f509
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:24:08 +02:00
James Yonan
98e5e0a6a3
HTTP: before logging, pass HTTP headers through HTTP::headers_redact()
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:08 +02:00
James Yonan
1443d9c000
Implement TCP shutdown at the HTTP layer
This patch tries to gracefully shutdown a socket before
closing it, in non-error, non-stop situations.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:07 +02:00
James Yonan
a52b22afe9
Replace AsioTimer with AsioTimerSafe in cases where handler doesn't clearly check for late cancellation
As noted in the Asio documentation, an AsioTimer handler can be
called with a non-error status after timer cancellation.

Unfortunately, this can lead to race conditions, so I'm moving over
all AsioTimer users to AsioTimerSafe when I don't see the handler
clearly checking for late cancellation.

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:07 +02:00
Lev Stipakov
a43a95a527
win agent: properly handle timeout
Sometimes when machine wakes from sleep,
it takes too long for agent service to start. This causes
an error which core treats as fatal and stops connection.

Fix by detecting timeout and throw non-fatal error, which
makes core reconnect.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-09 12:24:07 +02:00
James Yonan
8bfc822183
WS::ClientSet: HTTP persistence refactor
HTTP persistence across transaction sets can now be
simplified using assign_http_state()

Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:07 +02:00
James Yonan
72e5cb6b52
WS::ClientSet: added commented-out debug logging in keepalive_close()
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:07 +02:00
James Yonan
dfed44d539
WS::ClientSet: retry on 5xx HTTP status codes
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:06 +02:00
James Yonan
dd00ef3be3
WS::ClientSet::TransactionSet: added reset_host() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:06 +02:00
James Yonan
9cf0003de4
WS::ClientSet::Transaction: added new methods is_redirect() and get_redirect_location()
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:06 +02:00
James Yonan
cc2638a21d
WS::ClientSet: special case on retry -- no delay after TCP EOF on first retry
Signed-off-by: James Yonan <james@openvpn.net>
2020-01-09 12:24:06 +02:00