Loop call fixes, libquic bump to latest fixes

pull/2232/head
dr7ana 5 months ago
parent 27f09f0b50
commit 62002c3666

@ -1 +1 @@
Subproject commit 28ae47f5bf5f59cd71a82979bbc96660ca70e8c4 Subproject commit 1634c58dd7f73c4fb2a921c44520d3f8a5e69581

@ -356,28 +356,33 @@ namespace llarp
assert(_is_service_node); assert(_is_service_node);
RouterID rid{ci.remote_key()}; RouterID rid{ci.remote_key()};
if (auto it = ep.service_conns.find(rid); it != ep.service_conns.end()) auto control = make_control(ci, rid);
{
log::critical(logcat, "Configuring inbound connection from relay RID:{}", rid);
it->second = _router.loop()->call(
std::make_shared<link::Connection>(ci.shared_from_this(), make_control(ci, rid)); [this, ci_ptr = ci.shared_from_this(), bstream = std::move(control), rid]() {
} if (auto it = ep.service_conns.find(rid); it != ep.service_conns.end())
else if (auto it = ep.client_conns.find(rid); it != ep.client_conns.end()) {
{ log::critical(logcat, "Configuring inbound connection from relay RID:{}", rid);
log::critical(logcat, "Configuring inbound connection from client RID:{}", rid);
it->second = std::make_shared<link::Connection>( it->second = std::make_shared<link::Connection>(ci_ptr, std::move(bstream));
ci.shared_from_this(), make_control(ci, rid), false); }
} else if (auto it = ep.client_conns.find(rid); it != ep.client_conns.end())
else {
{ log::critical(logcat, "Configuring inbound connection from client RID:{}", rid);
log::critical( it->second =
logcat, std::make_shared<link::Connection>(ci_ptr, std::move(bstream), false);
"ERROR: connection accepted from RID:{} that was not logged in key verification!", }
rid); else
} {
log::critical(
logcat,
"ERROR: connection accepted from RID:{} that was not logged in key "
"verification!",
rid);
}
log::critical(logcat, "Successfully configured inbound connection fom {}...", rid); log::critical(logcat, "Successfully configured inbound connection fom {}...", rid);
});
} }
void LinkManager::on_outbound_conn(oxen::quic::connection_interface& ci) void LinkManager::on_outbound_conn(oxen::quic::connection_interface& ci)
@ -401,28 +406,27 @@ namespace llarp
// TODO: should we add routes here now that Router::SessionOpen is gone? // TODO: should we add routes here now that Router::SessionOpen is gone?
void LinkManager::on_conn_open(oxen::quic::connection_interface& ci) void LinkManager::on_conn_open(oxen::quic::connection_interface& ci)
{ {
_router.loop()->call([this, &conn_interface = ci, is_snode = _is_service_node]() { const auto rid = RouterID{ci.remote_key()};
const auto rid = RouterID{conn_interface.remote_key()};
const auto& remote = conn_interface.remote();
log::critical( log::critical(
logcat, logcat,
"{} (RID:{}) ESTABLISHED CONNECTION TO RID:{}", "{} (RID:{}) ESTABLISHED CONNECTION TO RID:{}",
is_snode ? "SERVICE NODE" : "CLIENT", _is_service_node ? "SERVICE NODE" : "CLIENT",
_router.local_rid(), _router.local_rid(),
rid); rid);
if (conn_interface.is_inbound()) if (ci.is_inbound())
{ {
log::critical(logcat, "Inbound connection from {} (remote:{})", rid, remote); log::critical(logcat, "Inbound connection from {} (remote:{})", rid);
on_inbound_conn(conn_interface); on_inbound_conn(ci);
} }
else else
{ {
log::critical(logcat, "Outbound connection to {} (remote:{})", rid, remote); log::critical(logcat, "Outbound connection to {} (remote:{})", rid);
on_outbound_conn(conn_interface); on_outbound_conn(ci);
} }
}); // _router.loop()->call([this, &conn_interface = ci, is_snode = _is_service_node]() {
// });
}; };
void LinkManager::on_conn_closed(oxen::quic::connection_interface& ci, uint64_t ec) void LinkManager::on_conn_closed(oxen::quic::connection_interface& ci, uint64_t ec)
@ -752,26 +756,13 @@ namespace llarp
// TODO: can probably use ::send_control_message instead. Need to discuss the potential // TODO: can probably use ::send_control_message instead. Need to discuss the potential
// difference in calling Endpoint::get_service_conn vs Endpoint::get_conn // difference in calling Endpoint::get_service_conn vs Endpoint::get_conn
void LinkManager::fetch_bootstrap_rcs( void LinkManager::fetch_bootstrap_rcs(
const RemoteRC& source, const RemoteRC& source, std::string payload, std::function<void(oxen::quic::message m)> f)
std::string payload,
std::function<void(oxen::quic::message m)> func)
{ {
func = [this, f = std::move(func)](oxen::quic::message m) mutable { _router.loop()->call([this, source, payload, func = std::move(f)]() {
_router.loop()->call( const auto& rid = source.router_id();
[func = std::move(f), msg = std::move(m)]() mutable { func(std::move(msg)); });
};
const auto& rid = source.router_id(); log::critical(logcat, "Dispatching bootstrap fetch request!");
send_control_message(rid, "bfetch_rcs"s, std::move(payload), std::move(func));
if (auto conn = ep.get_service_conn(rid); conn)
{
conn->control_stream->command("bfetch_rcs"s, std::move(payload), std::move(func));
log::critical(logcat, "Dispatched bootstrap fetch request!");
return;
}
_router.loop()->call([this, source, payload, f = std::move(func), rid = rid]() mutable {
connect_and_send(rid, "bfetch_rcs"s, std::move(payload), std::move(f));
}); });
} }
@ -794,7 +785,8 @@ namespace llarp
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
log::critical(link_cat, "Exception handling RC Fetch request (body:{}): {}", m.body(), e.what()); log::critical(
link_cat, "Exception handling RC Fetch request (body:{}): {}", m.body(), e.what());
m.respond(messages::ERROR_RESPONSE, true); m.respond(messages::ERROR_RESPONSE, true);
return; return;
} }

@ -823,7 +823,6 @@ namespace llarp
return false; return false;
} }
// TESTNET: make this check an updated registry // TESTNET: make this check an updated registry
return known_rids.count(remote) or _registered_routers.count(remote); return known_rids.count(remote) or _registered_routers.count(remote);
} }

@ -134,7 +134,7 @@ namespace llarp
std::set<RemoteRC> known_rcs; std::set<RemoteRC> known_rcs;
std::set<Unconfirmed<RemoteRC>> unconfirmed_rcs; std::set<Unconfirmed<RemoteRC>> unconfirmed_rcs;
std::map<RouterID, const RemoteRC&> rc_lookup; std::map<RouterID, RemoteRC> rc_lookup;
BootstrapList _bootstraps{}; BootstrapList _bootstraps{};

Loading…
Cancel
Save