mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
handle stop command
This commit is contained in:
parent
0214ad69a6
commit
b2a6b6657f
43
BOB.cpp
43
BOB.cpp
@ -265,7 +265,19 @@ namespace client
|
||||
else
|
||||
SendReplyError ("failed to create tunnel");
|
||||
}
|
||||
|
||||
|
||||
void BOBCommandSession::StopCommandHandler (const char * operand, size_t len)
|
||||
{
|
||||
auto tunnel = m_Owner.FindTunnel (m_Nickname);
|
||||
if (tunnel)
|
||||
{
|
||||
tunnel->Stop ();
|
||||
SendReplyOK ("tunnel stopping");
|
||||
}
|
||||
else
|
||||
SendReplyError ("tunnel not found");
|
||||
}
|
||||
|
||||
void BOBCommandSession::SetNickCommandHandler (const char * operand, size_t len)
|
||||
{
|
||||
LogPrint (eLogDebug, "BOB: setnick");
|
||||
@ -275,6 +287,20 @@ namespace client
|
||||
SendReplyOK (msg.c_str ());
|
||||
}
|
||||
|
||||
void BOBCommandSession::GetNickCommandHandler (const char * operand, size_t len)
|
||||
{
|
||||
LogPrint (eLogDebug, "BOB: getnick");
|
||||
if (m_Owner.FindTunnel (operand))
|
||||
{
|
||||
m_Nickname = operand;
|
||||
std::string msg ("Nickname set to");
|
||||
msg += operand;
|
||||
SendReplyOK (msg.c_str ());
|
||||
}
|
||||
else
|
||||
SendReplyError ("tunnel not found");
|
||||
}
|
||||
|
||||
void BOBCommandSession::NewkeysCommandHandler (const char * operand, size_t len)
|
||||
{
|
||||
LogPrint (eLogDebug, "BOB: newkeys");
|
||||
@ -322,7 +348,9 @@ namespace client
|
||||
m_CommandHandlers[BOB_COMMAND_ZAP] = &BOBCommandSession::ZapCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_QUIT] = &BOBCommandSession::QuitCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_START] = &BOBCommandSession::StartCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_STOP] = &BOBCommandSession::StopCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_SETNICK] = &BOBCommandSession::SetNickCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_GETNICK] = &BOBCommandSession::GetNickCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_NEWKEYS] = &BOBCommandSession::NewkeysCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_OUTHOST] = &BOBCommandSession::OuthostCommandHandler;
|
||||
m_CommandHandlers[BOB_COMMAND_OUTPORT] = &BOBCommandSession::OutportCommandHandler;
|
||||
@ -333,6 +361,8 @@ namespace client
|
||||
BOBCommandChannel::~BOBCommandChannel ()
|
||||
{
|
||||
Stop ();
|
||||
for (auto it: m_Tunnels)
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
void BOBCommandChannel::Start ()
|
||||
@ -345,8 +375,7 @@ namespace client
|
||||
void BOBCommandChannel::Stop ()
|
||||
{
|
||||
for (auto it: m_Tunnels)
|
||||
delete it.second;
|
||||
m_Tunnels.clear ();
|
||||
it.second->Stop ();
|
||||
m_IsRunning = false;
|
||||
m_Service.stop ();
|
||||
if (m_Thread)
|
||||
@ -376,6 +405,14 @@ namespace client
|
||||
{
|
||||
m_Tunnels[name] = tunnel;
|
||||
}
|
||||
|
||||
I2PTunnel * BOBCommandChannel::FindTunnel (const std::string& name)
|
||||
{
|
||||
auto it = m_Tunnels.find (name);
|
||||
if (it != m_Tunnels.end ())
|
||||
return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BOBCommandChannel::Accept ()
|
||||
{
|
||||
|
7
BOB.h
7
BOB.h
@ -19,7 +19,9 @@ namespace client
|
||||
const char BOB_COMMAND_ZAP[] = "zap";
|
||||
const char BOB_COMMAND_QUIT[] = "quit";
|
||||
const char BOB_COMMAND_START[] = "start";
|
||||
const char BOB_COMMAND_SETNICK[] = "setnick";
|
||||
const char BOB_COMMAND_STOP[] = "stop";
|
||||
const char BOB_COMMAND_SETNICK[] = "setnick";
|
||||
const char BOB_COMMAND_GETNICK[] = "getnick";
|
||||
const char BOB_COMMAND_NEWKEYS[] = "newkeys";
|
||||
const char BOB_COMMAND_OUTHOST[] = "outhost";
|
||||
const char BOB_COMMAND_OUTPORT[] = "outport";
|
||||
@ -75,7 +77,9 @@ namespace client
|
||||
void ZapCommandHandler (const char * operand, size_t len);
|
||||
void QuitCommandHandler (const char * operand, size_t len);
|
||||
void StartCommandHandler (const char * operand, size_t len);
|
||||
void StopCommandHandler (const char * operand, size_t len);
|
||||
void SetNickCommandHandler (const char * operand, size_t len);
|
||||
void GetNickCommandHandler (const char * operand, size_t len);
|
||||
void NewkeysCommandHandler (const char * operand, size_t len);
|
||||
void OuthostCommandHandler (const char * operand, size_t len);
|
||||
void OutportCommandHandler (const char * operand, size_t len);
|
||||
@ -117,6 +121,7 @@ namespace client
|
||||
boost::asio::io_service& GetService () { return m_Service; };
|
||||
std::map<std::string, BOBCommandHandler>& GetCommandHandlers () { return m_CommandHandlers; };
|
||||
void AddTunnel (const std::string& name, I2PTunnel * tunnel);
|
||||
I2PTunnel * FindTunnel (const std::string& name);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user