mirror of https://github.com/oxen-io/lokinet
Compare commits
3 Commits
d6e5aca572
...
575494c3da
Author | SHA1 | Date |
---|---|---|
dr7ana | 575494c3da | |
dr7ana | 2c3763b61c | |
dr7ana | 08c2c26c29 |
|
@ -1 +1 @@
|
|||
Subproject commit 0e431b912eb4bf76a9219861afc06cd8ceafa781
|
||||
Subproject commit 0060e9b9fa1d8fc75ad882d1764e032f65d19cdc
|
|
@ -123,12 +123,9 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
LinkManager::register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s)
|
||||
LinkManager::register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s, const RouterID& router_id)
|
||||
{
|
||||
log::critical(logcat, "{} called", __PRETTY_FUNCTION__);
|
||||
const RouterID& router_id {s->conn.remote_key()};
|
||||
|
||||
log::critical(logcat, "Registering commands (RID:{})", router_id);
|
||||
|
||||
s->register_command("bfetch_rcs"s, [this](oxen::quic::message m) {
|
||||
_router.loop()->call(
|
||||
|
@ -209,7 +206,7 @@ namespace llarp
|
|||
|
||||
if (_router.is_bootstrap_seed())
|
||||
{
|
||||
// FIXME: remove "|| true", this is just for local testing!
|
||||
// FIXME: remove "|| true", this is just for local testing!
|
||||
if (node_db->whitelist().count(other) || true)
|
||||
{
|
||||
log::critical(logcat, "Saving bootstrap seed requester...");
|
||||
|
@ -218,8 +215,10 @@ namespace llarp
|
|||
}
|
||||
log::critical(
|
||||
logcat,
|
||||
"Bootstrap seed node was {} to confirm fetch requester is white-listed; {}successfully saved RID",
|
||||
result ? "able" : "unable", result ? "" : "un");
|
||||
"Bootstrap seed node was {} to confirm fetch requester is white-listed; {}successfully "
|
||||
"saved RID",
|
||||
result ? "able" : "unable",
|
||||
result ? "" : "un");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -236,7 +235,6 @@ namespace llarp
|
|||
[&](oxen::quic::Connection& c,
|
||||
oxen::quic::Endpoint& e,
|
||||
std::optional<int64_t> id) -> std::shared_ptr<oxen::quic::Stream> {
|
||||
|
||||
if (id && *id == 0)
|
||||
{
|
||||
log::critical(logcat, "Stream constructor constructing BTStream (ID:{})", id);
|
||||
|
@ -248,7 +246,7 @@ namespace llarp
|
|||
error_code);
|
||||
s.conn.close_connection(error_code);
|
||||
});
|
||||
register_commands(s);
|
||||
// register_commands(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -279,7 +277,7 @@ namespace llarp
|
|||
|
||||
log::critical(logcat, "Queued BTStream to be opened ID:{}", control_stream->stream_id());
|
||||
assert(control_stream->stream_id() == 0);
|
||||
// register_commands(control_stream);
|
||||
register_commands(control_stream, rid);
|
||||
|
||||
itr->second = std::make_shared<link::Connection>(ci.shared_from_this(), control_stream);
|
||||
log::critical(logcat, "Successfully configured inbound connection fom {}...", rid);
|
||||
|
@ -368,6 +366,9 @@ namespace llarp
|
|||
if (auto p_itr = pending_conn_msg_queue.find(rid); p_itr != pending_conn_msg_queue.end())
|
||||
pending_conn_msg_queue.erase(p_itr);
|
||||
|
||||
if (auto c_itr = ep.pending_conns.find(rid); c_itr != ep.pending_conns.end())
|
||||
ep.pending_conns.erase(c_itr);
|
||||
|
||||
if (auto m_itr = ep.active_conns.find(rid); m_itr != ep.active_conns.end())
|
||||
ep.active_conns.erase(m_itr);
|
||||
|
||||
|
@ -378,7 +379,6 @@ namespace llarp
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LinkManager::send_control_message(
|
||||
const RouterID& remote,
|
||||
|
@ -421,23 +421,24 @@ namespace llarp
|
|||
body = std::move(body),
|
||||
f = std::move(func)]() {
|
||||
auto pending = PendingMessage(std::move(body), std::move(endpoint), std::move(f));
|
||||
|
||||
|
||||
if (auto it1 = ep.pending_conns.find(remote); it1 != ep.pending_conns.end())
|
||||
{
|
||||
if (auto it2 = pending_conn_msg_queue.find(remote); it2 != pending_conn_msg_queue.end())
|
||||
{
|
||||
it2->second.push_back(std::move(pending));
|
||||
log::critical(logcat, "Connection (RID:{}) is pending; message appended to send queue!", remote);
|
||||
log::critical(
|
||||
logcat, "Connection (RID:{}) is pending; message appended to send queue!", remote);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log::critical(logcat, "Connection (RID:{}) not found in pending conns; creating send queue!", remote);
|
||||
log::critical(
|
||||
logcat, "Connection (RID:{}) not found in pending conns; creating send queue!", remote);
|
||||
auto [itr, b] = pending_conn_msg_queue.emplace(remote, MessageQueue());
|
||||
itr->second.push_back(std::move(pending));
|
||||
connect_to(remote);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
|
@ -713,7 +714,7 @@ namespace llarp
|
|||
oxenc::bt_dict_consumer btdc{m.body()};
|
||||
btdc.required("local");
|
||||
auto rc_dict = btdc.consume_dict_data();
|
||||
log::critical(logcat, "incoming dict data: {}", oxenc::to_hex(rc_dict));
|
||||
// log::critical(logcat, "incoming dict data: {}", oxenc::to_hex(rc_dict));
|
||||
remote = RemoteRC{rc_dict};
|
||||
quantity = btdc.require<size_t>("quantity");
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ namespace llarp
|
|||
startup_endpoint();
|
||||
|
||||
void
|
||||
register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s);
|
||||
register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s, const RouterID& rid);
|
||||
|
||||
public:
|
||||
const link::Endpoint&
|
||||
|
@ -416,7 +416,7 @@ namespace llarp
|
|||
s.conn.close_connection(error_code);
|
||||
});
|
||||
|
||||
link_manager.register_commands(control_stream);
|
||||
link_manager.register_commands(control_stream, rid);
|
||||
itr->second = std::make_shared<link::Connection>(conn_interface, control_stream);
|
||||
|
||||
log::critical(logcat, "Connection to RID:{} added to pending connections...", rid);
|
||||
|
|
|
@ -339,9 +339,11 @@ namespace llarp
|
|||
void
|
||||
NodeDB::fetch_initial()
|
||||
{
|
||||
if (known_rids.empty())
|
||||
auto sz = num_rcs();
|
||||
|
||||
if (num_rcs() < MIN_ACTIVE_RCS)
|
||||
{
|
||||
log::critical(logcat, "No RouterID's held locally... BOOTSTRAP TIME");
|
||||
log::critical(logcat, "{}/{} RCs held locally... BOOTSTRAP TIME", sz, MIN_ACTIVE_RCS);
|
||||
fallback_to_bootstrap();
|
||||
}
|
||||
else
|
||||
|
@ -728,7 +730,12 @@ namespace llarp
|
|||
|
||||
// const auto& num = rids.size();
|
||||
|
||||
log::critical(logcat, "BootstrapRC fetch response from {} returned {}/{} needed RCs", fetch_source, num, BOOTSTRAP_SOURCE_COUNT);
|
||||
log::critical(
|
||||
logcat,
|
||||
"BootstrapRC fetch response from {} returned {}/{} needed RCs",
|
||||
fetch_source,
|
||||
num,
|
||||
BOOTSTRAP_SOURCE_COUNT);
|
||||
// known_rids.merge(rids);
|
||||
fetch_initial();
|
||||
|
||||
|
@ -964,6 +971,9 @@ namespace llarp
|
|||
{
|
||||
const auto& rid = rc.router_id();
|
||||
|
||||
if (rid == _router.local_rid())
|
||||
return false;
|
||||
|
||||
known_rcs.erase(rc);
|
||||
rc_lookup.erase(rid);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace llarp
|
|||
struct Router;
|
||||
|
||||
/* RC Fetch Constants */
|
||||
inline constexpr size_t MIN_ACTIVE_RCS{6};
|
||||
// max number of attempts we make in non-bootstrap fetch requests
|
||||
inline constexpr int MAX_FETCH_ATTEMPTS{10};
|
||||
// the total number of returned rcs that are held locally should be at least this
|
||||
|
|
|
@ -776,7 +776,7 @@ namespace llarp
|
|||
|
||||
if (is_service_node())
|
||||
{
|
||||
log::critical(
|
||||
log::info(
|
||||
logcat,
|
||||
"Local service node has {} client connections since last RC update ({} to expiry)",
|
||||
num_client_connections(),
|
||||
|
@ -911,11 +911,12 @@ namespace llarp
|
|||
// (client-only) periodically fetch updated RCs
|
||||
if (now_timepoint - last_rc_fetch > RC_UPDATE_INTERVAL)
|
||||
{
|
||||
log::critical(logcat, "Time to fetch RCs!");
|
||||
node_db()->fetch_rcs();
|
||||
}
|
||||
|
||||
// (client-only) periodically fetch updated RouterID list
|
||||
if (now_timepoint - last_rid_fetch > ROUTERID_UPDATE_INTERVAL)
|
||||
if (not is_snode and now_timepoint - last_rid_fetch > ROUTERID_UPDATE_INTERVAL)
|
||||
{
|
||||
node_db()->fetch_rids();
|
||||
}
|
||||
|
@ -1139,7 +1140,7 @@ namespace llarp
|
|||
|
||||
log::info(logcat, "Loading NodeDB from disk...");
|
||||
_node_db->load_from_disk();
|
||||
// _node_db->store_bootstraps();
|
||||
_node_db->store_bootstraps();
|
||||
|
||||
oxen::log::flush();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace llarp
|
|||
static constexpr size_t INTROSET_STORAGE_REDUNDANCY =
|
||||
(INTROSET_RELAY_REDUNDANCY * INTROSET_REQS_PER_RELAY);
|
||||
|
||||
static const std::chrono::seconds RC_UPDATE_INTERVAL = 5min;
|
||||
static const std::chrono::seconds RC_UPDATE_INTERVAL = 4min;
|
||||
static const std::chrono::seconds ROUTERID_UPDATE_INTERVAL = 1h;
|
||||
|
||||
struct Contacts;
|
||||
|
@ -105,7 +105,6 @@ namespace llarp
|
|||
std::shared_ptr<NodeDB> _node_db;
|
||||
llarp_time_t _started_at;
|
||||
const oxenmq::TaggedThreadID _disk_thread;
|
||||
// oxen::quic::Network _net; // DISCUSS: we don't use this anywhere..?
|
||||
|
||||
llarp_time_t _last_stats_report = 0s;
|
||||
llarp_time_t _next_decomm_warning = time_now_ms() + 15s;
|
||||
|
@ -158,6 +157,12 @@ namespace llarp
|
|||
std::chrono::system_clock::time_point next_bootstrap_attempt{last_rc_gossip};
|
||||
|
||||
public:
|
||||
bool
|
||||
testnet() const
|
||||
{
|
||||
return _testnet;
|
||||
}
|
||||
|
||||
bool
|
||||
is_bootstrap_seed() const
|
||||
{
|
||||
|
|
|
@ -46,13 +46,6 @@ namespace llarp
|
|||
throw std::runtime_error{err};
|
||||
}
|
||||
|
||||
log::error(
|
||||
log::Cat("FIXME"),
|
||||
"ABOUT TO VERIFY THIS: {}, WITH SIG {}, SIGNED BY {}",
|
||||
oxenc::to_hex(msg),
|
||||
oxenc::to_hex(sig),
|
||||
router_id().ToHex());
|
||||
|
||||
if (not crypto::verify(router_id(), msg, sig))
|
||||
throw std::runtime_error{"Failed to verify RemoteRC signature"};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue