From 7852735b368fa26538ef73850a4d25a3dd91224e Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 2 Oct 2020 05:48:08 -0400 Subject: [PATCH 01/10] tweak configuration defaults --- llarp/config/config.cpp | 6 ++---- llarp/config/key_manager.cpp | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 777aa9ba5..50adbc06c 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -36,7 +36,6 @@ namespace llarp constexpr int DefaultWorkerThreads = 1; constexpr int DefaultNetThreads = 1; constexpr bool DefaultBlockBogons = true; - constexpr bool DefaultEnablePeerStats = true; conf.defineOption("router", "job-queue-size", false, DefaultJobQueueSize, [this](int arg) { if (arg < 1024) @@ -134,7 +133,7 @@ namespace llarp "router", "enable-peer-stats", false, - DefaultEnablePeerStats, + params.isRelay, AssignmentAcceptor(m_enablePeerStats)); m_isRelay = params.isRelay; } @@ -478,7 +477,6 @@ namespace llarp { (void)params; - constexpr bool DefaultWhitelistRouters = false; constexpr auto DefaultLokidRPCAddr = "tcp://127.0.0.1:22023"; conf.defineOption( @@ -491,7 +489,7 @@ namespace llarp }); conf.defineOption( - "lokid", "enabled", false, DefaultWhitelistRouters, AssignmentAcceptor(whitelistRouters)); + "lokid", "enabled", false, params.isRelay, AssignmentAcceptor(whitelistRouters)); conf.defineOption("lokid", "jsonrpc", false, "", [](std::string arg) { if (arg.empty()) diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 5818db155..aebf41171 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -18,7 +18,7 @@ namespace llarp if (m_initialized) return false; - fs::path root = config.router.m_dataDir; + const fs::path root = config.router.m_dataDir; // utility function to assign a path, using the specified config parameter if present and // falling back to root / defaultName if not @@ -31,7 +31,7 @@ namespace llarp { fs::path file(option); if (not file.is_absolute()) - throw std::runtime_error(stringify("override for ", defaultName, " cannot be relative")); + file = root / file; return file; } From 503a92c992fabaaf6d599712d057c589da9a429e Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 2 Oct 2020 05:51:52 -0400 Subject: [PATCH 02/10] un limit lmq --- llarp/router/router.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 7cba6c818..8fb737ccb 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -66,7 +66,8 @@ namespace llarp , m_lokidRpcClient(std::make_shared(m_lmq, this)) { m_keyManager = std::make_shared(); - + // for lokid, so we don't close the connection when syncing the whitelist + m_lmq->MAX_MSG_SIZE = -1; _stopping.store(false); _running.store(false); _lastTick = llarp::time_now_ms(); From 3445716fceefeaffe9805e3038845440cd8aad74 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 2 Oct 2020 06:16:01 -0400 Subject: [PATCH 03/10] update readme build info --- readme.md | 24 +++++++++++++----------- readme_es.md | 34 ++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/readme.md b/readme.md index de4d976a9..9f98746ca 100644 --- a/readme.md +++ b/readme.md @@ -62,7 +62,9 @@ Build requirements: * C++ 17 capable C++ compiler * libuv >= 1.27.0 * libsodium >= 1.0.18 -* gcovr (if generating test coverage with gcc) +* libunbound +* libzmq +* sqlite3 ### Linux @@ -71,9 +73,9 @@ build: $ sudo apt install build-essential cmake git libcap-dev curl libuv1-dev libsodium-dev pkg-config $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network - $ mkdir build + $ mkdir build $ cd build - $ cmake .. + $ cmake .. -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON $ make -j$(nproc) install: @@ -84,14 +86,14 @@ install: build: make sure you have cmake, libuv and xcode command line tools installed - + $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network - $ mkdir build + $ mkdir build $ cd build - $ cmake .. + $ cmake .. -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON $ make -j$(nproc) - + install: $ sudo make install @@ -106,16 +108,16 @@ additional build requirements: * cpack setup: - + $ sudo apt install build-essential cmake git pkg-config mingw-w64 nsis - + building: $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network $ mkdir build-windows $ cd build-windows - $ cmake -DNATIVE_BUILD=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_PACKAGE=ON -DCMAKE_TOOLCHAIN_FILE='../contrib/cross/mingw64.cmake' -DWITH_TESTS=OFF -DCMAKE_CROSSCOMPILING=ON .. + $ cmake -DBUILD_STATIC_DEPS=ON -DNATIVE_BUILD=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_PACKAGE=ON -DCMAKE_TOOLCHAIN_FILE='../contrib/cross/mingw64.cmake' -DWITH_TESTS=OFF -DCMAKE_CROSSCOMPILING=ON .. $ cpack -D CPACK_MONOLITHIC_INSTALL=1 -G NSIS .. ### Solaris 2.10+ @@ -146,7 +148,7 @@ install: build: - $ pkg install cmake git curl libuv libsodium pkgconf + $ pkg install cmake git curl libuv libsodium pkgconf libunbound $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network $ mkdir build diff --git a/readme_es.md b/readme_es.md index 94f03a2b7..39d549b79 100644 --- a/readme_es.md +++ b/readme_es.md @@ -67,20 +67,25 @@ Requerimientos de compilaciĆ³n: * GNU Make * CMake -* Compilador C++ que pueda usar C++ 17 +* Compilador C++ que pueda usar C++ 17 * gcovr (para generar la covertura de prueba en gcc) * libuv >= 1.27.0 * libsodium >= 1.0.18 -* libcurl +* libunbound +* libzmq +* sqlite3 ### Linux compilando: - $ sudo apt install build-essential cmake git libcap-dev curl libuv1-dev libsodium-dev - $ git clone https://github.com/loki-project/loki-network + $ sudo apt install build-essential cmake git libcap-dev curl libuv1-dev libsodium-dev pkg-config + $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network - $ make + $ mkdir build + $ cd build + $ cmake .. -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON + $ make instalando: @@ -97,9 +102,12 @@ esto coloca el paquete compilado en `../` compilando: este seguro que usted tiene cmake y las herramientas de terminal de xcode ya instaladas - + $ git clone https://github.com/loki-project/loki-network $ cd loki-network + $ mkdir build + $ cd build + $ cmake .. $ make -j8 instalando: @@ -159,9 +167,12 @@ PENDIENTE: agregar instrucciones para pkgsrc compilando: # pkg_add curl cmake git (opcional: ninja ccache) - $ git clone https://github.com/loki-project/loki-network + $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network - $ gmake -j8 + $ mkdir build + $ cd build + $ cmake .. -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON + $ make instalando (root): @@ -172,9 +183,12 @@ instalando (root): compilando: $ pkg install cmake git curl libuv-1.27.0 libsodium - $ git clone https://github.com/loki-project/loki-network + $ git clone --recursive https://github.com/loki-project/loki-network $ cd loki-network - $ gmake -j8 + $ mkdir build + $ cd build + $ cmake .. -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON + $ make instalando (root): From 23302cd10c7786a28c180e56dbd4953f89291fbe Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 10:06:08 -0400 Subject: [PATCH 04/10] use size_left --- llarp/router_contact.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 2fd810f92..33f88ac30 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -235,7 +235,7 @@ namespace llarp try { - std::string_view buf_view(reinterpret_cast(buf->cur), buf->sz); + std::string_view buf_view(reinterpret_cast(buf->cur), buf->size_left()); lokimq::bt_list_consumer btlist(buf_view); uint64_t outer_version = btlist.consume_integer(); @@ -266,7 +266,7 @@ namespace llarp bool RouterContact::DecodeVersion_0(llarp_buffer_t* buf) { - signed_bt_dict = std::string(reinterpret_cast(buf->cur), buf->sz); + signed_bt_dict = std::string(reinterpret_cast(buf->cur), buf->size_left()); return bencode_decode_dict(*this, buf); } From bb67b42f0b3898f360c4957c19ba807b9db8ca02 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 10:06:35 -0400 Subject: [PATCH 05/10] put pubkey_ed25519 in fields --- llarp/rpc/lokid_rpc_client.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llarp/rpc/lokid_rpc_client.cpp b/llarp/rpc/lokid_rpc_client.cpp index 98a97a868..27edff10d 100644 --- a/llarp/rpc/lokid_rpc_client.cpp +++ b/llarp/rpc/lokid_rpc_client.cpp @@ -67,8 +67,9 @@ namespace llarp void LokidRpcClient::UpdateServiceNodeList() { - nlohmann::json request; - request["pubkey_ed25519"] = true; + nlohmann::json request, fields; + fields["pubkey_ed25519"] = true; + request["fields"] = fields; request["active_only"] = true; if (not m_CurrentBlockHash.empty()) request["poll_block_hash"] = m_CurrentBlockHash; From 5b4b1f7aeedf16666e52ae27cb793aa731cb1e50 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 11:08:49 -0400 Subject: [PATCH 06/10] disable whitelist in unit test --- test/exit/test_llarp_exit_context.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/exit/test_llarp_exit_context.cpp b/test/exit/test_llarp_exit_context.cpp index b7546d39f..4cb2bbb2d 100644 --- a/test/exit/test_llarp_exit_context.cpp +++ b/test/exit/test_llarp_exit_context.cpp @@ -19,6 +19,7 @@ make_context() conf.bootstrap.skipBootstrap = true; conf.api.m_enableRPCServer = false; conf.router.m_enablePeerStats = true; + conf.lokid.whitelistRouters = false; conf.router.m_publicAddress = llarp::IpAddress("1.1.1.1"); // make a fake inbound link conf.links.m_InboundLinks.emplace_back(); From 79dfb6d3571ebb78d7a6cc9b8a90cc156f6e718a Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 11:09:13 -0400 Subject: [PATCH 07/10] kill lmq before stopping links/ --- llarp/router/router.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 8fb737ccb..aa943a62e 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -1119,6 +1119,7 @@ namespace llarp StopLinks(); nodedb()->AsyncFlushToDisk(); _logic->call_later(200ms, std::bind(&Router::AfterStopLinks, this)); + m_lmq.reset(); } void From c04cbfe34f5acd214d9c729b90884ac774146870 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 11:09:38 -0400 Subject: [PATCH 08/10] fix decode version 0 rc when in version 1 mode --- llarp/router_contact.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 33f88ac30..f31705900 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -266,8 +266,12 @@ namespace llarp bool RouterContact::DecodeVersion_0(llarp_buffer_t* buf) { - signed_bt_dict = std::string(reinterpret_cast(buf->cur), buf->size_left()); - return bencode_decode_dict(*this, buf); + auto begin = reinterpret_cast(buf->cur); + if (not bencode_decode_dict(*this, buf)) + return false; + auto end = reinterpret_cast(buf->cur); + signed_bt_dict = std::string(begin, std::distance(begin, end)); + return true; } bool From 4f3ed5d1c43bda46e622b3ce501853f0fc0f6be7 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Fri, 2 Oct 2020 11:41:21 -0400 Subject: [PATCH 09/10] remove unnecessary code the signed_bt_dict field is not used for a Version 0 RC anyway, so no need to handle it here. That was my bad. --- llarp/router_contact.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index f31705900..bce459d1d 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -266,12 +266,7 @@ namespace llarp bool RouterContact::DecodeVersion_0(llarp_buffer_t* buf) { - auto begin = reinterpret_cast(buf->cur); - if (not bencode_decode_dict(*this, buf)) - return false; - auto end = reinterpret_cast(buf->cur); - signed_bt_dict = std::string(begin, std::distance(begin, end)); - return true; + return bencode_decode_dict(*this, buf); } bool From f79740531819ff3e8a9c76cf47f6ff735247f6bf Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 2 Oct 2020 14:11:39 -0400 Subject: [PATCH 10/10] ping lokid every 30 second after starting up --- llarp/rpc/lokid_rpc_client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llarp/rpc/lokid_rpc_client.cpp b/llarp/rpc/lokid_rpc_client.cpp index 27edff10d..3b6417a84 100644 --- a/llarp/rpc/lokid_rpc_client.cpp +++ b/llarp/rpc/lokid_rpc_client.cpp @@ -101,7 +101,7 @@ namespace llarp void LokidRpcClient::Connected() { - constexpr auto PingInterval = 1min; + constexpr auto PingInterval = 30s; constexpr auto NodeListUpdateInterval = 30s; auto makePingRequest = [self = shared_from_this()]() { @@ -114,7 +114,6 @@ namespace llarp }, payload.dump()); }; - makePingRequest(); m_lokiMQ->add_timer(makePingRequest, PingInterval); m_lokiMQ->add_timer( [self = shared_from_this()]() { self->UpdateServiceNodeList(); }, NodeListUpdateInterval);