|
|
|
@ -5,8 +5,10 @@
@@ -5,8 +5,10 @@
|
|
|
|
|
#include "NetDb.h" |
|
|
|
|
#include "Transports.h" |
|
|
|
|
#include "Config.h" |
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
#include "Event.h" |
|
|
|
|
#include "util.h" |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
using namespace i2p::data; |
|
|
|
|
|
|
|
|
@ -232,7 +234,9 @@ namespace transport
@@ -232,7 +234,9 @@ namespace transport
|
|
|
|
|
|
|
|
|
|
void Transports::SendMessages (const i2p::data::IdentHash& ident, const std::vector<std::shared_ptr<i2p::I2NPMessage> >& msgs) |
|
|
|
|
{ |
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
EmitEvent({{"type" , "transport.sendmsg"}, {"ident", ident.ToBase64()}, {"number", std::to_string(msgs.size())}}); |
|
|
|
|
#endif |
|
|
|
|
m_Service.post (std::bind (&Transports::PostMessages, this, ident, msgs)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -571,7 +575,9 @@ namespace transport
@@ -571,7 +575,9 @@ namespace transport
|
|
|
|
|
auto it = m_Peers.find (ident); |
|
|
|
|
if (it != m_Peers.end ()) |
|
|
|
|
{ |
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
EmitEvent({{"type" , "transport.connected"}, {"ident", ident.ToBase64()}, {"inbound", "false"}}); |
|
|
|
|
#endif |
|
|
|
|
bool sendDatabaseStore = true; |
|
|
|
|
if (it->second.delayedMessages.size () > 0) |
|
|
|
|
{ |
|
|
|
@ -597,7 +603,9 @@ namespace transport
@@ -597,7 +603,9 @@ namespace transport
|
|
|
|
|
session->Done(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
EmitEvent({{"type" , "transport.connected"}, {"ident", ident.ToBase64()}, {"inbound", "true"}}); |
|
|
|
|
#endif |
|
|
|
|
session->SendI2NPMessages ({ CreateDatabaseStoreMsg () }); // send DatabaseStore
|
|
|
|
|
std::unique_lock<std::mutex> l(m_PeersMutex); |
|
|
|
|
m_Peers.insert (std::make_pair (ident, Peer{ 0, nullptr, { session }, i2p::util::GetSecondsSinceEpoch (), {} })); |
|
|
|
@ -612,7 +620,9 @@ namespace transport
@@ -612,7 +620,9 @@ namespace transport
|
|
|
|
|
auto remoteIdentity = session->GetRemoteIdentity (); |
|
|
|
|
if (!remoteIdentity) return; |
|
|
|
|
auto ident = remoteIdentity->GetIdentHash (); |
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
EmitEvent({{"type" , "transport.disconnected"}, {"ident", ident.ToBase64()}}); |
|
|
|
|
#endif |
|
|
|
|
auto it = m_Peers.find (ident); |
|
|
|
|
if (it != m_Peers.end ()) |
|
|
|
|
{ |
|
|
|
|