From 7f27760c97da11dcca0b7aa54f869989a65fb7da Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 29 Aug 2022 10:24:04 -0400 Subject: [PATCH] disable lokinet-bootstrap on windows builds --- contrib/windows-configure.sh | 1 + daemon/CMakeLists.txt | 1 - daemon/lokinet.cpp | 2 +- llarp/constants/files.hpp | 23 +++++++++++++---------- llarp/dns/multi_platform.hpp | 1 - llarp/dns/nm_platform.hpp | 1 - llarp/dns/null_platform.hpp | 1 - llarp/dns/sd_platform.hpp | 1 - llarp/ev/ev.hpp | 1 - llarp/win32/windivert.cpp | 12 +++++++++--- 10 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 llarp/dns/multi_platform.hpp delete mode 100644 llarp/dns/null_platform.hpp diff --git a/contrib/windows-configure.sh b/contrib/windows-configure.sh index c4e193fe3..49668c7e7 100755 --- a/contrib/windows-configure.sh +++ b/contrib/windows-configure.sh @@ -21,6 +21,7 @@ cmake \ -DBUILD_TESTING=OFF \ -DBUILD_LIBLOKINET=OFF \ -DWITH_TESTS=OFF \ + -DWITH_BOOTSTRAP=OFF \ -DNATIVE_BUILD=OFF \ -DSTATIC_LINK=ON \ -DWITH_SYSTEMD=OFF \ diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 5372fe46d..c9ff4aec6 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -55,7 +55,6 @@ endif() foreach(exe ${exetargets}) if(WIN32) target_sources(${exe} PRIVATE ${CMAKE_BINARY_DIR}/${exe}.rc) - target_compile_options(${exe} PRIVATE $<$:-fpermissive>) target_link_libraries(${exe} PRIVATE -static-libstdc++ -static-libgcc --static -Wl,--pic-executable,-e,mainCRTStartup,--subsystem,console:5.00) elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") target_link_directories(${exe} PRIVATE /usr/local/lib) diff --git a/daemon/lokinet.cpp b/daemon/lokinet.cpp index 8ff06fdfd..ed8bfc09b 100644 --- a/daemon/lokinet.cpp +++ b/daemon/lokinet.cpp @@ -680,7 +680,7 @@ win32_daemon_entry(DWORD argc, LPTSTR* argv) ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000); // SCM clobbers startup args, regenerate them here argc = 2; - argv[1] = strdup("c:/programdata/lokinet/lokinet.ini"); + argv[1] = strdup("c:\\programdata\\lokinet\\lokinet.ini"); argv[2] = nullptr; lokinet_main(argc, argv); } diff --git a/llarp/constants/files.hpp b/llarp/constants/files.hpp index 27d7dd69a..6e0085121 100644 --- a/llarp/constants/files.hpp +++ b/llarp/constants/files.hpp @@ -1,4 +1,5 @@ #pragma once +#include "platform.hpp" #include @@ -21,20 +22,22 @@ namespace llarp inline fs::path GetDefaultDataDir() { -#ifdef _WIN32 - return "C:/programdata/lokinet"; -#else - fs::path datadir{"/var/lib/lokinet"}; - - if (auto uid = ::geteuid()) + if constexpr (not platform::is_windows) { - if (auto* pw = getpwuid(uid)) + fs::path datadir{"/var/lib/lokinet"}; +#ifndef _WIN32 + if (auto uid = geteuid()) { - datadir = fs::path{pw->pw_dir} / ".lokinet"; + if (auto* pw = getpwuid(uid)) + { + datadir = fs::path{pw->pw_dir} / ".lokinet"; + } } - } - return datadir; #endif + return datadir; + } + else + return "C:\\ProgramData\\Lokinet"; } inline fs::path diff --git a/llarp/dns/multi_platform.hpp b/llarp/dns/multi_platform.hpp deleted file mode 100644 index 8b1378917..000000000 --- a/llarp/dns/multi_platform.hpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/llarp/dns/nm_platform.hpp b/llarp/dns/nm_platform.hpp index 742b050c6..593cfaa28 100644 --- a/llarp/dns/nm_platform.hpp +++ b/llarp/dns/nm_platform.hpp @@ -1,6 +1,5 @@ #pragma once #include "platform.hpp" -#include "null_platform.hpp" #include #include diff --git a/llarp/dns/null_platform.hpp b/llarp/dns/null_platform.hpp deleted file mode 100644 index 8b1378917..000000000 --- a/llarp/dns/null_platform.hpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/llarp/dns/sd_platform.hpp b/llarp/dns/sd_platform.hpp index 532e73a15..27db6d6fa 100644 --- a/llarp/dns/sd_platform.hpp +++ b/llarp/dns/sd_platform.hpp @@ -1,6 +1,5 @@ #pragma once #include "platform.hpp" -#include "null_platform.hpp" #include #include diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index 54e9046f5..6addbf3d5 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -223,7 +223,6 @@ namespace llarp return nullptr; } - protected: // Triggers an event loop wakeup; use when something has been done that requires the event loop // to wake up (e.g. adding to queues). This is called implicitly by call() and call_soon(). // Idempotent and thread-safe. diff --git a/llarp/win32/windivert.cpp b/llarp/win32/windivert.cpp index 4e4e4d3f4..359d0f7b2 100644 --- a/llarp/win32/windivert.cpp +++ b/llarp/win32/windivert.cpp @@ -66,6 +66,8 @@ namespace llarp::win32 HANDLE m_Handle; std::thread m_Runner; thread::Queue m_RecvQueue; + // dns packet queue size + static constexpr size_t recv_queue_size = 64; public: WinDivert_IO( @@ -132,7 +134,7 @@ namespace llarp::win32 virtual net::IPPacket ReadNextPacket() override { - auto w_pkt = recv_packet(); + auto w_pkt = m_RecvQueue.tryPopFront(); if (not w_pkt) return net::IPPacket{}; net::IPPacket pkt{std::move(w_pkt->pkt)}; @@ -150,17 +152,21 @@ namespace llarp::win32 throw std::runtime_error{"windivert thread is already running"}; auto read_loop = [this]() { - log::debug(cat, "windivert read loop start"); + log::info(cat, "windivert read loop start"); while (true) { // in the read loop, read packets until they stop coming in // each packet is sent off if (auto maybe_pkt = recv_packet()) + { m_RecvQueue.pushBack(std::move(*maybe_pkt)); + // wake up event loop + m_Wake(); + } else // leave loop on read fail break; } - log::debug(cat, "windivert read loop end"); + log::info(cat, "windivert read loop end"); }; m_Runner = std::thread{std::move(read_loop)};