compile fixes (except for consteval fmt::format oddities

pull/2212/head
dr7ana 6 months ago
parent d0203b3dec
commit b037c04285

@ -37,7 +37,7 @@ namespace llarp
}
explicit RemoteAddress(PubKey pk, std::string_view tld, std::optional<std::string> n = std::nullopt)
: _pubkey{std::move(pk)}, _name{std::move(n)}, _tld{tld}
: _pubkey{pk.data()}, _name{std::move(n)}, _tld{tld}
{}
RemoteAddress(const RemoteAddress& other) : RemoteAddress{other._pubkey, other._tld, other._name}
{}
@ -94,17 +94,20 @@ namespace llarp
template <typename pubkey_t = PubKey, std::enable_if_t<std::is_base_of_v<PubKey, pubkey_t>, int> = 0>
std::optional<RemoteAddress<pubkey_t>> from_pubkey_addr(const std::string& arg)
{
if (service::is_valid_ons(arg))
if constexpr (std::is_same_v<pubkey_t, ClientPubKey> || std::is_same_v<pubkey_t, PubKey>)
{
return RemoteAddress<ClientPubKey>(arg, true);
}
if (auto maybe_addr = parse_addr_string(arg, TLD::CLIENT))
{
return RemoteAddress<ClientPubKey>(*maybe_addr);
if (service::is_valid_ons(arg))
{
return std::make_optional(RemoteAddress<ClientPubKey>(arg, true));
}
if (auto maybe_addr = parse_addr_string(arg, TLD::CLIENT))
{
return std::make_optional(RemoteAddress<ClientPubKey>(*maybe_addr));
}
}
if (auto maybe_addr = parse_addr_string(arg, TLD::RELAY))
{
return RemoteAddress<RelayPubKey>(*maybe_addr);
return std::make_optional(RemoteAddress<RelayPubKey>(*maybe_addr));
}
return std::nullopt;

@ -55,6 +55,8 @@ namespace llarp
{}
explicit RelayPubKey(const RelayPubKey& other) : RelayPubKey{other.data()}
{}
RelayPubKey(RelayPubKey&& other) : RelayPubKey{other.data()}
{}
std::string to_string() const;
@ -79,6 +81,8 @@ namespace llarp
{}
explicit ClientPubKey(const ClientPubKey& other) : ClientPubKey{other.data()}
{}
ClientPubKey(ClientPubKey&& other) : ClientPubKey{other.data()}
{}
std::string to_string() const;

@ -5,6 +5,8 @@
namespace llarp::auth
{
static auto logcat = log::Cat("rpc.auth");
RPCAuthPolicy::RPCAuthPolicy(
Router& r,
std::string url,

@ -1,5 +1,6 @@
#include "bootstrap.hpp"
#include "util/file.hpp"
#include "util/logging.hpp"
#include "util/logging/buffer.hpp"

@ -279,7 +279,7 @@ namespace llarp
if (default_values.empty())
return {};
if constexpr (std::is_same_v<fs::path, T>)
return {{default_values.front().u8string()}};
return {{default_values.front().string()}};
else
{
std::vector<std::string> def_strs;

@ -21,6 +21,8 @@
namespace llarp
{
static auto logcat = log::Cat("context");
bool Context::call_safe(std::function<void(void)> f)
{
if (!_loop)

@ -114,13 +114,15 @@ namespace llarp::dns
// our string right now is the little endian representation, so load it as such on
// little endian, or in reverse on big endian.
std::string arg;
if constexpr (oxenc::little_endian)
{
auto hex = oxenc::from_hex(in.begin(), in.end());
return ipv6{reinterpret_cast<const unsigned char*>(hex.data())};
}
arg = oxenc::from_hex(in.begin(), in.end());
else
return ipv6{reinterpret_cast<const unsigned char*>(in.data())};
arg = std::string{in.data(), in.size()};
return ipv6{arg};
}
return std::nullopt;
}

@ -21,7 +21,7 @@ namespace llarp::dns::sd
const bool isStandardDNSPort = dns.port() == 53;
if (dns.is_ipv6())
{
ipv6 ipv6{dns.in6().sin6_addr.s6_addr};
ipv6 ipv6{&dns.in6().sin6_addr};
static_assert(sizeof(ipv6) == 16);
auto* a = reinterpret_cast<const uint8_t*>(&ipv6);

@ -356,7 +356,7 @@ namespace llarp::dns
// add host files
for (const auto& file : conf.hostfiles)
{
const auto str = file.u8string();
const auto str = file.string();
if (auto ret = ub_ctx_hosts(m_ctx, str.c_str()))
{
throw std::runtime_error{fmt::format("Failed to add host file {}: {}", file, ub_strerror(ret))};

@ -62,20 +62,20 @@ namespace llarp
bool add_network_interface(std::shared_ptr<vpn::NetworkInterface> netif, udp_pkt_hook handler);
template <typename Callable>
void call(Callable&& f, source_location src = source_location::current())
void call(Callable&& f)
{
_loop->call(std::forward<Callable>(f), src);
_loop->call(std::forward<Callable>(f));
}
template <typename Callable, typename Ret = decltype(std::declval<Callable>()())>
Ret call_get(Callable&& f, source_location src = source_location::current())
Ret call_get(Callable&& f)
{
return _loop->call_get(std::forward<Callable>(f), src);
return _loop->call_get(std::forward<Callable>(f));
}
void call_soon(std::function<void(void)> f, source_location src = source_location::current())
void call_soon(std::function<void(void)> f)
{
_loop->call_soon(std::move(f), src);
_loop->call_soon(std::move(f));
}
void call_later(loop_time delay, std::function<void()> hook);

@ -14,6 +14,8 @@ namespace llarp
{
namespace messages
{
static auto logcat = log::Cat("messages");
inline std::string serialize_response(oxenc::bt_dict supplement = {})
{
return oxenc::bt_serialize(supplement);

@ -22,7 +22,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: FindIntroMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: FindIntroMessage failed to bt encode contents!");
}
return std::move(btdp).str();
@ -43,7 +43,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: FindNameMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: FindNameMessage failed to bt encode contents!");
}
return std::move(btdp).str();
@ -59,7 +59,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: FindNameMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: FindNameMessage failed to bt encode contents!");
}
return std::move(btdp).str();
@ -85,7 +85,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: FindNameMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: FindNameMessage failed to bt encode contents!");
}
return std::move(btdp).str();

@ -19,7 +19,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: GossipRCMessage failed to bt encode contents");
log::error(messages::logcat, "Error: GossipRCMessage failed to bt encode contents");
}
return std::move(btdp).str();
@ -49,7 +49,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: RCFetchMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: RCFetchMessage failed to bt encode contents!");
}
return std::move(btdp).str();
@ -65,7 +65,7 @@ namespace llarp
if (local_rc)
{
log::critical(link_cat, "Serializing localRC: {}", oxenc::to_hex(local_rc->view()));
log::critical(messages::logcat, "Serializing localRC: {}", oxenc::to_hex(local_rc->view()));
btdp.append_encoded("local", oxen::quic::to_sv(local_rc->view()));
}
@ -87,7 +87,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: BootstrapFetchMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: BootstrapFetchMessage failed to bt encode contents!");
}
return std::move(btdp).str();
@ -108,7 +108,7 @@ namespace llarp
}
catch (...)
{
log::error(link_cat, "Error: FetchRIDMessage failed to bt encode contents!");
log::error(messages::logcat, "Error: FetchRIDMessage failed to bt encode contents!");
}
return std::move(btdp).str();

@ -51,7 +51,7 @@ namespace llarp
if (!crypto::dh_client(hop.shared, hop.rc.router_id(), hop.commkey, hop.nonce))
{
auto err = fmt::format("Failed to generate shared key for path build!");
log::warning(path_cat, err);
log::warning(messages::logcat, "{}", err);
throw std::runtime_error{std::move(err)};
}
// generate nonceXOR value self->hop->pathKey
@ -89,7 +89,7 @@ namespace llarp
// derive (outer) shared key
if (!crypto::dh_client(shared, hop.rc.router_id(), framekey, outer_nonce))
{
log::warning(path_cat, "DH client failed during hop info encryption!");
log::warning(messages::logcat, "DH client failed during hop info encryption!");
throw std::runtime_error{"DH failed during hop info encryption"};
}
@ -97,7 +97,7 @@ namespace llarp
if (!crypto::xchacha20(
reinterpret_cast<unsigned char*>(hop_info.data()), hop_info.size(), shared, outer_nonce))
{
log::warning(path_cat, "Hop info encryption failed!");
log::warning(messages::logcat, "Hop info encryption failed!");
throw std::runtime_error{"Hop info encryption failed"};
}
@ -122,7 +122,7 @@ namespace llarp
hashed_data.size(),
shared))
{
log::warning(path_cat, "Failed to generate HMAC for hop info");
log::warning(messages::logcat, "Failed to generate HMAC for hop info");
throw std::runtime_error{"Failed to generate HMAC for hop info"};
}

