Refine messages to include peer info

pull/314/head
Nils Maier 2014-12-14 10:31:37 +01:00
parent 3c8704178a
commit 48bcb47a30
2 changed files with 18 additions and 4 deletions

View File

@ -45,6 +45,7 @@
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#include <sstream>
#include "message.h" #include "message.h"
#include "DlRetryEx.h" #include "DlRetryEx.h"
@ -885,12 +886,24 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)
break; break;
} }
std::stringstream ss;
if (!hostname.empty()) {
ss << hostname << " (";
}
std::pair<std::string, uint16_t> peer;
getPeerInfo(peer);
ss << peer.first << ":" << peer.second;
if (!hostname.empty()) {
ss << ")";
}
auto peerInfo = ss.str();
switch(ver) { switch(ver) {
case TLS_PROTO_NONE: case TLS_PROTO_NONE:
A2_LOG_WARN(MSG_WARN_UNKNOWN_TLS_CONNECTION); A2_LOG_WARN(fmt(MSG_WARN_UNKNOWN_TLS_CONNECTION, peerInfo.c_str()));
break; break;
case TLS_PROTO_SSL3: case TLS_PROTO_SSL3:
A2_LOG_WARN(fmt(MSG_WARN_OLD_TLS_CONNECTION, "SSLv3")); A2_LOG_WARN(fmt(MSG_WARN_OLD_TLS_CONNECTION, "SSLv3", peerInfo.c_str()));
break; break;
default: default:
break; break;

View File

@ -185,11 +185,12 @@
" See --ca-certificate and --check-certificate option.") " See --ca-certificate and --check-certificate option.")
#define MSG_WARN_UNKNOWN_TLS_CONNECTION \ #define MSG_WARN_UNKNOWN_TLS_CONNECTION \
_("aria2c had to connect to the other side using an unknown TLS protocol. " \ _("aria2c had to connect to the other side using an unknown TLS protocol. " \
"The integrity and confidentiality of the connection might be compromised.") "The integrity and confidentiality of the connection might be " \
"compromised.\nPeer: %s")
#define MSG_WARN_OLD_TLS_CONNECTION \ #define MSG_WARN_OLD_TLS_CONNECTION \
_("aria2c had to connect to the other side using an old and vulnerable TLS" \ _("aria2c had to connect to the other side using an old and vulnerable TLS" \
" protocol. The integrity and confidentiality of the connection might be" \ " protocol. The integrity and confidentiality of the connection might be" \
" compromised.\nProtocol: %s") " compromised.\nProtocol: %s, Peer: %s")
#define MSG_SHOW_FILES _("Printing the contents of file '%s'...") #define MSG_SHOW_FILES _("Printing the contents of file '%s'...")
#define MSG_NOT_TORRENT_METALINK _("This file is neither Torrent nor Metalink" \ #define MSG_NOT_TORRENT_METALINK _("This file is neither Torrent nor Metalink" \
" file. Skipping.") " file. Skipping.")