diff --git a/include/llarp/aligned.hpp b/include/llarp/aligned.hpp index 470a1221c..25db87ee1 100644 --- a/include/llarp/aligned.hpp +++ b/include/llarp/aligned.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace llarp @@ -37,22 +38,19 @@ namespace llarp return buf.b[idx]; } - std::ostream& - operator<<(std::ostream& out) const + std::string + Hex() const { - char buf[(1 + sz) * 2] = {0}; - size_t idx = 0; - char* ptr = buf; - char* end = ptr + (sz * 2); + std::stringstream out; + std::string str; + size_t idx = 0; while(idx < sz) { - auto wrote = snprintf(ptr, end - ptr, "%.2x", buf.b[idx]); - if(wrote == -1) - break; - ++idx; - ptr += wrote; + out << std::hex << std::setw(2) << std::setfill('0') + << (int)buf.b[++idx]; } - return out << std::string(buf); + str = out.str(); + return str; } bool diff --git a/llarp/link_intro.cpp b/llarp/link_intro.cpp index 00cb12f0a..90e4f748f 100644 --- a/llarp/link_intro.cpp +++ b/llarp/link_intro.cpp @@ -69,7 +69,7 @@ namespace llarp bool LinkIntroMessage::HandleMessage(llarp_router* router) const { - llarp::Info(__FILE__, "got LIM from ", remote); + llarp::Info(__FILE__, "got LIM from ", remote.Hex()); return true; } } diff --git a/llarp/router.cpp b/llarp/router.cpp index ab5a83543..efbcddb97 100644 --- a/llarp/router.cpp +++ b/llarp/router.cpp @@ -63,7 +63,7 @@ llarp_router::SendToOrQueue(const llarp::RouterID &remote, if(!llarp_nodedb_find_rc(nodedb, &rc, k)) { - llarp::Warn(__FILE__, "cannot find router ", remote, + llarp::Warn(__FILE__, "cannot find router ", remote.Hex(), " locally so we are dropping ", msgs.size(), " messages to them");