From 6e32f4bc85df9b53af188c59a2f6de97b43908a9 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 4 Oct 2017 12:27:08 -0400 Subject: [PATCH] set nickname for destination --- libi2pd/Destination.cpp | 15 ++++++++++++--- libi2pd/Destination.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index b0e3365a..a2ba765b 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -23,8 +23,10 @@ namespace client int outQty = DEFAULT_OUTBOUND_TUNNELS_QUANTITY; int numTags = DEFAULT_TAGS_TO_SEND; std::shared_ptr > explicitPeers; - try { - if (params) { + try + { + if (params) + { auto it = params->find (I2CP_PARAM_INBOUND_TUNNEL_LENGTH); if (it != params->end ()) inLen = std::stoi(it->second); @@ -55,8 +57,15 @@ namespace client LogPrint (eLogInfo, "Destination: Added to explicit peers list: ", b64); } } + it = params->find (I2CP_PARAM_INBOUND_NICKNAME); + if (it != params->end ()) + m_Nickname = it->second; + else + m_Nickname = i2p::data::GetIdentHashAbbreviation (GetIdentHash ()); } - } catch (std::exception & ex) { + } + catch (std::exception & ex) + { LogPrint(eLogError, "Destination: unable to parse parameters for destination: ", ex.what()); } SetNumTags (numTags); diff --git a/libi2pd/Destination.h b/libi2pd/Destination.h index ef7437fb..b4c20fcc 100644 --- a/libi2pd/Destination.h +++ b/libi2pd/Destination.h @@ -50,6 +50,7 @@ namespace client const int STREAM_REQUEST_TIMEOUT = 60; //in seconds const char I2CP_PARAM_TAGS_TO_SEND[] = "crypto.tagsToSend"; const int DEFAULT_TAGS_TO_SEND = 40; + const char I2CP_PARAM_INBOUND_NICKNAME[] = "inbound.nickname"; // latency const char I2CP_PARAM_MIN_TUNNEL_LATENCY[] = "latency.min"; @@ -86,6 +87,7 @@ namespace client LeaseSetDestination (bool isPublic, const std::map * params = nullptr); ~LeaseSetDestination (); + const std::string& GetNickname () const { return m_Nickname; }; virtual bool Start (); virtual bool Stop (); @@ -153,6 +155,7 @@ namespace client boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer, m_PublishDelayTimer, m_CleanupTimer; + std::string m_Nickname; public: