mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
Merge pull request #1374 from rszibele/openssl
BOB: fix status command.
This commit is contained in:
commit
e9fa4e94a6
@ -341,10 +341,10 @@ namespace client
|
|||||||
SendReplyOK();
|
SendReplyOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOBCommandSession::SendData (const char * data)
|
void BOBCommandSession::SendRaw (const char * data)
|
||||||
{
|
{
|
||||||
std::ostream os(&m_SendBuffer);
|
std::ostream os(&m_SendBuffer);
|
||||||
os << "DATA " << data << std::endl;
|
os << data << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOBCommandSession::BuildStatusLine(bool currentTunnel, BOBDestination *dest, std::string &out)
|
void BOBCommandSession::BuildStatusLine(bool currentTunnel, BOBDestination *dest, std::string &out)
|
||||||
@ -370,7 +370,8 @@ namespace client
|
|||||||
|
|
||||||
// build line
|
// build line
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "NICKNAME: " << nickname << " " << "STARTING: " << bool_str(starting) << " "
|
ss << "DATA "
|
||||||
|
<< "NICKNAME: " << nickname << " " << "STARTING: " << bool_str(starting) << " "
|
||||||
<< "RUNNING: " << bool_str(running) << " " << "STOPPING: " << bool_str(stopping) << " "
|
<< "RUNNING: " << bool_str(running) << " " << "STOPPING: " << bool_str(stopping) << " "
|
||||||
<< "KEYS: " << bool_str(keys) << " " << "QUIET: " << bool_str(quiet) << " "
|
<< "KEYS: " << bool_str(keys) << " " << "QUIET: " << bool_str(quiet) << " "
|
||||||
<< "INPORT: " << inport << " " << "INHOST: " << inhost << " "
|
<< "INPORT: " << inport << " " << "INHOST: " << inhost << " "
|
||||||
@ -654,16 +655,16 @@ namespace client
|
|||||||
for (const auto& it: destinations)
|
for (const auto& it: destinations)
|
||||||
{
|
{
|
||||||
BuildStatusLine(false, it.second, statusLine);
|
BuildStatusLine(false, it.second, statusLine);
|
||||||
SendData (statusLine.c_str());
|
SendRaw(statusLine.c_str());
|
||||||
if(m_Nickname.compare(it.second->GetNickname()) == 0)
|
if(m_Nickname.compare(it.second->GetNickname()) == 0)
|
||||||
sentCurrent = true;
|
sentCurrent = true;
|
||||||
}
|
}
|
||||||
if(!sentCurrent && !m_Nickname.empty())
|
if(!sentCurrent && !m_Nickname.empty())
|
||||||
{
|
{
|
||||||
// add the current tunnel to the list
|
// add the current tunnel to the list.
|
||||||
|
// this is for the incomplete tunnel which has not been started yet.
|
||||||
BuildStatusLine(true, m_CurrentDestination, statusLine);
|
BuildStatusLine(true, m_CurrentDestination, statusLine);
|
||||||
LogPrint(eLogError, statusLine);
|
SendRaw(statusLine.c_str());
|
||||||
SendData(statusLine.c_str());
|
|
||||||
}
|
}
|
||||||
SendReplyOK ("Listing done");
|
SendReplyOK ("Listing done");
|
||||||
}
|
}
|
||||||
@ -690,21 +691,23 @@ namespace client
|
|||||||
void BOBCommandSession::StatusCommandHandler (const char * operand, size_t len)
|
void BOBCommandSession::StatusCommandHandler (const char * operand, size_t len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "BOB: status ", operand);
|
LogPrint (eLogDebug, "BOB: status ", operand);
|
||||||
|
const std::string name = operand;
|
||||||
std::string statusLine;
|
std::string statusLine;
|
||||||
if (m_Nickname == operand)
|
|
||||||
|
// always prefer destination
|
||||||
|
auto ptr = m_Owner.FindDestination(name);
|
||||||
|
if(ptr != nullptr)
|
||||||
{
|
{
|
||||||
// check current tunnel
|
// tunnel destination exists
|
||||||
BuildStatusLine(true, nullptr, statusLine);
|
BuildStatusLine(false, ptr, statusLine);
|
||||||
SendReplyOK(statusLine.c_str());
|
SendReplyOK(statusLine.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check other
|
if(m_Nickname == name && !name.empty())
|
||||||
std::string name = operand;
|
|
||||||
auto ptr = m_Owner.FindDestination(name);
|
|
||||||
if(ptr != nullptr)
|
|
||||||
{
|
{
|
||||||
BuildStatusLine(false, ptr, statusLine);
|
// tunnel is incomplete / has not been started yet
|
||||||
|
BuildStatusLine(true, nullptr, statusLine);
|
||||||
SendReplyOK(statusLine.c_str());
|
SendReplyOK(statusLine.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -213,7 +213,7 @@ namespace client
|
|||||||
void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
||||||
void SendReplyOK (const char * msg = nullptr);
|
void SendReplyOK (const char * msg = nullptr);
|
||||||
void SendReplyError (const char * msg);
|
void SendReplyError (const char * msg);
|
||||||
void SendData (const char * data);
|
void SendRaw (const char * data);
|
||||||
|
|
||||||
void BuildStatusLine(bool currentTunnel, BOBDestination *destination, std::string &out);
|
void BuildStatusLine(bool currentTunnel, BOBDestination *destination, std::string &out);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user