]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#687] Moved the setRemote location breaking many UTs
authorFrancis Dupont <fdupont@isc.org>
Thu, 31 Mar 2022 22:52:43 +0000 (00:52 +0200)
committerTomek Mrugalski <tomek@isc.org>
Fri, 22 Apr 2022 11:35:42 +0000 (13:35 +0200)
src/lib/config/base_command_mgr.cc
src/lib/config/config_messages.cc
src/lib/config/config_messages.h
src/lib/config/config_messages.mes
src/lib/http/connection.cc

index 62eac5264dbc9d0dcd8884fc593d95df68690e0b..978a82f2f86bc7bfb96dfe8446615342b9df5c61 100644 (file)
@@ -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);
 
index e4d7ce3825245ae763bb75aa7d5ffb0f9abbfd21..254570c3f3671e4d6ba86c30b7347a755afed0dc 100644 (file)
@@ -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",
index 06a88f5bb06ea3776a9bd207edaccd4b2dd2f1ec..bb0f0036029778ddffeeae370835f4d4bd9bffef 100644 (file)
@@ -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;
index 8c66529483d0110b70b3a90ec509b53b666867ea..90d4b7a69e75e9afc02874a8042660e899b996af 100644 (file)
@@ -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.
index ba0b8f7a2019eb1626c94966ede2b3eed3ea2d89..b1e57bddbebb0ca37f683efedf81c80945fa2304 100644 (file)
@@ -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)