Skip to content

Commit

Permalink
Merge pull request #2228 from dr7ana/trust-model
Browse files Browse the repository at this point in the history
Trust model
  • Loading branch information
dr7ana authored Jan 16, 2024
2 parents c693569 + 7421d59 commit a4bd780
Show file tree
Hide file tree
Showing 70 changed files with 3,621 additions and 2,549 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ testnet_tmp
vsproject/
.vs

daemon.ini
*.ini


.gradle/
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ if(APPLE)
set(LOKINET_APPLE_BUILD 5)
endif()

set(LOKINET_RELEASE_MOTTO "Anonymous, decentralized, IP-based overlay network" CACHE STRING "Release motto")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

set(DEFAULT_WITH_BOOTSTRAP ON)
Expand Down
Binary file modified contrib/bootstrap/testnet.signed
Binary file not shown.
2 changes: 1 addition & 1 deletion daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ endforeach()
target_link_libraries(lokinet PRIVATE CLI11)
target_link_libraries(lokinet-vpn PRIVATE CLI11)

if(SETCAP)
if(WITH_SETCAP)
install(CODE "execute_process(COMMAND ${SETCAP} cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
endif()

Expand Down
4 changes: 1 addition & 3 deletions daemon/lokinet-bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ int
main(int argc, char* argv[])
{
const std::unordered_map<std::string, std::string> bootstrap_urls = {
{"mainnet", "https://seed.lokinet.org/lokinet.signed"},
{"lokinet", "https://seed.lokinet.org/lokinet.signed"},
{"testnet", "https://seed.lokinet.org/testnet.signed"},
{"gamma", "https://seed.lokinet.org/testnet.signed"}};
{"testnet", "https://seed.lokinet.org/testnet.signed"}};

std::string bootstrap_url = bootstrap_urls.at("lokinet");
fs::path outputfile{llarp::GetDefaultBootstrap()};
Expand Down
56 changes: 29 additions & 27 deletions daemon/lokinet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace

if (!GetModuleFileName(nullptr, szPath.data(), MAX_PATH))
{
llarp::LogError("Cannot install service ", GetLastError());
llarp::log::error(logcat, "Cannot install service {}", GetLastError());
return;
}

Expand All @@ -137,7 +137,7 @@ namespace

if (nullptr == schSCManager)
{
llarp::LogError("OpenSCManager failed ", GetLastError());
llarp::log::error(logcat, "OpenSCManager failed {}", GetLastError());
return;
}

Expand All @@ -159,12 +159,12 @@ namespace

if (schService == nullptr)
{
llarp::LogError("CreateService failed ", GetLastError());
llarp::log::error(logcat, "CreateService failed {}", GetLastError());
CloseServiceHandle(schSCManager);
return;
}
else
llarp::LogInfo("Service installed successfully");
llarp::log::info(logcat, "Service installed successfully");

CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
Expand All @@ -189,7 +189,7 @@ namespace

if (nullptr == schSCManager)
{
llarp::LogError("OpenSCManager failed ", GetLastError());
llarp::log::error(logcat, "OpenSCManager failed {}", GetLastError());
return;
}

Expand All @@ -201,7 +201,7 @@ namespace

if (schService == nullptr)
{
llarp::LogError("OpenService failed ", GetLastError());
llarp::log::error(logcat, "OpenService failed {}", GetLastError());
CloseServiceHandle(schSCManager);
return;
}
Expand All @@ -214,10 +214,10 @@ namespace
SERVICE_CONFIG_DESCRIPTION, // change: description
&sd)) // new description
{
llarp::LogError("ChangeServiceConfig2 failed");
llarp::log::error(logcat, "ChangeServiceConfig2 failed");
}
else
llarp::LogInfo("Service description updated successfully.");
llarp::log::info(log_cat, "Service description updated successfully.");

CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
Expand All @@ -237,7 +237,7 @@ namespace

