Julian Brost
a506d562ae
Add comment for remaining uses of async_shutdown() why it's safe
...
The reason for introducing AsioTlsStream::GracefulDisconnect() was to handle
the TLS shutdown properly with a timeout since it involves a timeout. However,
the implementation of this timeout involves spwaning coroutines which are
redundant in some cases. This commit adds comments to the remaining calls of
async_shutdown() stating why calling it is safe in these places.
2024-12-12 12:10:59 +01:00
Yonas Habteab
8574357443
ApiListener: Log error context only once
...
When logging at the warning level, the logger will automatically look up
for registered context and append them to the log entry accordingly.
2024-10-30 16:55:13 +01:00
Yonas Habteab
9d4625e1ec
ApiListener: Log connection attempts from an already connected client
...
Something is definitely going wrong if a client tries to reconnect to
this endpoint while it still has an active connection to that client. So
we shouldn't hide this, but at least log it at info level. Apart from
that, I've added some additional information about the currently active
client, such as when the last message was sent and received.
2024-10-30 11:26:21 +01:00
Yonas Habteab
9f84c1516e
ApiListener: Reorder logging in `ApiTimerHandler()`
2024-08-28 16:53:53 +02:00
Yonas Habteab
e062ceb901
ApiListener: Catch & supress clients runtime errors
2024-08-28 16:53:53 +02:00
Julian Brost
9222a63ff7
Make sure log file is reopened when `ApiListener::ReplayLog()` returns
2024-08-27 14:23:41 +02:00
Yonas Habteab
73db30c08b
Use `Defer` class for cleanup in `ApiListener::ReplayLog()`
2024-08-27 14:23:41 +02:00
Alexander A. Klimov
f074e24d2a
ApiListener#ReplayLog(): stop reading files ASAP on send error
2024-08-27 14:23:41 +02:00
Julian Brost
abea2f270c
Merge pull request #9997 from Icinga/ListenerCoroutineProc-remote_endpoint
...
ApiListener#ListenerCoroutineProc(): get remote endpoint ASAP for logging
2024-02-20 13:46:02 +01:00
Yonas Habteab
6e66cd9aff
ApiListener: Reset `m_LogMessageCount` when rotating
...
Closing and re-opening that very same log file shouldn't reset the
counter, otherwise some log files may exceed the max limit per file as
their offset indicator is reset each time they are re-opened.
2024-02-09 18:04:20 +01:00
Alexander A. Klimov
62e1d7650d
ApiListener#ListenerCoroutineProc(): get remote endpoint ASAP for logging
...
On incoming connection timeout we log the remote endpoint which isn't
available if it was already disconnected - an exception is thrown. Get it
as long as we're still connected not to lose it, nor to get an exception.
2024-02-09 12:27:25 +01:00
Alexander A. Klimov
bc778116e9
ApiListener#Start(): auto-renew CA on its owner
...
otherwise it would expire.
2023-12-18 15:28:11 +01:00
Alexander A. Klimov
36a08b0497
ApiListener#RenewCert(): enable optional CA creation
2023-12-18 15:28:11 +01:00
Alexander Aleksandrovič Klimov
000a776dfb
Built-in check command: ifw-api ( #9062 )
2023-07-06 14:18:21 +02:00
Julian Brost
af9d67b262
Merge pull request #9726 from Icinga/43624b
...
Remove -and notify- expired downtimes immediately, not every 60s II
2023-05-02 11:25:03 +02:00
Alexander A. Klimov
ba7102cae3
Explicitly stop started timers and wait for them
...
before permitting their parent objects' destruction.
For the cases where the handlers have raw pointers to these objects.
2023-04-14 14:52:04 +02:00
Alexander A. Klimov
21b68455ce
Use Timer::Create() instead of new Timer()
...
git ls-files -z |xargs -0 perl -pi -e 's/\bnew Timer\b/Timer::Create/g'
ex. in Timer::Create() itself.
2023-04-04 10:35:20 +02:00
Alexander A. Klimov
4c154f93dc
ApiListener#NewClientHandlerInternal(): on basic_socket#cancel() (due to timeout) don't ssl::stream#async_shutdown()
...
If a connection hangs for too long in ApiListener#NewClientHandler(),
ApiListener#AddConnection()'s Timeout calls boost::asio::basic_socket#cancel()
on that connection to trigger an exception which unwinds
ApiListener#NewClientHandler(). Previously that unwind could trigger a Defer
which called boost::asio::ssl::stream#async_shutdown() which extended the hang.
2023-03-21 10:57:40 +01:00
Julian Brost
c51037725a
Merge pull request #9466 from Icinga/flush-temp-files
...
Deduplicate and stabilize fragile filesystem transactions
2023-02-02 16:29:11 +01:00
Alexander A. Klimov
b92fe23469
Deduplicate and stabilize fragile filesystem transactions
...
by using AtomicFile so they ensure all or nothing of a file gets replaced.
2023-01-27 12:03:56 +01:00
Yonas Habteab
8bb0b857d8
ApiListener: Fix memory leak & group `a || b && c` correctly
2023-01-26 09:10:49 +01:00
Alexander A. Klimov
83021f8231
CONTEXT: use << everywhere to unify usages
2022-11-30 11:06:51 +01:00
Alexander A. Klimov
c9e4c016e0
Protect ApiListener#m_SSLContext with a mutex
2022-04-11 11:02:45 +02:00
Alexander A. Klimov
e490883577
Renew certificates also periodically
2022-04-11 11:02:39 +02:00
Alexander A. Klimov
3753f86c80
ApiListener#Start(): auto-renew own cert if CA owner
...
otherwise that particular cert would expire.
2022-04-04 12:13:31 +02:00
Alexander A. Klimov
6d470a3ca5
Introduce ApiListener#RenewCert()
2022-04-04 12:12:31 +02:00
Alexander A. Klimov
5f2e021390
Request certificate renewal also master2->master1
...
not only sat->master to prevent master2's certificate from expiring.
2022-03-29 16:47:23 +02:00
Alexander A. Klimov
3bf180a341
Fix typo
...
refs #8766
2021-10-08 10:27:35 +02:00
Alexander A. Klimov
80a1128ec7
Introduce SetupSslContext()
2021-07-22 11:12:33 +02:00
Alexander Aleksandrovič Klimov
692f5aa615
Merge pull request #8718 from Icinga/feature/tls-1.3
...
Support TLS 1.3
2021-06-29 17:52:55 +02:00
Julian Brost
0e7a05ad7a
Support TLS 1.3
2021-06-29 11:08:47 +02:00
Julian Brost
84d778580f
Add timeout for all new connections
...
This commit adds a timeout for both establishing new outgoing and incoming
connections. This timeout applies to everything until the connection is in a
state where either JsonRpcConnection or HttpServerConnection takes over.
2021-06-23 11:21:42 +02:00
Julian Brost
f346a9eea4
Merge pull request #8652 from Icinga/bugfix/l_appversionint-0-8628
...
l_AppVersionInt: respect versions like r2.12.0, not just v2.12.0
2021-06-07 16:07:04 +02:00
Alexander Aleksandrovič Klimov
ef8619f76b
Merge pull request #8601 from Icinga/feature/replace-std-boost-bind-with-lambdas-7006
...
Feature: Replace std/boost::bind() with lambdas
2021-03-18 17:56:13 +01:00
Yonas Habteab
43ba2da39c
Replace std/boost::bind() function with lambda expression
2021-03-10 16:29:40 +01:00
Alexander A. Klimov
1c5f69683f
l_AppVersionInt: respect versions like r2.12.0, not just v2.12.0
...
refs #8628
2021-02-25 15:31:07 +01:00
Alexander A. Klimov
c3388e9af6
Use std::mutex, not boost::mutex
2021-02-03 09:54:57 +01:00
Yonas Habteab
d27f533e5f
ApiListener: Update the ssl cont after each accepting incoming connection
2021-01-14 18:40:20 +01:00
Yonas Habteab
8eb4f2e062
ApiListener: Display log message if two nodes run on different versions
2020-12-16 16:09:28 +01:00
Alexander Aleksandrovič Klimov
bee4ac7f7c
Merge pull request #8040 from Icinga/feature/v1-actions-execute-command-8034
...
Add API endpoint: /v1/actions/execute-command
2020-12-02 10:53:24 +01:00
Alexander A. Klimov
1343fd538d
Start ApiListener#SyncClient() in the thread pool
...
... not hosting the coroutines not to block them.
Otherwise a large replay log would block messages sending
until the peer disconnects us.
2020-11-24 17:25:43 +01:00
Julian Brost
c154d4d50e
Merge pull request #8466 from Icinga/feature/one-connection
...
ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints
2020-11-24 16:33:15 +01:00
Julian Brost
cb476172ec
Fix cluster message routing for global zones
...
RelayMessageOne used to relay the message only to one other endpoint for
other zones, which is fine, as long as the target zone is a child/parent
zone but breaks if the target zone is a global one. In this case, the
message has to be forwarded within the local zone as well as to one node
in each child zone.
2020-11-09 15:43:43 +01:00
Alexander Aleksandrovič Klimov
1e281b060a
Merge pull request #7952 from Icinga/fix/SO_REUSEPORT-optional
...
apilistener: Make SO_REUSEPORT optional
2020-10-29 15:56:56 +01:00
Alexander A. Klimov
bb851b0558
Merge branch 'master' into feature/v1-actions-execute-command-8034
2020-10-28 18:37:08 +01:00
Alexander A. Klimov
38110e55d3
ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints
2020-10-26 15:20:58 +01:00
Alexander A. Klimov
40ac05c182
Introduce Endpoint#capabilities
...
refs #8034
2020-10-19 13:04:20 +02:00
Alexander A. Klimov
645dcbdc9e
Introduce Endpoint#icinga_version
...
... and set it to e.g. 21200 via icinga::Hello.
2020-07-07 18:24:06 +02:00
Alexander A. Klimov
647f1547a9
Generalize I/O timeout emulation
2020-06-17 10:31:40 +02:00
Markus Frosch
b5fa7569f2
apilistener: Make SO_REUSEPORT optional
2020-03-31 18:03:59 +02:00