|
|
|
@ -472,64 +472,5 @@ namespace garlic
@@ -472,64 +472,5 @@ namespace garlic
|
|
|
|
|
} |
|
|
|
|
DeleteI2NPMessage (msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GarlicRouting routing; |
|
|
|
|
|
|
|
|
|
void GarlicRouting::HandleGarlicMessage (I2NPMessage * msg) |
|
|
|
|
{ |
|
|
|
|
auto pool = msg->from ? msg->from->GetTunnelPool () : nullptr; |
|
|
|
|
if (pool) |
|
|
|
|
pool->GetGarlicDestination ().HandleGarlicMessage (msg); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
LogPrint ("Local destination doesn't exist"); |
|
|
|
|
DeleteI2NPMessage (msg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GarlicRouting::Start () |
|
|
|
|
{ |
|
|
|
|
m_IsRunning = true; |
|
|
|
|
m_Thread = new std::thread (std::bind (&GarlicRouting::Run, this)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GarlicRouting::Stop () |
|
|
|
|
{ |
|
|
|
|
m_IsRunning = false; |
|
|
|
|
m_Queue.WakeUp (); |
|
|
|
|
if (m_Thread) |
|
|
|
|
{ |
|
|
|
|
m_Thread->join (); |
|
|
|
|
delete m_Thread; |
|
|
|
|
m_Thread = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GarlicRouting::PostI2NPMsg (I2NPMessage * msg) |
|
|
|
|
{ |
|
|
|
|
if (msg) m_Queue.Put (msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GarlicRouting::Run () |
|
|
|
|
{ |
|
|
|
|
while (m_IsRunning) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
I2NPMessage * msg = m_Queue.GetNext (); |
|
|
|
|
if (msg->GetHeader ()->typeID == eI2NPGarlic) |
|
|
|
|
HandleGarlicMessage (msg); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
LogPrint ("Garlic: unexpected message type ", msg->GetHeader ()->typeID); |
|
|
|
|
i2p::HandleI2NPMessage (msg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (std::exception& ex) |
|
|
|
|
{ |
|
|
|
|
LogPrint ("GarlicRouting: ", ex.what ()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|