Replace logging with oxen-logger
Replaces custom logging system with spdlog-based oxen logging. This commit mainly replaces the backend logging with the spdlog-based system, but doesn't (yet) convert all the existing LogWarn, etc. to use the new format-based logging. New logging statements will look like: llarp::log::warning(cat, "blah: {}", val); where `cat` should be set up in each .cpp or cluster of .cpp files, as described in the oxen-logging README. As part of spdlog we get fmt, which gives us nice format strings, where are applied generously in this commit. Making types printable now requires two steps: - add a ToString() method - add this specialization: template <> constexpr inline bool llarp::IsToStringFormattable<llarp::Whatever> = true; This will then allow the type to be printed as a "{}" value in a fmt::format string. This is applied to all our printable types here, and all of the `operator<<` are removed. This commit also: - replaces various uses of `operator<<` to ToString() - replaces various uses of std::stringstream with either fmt::format or plain std::string - Rename some to_string and toString() methods to ToString() for consistency (and to work with fmt) - Replace `stringify(...)` and `make_exception` usage with fmt::format (and remove stringify/make_exception from util/str.hpp).stable
parent
43191ec100
commit
b81f7025c9
|
@ -16,7 +16,10 @@ local default_deps = ['g++'] + default_deps_nocxx;
|
|||
local default_windows_deps = ['mingw-w64', 'zip', 'nsis'];
|
||||
local docker_base = 'registry.oxen.rocks/lokinet-ci-';
|
||||
|
||||
local submodule_commands = ['git fetch --tags', 'git submodule update --init --recursive --depth=1 --jobs=4'];
|
||||
local submodule_commands = [
|
||||
'git fetch --tags',
|
||||
'git submodule update --init --recursive --depth=1 --jobs=4',
|
||||
];
|
||||
local submodules = {
|
||||
name: 'submodules',
|
||||
image: 'drone/git',
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
[submodule "test/Catch2"]
|
||||
path = test/Catch2
|
||||
url = https://github.com/catchorg/Catch2
|
||||
[submodule "external/date"]
|
||||
path = external/date
|
||||
url = https://github.com/HowardHinnant/date.git
|
||||
[submodule "external/pybind11"]
|
||||
path = external/pybind11
|
||||
url = https://github.com/pybind/pybind11
|
||||
|
@ -36,3 +33,6 @@
|
|||
[submodule "external/oxen-encoding"]
|
||||
path = external/oxen-encoding
|
||||
url = https://github.com/oxen-io/oxen-encoding.git
|
||||
[submodule "external/oxen-logging"]
|
||||
path = external/oxen-logging
|
||||
url = https://github.com/oxen-io/oxen-logging.git
|
||||
|
|
|
@ -96,7 +96,6 @@ set(CMAKE_C_EXTENSIONS OFF)
|
|||
|
||||
include(cmake/target_link_libraries_system.cmake)
|
||||
include(cmake/add_import_library.cmake)
|
||||
include(cmake/add_log_tag.cmake)
|
||||
include(cmake/libatomic.cmake)
|
||||
|
||||
if (STATIC_LINK)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
function(add_log_tag target)
|
||||
get_target_property(TARGET_SRCS ${target} SOURCES)
|
||||
foreach(F ${TARGET_SRCS})
|
||||
get_filename_component(fpath "${F}" ABSOLUTE)
|
||||
set_property(SOURCE ${F} APPEND PROPERTY COMPILE_DEFINITIONS SOURCE_ROOT=\"${PROJECT_SOURCE_DIR}\")
|
||||
endforeach()
|
||||
endfunction()
|
|
@ -57,7 +57,6 @@ else()
|
|||
endif()
|
||||
|
||||
enable_lto(lokinet-cryptography)
|
||||
add_log_tag(lokinet-cryptography)
|
||||
|
||||
if (WARNINGS_AS_ERRORS)
|
||||
target_compile_options(lokinet-cryptography PUBLIC -Wall -Wextra -Werror)
|
||||
|
|
|
@ -58,7 +58,6 @@ foreach(exe ${exetargets})
|
|||
target_link_libraries(${exe} PUBLIC liblokinet)
|
||||
target_include_directories(${exe} PUBLIC "${PROJECT_SOURCE_DIR}")
|
||||
target_compile_definitions(${exe} PRIVATE -DVERSIONTAG=${GIT_VERSION_REAL})
|
||||
add_log_tag(${exe})
|
||||
if(should_install)
|
||||
if(APPLE)
|
||||
install(TARGETS ${exe} BUNDLE DESTINATION "${PROJECT_BINARY_DIR}" COMPONENT lokinet)
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include <llarp.hpp>
|
||||
#include <llarp/util/lokinet_init.h>
|
||||
#include <llarp/util/fs.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging/ostream_logger.hpp>
|
||||
#include <llarp/util/str.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -379,11 +377,14 @@ main(int argc, char* argv[])
|
|||
int
|
||||
lokinet_main(int argc, char* argv[])
|
||||
{
|
||||
auto result = Lokinet_INIT();
|
||||
if (result)
|
||||
{
|
||||
if (auto result = Lokinet_INIT())
|
||||
return result;
|
||||
}
|
||||
|
||||
// Set up a default, stderr logging for very early logging; we'll replace this later once we read
|
||||
// the desired log info from config.
|
||||
llarp::log::add_sink(llarp::log::Type::Print, "stderr");
|
||||
llarp::log::reset_level(llarp::log::Level::info);
|
||||
|
||||
llarp::RuntimeOptions opts;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -410,7 +411,6 @@ lokinet_main(int argc, char* argv[])
|
|||
("g,generate", "generate default configuration and exit", cxxopts::value<bool>())
|
||||
("r,router", "run in routing mode instead of client only mode", cxxopts::value<bool>())
|
||||
("f,force", "force writing config even if it already exists", cxxopts::value<bool>())
|
||||
("c,colour", "colour output", cxxopts::value<bool>()->default_value("true"))
|
||||
("config", "path to lokinet.ini configuration file", cxxopts::value<std::string>())
|
||||
;
|
||||
// clang-format on
|
||||
|
@ -424,12 +424,6 @@ lokinet_main(int argc, char* argv[])
|
|||
{
|
||||
auto result = options.parse(argc, argv);
|
||||
|
||||
if (!result["colour"].as<bool>())
|
||||
{
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique<llarp::OStreamLogStream>(false, std::cerr);
|
||||
}
|
||||
|
||||
if (result.count("help"))
|
||||
{
|
||||
std::cout << options.help() << std::endl;
|
||||
|
@ -554,6 +548,7 @@ lokinet_main(int argc, char* argv[])
|
|||
// do periodic non lokinet related tasks here
|
||||
if (ctx and ctx->IsUp() and not ctx->LooksAlive())
|
||||
{
|
||||
auto deadlock_cat = llarp::log::Cat("deadlock");
|
||||
for (const auto& wtf :
|
||||
{"you have been visited by the mascott of the deadlocked router.",
|
||||
"⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠄⠄⠄⠄",
|
||||
|
@ -575,8 +570,8 @@ lokinet_main(int argc, char* argv[])
|
|||
"file a bug report now or be cursed with this "
|
||||
"annoying image in your syslog for all time."})
|
||||
{
|
||||
llarp::LogError{wtf};
|
||||
llarp::LogContext::Instance().ImmediateFlush();
|
||||
llarp::log::critical(deadlock_cat, wtf);
|
||||
llarp::log::flush();
|
||||
}
|
||||
#ifdef _WIN32
|
||||
TellWindowsServiceStopped();
|
||||
|
@ -604,7 +599,7 @@ lokinet_main(int argc, char* argv[])
|
|||
code = 2;
|
||||
}
|
||||
|
||||
llarp::LogContext::Instance().ImmediateFlush();
|
||||
llarp::log::flush();
|
||||
if (ctx)
|
||||
{
|
||||
ctx.reset();
|
||||
|
|
|
@ -12,13 +12,23 @@ if(SUBMODULE_CHECK)
|
|||
else()
|
||||
message(FATAL_ERROR "Submodule 'external/${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DSUBMODULE_CHECK=OFF")
|
||||
endif()
|
||||
|
||||
# Extra arguments check nested submodules
|
||||
foreach(submod ${ARGN})
|
||||
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path}/${submod} OUTPUT_VARIABLE localHead)
|
||||
execute_process(COMMAND git rev-parse "HEAD:${submod}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE checkedHead)
|
||||
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
|
||||
if (NOT upToDate)
|
||||
message(FATAL_ERROR "Nested submodule '${relative_path}/${submod}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DSUBMODULE_CHECK=OFF")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction ()
|
||||
|
||||
message(STATUS "Checking submodules")
|
||||
check_submodule(nlohmann)
|
||||
check_submodule(cxxopts)
|
||||
check_submodule(ghc-filesystem)
|
||||
check_submodule(date)
|
||||
check_submodule(oxen-logging fmt spdlog)
|
||||
check_submodule(pybind11)
|
||||
check_submodule(sqlite_orm)
|
||||
check_submodule(oxen-mq)
|
||||
|
@ -56,13 +66,17 @@ system_or_submodule(OXENMQ oxenmq liboxenmq>=1.2.12 oxen-mq)
|
|||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
system_or_submodule(NLOHMANN nlohmann_json nlohmann_json>=3.7.0 nlohmann)
|
||||
|
||||
if (STATIC OR FORCE_SPDLOG_SUBMODULE OR FORCE_FMT_SUBMODULE)
|
||||
set(OXEN_LOGGING_FORCE_SUBMODULES ON CACHE INTERNAL "")
|
||||
endif()
|
||||
set(OXEN_LOGGING_SOURCE_ROOT "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "")
|
||||
add_subdirectory(oxen-logging)
|
||||
|
||||
if(WITH_HIVE)
|
||||
add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(cxxopts EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(date EXCLUDE_FROM_ALL)
|
||||
|
||||
add_library(sqlite_orm INTERFACE)
|
||||
target_include_directories(sqlite_orm SYSTEM INTERFACE sqlite_orm/include)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit cac99da8dc88be719a728dc1b597b0ac307c1800
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0fc1b3528a52475c4007d734a7861faa2212fe75
|
|
@ -7,7 +7,7 @@ extern "C"
|
|||
|
||||
/// change our network id globally across all contexts
|
||||
void EXPORT
|
||||
lokinet_set_netid(const char*);
|
||||
lokinet_set_netid(const char* netid);
|
||||
|
||||
/// get our current netid
|
||||
/// must be free()'d after use
|
||||
|
@ -15,17 +15,27 @@ extern "C"
|
|||
lokinet_get_netid();
|
||||
|
||||
/// set log level
|
||||
/// possible values: trace, debug, info, warn, error, none
|
||||
/// possible values: trace, debug, info, warn, error, critical, none
|
||||
/// return 0 on success
|
||||
/// return non zero on fail
|
||||
int EXPORT
|
||||
lokinet_log_level(const char*);
|
||||
lokinet_log_level(const char* level);
|
||||
|
||||
typedef void (*lokinet_logger_func)(const char*, void*);
|
||||
/// Function pointer to invoke with lokinet log messages
|
||||
typedef void (*lokinet_logger_func)(const char* message, void* context);
|
||||
|
||||
/// set a custom logger function
|
||||
/// Optional function to call when flushing lokinet log messages; can be NULL if flushing is not
|
||||
/// meaningful for the logging system.
|
||||
typedef void (*lokinet_logger_sync)(void* context);
|
||||
|
||||
/// set a custom logger function; it is safe (and often desirable) to call this before calling
|
||||
/// initializing lokinet via lokinet_context_new.
|
||||
void EXPORT
|
||||
lokinet_set_logger(lokinet_logger_func func, void* user);
|
||||
lokinet_set_syncing_logger(lokinet_logger_func func, lokinet_logger_sync sync, void* context);
|
||||
|
||||
/// shortcut for calling `lokinet_set_syncing_logger` with a NULL sync
|
||||
void EXPORT
|
||||
lokinet_set_logger(lokinet_logger_func func, void* context);
|
||||
|
||||
/// @brief take in hex and turn it into base32z
|
||||
/// @return value must be free()'d later
|
||||
|
|
|
@ -8,12 +8,6 @@ add_library(lokinet-util
|
|||
util/fs.cpp
|
||||
util/json.cpp
|
||||
util/logging/buffer.cpp
|
||||
util/logging/file_logger.cpp
|
||||
util/logging/logger.cpp
|
||||
util/logging/logger_internal.cpp
|
||||
util/logging/loglevel.cpp
|
||||
util/logging/ostream_logger.cpp
|
||||
util/logging/syslog_logger.cpp
|
||||
util/lokinet_init.c
|
||||
util/mem.cpp
|
||||
util/printer.cpp
|
||||
|
@ -31,8 +25,8 @@ target_link_libraries(lokinet-util PUBLIC
|
|||
lokinet-cryptography
|
||||
nlohmann_json::nlohmann_json
|
||||
filesystem
|
||||
date::date
|
||||
oxenc::oxenc
|
||||
oxen::logging
|
||||
)
|
||||
|
||||
if(ANDROID)
|
||||
|
@ -213,7 +207,6 @@ add_library(liblokinet
|
|||
service/name.cpp
|
||||
service/outbound_context.cpp
|
||||
service/protocol.cpp
|
||||
service/protocol_type.cpp
|
||||
service/router_lookup_job.cpp
|
||||
service/sendcontext.cpp
|
||||
service/session.cpp
|
||||
|
@ -236,7 +229,15 @@ if(WITH_HIVE)
|
|||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(liblokinet PUBLIC cxxopts oxenc::oxenc lokinet-platform lokinet-util lokinet-cryptography sqlite_orm ngtcp2_static oxenmq::oxenmq)
|
||||
target_link_libraries(liblokinet PUBLIC
|
||||
cxxopts
|
||||
oxenc::oxenc
|
||||
lokinet-platform
|
||||
lokinet-util
|
||||
lokinet-cryptography
|
||||
sqlite_orm
|
||||
ngtcp2_static
|
||||
oxenmq::oxenmq)
|
||||
target_link_libraries(liblokinet PRIVATE libunbound)
|
||||
pkg_check_modules(CRYPT libcrypt IMPORTED_TARGET)
|
||||
if(CRYPT_FOUND AND NOT CMAKE_CROSSCOMPILING)
|
||||
|
@ -262,17 +263,12 @@ if(BUILD_LIBLOKINET)
|
|||
else()
|
||||
install(TARGETS lokinet-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT liblokinet)
|
||||
endif()
|
||||
add_log_tag(lokinet-shared)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
add_subdirectory(apple)
|
||||
endif()
|
||||
|
||||
foreach(lokinet_lib liblokinet lokinet-platform lokinet-util lokinet-cryptography)
|
||||
add_log_tag(${lokinet_lib})
|
||||
endforeach()
|
||||
|
||||
file(GLOB_RECURSE docs_SRC */*.hpp *.hpp)
|
||||
|
||||
set(DOCS_SRC ${docs_SRC} PARENT_SCOPE)
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include "apple_logger.hpp"
|
||||
|
||||
namespace llarp::apple
|
||||
{
|
||||
void
|
||||
NSLogStream::PreLog(
|
||||
std::stringstream& ss,
|
||||
LogLevel lvl,
|
||||
std::string_view fname,
|
||||
int lineno,
|
||||
const std::string& nodename) const
|
||||
{
|
||||
ss << "[" << LogLevelToString(lvl) << "] ";
|
||||
ss << "[" << nodename << "]"
|
||||
<< "(" << thread_id_string() << ") " << log_timestamp() << " " << fname << ":" << lineno
|
||||
<< "\t";
|
||||
}
|
||||
|
||||
void
|
||||
NSLogStream::Print(LogLevel, std::string_view, const std::string& msg)
|
||||
{
|
||||
ns_logger(msg.c_str());
|
||||
}
|
||||
|
||||
} // namespace llarp::apple
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging/logstream.hpp>
|
||||
|
||||
namespace llarp::apple
|
||||
{
|
||||
struct NSLogStream : public ILogStream
|
||||
{
|
||||
using ns_logger_callback = void (*)(const char* log_this);
|
||||
|
||||
NSLogStream(ns_logger_callback logger) : ns_logger{logger}
|
||||
{}
|
||||
|
||||
void
|
||||
PreLog(
|
||||
std::stringstream& s,
|
||||
LogLevel lvl,
|
||||
std::string_view fname,
|
||||
int lineno,
|
||||
const std::string& nodename) const override;
|
||||
|
||||
void
|
||||
Print(LogLevel lvl, std::string_view tag, const std::string& msg) override;
|
||||
|
||||
void
|
||||
PostLog(std::stringstream&) const override
|
||||
{}
|
||||
|
||||
void
|
||||
ImmediateFlush() override
|
||||
{}
|
||||
|
||||
void Tick(llarp_time_t) override
|
||||
{}
|
||||
|
||||
private:
|
||||
ns_logger_callback ns_logger;
|
||||
};
|
||||
} // namespace llarp::apple
|
|
@ -6,10 +6,11 @@
|
|||
#include <llarp/util/fs.hpp>
|
||||
#include <llarp/util/logging/buffer.hpp>
|
||||
#include <uvw/loop.h>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging/callback_sink.hpp>
|
||||
#include "vpn_interface.hpp"
|
||||
#include "context_wrapper.h"
|
||||
#include "context.hpp"
|
||||
#include "apple_logger.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -34,8 +35,10 @@ const uint16_t dns_trampoline_port = 1053;
|
|||
void*
|
||||
llarp_apple_init(llarp_apple_config* appleconf)
|
||||
{
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique<llarp::apple::NSLogStream>(appleconf->ns_logger);
|
||||
llarp::log::ReplaceLogger(std::make_shared<llarp::log::CallbackSink_mt>(
|
||||
[](const char* msg, void* nslog) { reinterpret_cast<ns_logger_callback>(nslog)(msg); },
|
||||
nullptr,
|
||||
appleconf->ns_logger));
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -43,7 +46,7 @@ llarp_apple_init(llarp_apple_config* appleconf)
|
|||
auto config = std::make_shared<llarp::Config>(config_dir);
|
||||
fs::path config_path = config_dir / "lokinet.ini";
|
||||
if (!fs::exists(config_path))
|
||||
llarp::ensureConfig(config_dir, config_path, /*overwrite=*/false, /*router=*/false);
|
||||
llarp::ensureConfig(config_dir, config_path, /*overwrite=*/false, /*asRouter=*/false);
|
||||
config->Load(config_path);
|
||||
|
||||
// If no range is specified then go look for a free one, set that in the config, and then return
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "bootstrap.hpp"
|
||||
#include "util/bencode.hpp"
|
||||
#include "util/logging/logger.hpp"
|
||||
#include "util/logging.hpp"
|
||||
#include "util/logging/buffer.hpp"
|
||||
|
||||
namespace llarp
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
#include "config/definition.hpp"
|
||||
#include "ini.hpp"
|
||||
#include <llarp/constants/files.hpp>
|
||||
#include <llarp/constants/platform.hpp>
|
||||
#include <llarp/constants/version.hpp>
|
||||
#include <llarp/net/net.hpp>
|
||||
#include <llarp/net/ip.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
#include <stdexcept>
|
||||
#include <llarp/util/fs.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/formattable.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/util/mem.hpp>
|
||||
#include <llarp/util/str.hpp>
|
||||
|
||||
|
@ -19,7 +22,6 @@
|
|||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <llarp/constants/version.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -58,8 +60,8 @@ namespace llarp
|
|||
},
|
||||
[this](std::string arg) {
|
||||
if (arg.size() > NetID::size())
|
||||
throw std::invalid_argument(
|
||||
stringify("netid is too long, max length is ", NetID::size()));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("netid is too long, max length is {}", NetID::size())};
|
||||
|
||||
m_netId = std::move(arg);
|
||||
});
|
||||
|
@ -75,7 +77,8 @@ namespace llarp
|
|||
},
|
||||
[=](int arg) {
|
||||
if (arg < minConnections)
|
||||
throw std::invalid_argument(stringify("min-connections must be >= ", minConnections));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("min-connections must be >= {}", minConnections)};
|
||||
|
||||
m_minConnectedRouters = arg;
|
||||
});
|
||||
|
@ -91,7 +94,8 @@ namespace llarp
|
|||
},
|
||||
[=](int arg) {
|
||||
if (arg < maxConnections)
|
||||
throw std::invalid_argument(stringify("max-connections must be >= ", maxConnections));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("max-connections must be >= {}", maxConnections)};
|
||||
|
||||
m_maxConnectedRouters = arg;
|
||||
});
|
||||
|
@ -110,8 +114,8 @@ namespace llarp
|
|||
if (arg.empty())
|
||||
throw std::invalid_argument("[router]:data-dir is empty");
|
||||
if (not fs::exists(arg))
|
||||
throw std::runtime_error(
|
||||
stringify("Specified [router]:data-dir ", arg, " does not exist"));
|
||||
throw std::runtime_error{
|
||||
fmt::format("Specified [router]:data-dir {} does not exist", arg)};
|
||||
|
||||
m_dataDir = std::move(arg);
|
||||
});
|
||||
|
@ -130,11 +134,11 @@ namespace llarp
|
|||
return;
|
||||
nuint32_t addr{};
|
||||
if (not addr.FromString(arg))
|
||||
throw std::invalid_argument{stringify(arg, " is not a valid IPv4 address")};
|
||||
throw std::invalid_argument{fmt::format("{} is not a valid IPv4 address", arg)};
|
||||
|
||||
if (IsIPv4Bogon(addr))
|
||||
throw std::invalid_argument{
|
||||
stringify(addr, " looks like it is not a publicly routable ip address")};
|
||||
fmt::format("{} is not a publicly routable ip address", addr)};
|
||||
|
||||
m_PublicIP = addr;
|
||||
});
|
||||
|
@ -352,7 +356,7 @@ namespace llarp
|
|||
[this](std::string arg) {
|
||||
service::Address addr;
|
||||
if (not addr.FromString(arg))
|
||||
throw std::invalid_argument(stringify("bad loki address: ", arg));
|
||||
throw std::invalid_argument{fmt::format("bad loki address: {}", arg)};
|
||||
m_AuthWhitelist.emplace(std::move(addr));
|
||||
});
|
||||
|
||||
|
@ -368,7 +372,7 @@ namespace llarp
|
|||
[this](fs::path arg) {
|
||||
if (not fs::exists(arg))
|
||||
throw std::invalid_argument{
|
||||
stringify("cannot load auth file ", arg, " as it does not seem to exist")};
|
||||
fmt::format("cannot load auth file {}: file does not exist", arg)};
|
||||
m_AuthFiles.emplace(std::move(arg));
|
||||
});
|
||||
conf.defineOption<std::string>(
|
||||
|
@ -514,7 +518,7 @@ namespace llarp
|
|||
|
||||
if (arg != "null" and not exit.FromString(arg))
|
||||
{
|
||||
throw std::invalid_argument(stringify("[network]:exit-node bad address: ", arg));
|
||||
throw std::invalid_argument{fmt::format("[network]:exit-node bad address: {}", arg)};
|
||||
}
|
||||
m_ExitMap.Insert(range, exit);
|
||||
});
|
||||
|
@ -603,7 +607,7 @@ namespace llarp
|
|||
[this](std::string arg) {
|
||||
if (not m_ifaddr.FromString(arg))
|
||||
{
|
||||
throw std::invalid_argument(stringify("[network]:ifaddr invalid value: '", arg, "'"));
|
||||
throw std::invalid_argument{fmt::format("[network]:ifaddr invalid value: '{}'", arg)};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -630,8 +634,8 @@ namespace llarp
|
|||
}
|
||||
m_baseV6Address = huint128_t{};
|
||||
if (not m_baseV6Address->FromString(arg))
|
||||
throw std::invalid_argument(
|
||||
stringify("[network]:ip6-range invalid value: '", arg, "'"));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("[network]:ip6-range invalid value: '{}'", arg)};
|
||||
});
|
||||
// TODO: could be useful for snodes in the future, but currently only implemented for clients:
|
||||
conf.defineOption<std::string>(
|
||||
|
@ -653,7 +657,7 @@ namespace llarp
|
|||
const auto pos = arg.find(":");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
throw std::invalid_argument(stringify("[endpoint]:mapaddr invalid entry: ", arg));
|
||||
throw std::invalid_argument{fmt::format("[endpoint]:mapaddr invalid entry: {}", arg)};
|
||||
}
|
||||
std::string addrstr = arg.substr(0, pos);
|
||||
std::string ipstr = arg.substr(pos + 1);
|
||||
|
@ -662,18 +666,19 @@ namespace llarp
|
|||
huint32_t ipv4;
|
||||
if (not ipv4.FromString(ipstr))
|
||||
{
|
||||
throw std::invalid_argument(stringify("[endpoint]:mapaddr invalid ip: ", ipstr));
|
||||
throw std::invalid_argument{fmt::format("[endpoint]:mapaddr invalid ip: {}", ipstr)};
|
||||
}
|
||||
ip = net::ExpandV4(ipv4);
|
||||
}
|
||||
if (not addr.FromString(addrstr))
|
||||
{
|
||||
throw std::invalid_argument(
|
||||
stringify("[endpoint]:mapaddr invalid addresss: ", addrstr));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("[endpoint]:mapaddr invalid addresss: {}", addrstr)};
|
||||
}
|
||||
if (m_mapAddrs.find(ip) != m_mapAddrs.end())
|
||||
{
|
||||
throw std::invalid_argument(stringify("[endpoint]:mapaddr ip already mapped: ", ipstr));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("[endpoint]:mapaddr ip already mapped: {}", ipstr)};
|
||||
}
|
||||
m_mapAddrs[ip] = addr;
|
||||
});
|
||||
|
@ -690,11 +695,11 @@ namespace llarp
|
|||
[this](std::string arg) {
|
||||
RouterID id;
|
||||
if (not id.FromString(arg))
|
||||
throw std::invalid_argument(stringify("Invalid RouterID: ", arg));
|
||||
throw std::invalid_argument{fmt::format("Invalid RouterID: {}", arg)};
|
||||
|
||||
auto itr = m_snodeBlacklist.emplace(std::move(id));
|
||||
if (not itr.second)
|
||||
throw std::invalid_argument(stringify("Duplicate blacklist-snode: ", arg));
|
||||
throw std::invalid_argument{fmt::format("Duplicate blacklist-snode: {}", arg)};
|
||||
});
|
||||
|
||||
// TODO: support SRV records for routers, but for now client only
|
||||
|
@ -711,7 +716,7 @@ namespace llarp
|
|||
[this](std::string arg) {
|
||||
llarp::dns::SRVData newSRV;
|
||||
if (not newSRV.fromString(arg))
|
||||
throw std::invalid_argument(stringify("Invalid SRV Record string: ", arg));
|
||||
throw std::invalid_argument{fmt::format("Invalid SRV Record string: {}", arg)};
|
||||
|
||||
m_SRVRecords.push_back(std::move(newSRV));
|
||||
});
|
||||
|
@ -817,7 +822,7 @@ namespace llarp
|
|||
return;
|
||||
if (not fs::exists(path))
|
||||
throw std::invalid_argument{
|
||||
stringify("cannot add hosts file ", path, " as it does not seem to exist")};
|
||||
fmt::format("cannot add hosts file {} as it does not exist", path)};
|
||||
m_hostfiles.emplace_back(std::move(path));
|
||||
});
|
||||
|
||||
|
@ -897,7 +902,7 @@ namespace llarp
|
|||
"if the 0.0.0.0 all-address IP is given then you must also specify the",
|
||||
"public-ip= and public-port= settings in the [router] section with a public",
|
||||
"address at which this router can be reached.",
|
||||
""
|
||||
"",
|
||||
"Typically this section can be left blank: if no inbound bind addresses are",
|
||||
"configured then lokinet will search for a local network interface with a public",
|
||||
"IP address and use that (with port 1090).",
|
||||
|
@ -932,8 +937,8 @@ namespace llarp
|
|||
LinkInfo info = LinkInfoFromINIValues(name, value);
|
||||
|
||||
if (info.port <= 0)
|
||||
throw std::invalid_argument(
|
||||
stringify("Invalid [bind] port specified on interface", name));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("Invalid [bind] port specified on interface {}", name)};
|
||||
|
||||
assert(name != "*"); // handled by defineOption("bind", "*", ...) above
|
||||
|
||||
|
@ -950,14 +955,11 @@ namespace llarp
|
|||
"connect", [this](std::string_view section, std::string_view name, std::string_view value) {
|
||||
fs::path file{value.begin(), value.end()};
|
||||
if (not fs::exists(file))
|
||||
throw std::runtime_error(stringify(
|
||||
"Specified bootstrap file ",
|
||||
throw std::runtime_error{fmt::format(
|
||||
"Specified bootstrap file {} specified in [{}]:{} does not exist",
|
||||
value,
|
||||
"specified in [",
|
||||
section,
|
||||
"]:",
|
||||
name,
|
||||
" does not exist"));
|
||||
name)};
|
||||
|
||||
routers.emplace_back(std::move(file));
|
||||
return true;
|
||||
|
@ -1088,7 +1090,8 @@ namespace llarp
|
|||
{
|
||||
(void)params;
|
||||
|
||||
constexpr Default DefaultLogType{"file"};
|
||||
constexpr Default DefaultLogType{
|
||||
platform::is_android or platform::is_apple ? "system" : "print"};
|
||||
constexpr Default DefaultLogFile{""};
|
||||
constexpr Default DefaultLogLevel{"warn"};
|
||||
|
||||
|
@ -1097,16 +1100,17 @@ namespace llarp
|
|||
"type",
|
||||
DefaultLogType,
|
||||
[this](std::string arg) {
|
||||
LogType type = LogTypeFromString(arg);
|
||||
if (type == LogType::Unknown)
|
||||
throw std::invalid_argument(stringify("invalid log type: ", arg));
|
||||
auto type = log::type_from_string(arg);
|
||||
if (type == log::Type::Unknown)
|
||||
throw std::invalid_argument{fmt::format("invalid log type: {}", arg)};
|
||||
|
||||
m_logType = type;
|
||||
},
|
||||
Comment{
|
||||
"Log type (format). Valid options are:",
|
||||
" file - plaintext formatting",
|
||||
" syslog - logs directed to syslog",
|
||||
" print - print logs to standard output",
|
||||
" system - logs directed to the system logger (syslog/eventlog/etc.)",
|
||||
" file - plaintext formatting to a file",
|
||||
});
|
||||
|
||||
conf.defineOption<std::string>(
|
||||
|
@ -1114,9 +1118,9 @@ namespace llarp
|
|||
"level",
|
||||
DefaultLogLevel,
|
||||
[this](std::string arg) {
|
||||
std::optional<LogLevel> level = LogLevelFromString(arg);
|
||||
std::optional<log::Level> level = log::level_from_string(arg);
|
||||
if (not level)
|
||||
throw std::invalid_argument(stringify("invalid log level value: ", arg));
|
||||
throw std::invalid_argument{fmt::format("invalid log level value: {}", arg)};
|
||||
|
||||
m_logLevel = *level;
|
||||
},
|
||||
|
@ -1128,6 +1132,8 @@ namespace llarp
|
|||
" info",
|
||||
" warn",
|
||||
" error",
|
||||
" critical",
|
||||
" none",
|
||||
});
|
||||
|
||||
conf.defineOption<std::string>(
|
||||
|
@ -1136,9 +1142,7 @@ namespace llarp
|
|||
DefaultLogFile,
|
||||
AssignmentAcceptor(m_logFile),
|
||||
Comment{
|
||||
"When using type=file this is the output filename. If given the value 'stdout' or",
|
||||
"left empty then logging is printed as standard output rather than written to a",
|
||||
"file.",
|
||||
"When using type=file this is the output filename.",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1390,7 +1394,7 @@ namespace llarp
|
|||
// open a filestream
|
||||
auto stream = llarp::util::OpenFileStream<std::ofstream>(confFile.c_str(), std::ios::binary);
|
||||
if (not stream or not stream->is_open())
|
||||
throw std::runtime_error(stringify("Failed to open file ", confFile, " for writing"));
|
||||
throw std::runtime_error{fmt::format("Failed to open file {} for writing", confFile)};
|
||||
|
||||
*stream << confStr;
|
||||
stream->flush();
|
||||
|
@ -1495,7 +1499,7 @@ namespace llarp
|
|||
{
|
||||
auto config = std::make_shared<Config>(fs::path{});
|
||||
config->Load();
|
||||
config->logging.m_logLevel = eLogNone;
|
||||
config->logging.m_logLevel = log::Level::off;
|
||||
config->api.m_enableRPCServer = false;
|
||||
config->network.m_endpointType = "null";
|
||||
config->network.m_saveProfiles = false;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <llarp/router_contact.hpp>
|
||||
#include <llarp/util/fs.hpp>
|
||||
#include <llarp/util/str.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include "ini.hpp"
|
||||
#include "definition.hpp"
|
||||
#include <llarp/constants/files.hpp>
|
||||
|
@ -209,8 +210,8 @@ namespace llarp
|
|||
|
||||
struct LoggingConfig
|
||||
{
|
||||
LogType m_logType = LogType::Unknown;
|
||||
LogLevel m_logLevel = eLogNone;
|
||||
log::Type m_logType = log::Type::Unknown;
|
||||
log::Level m_logLevel = log::Level::off;
|
||||
std::string m_logFile;
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "definition.hpp"
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
@ -17,7 +17,7 @@ namespace llarp
|
|||
else if (input == "true" || input == "on" || input == "1" || input == "yes")
|
||||
return true;
|
||||
else
|
||||
throw std::invalid_argument(stringify(input, " is not a valid bool"));
|
||||
throw std::invalid_argument{fmt::format("{} is not a valid bool", input)};
|
||||
}
|
||||
|
||||
ConfigDefinition&
|
||||
|
@ -53,8 +53,8 @@ namespace llarp
|
|||
|
||||
auto [it, added] = m_definitions[section].try_emplace(std::string{def->name}, std::move(def));
|
||||
if (!added)
|
||||
throw std::invalid_argument(
|
||||
stringify("definition for [", def->section, "]:", def->name, " already exists"));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("definition for [{}]:{} already exists", def->section, def->name)};
|
||||
|
||||
m_definitionOrdering[section].push_back(it->first);
|
||||
|
||||
|
@ -79,13 +79,10 @@ namespace llarp
|
|||
{
|
||||
// fallback to undeclared handler if available
|
||||
if (not haveUndeclaredHandler)
|
||||
throw std::invalid_argument(stringify("unrecognized section [", section, "]"));
|
||||
else
|
||||
{
|
||||
auto& handler = undItr->second;
|
||||
handler(section, name, value);
|
||||
return *this;
|
||||
}
|
||||
throw std::invalid_argument{fmt::format("unrecognized section [{}]", section)};
|
||||
auto& handler = undItr->second;
|
||||
handler(section, name, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// section was valid, get definition by name
|
||||
|
@ -95,13 +92,10 @@ namespace llarp
|
|||
if (defItr == sectionDefinitions.end())
|
||||
{
|
||||
if (not haveUndeclaredHandler)
|
||||
throw std::invalid_argument(stringify("unrecognized option [", section, "]:", name));
|
||||
else
|
||||
{
|
||||
auto& handler = undItr->second;
|
||||
handler(section, name, value);
|
||||
return *this;
|
||||
}
|
||||
throw std::invalid_argument{fmt::format("unrecognized option [{}]:{}", section, name)};
|
||||
auto& handler = undItr->second;
|
||||
handler(section, name, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
OptionDefinition_ptr& definition = defItr->second;
|
||||
|
@ -115,7 +109,7 @@ namespace llarp
|
|||
{
|
||||
auto itr = m_undeclaredHandlers.find(section);
|
||||
if (itr != m_undeclaredHandlers.end())
|
||||
throw std::logic_error(stringify("section ", section, " already has a handler"));
|
||||
throw std::logic_error{fmt::format("section {} already has a handler", section)};
|
||||
|
||||
m_undeclaredHandlers[section] = std::move(handler);
|
||||
}
|
||||
|
@ -135,8 +129,8 @@ namespace llarp
|
|||
visitDefinitions(section, [&](const std::string&, const OptionDefinition_ptr& def) {
|
||||
if (def->required and def->getNumberFound() < 1)
|
||||
{
|
||||
throw std::invalid_argument(
|
||||
stringify("[", section, "]:", def->name, " is required but missing"));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("[{}]:{} is required but missing", section, def->name)};
|
||||
}
|
||||
|
||||
// should be handled earlier in OptionDefinition::parseValue()
|
||||
|
@ -241,12 +235,13 @@ namespace llarp
|
|||
{
|
||||
const auto sectionItr = m_definitions.find(std::string(section));
|
||||
if (sectionItr == m_definitions.end())
|
||||
throw std::invalid_argument(stringify("No config section [", section, "]"));
|
||||
throw std::invalid_argument{fmt::format("No config section [{}]", section)};
|
||||
|
||||
auto& sectionDefinitions = sectionItr->second;
|
||||
const auto definitionItr = sectionDefinitions.find(std::string(name));
|
||||
if (definitionItr == sectionDefinitions.end())
|
||||
throw std::invalid_argument(stringify("No config item ", name, " within section ", section));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("No config item {} within section {}", name, section)};
|
||||
|
||||
return definitionItr->second;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <llarp/util/str.hpp>
|
||||
|
@ -259,8 +260,8 @@ namespace llarp
|
|||
getValueAt(size_t index) const
|
||||
{
|
||||
if (index >= parsedValues.size())
|
||||
throw std::range_error(
|
||||
stringify("no value at index ", index, ", size: ", parsedValues.size()));
|
||||
throw std::range_error{
|
||||
fmt::format("no value at index {}, size: {}", index, parsedValues.size())};
|
||||
|
||||
return parsedValues[index];
|
||||
}
|
||||
|
@ -293,8 +294,8 @@ namespace llarp
|
|||
{
|
||||
if (not multiValued and parsedValues.size() > 0)
|
||||
{
|
||||
throw std::invalid_argument(
|
||||
stringify("duplicate value for ", name, ", previous value: ", parsedValues[0]));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("duplicate value for {}, previous value: {}", name, parsedValues[0])};
|
||||
}
|
||||
|
||||
parsedValues.emplace_back(fromString(input));
|
||||
|
@ -313,7 +314,7 @@ namespace llarp
|
|||
T t;
|
||||
iss >> t;
|
||||
if (iss.fail())
|
||||
throw std::invalid_argument(stringify(input, " is not a valid ", typeid(T).name()));
|
||||
throw std::invalid_argument{fmt::format("{} is not a valid {}", input, typeid(T).name())};
|
||||
else
|
||||
return t;
|
||||
}
|
||||
|
@ -341,12 +342,10 @@ namespace llarp
|
|||
{
|
||||
if (required and parsedValues.size() == 0)
|
||||
{
|
||||
throw std::runtime_error(stringify(
|
||||
"cannot call tryAccept() on [",
|
||||
throw std::runtime_error{fmt::format(
|
||||
"cannot call tryAccept() on [{}]:{} when required but no value available",
|
||||
section,
|
||||
"]:",
|
||||
name,
|
||||
" when required but no value available"));
|
||||
name)};
|
||||
}
|
||||
|
||||
// don't use default value if we are multi-valued and have no value
|
||||
|
@ -472,8 +471,8 @@ namespace llarp
|
|||
|
||||
auto derived = dynamic_cast<const OptionDefinition<T>*>(definition.get());
|
||||
if (not derived)
|
||||
throw std::invalid_argument(
|
||||
stringify("", typeid(T).name(), " is the incorrect type for [", section, "]:", name));
|
||||
throw std::invalid_argument{
|
||||
fmt::format("{} is the incorrect type for [{}]:{}", typeid(T).name(), section, name)};
|
||||
|
||||
return derived->getValue();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ini.hpp"
|
||||
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/util/formattable.hpp>
|
||||
#include <llarp/util/str.hpp>
|
||||
|
||||
#include <cctype>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "key_manager.hpp"
|
||||
|
||||
#include <system_error>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include "config.hpp"
|
||||
#include <llarp/crypto/crypto.hpp>
|
||||
#include <llarp/crypto/types.hpp>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "reachability_testing.hpp"
|
||||
#include <chrono>
|
||||
#include <llarp/router/abstractrouter.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/crypto/crypto.hpp>
|
||||
|
||||
using std::chrono::steady_clock;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "nodedb.hpp"
|
||||
#include "router/router.hpp"
|
||||
#include "service/context.hpp"
|
||||
#include "util/logging/logger.hpp"
|
||||
#include "util/logging.hpp"
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
#include <csignal>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "encrypted_frame.hpp"
|
||||
|
||||
#include "crypto.hpp"
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/util/mem.hpp>
|
||||
|
||||
namespace llarp
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace llarp
|
|||
|
||||
operator RouterID() const
|
||||
{
|
||||
return RouterID(as_array());
|
||||
return {as_array()};
|
||||
}
|
||||
|
||||
PubKey&
|
||||
|
@ -46,12 +46,6 @@ namespace llarp
|
|||
}
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const PubKey& k)
|
||||
{
|
||||
return out << k.ToString();
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(const PubKey& lhs, const PubKey& rhs)
|
||||
{
|
||||
|
@ -97,12 +91,10 @@ namespace llarp
|
|||
bool
|
||||
Recalculate();
|
||||
|
||||
std::ostream&
|
||||
print(std::ostream& stream, int level, int spaces) const
|
||||
std::string_view
|
||||
ToString() const
|
||||
{
|
||||
Printer printer(stream, level, spaces);
|
||||
printer.printValue("secretkey");
|
||||
return stream;
|
||||
return "[secretkey]";
|
||||
}
|
||||
|
||||
PubKey
|
||||
|
@ -123,14 +115,6 @@ namespace llarp
|
|||
SaveToFile(const fs::path& fname) const;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const SecretKey&)
|
||||
{
|
||||
// return out << k.ToHex();
|
||||
// make sure we never print out secret keys
|
||||
return out << "[secretkey]";
|
||||
}
|
||||
|
||||
/// PrivateKey is similar to SecretKey except that it only stores the private
|
||||
/// key value and a hash, unlike SecretKey which stores the seed from which
|
||||
/// the private key and hash value are generated. This is primarily intended
|
||||
|
@ -162,12 +146,10 @@ namespace llarp
|
|||
return data() + 32;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
print(std::ostream& stream, int level, int spaces) const
|
||||
std::string_view
|
||||
ToString() const
|
||||
{
|
||||
Printer printer(stream, level, spaces);
|
||||
printer.printValue("privatekey");
|
||||
return stream;
|
||||
return "[privatekey]";
|
||||
}
|
||||
|
||||
/// Computes the public key
|
||||
|
@ -175,14 +157,6 @@ namespace llarp
|
|||
toPublic(PubKey& pubkey) const;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const PrivateKey&)
|
||||
{
|
||||
// return out << k.ToHex();
|
||||
// make sure we never print out private keys
|
||||
return out << "[privatekey]";
|
||||
}
|
||||
|
||||
/// IdentitySecret is a secret key from a service node secret seed
|
||||
struct IdentitySecret final : public AlignedBuffer<32>
|
||||
{
|
||||
|
@ -197,14 +171,22 @@ namespace llarp
|
|||
/// load service node seed from file
|
||||
bool
|
||||
LoadFromFile(const fs::path& fname);
|
||||
|
||||
std::string_view
|
||||
ToString() const
|
||||
{
|
||||
return "[IdentitySecret]";
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const IdentitySecret&)
|
||||
{
|
||||
// make sure we never print out secret keys
|
||||
return out << "[IdentitySecret]";
|
||||
}
|
||||
template <>
|
||||
constexpr inline bool IsToStringFormattable<PubKey> = true;
|
||||
template <>
|
||||
constexpr inline bool IsToStringFormattable<SecretKey> = true;
|
||||
template <>
|
||||
constexpr inline bool IsToStringFormattable<PrivateKey> = true;
|
||||
template <>
|
||||
constexpr inline bool IsToStringFormattable<IdentitySecret> = true;
|
||||
|
||||
using ShortHash = AlignedBuffer<SHORTHASHSIZE>;
|
||||
using LongHash = AlignedBuffer<HASHSIZE>;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <llarp/util/aligned.hpp>
|
||||
#include <llarp/router_id.hpp>
|
||||
#include <llarp/util/formattable.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <llarp/path/path_context.hpp>
|
||||
#include <llarp/router/abstractrouter.hpp>
|
||||
#include <llarp/routing/dht_message.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <llarp/path/path_context.hpp>
|
||||
#include <llarp/router/abstractrouter.hpp>
|
||||
#include <llarp/routing/dht_message.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "key.hpp"
|
||||
#include "txowner.hpp"
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/util/status.hpp>
|
||||
|
||||
#include <set>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "dns.hpp"
|
||||
#include "srv_data.hpp"
|
||||
#include <llarp/util/buffer.hpp>
|
||||
#include <llarp/util/logging/logger.hpp>
|
||||
#include <llarp/util/logging.hpp>
|
||||
#include <llarp/util/printer.hpp>
|
||||
#include <llarp/net/ip.hpp>
|
||||
|
||||
|
|