84 Commits

Author SHA1 Message Date
Alexander A. Klimov
f60758dc7c JsonRpcConnection: always log errors 2021-03-04 16:23:07 +01:00
Julian Brost
d1edcb909c Close anonymous connections after 10 seconds
Anonymous connections are normally only used for requesting a
certificate and are closed after this request is received. However, the
request is only sent if the child has successfully verified the
certificate of its parent so that it is an authenticated connection from
its perspective. In case this verification fails, both ends view it as
an anonymous connection and never actually use it but attempt a
reconnect after 10 seconds leaking the connection. Therefore close it
after a timeout.
2020-11-12 18:01:11 +01:00
Alexander Aleksandrovič Klimov
a32c1bf910
Merge pull request #7864 from Icinga/bugfix/icinga2-doesn-t-close-connections-7203
Add timeout for boost::asio::ssl::stream#async_shutdown()
2020-10-19 15:25:12 +02:00
Noah Hilverling
97fc70ccb2
Merge pull request #7836 from Icinga/bugfix/jsonrpcconnection-m_seen
Consider a JsonRpcConnection being seen on a single byte of TLS payload, not only a whole message
2020-07-29 15:02:48 +02:00
Alexander A. Klimov
19c632e44b Add timeout for boost::asio::ssl::stream#async_shutdown()
refs #7203
2020-06-17 10:33:35 +02:00
Noah Hilverling
c9ab04d511
Merge pull request #7841 from Icinga/bugfix/jsonrpcconnection-sendmessage-keepalive
JsonRpcConnection#Send*Message(): keep this alive
2020-03-03 10:46:33 +01:00
Alexander A. Klimov
0f84ce0470 Consider a JsonRpcConnection being seen on a single byte of TLS payload, not only a whole message 2020-02-19 11:11:53 +01:00
Alexander A. Klimov
fbce756007 JsonRpcConnection#Send*Message(): keep this alive 2020-02-17 16:12:07 +01:00
Alexander A. Klimov
a1683568a1 Replace std::shared_ptr<AsioTlsStream> with Shared<AsioTlsStream>::Ptr 2019-10-21 16:12:35 +02:00
Michael Friedrich
2c0e0da2d9 Introduce IoEngine::SpawnCoroutine wrapping asio::spawn and Boost exceptions
This is required to

- catch all exceptions and wrap them into Boost exceptions. They
are the only ones allowed with Boost.Coroutine.
- set a dedicated coroutine stack size for Windows.

refs #7431
2019-09-09 16:40:35 +02:00
Michael Friedrich
5fa7331cc9 Quality: Replace deprecated Boost IO service code
https://github.com/boostorg/asio/issues/110
https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/example/cpp03/services/logger_service.hpp
2019-09-09 15:27:57 +02:00
Alexander A. Klimov
dfaeb88ac3 {HttpServer,JsonRpc}Connection#Disconnect(): cancel I/O ops ASAP
refs #7431
2019-09-09 13:11:51 +02:00
Michael Friedrich
17d4d17307 Avoid the Defer-Disconnect destructor pattern with Boost.Coroutines
Exceptions in Disconnect() might be thrown (this has been reworked
into error_code locally) which are swallowed inside the Destructor
for being dangerous. On the other hand, swallowing them may
corrupt the stack unwinding operation from the coroutine layer.

The best is to avoid Defer inside lib/remote and call Disconnect()
directly after breaking from other operations.

refs #7351
refs #7431
2019-09-09 10:57:13 +02:00
Michael Friedrich
ebb0826be0 JsonRpcConnection: Don't swallow exceptions in Boost.Coroutine
refs #7351
2019-09-09 09:26:12 +02:00
Alexander A. Klimov
c24312b870 JsonRpcConnection#Disconnect(): unregister the connection ASAP
refs #7444
2019-08-23 17:14:13 +02:00
Michael Friedrich
2760748d78 Fix and improve logging for runtime object sync
config::UpdateObject would create a new object, but this may
have been silently ignored with 'ignore_on_error' - downtimes, etc.
Since we cannot simply fetch the error from inside the config compiler,
we'd just check whether there's a config object created at this stage.
This happens synchronously, and once there is, log something.

The previous code always logged the creation, even if the downtime
was ignored, e.g. when the first master sent one for local host objects.

This commit also adds more details: identity, endpoint, zone to extract
the MessageOrigin details into log messages for better troubleshooting
and debugging.