if (nullptr == schSCManager)
{
llarp::LogError("OpenSCManager failed ", GetLastError());
llarp::log::error(logcat, "OpenSCManager failed {}", GetLastError());
return;
}

Expand All @@ -249,18 +249,18 @@ namespace

if (schService == nullptr)
{
llarp::LogError("OpenService failed ", GetLastError());
llarp::log::error(logcat, "OpenService failed {}", GetLastError());
CloseServiceHandle(schSCManager);
return;
}

// Delete the service.
if (!DeleteService(schService))
{
llarp::LogError("DeleteService failed ", GetLastError());
llarp::log::error(logcat, "DeleteService failed {}", GetLastError());
}
else
llarp::LogInfo("Service deleted successfully\n");
llarp::log::info(logcat, "Service deleted successfully");

CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace

if (svc->handle == nullptr)
{
llarp::LogError("failed to register daemon control handler");
llarp::log::error(logcat, "failed to register daemon control handler");
return;
}

Expand Down Expand Up @@ -442,6 +442,9 @@ namespace
cli.exit(e);
};

// TESTNET:
oxen::log::set_level("quic", oxen::log::Level::critical);

if (configFile.has_value())
{
// when we have an explicit filepath
Expand All @@ -454,7 +457,7 @@ namespace
}
catch (std::exception& ex)
{
llarp::LogError("cannot generate config at ", *configFile, ": ", ex.what());
llarp::log::error(logcat, "cannot generate config at {}: {}", *configFile, ex.what());
return 1;
}
}
Expand All @@ -464,13 +467,13 @@ namespace
{
if (!fs::exists(*configFile))
{
llarp::LogError("Config file not found ", *configFile);
llarp::log::error(logcat, "Config file not found {}", *configFile);
return 1;
}
}
catch (std::exception& ex)
{
llarp::LogError("cannot check if ", *configFile, " exists: ", ex.what());
llarp::log::error(logcat, "cannot check if ", *configFile, " exists: ", ex.what());
return 1;
}
}
Expand All @@ -487,7 +490,7 @@ namespace
}
catch (std::exception& ex)
{
llarp::LogError("cannot ensure config: ", ex.what());
llarp::log::error(logcat, "cannot ensure config: {}", ex.what());
return 1;
}
configFile = llarp::GetDefaultConfigPath();
Expand Down Expand Up @@ -548,14 +551,13 @@ namespace
static void
run_main_context(std::optional<fs::path> confFile, const llarp::RuntimeOptions opts)
{
llarp::LogInfo(fmt::format(
"starting up {} {}", llarp::LOKINET_VERSION_FULL, llarp::LOKINET_RELEASE_MOTTO));
llarp::log::info(logcat, "starting up {}", llarp::LOKINET_VERSION_FULL);
try
{
std::shared_ptr<llarp::Config> conf;
if (confFile)
{
llarp::LogInfo("Using config file: ", *confFile);
llarp::log::info(logcat, "Using config file: {}", *confFile);
conf = std::make_shared<llarp::Config>(confFile->parent_path());
}
else
Expand All @@ -564,7 +566,7 @@ namespace
}
if (not conf->load(confFile, opts.isSNode))
{
llarp::LogError("failed to parse configuration");
llarp::log::error(logcat, "failed to parse configuration");
exit_code.set_value(1);
return;
}
Expand All @@ -589,13 +591,13 @@ namespace
}
catch (llarp::util::bind_socket_error& ex)
{
llarp::LogError(fmt::format("{}, is lokinet already running? 🤔", ex.what()));
llarp::log::error(logcat, "{}; is lokinet already running?", ex.what());
exit_code.set_value(1);
return;
}
catch (std::exception& ex)
catch (const std::exception& ex)
{
llarp::LogError(fmt::format("failed to start up lokinet: {}", ex.what()));
llarp::log::error(logcat, "failed to start up lokinet: {}", ex.what());
exit_code.set_value(1);
return;
}
Expand All @@ -604,14 +606,14 @@ namespace
auto result = ctx->Run(opts);
exit_code.set_value(result);
}
catch (std::exception& e)
catch (const std::exception& e)
{
llarp::LogError("Fatal: caught exception while running: ", e.what());
llarp::log::error(logcat, "Fatal: caught exception while running: {}", e.what());
exit_code.set_exception(std::current_exception());
}
catch (...)
{
llarp::LogError("Fatal: caught non-standard exception while running");
llarp::log::error(logcat, "Fatal: caught non-standard exception while running");
exit_code.set_exception(std::current_exception());
}
}
Expand Down
2 changes: 1 addition & 1 deletion external/oxen-encoding
2 changes: 1 addition & 1 deletion external/oxen-libquic
Submodule oxen-libquic updated 46 files
+3 −2 CMakeLists.txt
+0 −1 cmake/StaticBuild.cmake
+1 −1 external/CMakeLists.txt
+1 −1 external/ngtcp2
+1 −1 external/oxen-encoding
+26 −1 include/quic/address.hpp
+122 −66 include/quic/btstream.hpp
+192 −87 include/quic/connection.hpp
+101 −0 include/quic/connection_ids.hpp
+17 −5 include/quic/context.hpp
+7 −1 include/quic/crypto.hpp
+40 −8 include/quic/datagram.hpp
+126 −57 include/quic/endpoint.hpp
+55 −34 include/quic/error.hpp
+21 −33 include/quic/gnutls_crypto.hpp
+18 −0 include/quic/network.hpp
+21 −9 include/quic/opt.hpp
+24 −41 include/quic/stream.hpp
+10 −16 include/quic/utils.hpp
+7 −3 src/CMakeLists.txt
+31 −0 src/address.cpp
+139 −84 src/btstream.cpp
+513 −166 src/connection.cpp
+6 −0 src/context.cpp
+5 −5 src/datagram.cpp
+398 −87 src/endpoint.cpp
+34 −35 src/gnutls_creds.cpp
+172 −156 src/gnutls_session.cpp
+11 −9 src/stream.cpp
+64 −58 tests/001-handshake.cpp
+457 −30 tests/002-send-receive.cpp
+5 −5 tests/003-multiclient.cpp
+494 −127 tests/004-streams.cpp
+2 −2 tests/005-chunked-sender.cpp
+5 −5 tests/006-server-send.cpp
+2 −2 tests/008-conn_hooks.cpp
+12 −12 tests/009-alpns.cpp
+113 −0 tests/010-migration.cpp
+42 −23 tests/CMakeLists.txt
+18 −31 tests/dgram-speed-client.cpp
+29 −33 tests/dgram-speed-server.cpp
+3 −0 tests/main.cpp
+17 −22 tests/speedtest-client.cpp
+29 −25 tests/speedtest-server.cpp
+161 −0 tests/utils.cpp
+72 −79 tests/utils.hpp
4 changes: 2 additions & 2 deletions llarp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ lokinet_add_library(lokinet-nodedb
set(BOOTSTRAP_FALLBACKS)
foreach(bs IN ITEMS MAINNET TESTNET)
if(BOOTSTRAP_FALLBACK_${bs})
message(STATUS "Building with ${bs} fallback boostrap path \"${BOOTSTRAP_FALLBACK_${bs}}\"")
message(STATUS "Building with ${bs} fallback bootstrap path \"${BOOTSTRAP_FALLBACK_${bs}}\"")
file(READ "${BOOTSTRAP_FALLBACK_${bs}}" bs_data HEX)
if(bs STREQUAL TESTNET)
set(network "gamma")
set(network "testnet")
elseif(bs STREQUAL MAINNET)
set(network "lokinet")
else()
Expand Down
Loading

0 comments on commit a4bd780

Please sign in to comment.