summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2022-04-01 00:52:43 +0200
committerTomek Mrugalski <tomek@isc.org>2022-04-22 13:35:05 +0200
commitfa151329bff3d6e4af50a9f291b6f547f7a2b519 (patch)
treebf97981c62d78a3c63248c9d2a81a856a8f574f0 /src
parent[#687] Added the remote address in the json (diff)
downloadkea-fa151329bff3d6e4af50a9f291b6f547f7a2b519.tar.xz
kea-fa151329bff3d6e4af50a9f291b6f547f7a2b519.zip
[#687] Moved the setRemote location breaking many UTs
Diffstat (limited to 'src')
-rw-r--r--src/lib/cc/command_interpreter.cc6
-rw-r--r--src/lib/cc/command_interpreter.h5
-rw-r--r--src/lib/config/base_command_mgr.cc15
-rw-r--r--src/lib/config/config_messages.cc2
-rw-r--r--src/lib/config/config_messages.h1
-rw-r--r--src/lib/config/config_messages.mes7
-rw-r--r--src/lib/http/connection.cc13
7 files changed, 35 insertions, 14 deletions
diff --git a/src/lib/cc/command_interpreter.cc b/src/lib/cc/command_interpreter.cc
index 6ee57af37d..68f880cfc1 100644
--- a/src/lib/cc/command_interpreter.cc
+++ b/src/lib/cc/command_interpreter.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2009-2022 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
@@ -27,6 +27,7 @@ const char *CONTROL_RESULT = "result";
const char *CONTROL_TEXT = "text";
const char *CONTROL_ARGUMENTS = "arguments";
const char *CONTROL_SERVICE = "service";
+const char *CONTROL_REMOTE_ADDRESS = "remote-address";
// Full version, with status, text and arguments
ConstElementPtr
@@ -184,7 +185,8 @@ parseCommand(ConstElementPtr& arg, ConstElementPtr command) {
for (auto param : command_params) {
if ((param.first != CONTROL_COMMAND) &&
(param.first != CONTROL_ARGUMENTS) &&
- (param.first != CONTROL_SERVICE)) {
+ (param.first != CONTROL_SERVICE) &&
+ (param.first != CONTROL_REMOTE_ADDRESS)) {
isc_throw(CtrlChannelError, "Received command contains unsupported "
"parameter '" << param.first << "'");
}
diff --git a/src/lib/cc/command_interpreter.h b/src/lib/cc/command_interpreter.h
index f52d3fd171..2b5b1146b6 100644
--- a/src/lib/cc/command_interpreter.h
+++ b/src/lib/cc/command_interpreter.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2009-2022 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
@@ -35,6 +35,9 @@ extern const char *CONTROL_ARGUMENTS;
/// @brief String used for service list ("service")
extern const char *CONTROL_SERVICE;
+/// @brief String used for remote address ("remote-address")
+extern const char *CONTROL_REMOTE_ADDRESS;
+
/// @brief Status code indicating a successful operation
const int CONTROL_RESULT_SUCCESS = 0;
diff --git a/src/lib/config/base_command_mgr.cc b/src/lib/config/base_command_mgr.cc
index 62eac5264d..978a82f2f8 100644
--- a/src/lib/config/base_command_mgr.cc
+++ b/src/lib/config/base_command_mgr.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2022 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
@@ -121,8 +121,19 @@ BaseCommandMgr::processCommand(const isc::data::ConstElementPtr& cmd) {
try {
ConstElementPtr arg;
std::string name = parseCommand(arg, cmd);
+ ConstElementPtr remote = cmd->get(CONTROL_REMOTE_ADDRESS);
+ std::string remote_addr;
+ if (remote && (remote->getType() == Element::string)) {
+ remote_addr = remote->stringValue();
+ }
- LOG_INFO(command_logger, COMMAND_RECEIVED).arg(name);
+ if (remote_addr.empty()) {
+ LOG_INFO(command_logger, COMMAND_RECEIVED).arg(name);
+ } else {
+ LOG_INFO(command_logger, COMMAND_RECEIVED_FROM)
+ .arg(name)
+ .arg(remote_addr);
+ }
ConstElementPtr response = handleCommand(name, arg, cmd);
diff --git a/src/lib/config/config_messages.cc b/src/lib/config/config_messages.cc
index e4d7ce3825..254570c3f3 100644
--- a/src/lib/config/config_messages.cc
+++ b/src/lib/config/config_messages.cc
@@ -16,6 +16,7 @@ extern const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPING = "COMMAND_HTTP_
extern const isc::log::MessageID COMMAND_PROCESS_ERROR1 = "COMMAND_PROCESS_ERROR1";
extern const isc::log::MessageID COMMAND_PROCESS_ERROR2 = "COMMAND_PROCESS_ERROR2";
extern const isc::log::MessageID COMMAND_RECEIVED = "COMMAND_RECEIVED";
+extern const isc::log::MessageID COMMAND_RECEIVED_FROM = "COMMAND_RECEIVED_FROM";
extern const isc::log::MessageID COMMAND_REGISTERED = "COMMAND_REGISTERED";
extern const isc::log::MessageID COMMAND_RESPONSE_ERROR = "COMMAND_RESPONSE_ERROR";
extern const isc::log::MessageID COMMAND_SOCKET_ACCEPT_FAIL = "COMMAND_SOCKET_ACCEPT_FAIL";
@@ -49,6 +50,7 @@ const char* values[] = {
"COMMAND_PROCESS_ERROR1", "Error while processing command: %1",
"COMMAND_PROCESS_ERROR2", "Error while processing command: %1",
"COMMAND_RECEIVED", "Received command '%1'",
+ "COMMAND_RECEIVED_FROM", "Received command '%1' from %2",
"COMMAND_REGISTERED", "Command %1 registered",
"COMMAND_RESPONSE_ERROR", "Server failed to generate response for command: %1",
"COMMAND_SOCKET_ACCEPT_FAIL", "Failed to accept incoming connection on command socket %1: %2",
diff --git a/src/lib/config/config_messages.h b/src/lib/config/config_messages.h
index 06a88f5bb0..bb0f003602 100644
--- a/src/lib/config/config_messages.h
+++ b/src/lib/config/config_messages.h
@@ -17,6 +17,7 @@ extern const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPING;
extern const isc::log::MessageID COMMAND_PROCESS_ERROR1;
extern const isc::log::MessageID COMMAND_PROCESS_ERROR2;
extern const isc::log::MessageID COMMAND_RECEIVED;
+extern const isc::log::MessageID COMMAND_RECEIVED_FROM;
extern const isc::log::MessageID COMMAND_REGISTERED;
extern const isc::log::MessageID COMMAND_RESPONSE_ERROR;
extern const isc::log::MessageID COMMAND_SOCKET_ACCEPT_FAIL;
diff --git a/src/lib/config/config_messages.mes b/src/lib/config/config_messages.mes
index 8c66529483..90d4b7a69e 100644
--- a/src/lib/config/config_messages.mes
+++ b/src/lib/config/config_messages.mes
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2011-2022 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
@@ -55,6 +55,11 @@ This informational message indicates that a command was received over command
socket. The nature of this command and its possible results will be logged
with separate messages.
+% COMMAND_RECEIVED_FROM Received command '%1' from %2
+This informational message indicates that a command was received from HTTP.
+Only the command name and the remote address are displayed, other details
+will be logged with separate messages.
+
% COMMAND_REGISTERED Command %1 registered
This debug message indicates that the daemon started supporting specified
command. If the command socket is open, this command can now be issued.
diff --git a/src/lib/http/connection.cc b/src/lib/http/connection.cc
index ba0b8f7a20..b1e57bddbe 100644
--- a/src/lib/http/connection.cc
+++ b/src/lib/http/connection.cc
@@ -401,13 +401,11 @@ HttpConnection::socketReadCallback(HttpConnection::TransactionPtr transaction,
// Receiving is in progress, so push back the timeout.
setupRequestTimer(transaction);
- const std::string& remote = getRemoteEndpointAddressAsText();
-
if (length != 0) {
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_DETAIL_DATA,
HTTP_DATA_RECEIVED)
.arg(length)
- .arg(remote);
+ .arg(getRemoteEndpointAddressAsText());
transaction->getParser()->postBuffer(static_cast<void*>(transaction->getInputBufData()),
length);
@@ -422,7 +420,6 @@ HttpConnection::socketReadCallback(HttpConnection::TransactionPtr transaction,
} else {
try {
// The whole message has been received, so let's finalize it.
- transaction->getRequest()->setRemote(remote);
transaction->getRequest()->finalize();
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC,
@@ -431,18 +428,18 @@ HttpConnection::socketReadCallback(HttpConnection::TransactionPtr transaction,
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC_DATA,
HTTP_CLIENT_REQUEST_RECEIVED_DETAILS)
- .arg(remote)
+ .arg(getRemoteEndpointAddressAsText())
.arg(transaction->getParser()->getBufferAsString(MAX_LOGGED_MESSAGE_SIZE));
} catch (const std::exception& ex) {
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC,
HTTP_BAD_CLIENT_REQUEST_RECEIVED)
- .arg(remote)
+ .arg(getRemoteEndpointAddressAsText())
.arg(ex.what());
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC_DATA,
HTTP_BAD_CLIENT_REQUEST_RECEIVED_DETAILS)
- .arg(remote)
+ .arg(getRemoteEndpointAddressAsText())
.arg(transaction->getParser()->getBufferAsString(MAX_LOGGED_MESSAGE_SIZE));
}
@@ -455,7 +452,7 @@ HttpConnection::socketReadCallback(HttpConnection::TransactionPtr transaction,
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC,
HTTP_SERVER_RESPONSE_SEND)
.arg(response->toBriefString())
- .arg(remote);
+ .arg(getRemoteEndpointAddressAsText());
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC_DATA,
HTTP_SERVER_RESPONSE_SEND_DETAILS)