]> granicus.if.org Git - icinga2/commitdiff
Include IP address and port in the "New connection" log message
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 25 Jul 2016 07:31:38 +0000 (09:31 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 25 Jul 2016 07:31:38 +0000 (09:31 +0200)
fixes #12215

lib/remote/apilistener.cpp

index de2a4f7a91479906d48897c18176d3c95bb42d46..cb866979339d0e276748df1a3f6d4c7513b30874 100644 (file)
@@ -330,6 +330,15 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
        Endpoint::Ptr endpoint;
        bool verify_ok = false;
 
+       String conninfo;
+
+       if (role == RoleClient)
+               conninfo = "to";
+       else
+               conninfo = "from";
+
+       conninfo += " " + client->GetPeerAddress();
+
        if (cert) {
                try {
                        identity = GetCertificateCN(cert);
@@ -360,7 +369,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
                {
                        Log log(LogInformation, "ApiListener");
 
-                       log << "New client connection for identity '" << identity << "'";
+                       log << "New client connection for identity '" << identity << "' " << conninfo;
 
                        if (!verify_ok)
                                log << " (certificate validation failed: " << tlsStream->GetVerifyError() << ")";
@@ -369,7 +378,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
                }
        } else {
                Log(LogInformation, "ApiListener")
-                   << "New client connection (no client certificate)";
+                   << "New client connection " << conninfo << " (no client certificate)";
        }
 
        ClientType ctype;