RouterHive ConnectionAttemptEvent

pull/1312/head
Stephen Shelton 4 years ago
parent d69d538f1a
commit d1b629f494
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -1,5 +1,7 @@
#include <router/outbound_session_maker.hpp>
#include <router/abstractrouter.hpp>
#include <tooling/peer_stats_event.hpp>
#include <link/server.hpp>
#include <router_contact.hpp>
#include <nodedb.hpp>
@ -152,6 +154,7 @@ namespace llarp
void
OutboundSessionMaker::Init(
AbstractRouter* router,
ILinkManager* linkManager,
I_RCLookupHandler* rcLookup,
Profiling* profiler,
@ -159,6 +162,7 @@ namespace llarp
llarp_nodedb* nodedb,
WorkerFunc_t dowork)
{
_router = router;
_linkManager = linkManager;
_rcLookup = rcLookup;
_logic = logic;
@ -298,8 +302,18 @@ namespace llarp
void
OutboundSessionMaker::CreatePendingSession(const RouterID& router)
{
util::Lock l(_mutex);
pendingSessions.emplace(router, nullptr);
{
util::Lock l(_mutex);
pendingSessions.emplace(router, nullptr);
}
auto peerDb = _router->peerDb();
if (peerDb)
{
peerDb->modifyPeerStats(router, [](PeerStats& stats) { stats.numConnectionAttempts++; });
}
_router->NotifyRouterEvent<tooling::ConnectionAttemptEvent>(_router->pubkey(), router);
}
void

@ -58,6 +58,7 @@ namespace llarp
void
Init(
AbstractRouter* router,
ILinkManager* linkManager,
I_RCLookupHandler* rcLookup,
Profiling* profiler,
@ -110,6 +111,7 @@ namespace llarp
std::unordered_map<RouterID, CallbacksQueue, RouterID::Hash> pendingCallbacks
GUARDED_BY(_mutex);
AbstractRouter* _router = nullptr;
ILinkManager* _linkManager = nullptr;
I_RCLookupHandler* _rcLookup = nullptr;
Profiling* _profiler = nullptr;

@ -523,6 +523,7 @@ namespace llarp
// Init components after relevant config settings loaded
_outboundMessageHandler.Init(&_linkManager, _logic);
_outboundSessionMaker.Init(
this,
&_linkManager,
&_rcLookupHandler,
&_routerProfiling,

@ -78,6 +78,9 @@ namespace tooling
py::class_<LinkSessionEstablishedEvent, RouterEvent>(mod, "LinkSessionEstablishedEvent")
.def_readonly("remoteId", &LinkSessionEstablishedEvent::remoteId)
.def_readonly("inbound", &LinkSessionEstablishedEvent::inbound);
py::class_<ConnectionAttemptEvent, RouterEvent>(mod, "ConnectionAttemptEvent")
.def_readonly("remoteId", &ConnectionAttemptEvent::remoteId);
}
} // namespace tooling

@ -2,7 +2,7 @@ import pyllarp
from time import time
def test_peer_stats(HiveForPeerStats):
hive = HiveForPeerStats(n_relays=5, n_clients=0, netid="hive")
hive = HiveForPeerStats(n_relays=12, n_clients=0, netid="hive")
start_time = time()
cur_time = start_time

Loading…
Cancel
Save