@ -176,7 +176,7 @@ namespace llarp
{
nuint_t<UInt_t> x{};
if (not x.FromString(str))
throw std::invalid_argument{fmt::format("{} is not a valid value")};
throw std::invalid_argument{fmt::format("{} is not a valid value", str)};
return x;
}

@ -15,6 +15,8 @@ static const std::string RC_FILE_EXT = ".signed";
namespace llarp
{
static auto logcat = llarp::log::Cat("nodedb");
static void EnsureSkiplist(fs::path nodedbDir)
{
if (not fs::exists(nodedbDir))
@ -450,7 +452,7 @@ namespace llarp
{
auto err =
"RID fetch from {} via {} {}"_format(target, source, m.timed_out ? "timed out" : "failed");
log::critical(link_cat, err);
log::critical(logcat, "{}", err);
ingest_rid_fetch_responses(target);
fetch_rids_result(initial);
return;
@ -476,8 +478,7 @@ namespace llarp
{
if (s.size() != RouterID::SIZE)
{
log::critical(
link_cat, "RID fetch from {} via {} returned bad RouterID", target, source);
log::critical(logcat, "RID fetch from {} via {} returned bad RouterID", target, source);
ingest_rid_fetch_responses(target);
fetch_rids_result(initial);
return;
@ -492,7 +493,7 @@ namespace llarp
}
catch (const std::exception& e)
{
log::critical(link_cat, "Error handling fetch RouterIDs response: {}", e.what());
log::critical(logcat, "Error handling fetch RouterIDs response: {}", e.what());
ingest_rid_fetch_responses(target);
fetch_rids_result(initial);
}
@ -634,7 +635,7 @@ namespace llarp
if (_using_bootstrap_fallback)
{
auto err = fmt::format("ERROR: ALL BOOTSTRAPS ARE BAD... REATTEMPTING IN {}...", BOOTSTRAP_COOLDOWN);
log::error(logcat, err);
log::error(logcat, "{}", err);
bootstrap_cooldown();
return;

@ -91,6 +91,18 @@ namespace llarp::path
return send_path_control_message("find_name", FindNameMessage::serialize(std::move(name)), std::move(func));
}
void Path::enable_exit_traffic()
{
log::info(logcat, "{} {} granted exit", name(), pivot_router_id());
// _role |= ePathRoleExit;
}
void Path::mark_exit_closed()
{
log::info(logcat, "{} hd its exit closed", name());
// _role &= ePathRoleExit;
}
std::string Path::make_outer_payload(std::string payload)
{
SymmNonce nonce;

@ -95,17 +95,9 @@ namespace llarp
return now >= (ExpireTime() - dlt);
}
void enable_exit_traffic()
{
log::info(path_cat, "{} {} granted exit", name(), pivot_router_id());
// _role |= ePathRoleExit;
}
void enable_exit_traffic();
void mark_exit_closed()
{
log::info(path_cat, "{} hd its exit closed", name());
// _role &= ePathRoleExit;
}
void mark_exit_closed();
bool update_exit(uint64_t tx_id);

@ -13,13 +13,10 @@
#include <functional>
namespace llarp
{
auto path_cat = log::Cat("path");
}
namespace llarp::path
{
static auto logcat = log::Cat("pathhandler");
bool BuildLimiter::Attempt(const RouterID& router)
{
return _edge_limiter.Insert(router);
@ -104,7 +101,7 @@ namespace llarp::path
if (!crypto::dh_client(hop.shared, hop.rc.router_id(), hop.commkey, hop.nonce))
{
auto err = fmt::format("{} failed to generate shared key for path build!", name());
log::error(path_cat, err);
log::error(logcat, "{}", err);
throw std::runtime_error{std::move(err)};
}
// generate nonceXOR value self->hop->pathKey
@ -263,14 +260,14 @@ namespace llarp::path
// derive (outer) shared key
if (!crypto::dh_client(shared, hop.rc.router_id(), framekey, outer_nonce))
{
log::error(path_cat, "DH client failed during hop info encryption!");
log::error(logcat, "DH client failed during hop info encryption!");
throw std::runtime_error{"DH failed during hop info encryption"};
}
// encrypt hop_info (mutates in-place)
if (!crypto::xchacha20(reinterpret_cast<uint8_t*>(hop_info.data()), hop_info.size(), shared, outer_nonce))
{
log::error(path_cat, "Hop info encryption failed!");
log::error(logcat, "Hop info encryption failed!");
throw std::runtime_error{"Hop info encryption failed"};
}
@ -295,7 +292,7 @@ namespace llarp::path
hashed_data.size(),
shared))
{
log::error(path_cat, "Failed to generate HMAC for hop info");
log::error(logcat, "Failed to generate HMAC for hop info");
throw std::runtime_error{"Failed to generate HMAC for hop info"};
}
@ -551,7 +548,7 @@ namespace llarp::path
hops.push_back(*maybe);
else
{
log::warning(path_cat, "{} has no first hop candidate", name());
log::warning(logcat, "{} has no first hop candidate", name());
return std::nullopt;
}
@ -623,7 +620,7 @@ namespace llarp::path
{
if (is_stopped())
{
log::info(path_cat, "Path builder is stopped, aborting path build...");
log::info(logcat, "Path builder is stopped, aborting path build...");
return;
}
@ -633,7 +630,7 @@ namespace llarp::path
if (not _router.pathbuild_limiter().Attempt(edge))
{
log::warning(path_cat, "{} building too quickly to edge router {}", name(), edge);
log::warning(logcat, "{} building too quickly to edge router {}", name(), edge);
return;
}
@ -652,7 +649,7 @@ namespace llarp::path
auto path = std::make_shared<path::Path>(_router, hops, get_weak(), std::move(path_shortName));
log::info(path_cat, "{} building path -> {} : {}", name(), path->short_name(), path->HopsString());
log::info(logcat, "{} building path -> {} : {}", name(), path->short_name(), path->HopsString());
oxenc::bt_list_producer frames;
std::vector<std::string> frame_str(path::MAX_LEN);
@ -743,27 +740,27 @@ namespace llarp::path
// TODO: inform failure (what this means needs revisiting, badly)
if (m.timed_out)
{
log::warning(path_cat, "Path build request timed out!");
log::warning(logcat, "Path build request timed out!");
path_build_failed(terminus, path, true);
}
else
{
oxenc::bt_dict_consumer d{m.body()};
auto status = d.require<std::string_view>(messages::STATUS_KEY);
log::warning(path_cat, "Path build returned failure status: {}", status);
log::warning(logcat, "Path build returned failure status: {}", status);
path_build_failed(terminus, path);
}
}
catch (const std::exception& e)
{
log::warning(path_cat, "Exception caught parsing path build response: {}", e.what());
log::warning(logcat, "Exception caught parsing path build response: {}", e.what());
}
};
if (not _router.send_control_message(
path->upstream(), "path_build", std::move(frames).str(), std::move(response_cb)))
{
log::warning(path_cat, "Error sending path_build control message");
log::warning(logcat, "Error sending path_build control message");
path_build_failed(terminus, path);
}
}

@ -285,7 +285,10 @@ namespace llarp
void Profiling::BEncode(bt_dict_producer& dict) const
{
for (const auto& [r_id, profile] : _profiles)
profile.BEncode(dict.append_dict(r_id.ToView()));
{
auto subdict = dict.append_dict(r_id.ToView());
profile.bt_encode(subdict);
}
}
void Profiling::BDecode(bt_dict_consumer dict)

@ -6,6 +6,8 @@
namespace llarp
{
static auto logcat = log::Cat("route_poker");
void RoutePoker::add_route(oxen::quic::Address ip)
{
if (not is_up)

@ -24,7 +24,7 @@ namespace llarp
if (not addr().is_public() and BLOCK_BOGONS)
{
auto err = "Unable to verify expired RemoteRC address!";
log::info(logcat, err);
log::info(logcat, "{}", err);
throw std::runtime_error{err};
}

@ -251,7 +251,7 @@ namespace llarp::rpc
if (activeNodeList.empty())
{
LogWarn("got empty service node list, ignoring.");
log::warning(logcat, "Received empty service node list, ignoring.");
return;
}

@ -76,6 +76,8 @@ namespace llarp::service
log::warning(logcat, "{}", err);
throw std::runtime_error{err};
}
return true;
}
void Introduction::bt_decode(oxenc::bt_dict_consumer& btdc)

@ -10,6 +10,8 @@
namespace llarp::session
{
static auto logcat = log::Cat("session.base");
BaseSession::BaseSession(
RouterID _router, Router& r, size_t hoplen, EndpointBase& parent, std::shared_ptr<auth::SessionAuthPolicy> a)
: PathHandler{r, NUM_SESSION_PATHS, hoplen},

@ -24,18 +24,18 @@ namespace llarp
else
fmt::format_to(ins, "{:02x}", std::to_integer<uint_fast16_t>(b[k]));
}
out.append(u8"");
out.append("");
for (size_t j = i; j < stop; j++)
{
auto c = std::to_integer<char>(b[j]);
if (c == 0x00)
out.append(u8"");
out.append("");
else if (c < 0x20 || c > 0x7e)
out.append(u8"·");
out.append("·");
else
out.push_back(c);
}
out.append(u8"");
out.append("");
}
return out;
}

@ -24,6 +24,8 @@
namespace llarp::vpn
{
static auto logcat = log::Cat("vpn.linux");
struct in6_ifreq
{
in6_addr addr;

Loading…
Cancel
Save