refs #7198
2019-08-15 09:29:05 +02:00
Alexander A. Klimov
42a33cdc7d Fix build errors with Boost v1.70
refs #7237
2019-06-07 16:30:34 +02:00
Alexander A. Klimov
ad28380884 Close server connections and shutdown coroutines immediately on disconnect 2019-06-05 10:42:03 +02:00
Michael Friedrich
59b95ed1f0 Quality: Replace deprecated get_io_service() with get_executor().context() for Boost ASIO
refs #7041
2019-05-29 14:36:10 +02:00
Alexander A. Klimov
a6cd3e65cb JsonRpcConnection: reduce log spam on disconnect 2019-04-23 14:09:07 +02:00
Alexander A. Klimov
de04bb13a8 JsonRpcConnection: reduce log spam on disconnect 2019-04-09 13:53:41 +02:00
Alexander A. Klimov
d428bdf384 Add missing includes 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
5b2c1f023d Rename preventGc to keepAlive 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
5208448b76 Restore the previous performance of replaying logs 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
79e95d2355 Introduce JsonRpcConnection#SendMessageInternal() 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
8b3efe5759 Introduce AsioConditionVariable 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
16913cb977 JsonRpcConnection: add missing CpuBoundWork 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
a451327b81 JsonRpcConnection: re-add num_json_rpc_work_queue_item_rate 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
a54bd9d5c4 JsonRpcConnection: re-add automatic disconnect 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
7aae8bd265 JsonRpcConnection: re-add heartbeats 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
84b411501b Re-add JsonRpcConnection#Disconnect() 2019-04-01 13:31:16 +02:00
Alexander A. Klimov
6c86c127f1 Port JsonRpcConnection to Boost ASIO 2019-04-01 11:40:14 +02:00
Michael Friedrich
d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Michael Friedrich
5406ce6540 Ensure that API/JSON-RPC messages in the same session are processed and not stalled
This basically drops the "corked" implementation which just stalled the
TLS IO polling after some requests. If you need sort of rate limiting
for these events, use an external TLS proxy which terminates that in front
of Icinga.

fixes #6635
2018-10-29 12:57:24 +01:00
Michael Friedrich
dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
Michael Friedrich
a1ec919f5b Raise the message size for anonymous client and pki request calls to 1MB
If one sends the full certificate chain, this previous limit of 64KB
could be hit.
2018-09-05 17:44:05 +02:00
Gunnar Beutner
e678fa1aa5 Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
Gunnar Beutner
9cd5298d8b Ensure that SetCorked() works properly 2018-03-06 09:03:35 +01:00
Noah Hilverling
54ff60cd8c Limit JSON-RPC message size 2018-03-05 10:29:05 +01:00
Gunnar Beutner
6848af50ff Add SetCorked() calls to the JsonRpcConnection class 2018-02-28 11:42:05 +01:00
Noah Hilverling
948333225d Fix nullptr deref in cluster events 2018-02-21 13:47:46 +01:00
Michael Friedrich
ad7e801db9 Fix crash with anonymous clients on certificate signing request and storing sent bytes
refs #5753
2018-02-09 17:18:20 +01:00
Gunnar Beutner
621eed3f13 Apply clang-tidy fix 'modernize-pass-by-value' 2018-01-04 12:24:57 +01:00
Gunnar Beutner
ac155d1dda Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
Michael Insel
158ae2188e Change copyright header for 2018 2018-01-02 12:08:55 +01:00
Jean Flach
2636e6a77a Whitespace fix
What does this change?
* Remove use of spaces for formatting
These could be found by using `grep -r -l -P '^\t+ +[^*]'
* Removal of training whitespaces
* A few lines longer than 120 chars
2017-12-20 14:53:52 +01:00
Gunnar Beutner
3c5af89d5f Fix compiler warnings 2017-12-14 09:15:37 +01:00
Gunnar Beutner
75def4b074
Merge pull request #5753 from Icinga/fix/ringbuffer-does-not-get-updated-if-nothing-is-written-5750
Fix that RingBuffer does not get updated and add metrics about communication between endpoints
2017-12-12 11:32:18 +01:00
Noah Hilverling
5519626f84 Add metrics about communication between endpoints
refs #5509
2017-12-11 10:20:25 +01:00
Gunnar Beutner
6739023678 Dynamically create and destroy the timer thread 2017-11-30 17:41:02 +01:00