diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index 759225118..5297e34b0 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -115,7 +115,7 @@ namespace llarp Endpoint::close_connection(RouterID _rid) { // assert(link_manager._router.loop()->inEventLoop()); - link_manager._router.loop()->call([this, rid = _rid](){ + link_manager._router.loop()->call([this, rid = _rid]() { // deletion from pending_conns, pending_conn_msg_queue, active_conns, etc is taken care // of by LinkManager::on_conn_closed if (auto itr = active_conns.find(rid); itr != active_conns.end()) @@ -233,35 +233,14 @@ namespace llarp logcat, "{} node was {} to confirm remote (RID:{}) is registered; allowing connection!", router().is_bootstrap_seed() ? "Bootstrap seed node" : "Service node", - other, - result ? "able" : "unable"); + result ? "able" : "unable", + other); return result; }); if (_router.is_service_node()) { - ep->listen( - tls_creds, - ROUTER_KEEP_ALIVE/* , - [&](oxen::quic::Connection& c, - oxen::quic::Endpoint& e, - std::optional id) -> std::shared_ptr { - if (id && *id == 0) - { - auto s = e.make_shared( - c, e, [](oxen::quic::Stream& s, uint64_t error_code) { - log::warning( - logcat, - "BTRequestStream closed unexpectedly (ec:{}); closing connection...", - error_code); - s.conn.close_connection(error_code); - }); - // register_commands(s); - return s; - } - - return e.make_shared(c, e); - } */); + ep->listen(tls_creds, ROUTER_KEEP_ALIVE); } return ep; } @@ -276,8 +255,9 @@ namespace llarp log::critical(logcat, "Queueing BTStream to be opened..."); - auto control_stream = ci.queue_stream([this, rid = rid](oxen::quic::Stream&, - uint64_t error_code) { + auto control_stream = ci.queue_stream([this, rid = rid]( + oxen::quic::Stream&, + uint64_t error_code) { log::warning( logcat, "BTRequestStream closed unexpectedly (ec:{}); closing connection...", error_code); ep.close_connection(rid); @@ -630,8 +610,12 @@ namespace llarp LinkManager::connect_to_random(int num_conns, bool client_only) { auto filter = [this, client_only](const RemoteRC& rc) -> bool { - return client_only ? not ep.have_client_conn(rc.router_id()) - : not ep.have_conn(rc.router_id()); + auto res = + client_only ? not ep.have_client_conn(rc.router_id()) : not ep.have_conn(rc.router_id()); + + log::critical(logcat, "RID:{} {}", rc.router_id(), res ? "ACCEPTED" : "REJECTED"); + + return res; }; if (auto maybe = node_db->get_n_random_rcs_conditional(num_conns, filter)) @@ -824,7 +808,7 @@ namespace llarp { // this handler should not be registered for service nodes assert(not _router.is_service_node()); - + send_control_message(source, "fetch_rcs", std::move(payload), std::move(func)); } diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index d2ddc81fb..39d9e8c05 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -992,7 +992,7 @@ namespace llarp bool NodeDB::verify_store_gossip_rc(const RemoteRC& rc) { - if (not router_whitelist.count(rc.router_id())) + if (not registered_routers().count(rc.router_id())) return put_rc_if_newer(rc); return false; diff --git a/llarp/nodedb.hpp b/llarp/nodedb.hpp index 455fd7eb2..3bff7be1f 100644 --- a/llarp/nodedb.hpp +++ b/llarp/nodedb.hpp @@ -45,7 +45,7 @@ namespace llarp inline constexpr size_t MIN_GOOD_RID_FETCH_TOTAL{}; // the ratio of accepted:rejected rids must be above this ratio inline constexpr double GOOD_RID_FETCH_THRESHOLD{}; - + /* Bootstrap Constants */ // the number of rc's we query the bootstrap for; service nodes pass 0, which means // gimme all dat RCs