Skip to content

Commit

Permalink
set nickname for destination
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 4, 2017
1 parent 8460a8f commit 6e32f4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libi2pd/Destination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ namespace client
int outQty = DEFAULT_OUTBOUND_TUNNELS_QUANTITY;
int numTags = DEFAULT_TAGS_TO_SEND;
std::shared_ptr<std::vector<i2p::data::IdentHash> > 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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions libi2pd/Destination.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -86,6 +87,7 @@ namespace client

LeaseSetDestination (bool isPublic, const std::map<std::string, std::string> * params = nullptr);
~LeaseSetDestination ();
const std::string& GetNickname () const { return m_Nickname; };

virtual bool Start ();
virtual bool Stop ();
Expand Down Expand Up @@ -153,6 +155,7 @@ namespace client

boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer,
m_PublishDelayTimer, m_CleanupTimer;
std::string m_Nickname;

public:

Expand Down

0 comments on commit 6e32f4b

Please sign in to comment.