mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[#3082] addressed review comments
This commit is contained in:
@@ -7818,6 +7818,8 @@ operating system, i.e. the size of the ``sun_path`` field in the
|
||||
different operating systems, between 91 and 107 characters. Typical
|
||||
values are 107 on Linux and 103 on FreeBSD.
|
||||
|
||||
Kea supports only one ``unix`` control socket in the "control-sockets" list.
|
||||
|
||||
Communication over the control channel is conducted using JSON
|
||||
structures. See the
|
||||
`Control Channel section in the Kea Developer's Guide
|
||||
@@ -7914,6 +7916,9 @@ password, these values can be read from files. The syntax is extended by:
|
||||
- The ``user-file`` client parameter, which, with the ``directory`` parameter,
|
||||
specifies the path of a file where the user ID can be read.
|
||||
|
||||
Since Kea-2.7.6 Kea supports multiple HTTP/HTTPS connections.
|
||||
Both IPv4 and IPv6 addresses can be used.
|
||||
|
||||
When files are used, they are read when the configuration is loaded,
|
||||
to detect configuration errors as soon as possible.
|
||||
|
||||
@@ -7944,6 +7949,11 @@ to detect configuration errors as soon as possible.
|
||||
"password": "1234"
|
||||
} ]
|
||||
}
|
||||
},
|
||||
{
|
||||
"socket-type": "http",
|
||||
"socket-address": "2010:30:40::50",
|
||||
"socket-port": 8004
|
||||
}
|
||||
],
|
||||
|
||||
|
@@ -7618,6 +7618,8 @@ operating system, i.e. the size of the ``sun_path`` field in the
|
||||
different operating systems, between 91 and 107 characters. Typical
|
||||
values are 107 on Linux and 103 on FreeBSD.
|
||||
|
||||
Kea supports only one ``unix`` control socket in the "control-sockets" list.
|
||||
|
||||
Communication over the control channel is conducted using JSON
|
||||
structures. See the
|
||||
`Control Channel section in the Kea Developer's Guide
|
||||
@@ -7714,6 +7716,9 @@ password, these values can be read from files. The syntax is extended by:
|
||||
- The ``user-file`` client parameter, which, with the ``directory`` parameter,
|
||||
specifies the path of a file where the user ID can be read.
|
||||
|
||||
Since Kea-2.7.6 Kea supports multiple HTTP/HTTPS connections.
|
||||
Both IPv4 and IPv6 addresses can be used.
|
||||
|
||||
When files are used, they are read when the configuration is loaded,
|
||||
to detect configuration errors as soon as possible.
|
||||
|
||||
@@ -7744,6 +7749,11 @@ to detect configuration errors as soon as possible.
|
||||
"password": "1234"
|
||||
} ]
|
||||
}
|
||||
},
|
||||
{
|
||||
"socket-type": "http",
|
||||
"socket-address": "10.20.30.40",
|
||||
"socket-port": 8005
|
||||
}
|
||||
],
|
||||
|
||||
|
@@ -136,6 +136,7 @@ CtrlAgentProcess::configure(isc::data::ConstElementPtr config_set,
|
||||
|
||||
uint16_t server_port = ctx->getHttpPort();
|
||||
|
||||
// Search for the specific connection and reuse the existing one if found.
|
||||
auto it = sockets_.find(std::make_pair(server_address, server_port));
|
||||
if (it != sockets_.end()) {
|
||||
auto listener = getHttpListener();
|
||||
@@ -155,6 +156,8 @@ CtrlAgentProcess::configure(isc::data::ConstElementPtr config_set,
|
||||
return;
|
||||
}
|
||||
|
||||
// Connection not found so it needs to be created.
|
||||
// When TLS is enabled configure it.
|
||||
bool use_https = false;
|
||||
TlsContextPtr tls_context;
|
||||
if (!ctx->getCertFile().empty()) {
|
||||
|
@@ -15,6 +15,8 @@
|
||||
namespace isc {
|
||||
namespace agent {
|
||||
|
||||
/// @brief Structure used to store HTTP/HTTPS connection data.
|
||||
/// (configuration, listener, etc.)
|
||||
struct HttpSocketInfo {
|
||||
/// @brief Flag which indicates if socket can be reused.
|
||||
bool usable_;
|
||||
@@ -143,7 +145,7 @@ public:
|
||||
/// @return true if the process is listening.
|
||||
bool isListening() const;
|
||||
|
||||
/// @brief Close http control socket.
|
||||
/// @brief Close http control sockets.
|
||||
void closeCommandSockets();
|
||||
|
||||
private:
|
||||
@@ -154,7 +156,7 @@ private:
|
||||
/// @return Number of executed handlers.
|
||||
size_t runIO();
|
||||
|
||||
/// @brief The HTTP/HTTPS socket configurations.
|
||||
/// @brief The HTTP/HTTPS socket data (configuration, listener, etc.).
|
||||
std::map<std::pair<isc::asiolink::IOAddress, uint16_t>, HttpSocketInfoPtr> sockets_;
|
||||
};
|
||||
|
||||
|
@@ -164,13 +164,14 @@ This informational message indicates that the server has started
|
||||
HTTP/HTTPS service on the specified address and port for receiving
|
||||
control commands.
|
||||
|
||||
% HTTP_COMMAND_MGR_SERVICE_STOPPING stopping %1 service %2
|
||||
% HTTP_COMMAND_MGR_SERVICE_STOPPING Server is stopping %1 service %2
|
||||
This informational message indicates that the server has stopped
|
||||
HTTP/HTTPS service. When known the address and port are displayed.
|
||||
|
||||
% HTTP_COMMAND_MGR_SERVICE_STOPPING_NO_DATA stopping %1 service %2
|
||||
This informational message indicates that the server has stopped
|
||||
HTTP/HTTPS service. When known the address and port are displayed.
|
||||
% HTTP_COMMAND_MGR_SERVICE_STOPPING_NO_DATA Server is stopping all services including %1 service %2
|
||||
This informational message indicates that the server is stopping all
|
||||
HTTP/HTTPS services. When known the address and port are displayed for
|
||||
each service.
|
||||
|
||||
% HTTP_COMMAND_MGR_SERVICE_STOPPING_ALL stopping %1 service %2
|
||||
This informational message indicates that the server has stopped
|
||||
|
@@ -232,6 +232,8 @@ private:
|
||||
/// @brief Pointer to a HttpCommandConfig object.
|
||||
typedef boost::shared_ptr<HttpCommandConfig> HttpCommandConfigPtr;
|
||||
|
||||
/// @brief Structure used to store HTTP/HTTPS connection data.
|
||||
/// (configuration, listener, etc.)
|
||||
struct HttpSocketInfo {
|
||||
/// @brief Flag which indicates if socket can be reused.
|
||||
bool usable_;
|
||||
|
@@ -38,16 +38,19 @@ public:
|
||||
use_external_(true) {
|
||||
}
|
||||
|
||||
/// @brief Configure control socket from configuration.
|
||||
/// @brief Open http control sockets using configuration.
|
||||
///
|
||||
/// @param config Configuration of the control socket.
|
||||
void openCommandSocket(const isc::data::ConstElementPtr config);
|
||||
|
||||
/// @brief Configure control socket from configuration.
|
||||
///
|
||||
/// @param config Configuration of the control socket.
|
||||
/// @param config Configuration information for the http control sockets.
|
||||
void openCommandSockets(const isc::data::ConstElementPtr config);
|
||||
|
||||
/// @brief Open http control socket using configuration.
|
||||
///
|
||||
/// Creates http/https listener, or reuses the existing one reapplying
|
||||
/// changes.
|
||||
///
|
||||
/// @param config Configuration information for the http control socket.
|
||||
void openCommandSocket(const isc::data::ConstElementPtr config);
|
||||
|
||||
/// @brief Close control socket.
|
||||
///
|
||||
/// @param info Configuration information for the http control socket.
|
||||
@@ -74,7 +77,7 @@ public:
|
||||
/// @brief Idle connection timeout.
|
||||
long idle_timeout_;
|
||||
|
||||
/// @brief The HTTP/HTTPS socket configurations.
|
||||
/// @brief The HTTP/HTTPS socket data (configuration, listener, etc.).
|
||||
std::map<std::pair<IOAddress, uint16_t>, HttpSocketInfoPtr> sockets_;
|
||||
|
||||
/// @brief Use external sockets flag.
|
||||
@@ -117,6 +120,7 @@ HttpCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) {
|
||||
IOAddress server_address = cmd_config->getSocketAddress();
|
||||
uint16_t server_port = cmd_config->getSocketPort();
|
||||
|
||||
// Search for the specific connection and reuse the existing one if found.
|
||||
auto it = sockets_.find(std::make_pair(server_address, server_port));
|
||||
if (it != sockets_.end()) {
|
||||
if ((cmd_config->getTrustAnchor() != it->second->config_->getTrustAnchor()) ||
|
||||
@@ -133,6 +137,8 @@ HttpCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Connection not found so it needs to be created.
|
||||
// When TLS is enabled configure it.
|
||||
bool use_https = false;
|
||||
TlsContextPtr tls_context;
|
||||
if (!cmd_config->getCertFile().empty()) {
|
||||
|
@@ -54,12 +54,15 @@ public:
|
||||
/// @param use_external True (default) add external sockets.
|
||||
void addExternalSockets(bool use_external = true);
|
||||
|
||||
/// @brief Configure http control socket from configuration.
|
||||
/// @brief Open http control sockets using configuration.
|
||||
///
|
||||
/// @param config Configuration information for the http control socket.
|
||||
/// @param config Configuration information for the http control sockets.
|
||||
void openCommandSockets(const isc::data::ConstElementPtr config);
|
||||
|
||||
/// @brief Configure http control socket from configuration.
|
||||
/// @brief Open http control socket using configuration.
|
||||
///
|
||||
/// Creates http/https listener, or reuses the existing one reapplying
|
||||
/// changes.
|
||||
///
|
||||
/// @param config Configuration information for the http control socket.
|
||||
void openCommandSocket(const isc::data::ConstElementPtr config);
|
||||
@@ -70,7 +73,7 @@ public:
|
||||
/// @param remove When true remove the listeners immediately.
|
||||
void closeCommandSocket(HttpSocketInfoPtr info = HttpSocketInfoPtr(), bool remove = true);
|
||||
|
||||
/// @brief Close http control socket.
|
||||
/// @brief Close http control sockets.
|
||||
void closeCommandSockets();
|
||||
|
||||
/// @brief Returns a const pointer to the HTTP listener.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2021-2024 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
@@ -510,6 +510,8 @@ public:
|
||||
|
||||
/// @brief Opens acceptor service allowing the control clients to connect.
|
||||
///
|
||||
/// Creates acceptor, or reuses the existing one.
|
||||
///
|
||||
/// @param config Configuration information for the control socket.
|
||||
/// @throw BadSocketInfo When socket configuration is invalid.
|
||||
/// @throw SocketError When socket operation fails.
|
||||
@@ -544,7 +546,7 @@ public:
|
||||
/// @brief Pool of connections.
|
||||
ConnectionPool connection_pool_;
|
||||
|
||||
/// @brief The UNIX sockets.
|
||||
/// @brief The UNIX socket data (configuration, acceptor, etc.).
|
||||
std::map<std::string, UnixSocketInfoPtr> sockets_;
|
||||
|
||||
/// @brief Connection timeout.
|
||||
@@ -587,12 +589,14 @@ UnixCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) {
|
||||
|
||||
UnixCommandConfigPtr cmd_config(new UnixCommandConfig(config));
|
||||
|
||||
// Search for the specific connection and reuse the existing one if found.
|
||||
auto it = sockets_.find(cmd_config->getSocketName());
|
||||
if (it != sockets_.end()) {
|
||||
it->second->usable_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Connection not found so it needs to be created.
|
||||
// First let's open lock file.
|
||||
std::string lock_name = cmd_config->getLockName();
|
||||
int lock_fd = open(lock_name.c_str(), O_RDONLY | O_CREAT, 0600);
|
||||
|
@@ -71,6 +71,8 @@ public:
|
||||
/// @brief Opens unix control socket with parameters specified in socket_info
|
||||
/// (required parameters: socket-type: unix, socket-name:/unix/path).
|
||||
///
|
||||
/// Creates acceptor, or reuses the existing one.
|
||||
///
|
||||
/// @throw BadSocketInfo When socket configuration is invalid.
|
||||
/// @throw SocketError When socket operation fails.
|
||||
///
|
||||
|
Reference in New Issue
Block a user