From c2a30692cf1ab833092674b8402a9c5fca05b234 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 9 Jun 2020 12:59:49 -0400 Subject: [PATCH 01/22] Implement upstream DNS using libunbound --- llarp/CMakeLists.txt | 3 +- llarp/dns/message.hpp | 3 - llarp/dns/server.cpp | 62 ++++++++++------ llarp/dns/server.hpp | 8 ++- llarp/dns/unbound_resolver.cpp | 128 +++++++++++++++++++++++++++++++++ llarp/dns/unbound_resolver.hpp | 52 ++++++++++++++ llarp/ev/ev.hpp | 7 ++ llarp/ev/ev_libuv.cpp | 46 +++++++++++- llarp/ev/ev_libuv.hpp | 8 +++ 9 files changed, 287 insertions(+), 30 deletions(-) create mode 100644 llarp/dns/unbound_resolver.cpp create mode 100644 llarp/dns/unbound_resolver.hpp diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 41270b359..422ee13ad 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -101,6 +101,7 @@ add_library(liblokinet dns/rr.cpp dns/serialize.cpp dns/server.cpp + dns/unbound_resolver.cpp consensus/table.cpp @@ -220,7 +221,7 @@ if(WITH_HIVE) target_sources(liblokinet PRIVATE tooling/router_hive.cpp) endif() -target_link_libraries(liblokinet PUBLIC cxxopts abyss lokinet-platform lokinet-util lokinet-cryptography) +target_link_libraries(liblokinet PUBLIC cxxopts unbound abyss lokinet-platform lokinet-util lokinet-cryptography) if(BUILD_SHARED_LIBS) install(TARGETS lokinet-util lokinet-platform liblokinet LIBRARY DESTINATION lib) diff --git a/llarp/dns/message.hpp b/llarp/dns/message.hpp index b4b0379fb..a0de70189 100644 --- a/llarp/dns/message.hpp +++ b/llarp/dns/message.hpp @@ -48,9 +48,6 @@ namespace llarp Message(Message&& other); Message(const Message& other); - void - UpdateHeader(); - void AddNXReply(RR_TTL_t ttl = 1); diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index e0eeb2e3d..948cace0a 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -37,8 +37,14 @@ namespace llarp bool Proxy::Start(const IpAddress& addr, const std::vector& resolvers) { - m_Resolvers.clear(); - m_Resolvers = resolvers; + if (resolvers.size()) + { + if (not SetupUnboundResolver(resolvers)) + { + return false; + } + } + const IpAddress any("0.0.0.0", 0); auto self = shared_from_this(); LogicCall(m_ClientLogic, [=]() { @@ -89,6 +95,36 @@ namespace llarp return *itr; } + bool + Proxy::SetupUnboundResolver(const std::vector& resolvers) + { + auto replyFunc = [self=weak_from_this()](const SockAddr& to, Message msg) + { + auto this_ptr = self.lock(); + if (this_ptr) + { + this_ptr->SendServerMessageTo(to, msg); + } + }; + + m_UnboundResolver = std::make_shared(m_ServerLoop, std::move(replyFunc)); + if (not m_UnboundResolver->Init()) + { + m_UnboundResolver = nullptr; + return false; + } + for (const auto& resolver : resolvers) + { + if (not m_UnboundResolver->AddUpstreamResolver(resolver.toString())) + { + m_UnboundResolver = nullptr; + return false; + } + } + + return true; + } + void Proxy::HandleTick(llarp_udp_io*) { @@ -186,7 +222,6 @@ namespace llarp } TX tx = {hdr.id, from}; - auto itr = m_Forwarded.find(tx); Message msg(hdr); if (!msg.Decode(&pkt)) { @@ -222,7 +257,7 @@ namespace llarp llarp::LogWarn("failed to handle hooked dns"); } } - else if (m_Resolvers.size() == 0) + else if (not m_UnboundResolver) { // no upstream resolvers // let's serv fail it @@ -230,26 +265,9 @@ namespace llarp SendServerMessageTo(from, std::move(msg)); } - else if (itr == m_Forwarded.end()) - { - // new forwarded query - tx.from = PickRandomResolver(); - m_Forwarded[tx] = from; - LogicCall(m_ClientLogic, [=] { - // do query - const llarp_buffer_t tmpbuf(buf); - llarp_ev_udp_sendto(&self->m_Client, tx.from.createSockAddr(), tmpbuf); - }); - } else { - // send the query again because it's probably FEC from the requester - const auto resolver = itr->first.from; - LogicCall(m_ClientLogic, [=] { - // send it - const llarp_buffer_t tmpbuf(buf); - llarp_ev_udp_sendto(&self->m_Client, resolver.createSockAddr(), tmpbuf); - }); + m_UnboundResolver->Lookup(from, msg); } } diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index 40cb4cca6..706412211 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -55,9 +56,6 @@ namespace llarp static void HandleTick(llarp_udp_io*); - void - Tick(llarp_time_t now); - void HandlePktClient(const SockAddr& from, Buffer_t buf); @@ -73,6 +71,9 @@ namespace llarp IpAddress PickRandomResolver() const; + bool + SetupUnboundResolver(const std::vector& resolvers); + private: llarp_udp_io m_Server; llarp_udp_io m_Client; @@ -82,6 +83,7 @@ namespace llarp Logic_ptr m_ClientLogic; IQueryHandler* m_QueryHandler; std::vector m_Resolvers; + std::shared_ptr m_UnboundResolver; struct TX { diff --git a/llarp/dns/unbound_resolver.cpp b/llarp/dns/unbound_resolver.cpp new file mode 100644 index 000000000..bafd3b2f0 --- /dev/null +++ b/llarp/dns/unbound_resolver.cpp @@ -0,0 +1,128 @@ +#include + +#include +#include + +namespace llarp::dns +{ + struct PendingUnboundLookup + { + std::weak_ptr resolver; + Message msg; + SockAddr source; + }; + + void UnboundResolver::Reset() + { + started = false; + if (unboundContext) + { + DeregisterPollFD(); + ub_ctx_delete(unboundContext); + } + unboundContext = nullptr; + } + + void UnboundResolver::DeregisterPollFD() + { + eventLoop->deregister_poll_fd_readable(ub_fd(unboundContext)); + } + + void UnboundResolver::RegisterPollFD() + { + eventLoop->register_poll_fd_readable(ub_fd(unboundContext), [=](){ ub_process(unboundContext); }); + } + + UnboundResolver::UnboundResolver( + llarp_ev_loop_ptr eventLoop, + ReplyFunction replyFunc) + : unboundContext(nullptr), started(false), eventLoop(eventLoop), replyFunc(replyFunc) + { + } + + // static callback + void UnboundResolver::Callback(void* data, int err, ub_result* result) + { + std::unique_ptr lookup{static_cast(data)}; + + auto this_ptr = lookup->resolver.lock(); + if (not this_ptr) return; // resolver is gone, so we don't reply. + + if (err != 0) + { + Message& msg = lookup->msg; + msg.AddServFail(); + this_ptr->replyFunc(lookup->source, msg); + ub_resolve_free(result); + return; + } + + llarp_buffer_t buf; + buf.base = buf.cur = static_cast(result->answer_packet); + buf.sz = result->answer_len; + + MessageHeader hdr; + hdr.Decode(&buf); + hdr.id = lookup->msg.hdr_id; + + Message msg(hdr); + msg.Decode(&buf); + + this_ptr->replyFunc(lookup->source, msg); + + ub_resolve_free(result); + } + + bool UnboundResolver::Init() + { + if (started) + { + Reset(); + } + + unboundContext = ub_ctx_create(); + + if (not unboundContext) + { + return false; + } + + RegisterPollFD(); + + return true; + } + + bool UnboundResolver::AddUpstreamResolver(const std::string& upstreamResolverIP) + { + if (ub_ctx_set_fwd(unboundContext, upstreamResolverIP.c_str()) != 0) + { + Reset(); + return false; + } + return true; + } + + void UnboundResolver::Lookup(const SockAddr& source, Message& msg) + { + if (not unboundContext) + { + msg.AddServFail(); + replyFunc(source, msg); + return; + } + + started = true; + + const auto& q = msg.questions[0]; + auto* lookup = new PendingUnboundLookup{weak_from_this(), msg, source}; + int err = ub_resolve_async(unboundContext, q.Name().c_str(), q.qtype, q.qclass, (void*)lookup, &UnboundResolver::Callback, nullptr); + + if (err != 0) + { + msg.AddServFail(); + replyFunc(source, msg); + return; + } + } + +} // namespace llarp::dns diff --git a/llarp/dns/unbound_resolver.hpp b/llarp/dns/unbound_resolver.hpp new file mode 100644 index 000000000..9d980f8b9 --- /dev/null +++ b/llarp/dns/unbound_resolver.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace llarp::dns +{ + using ReplyFunction = std::function; + + class UnboundResolver : public std::enable_shared_from_this + { + + private: + ub_ctx* unboundContext; + + bool started; + + llarp_ev_loop_ptr eventLoop; + ReplyFunction replyFunc; + + void Reset(); + + void DeregisterPollFD(); + void RegisterPollFD(); + + public: + + + UnboundResolver( + llarp_ev_loop_ptr eventLoop, + ReplyFunction replyFunc); + + static void Callback(void* data, int err, ub_result* result); + + // upstream resolver IP can be IPv4 or IPv6 + bool Init(); + + bool AddUpstreamResolver(const std::string& upstreamResolverIP); + + void Lookup(const SockAddr& source, Message& msg); + }; + +} // namespace llarp::dns + diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index ee9789e51..be43c471d 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -810,6 +810,13 @@ struct llarp_ev_loop virtual void call_soon(std::function f) = 0; + + virtual void + register_poll_fd_readable(int fd, std::function callback) = 0; + + virtual void + deregister_poll_fd_readable(int fd) = 0; + }; #endif diff --git a/llarp/ev/ev_libuv.cpp b/llarp/ev/ev_libuv.cpp index 0334b87cd..3ecf5b37f 100644 --- a/llarp/ev/ev_libuv.cpp +++ b/llarp/ev/ev_libuv.cpp @@ -957,7 +957,7 @@ namespace libuv [](uv_handle_t* h, void*) { if (uv_is_closing(h)) return; - if (h->data && uv_is_active(h) && h->type != UV_TIMER) + if (h->data && uv_is_active(h) && h->type != UV_TIMER && h->type != UV_POLL) { static_cast(h->data)->Close(); } @@ -1056,4 +1056,48 @@ namespace libuv uv_async_send(&m_WakeUp); } + void + OnUVPollFDReadable(uv_poll_t* handle, int status, [[maybe_unused]] int events) + { + if (status < 0) return; // probably fd was closed + + auto func = static_cast(handle->data); + + (*func)(); + } + + void + Loop::register_poll_fd_readable(int fd, Callback callback) + { + if (m_Polls.count(fd)) + { + llarp::LogError("Attempting to create event loop poll on fd ", fd, ", but an event loop poll for that fd already exists."); + return; + } + + // new a copy as the one passed in here will go out of scope + auto function_ptr = new Callback(callback); + + auto& new_poll = m_Polls[fd]; + + uv_poll_init(&m_Impl, &new_poll, fd); + new_poll.data = (void *) function_ptr; + uv_poll_start(&new_poll, UV_READABLE, &OnUVPollFDReadable); + + } + + void + Loop::deregister_poll_fd_readable(int fd) + { + auto itr = m_Polls.find(fd); + + if (itr != m_Polls.end()) + { + uv_poll_stop(&(itr->second)); + auto func = static_cast(itr->second.data); + delete func; + m_Polls.erase(itr); + } + } + } // namespace libuv diff --git a/llarp/ev/ev_libuv.hpp b/llarp/ev/ev_libuv.hpp index 3eac53481..6d4cd5bb0 100644 --- a/llarp/ev/ev_libuv.hpp +++ b/llarp/ev/ev_libuv.hpp @@ -125,6 +125,12 @@ namespace libuv void call_soon(std::function f) override; + void + register_poll_fd_readable(int fd, Callback callback) override; + + void + deregister_poll_fd_readable(int fd) override; + void FlushLogic(); @@ -144,6 +150,8 @@ namespace libuv std::map m_pendingCalls; + std::unordered_map m_Polls; + llarp::thread::Queue m_timerQueue; llarp::thread::Queue m_timerCancelQueue; }; From df284cb75711add86e33cddc8b8c55f31fb958fa Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Thu, 11 Jun 2020 15:27:29 -0400 Subject: [PATCH 02/22] proper CMake finding and using of libunbound --- CMakeLists.txt | 29 ++++++++++++++++------------- llarp/CMakeLists.txt | 4 +++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ff8ae7ec..146aadeda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,20 +226,23 @@ endif() string(REGEX REPLACE "^fatal.*$" nogit GIT_VERSION_REAL "${GIT_VERSION}") -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(SD libsystemd) - # Default WITH_SYSTEMD to true if we found it - option(WITH_SYSTEMD "enable systemd integration for sd_notify" ${SD_FOUND}) +find_package(PkgConfig REQUIRED) - if(WITH_SYSTEMD) - if(NOT SD_FOUND) - message(FATAL_ERROR "libsystemd not found") - endif() - add_definitions(-DWITH_SYSTEMD) - include_directories(${SD_INCLUDE_DIRS}) - set(SD_LIBS ${SD_LDFLAGS}) - endif() +pkg_check_modules(UNBOUND libunbound REQUIRED IMPORTED_TARGET) + +add_library(libunbound INTERFACE) + +pkg_check_modules(SD libsystemd) +# Default WITH_SYSTEMD to true if we found it +option(WITH_SYSTEMD "enable systemd integration for sd_notify" ${SD_FOUND}) + +if(WITH_SYSTEMD) + if(NOT SD_FOUND) + message(FATAL_ERROR "libsystemd not found") + endif() + add_definitions(-DWITH_SYSTEMD) + include_directories(${SD_INCLUDE_DIRS}) + set(SD_LIBS ${SD_LDFLAGS}) endif() option(SUBMODULE_CHECK "Enables checking that vendored library submodules are up to date" ON) diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 422ee13ad..d7ba67482 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -221,7 +221,9 @@ if(WITH_HIVE) target_sources(liblokinet PRIVATE tooling/router_hive.cpp) endif() -target_link_libraries(liblokinet PUBLIC cxxopts unbound abyss lokinet-platform lokinet-util lokinet-cryptography) +target_link_libraries(liblokinet PUBLIC cxxopts abyss lokinet-platform lokinet-util lokinet-cryptography) + +target_link_libraries(liblokinet PRIVATE PkgConfig::UNBOUND) if(BUILD_SHARED_LIBS) install(TARGETS lokinet-util lokinet-platform liblokinet LIBRARY DESTINATION lib) From f58c7df54d90c58256cac18ec9bea03d68aaa827 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Thu, 11 Jun 2020 15:35:38 -0400 Subject: [PATCH 03/22] add libunbound-dev dep to drone config --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 58ca7ae6e..c655dcec4 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,4 +1,4 @@ -local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev'; +local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev libunbound-dev'; local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement From 221e9ff5dec54a65bb3eb82bf745899c78502a69 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Thu, 11 Jun 2020 15:36:19 -0400 Subject: [PATCH 04/22] make format --- llarp/dns/server.cpp | 15 ++++++------ llarp/dns/unbound_resolver.cpp | 44 ++++++++++++++++++++++------------ llarp/dns/unbound_resolver.hpp | 35 ++++++++++++++------------- llarp/ev/ev.hpp | 1 - llarp/ev/ev_libuv.cpp | 15 +++++++----- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 948cace0a..0a0faf701 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -98,14 +98,13 @@ namespace llarp bool Proxy::SetupUnboundResolver(const std::vector& resolvers) { - auto replyFunc = [self=weak_from_this()](const SockAddr& to, Message msg) - { - auto this_ptr = self.lock(); - if (this_ptr) - { - this_ptr->SendServerMessageTo(to, msg); - } - }; + auto replyFunc = [self = weak_from_this()](const SockAddr& to, Message msg) { + auto this_ptr = self.lock(); + if (this_ptr) + { + this_ptr->SendServerMessageTo(to, msg); + } + }; m_UnboundResolver = std::make_shared(m_ServerLoop, std::move(replyFunc)); if (not m_UnboundResolver->Init()) diff --git a/llarp/dns/unbound_resolver.cpp b/llarp/dns/unbound_resolver.cpp index bafd3b2f0..7e61f5242 100644 --- a/llarp/dns/unbound_resolver.cpp +++ b/llarp/dns/unbound_resolver.cpp @@ -12,7 +12,8 @@ namespace llarp::dns SockAddr source; }; - void UnboundResolver::Reset() + void + UnboundResolver::Reset() { started = false; if (unboundContext) @@ -23,30 +24,33 @@ namespace llarp::dns unboundContext = nullptr; } - void UnboundResolver::DeregisterPollFD() + void + UnboundResolver::DeregisterPollFD() { eventLoop->deregister_poll_fd_readable(ub_fd(unboundContext)); } - void UnboundResolver::RegisterPollFD() + void + UnboundResolver::RegisterPollFD() { - eventLoop->register_poll_fd_readable(ub_fd(unboundContext), [=](){ ub_process(unboundContext); }); + eventLoop->register_poll_fd_readable( + ub_fd(unboundContext), [=]() { ub_process(unboundContext); }); } - UnboundResolver::UnboundResolver( - llarp_ev_loop_ptr eventLoop, - ReplyFunction replyFunc) - : unboundContext(nullptr), started(false), eventLoop(eventLoop), replyFunc(replyFunc) + UnboundResolver::UnboundResolver(llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc) + : unboundContext(nullptr), started(false), eventLoop(eventLoop), replyFunc(replyFunc) { } // static callback - void UnboundResolver::Callback(void* data, int err, ub_result* result) + void + UnboundResolver::Callback(void* data, int err, ub_result* result) { std::unique_ptr lookup{static_cast(data)}; auto this_ptr = lookup->resolver.lock(); - if (not this_ptr) return; // resolver is gone, so we don't reply. + if (not this_ptr) + return; // resolver is gone, so we don't reply. if (err != 0) { @@ -73,7 +77,8 @@ namespace llarp::dns ub_resolve_free(result); } - bool UnboundResolver::Init() + bool + UnboundResolver::Init() { if (started) { @@ -92,7 +97,8 @@ namespace llarp::dns return true; } - bool UnboundResolver::AddUpstreamResolver(const std::string& upstreamResolverIP) + bool + UnboundResolver::AddUpstreamResolver(const std::string& upstreamResolverIP) { if (ub_ctx_set_fwd(unboundContext, upstreamResolverIP.c_str()) != 0) { @@ -102,7 +108,8 @@ namespace llarp::dns return true; } - void UnboundResolver::Lookup(const SockAddr& source, Message& msg) + void + UnboundResolver::Lookup(const SockAddr& source, Message& msg) { if (not unboundContext) { @@ -115,7 +122,14 @@ namespace llarp::dns const auto& q = msg.questions[0]; auto* lookup = new PendingUnboundLookup{weak_from_this(), msg, source}; - int err = ub_resolve_async(unboundContext, q.Name().c_str(), q.qtype, q.qclass, (void*)lookup, &UnboundResolver::Callback, nullptr); + int err = ub_resolve_async( + unboundContext, + q.Name().c_str(), + q.qtype, + q.qclass, + (void*)lookup, + &UnboundResolver::Callback, + nullptr); if (err != 0) { @@ -125,4 +139,4 @@ namespace llarp::dns } } -} // namespace llarp::dns +} // namespace llarp::dns diff --git a/llarp/dns/unbound_resolver.hpp b/llarp/dns/unbound_resolver.hpp index 9d980f8b9..7db878b24 100644 --- a/llarp/dns/unbound_resolver.hpp +++ b/llarp/dns/unbound_resolver.hpp @@ -17,8 +17,7 @@ namespace llarp::dns class UnboundResolver : public std::enable_shared_from_this { - - private: + private: ub_ctx* unboundContext; bool started; @@ -26,27 +25,29 @@ namespace llarp::dns llarp_ev_loop_ptr eventLoop; ReplyFunction replyFunc; - void Reset(); + void + Reset(); - void DeregisterPollFD(); - void RegisterPollFD(); + void + DeregisterPollFD(); + void + RegisterPollFD(); - public: + public: + UnboundResolver(llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc); - - UnboundResolver( - llarp_ev_loop_ptr eventLoop, - ReplyFunction replyFunc); - - static void Callback(void* data, int err, ub_result* result); + static void + Callback(void* data, int err, ub_result* result); // upstream resolver IP can be IPv4 or IPv6 - bool Init(); + bool + Init(); - bool AddUpstreamResolver(const std::string& upstreamResolverIP); + bool + AddUpstreamResolver(const std::string& upstreamResolverIP); - void Lookup(const SockAddr& source, Message& msg); + void + Lookup(const SockAddr& source, Message& msg); }; -} // namespace llarp::dns - +} // namespace llarp::dns diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index be43c471d..defd231e5 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -816,7 +816,6 @@ struct llarp_ev_loop virtual void deregister_poll_fd_readable(int fd) = 0; - }; #endif diff --git a/llarp/ev/ev_libuv.cpp b/llarp/ev/ev_libuv.cpp index 3ecf5b37f..78fa8f3e2 100644 --- a/llarp/ev/ev_libuv.cpp +++ b/llarp/ev/ev_libuv.cpp @@ -1059,9 +1059,10 @@ namespace libuv void OnUVPollFDReadable(uv_poll_t* handle, int status, [[maybe_unused]] int events) { - if (status < 0) return; // probably fd was closed + if (status < 0) + return; // probably fd was closed - auto func = static_cast(handle->data); + auto func = static_cast(handle->data); (*func)(); } @@ -1071,7 +1072,10 @@ namespace libuv { if (m_Polls.count(fd)) { - llarp::LogError("Attempting to create event loop poll on fd ", fd, ", but an event loop poll for that fd already exists."); + llarp::LogError( + "Attempting to create event loop poll on fd ", + fd, + ", but an event loop poll for that fd already exists."); return; } @@ -1081,9 +1085,8 @@ namespace libuv auto& new_poll = m_Polls[fd]; uv_poll_init(&m_Impl, &new_poll, fd); - new_poll.data = (void *) function_ptr; + new_poll.data = (void*)function_ptr; uv_poll_start(&new_poll, UV_READABLE, &OnUVPollFDReadable); - } void @@ -1094,7 +1097,7 @@ namespace libuv if (itr != m_Polls.end()) { uv_poll_stop(&(itr->second)); - auto func = static_cast(itr->second.data); + auto func = static_cast(itr->second.data); delete func; m_Polls.erase(itr); } From 4ee95d4ad064474d673813f0f2f7a939b29d4e41 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Thu, 11 Jun 2020 15:48:03 -0400 Subject: [PATCH 05/22] libunbound deps in drone config...watch *them* have deps too --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index c655dcec4..501686c33 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,4 +1,4 @@ -local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev libunbound-dev'; +local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev libunbound-dev nettle-dev libssl-dev'; local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement From 755b4d89b6d265c2aef6c8aec032e179ffbd7839 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Thu, 11 Jun 2020 15:55:07 -0400 Subject: [PATCH 06/22] libunbound deps in drone config 3: dependency boogaloo --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 501686c33..fb568ff7e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,4 +1,4 @@ -local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev libunbound-dev nettle-dev libssl-dev'; +local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev'; local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement From b875d40491338e580b3e4be87d77bee37262d06c Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 15 Jun 2020 14:15:10 -0400 Subject: [PATCH 07/22] restructure how upstream dns replies are handled llarp::dns::Message does not fully support DNS packets, so converting the upstream response to one will not work for all query types. Also it is kinda silly to begin with, as the upstream reply is already a network packet, ready to go. --- llarp/dns/server.cpp | 41 +++++++++++++++++++++++++++++----- llarp/dns/server.hpp | 9 ++++++++ llarp/dns/unbound_resolver.cpp | 26 +++++++++++++-------- llarp/dns/unbound_resolver.hpp | 9 +++++--- 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 0a0faf701..6c56846d8 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -98,17 +98,28 @@ namespace llarp bool Proxy::SetupUnboundResolver(const std::vector& resolvers) { - auto replyFunc = [self = weak_from_this()](const SockAddr& to, Message msg) { + auto failFunc = [self = weak_from_this()](SockAddr to, Message msg) { auto this_ptr = self.lock(); if (this_ptr) { - this_ptr->SendServerMessageTo(to, msg); + this_ptr->SendServerMessageTo(to, std::move(msg)); } }; - m_UnboundResolver = std::make_shared(m_ServerLoop, std::move(replyFunc)); + auto replyFunc = [self = weak_from_this()]( + SockAddr to, std::array buf, size_t len) { + auto this_ptr = self.lock(); + if (this_ptr) + { + this_ptr->HandleUpstreamResponse(to, std::move(buf), len); + } + }; + + m_UnboundResolver = std::make_shared( + m_ServerLoop, std::move(replyFunc), std::move(failFunc)); if (not m_UnboundResolver->Init()) { + llarp::LogError("Failed to initialize upstream DNS resolver."); m_UnboundResolver = nullptr; return false; } @@ -116,6 +127,7 @@ namespace llarp { if (not m_UnboundResolver->AddUpstreamResolver(resolver.toString())) { + llarp::LogError("Failed to add upstream DNS server: ", resolver.toString()); m_UnboundResolver = nullptr; return false; } @@ -129,24 +141,41 @@ namespace llarp { } + void + Proxy::SendServerMessageBufferTo(const SockAddr& to, const llarp_buffer_t& buf) + { + llarp_ev_udp_sendto(&m_Server, to, buf); + } + void Proxy::SendServerMessageTo(const SockAddr& to, Message msg) { auto self = shared_from_this(); - LogicCall(m_ServerLogic, [to, msg, self]() { + LogicCall(m_ServerLogic, [to, msg = std::move(msg), self]() { std::array tmp = {{0}}; llarp_buffer_t buf(tmp); if (msg.Encode(&buf)) { buf.sz = buf.cur - buf.base; buf.cur = buf.base; - llarp_ev_udp_sendto(&self->m_Server, to, buf); + self->SendServerMessageBufferTo(to, buf); } else llarp::LogWarn("failed to encode dns message when sending"); }); } + void + Proxy::HandleUpstreamResponse(SockAddr to, std::array buf, size_t len) + { + auto self = shared_from_this(); + LogicCall(m_ServerLogic, [to, buffer = std::move(buf), self, len]() { + llarp_buffer_t buf(buffer); + buf.sz = len; + self->SendServerMessageBufferTo(to, buf); + }); + } + void Proxy::SendClientMessageTo(const SockAddr& to, Message msg) { @@ -266,7 +295,7 @@ namespace llarp } else { - m_UnboundResolver->Lookup(from, msg); + m_UnboundResolver->Lookup(from, std::move(msg)); } } diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index 706412211..fb91cbdbb 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -65,9 +65,18 @@ namespace llarp void SendClientMessageTo(const SockAddr& to, Message msg); + void + SendServerMessageBufferTo(const SockAddr& to, const llarp_buffer_t& buf); + void SendServerMessageTo(const SockAddr& to, Message msg); + void + HandleUpstreamResponse(SockAddr to, std::array buf, size_t len); + + void + HandleUpstreamFailure(const SockAddr& to, Message msg); + IpAddress PickRandomResolver() const; diff --git a/llarp/dns/unbound_resolver.cpp b/llarp/dns/unbound_resolver.cpp index 7e61f5242..6b02e8b32 100644 --- a/llarp/dns/unbound_resolver.cpp +++ b/llarp/dns/unbound_resolver.cpp @@ -37,8 +37,13 @@ namespace llarp::dns ub_fd(unboundContext), [=]() { ub_process(unboundContext); }); } - UnboundResolver::UnboundResolver(llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc) - : unboundContext(nullptr), started(false), eventLoop(eventLoop), replyFunc(replyFunc) + UnboundResolver::UnboundResolver( + llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc, FailFunction failFunc) + : unboundContext(nullptr) + , started(false) + , eventLoop(eventLoop) + , replyFunc(replyFunc) + , failFunc(failFunc) { } @@ -56,7 +61,7 @@ namespace llarp::dns { Message& msg = lookup->msg; msg.AddServFail(); - this_ptr->replyFunc(lookup->source, msg); + this_ptr->failFunc(lookup->source, msg); ub_resolve_free(result); return; } @@ -69,10 +74,13 @@ namespace llarp::dns hdr.Decode(&buf); hdr.id = lookup->msg.hdr_id; - Message msg(hdr); - msg.Decode(&buf); + buf.cur = buf.base; + hdr.Encode(&buf); - this_ptr->replyFunc(lookup->source, msg); + std::array buf_copy; + std::copy_n(buf.base, buf.sz, buf_copy.begin()); + + this_ptr->replyFunc(lookup->source, std::move(buf_copy), buf.sz); ub_resolve_free(result); } @@ -109,12 +117,12 @@ namespace llarp::dns } void - UnboundResolver::Lookup(const SockAddr& source, Message& msg) + UnboundResolver::Lookup(const SockAddr& source, Message msg) { if (not unboundContext) { msg.AddServFail(); - replyFunc(source, msg); + failFunc(source, std::move(msg)); return; } @@ -134,7 +142,7 @@ namespace llarp::dns if (err != 0) { msg.AddServFail(); - replyFunc(source, msg); + failFunc(source, std::move(msg)); return; } } diff --git a/llarp/dns/unbound_resolver.hpp b/llarp/dns/unbound_resolver.hpp index 7db878b24..1e7ffb235 100644 --- a/llarp/dns/unbound_resolver.hpp +++ b/llarp/dns/unbound_resolver.hpp @@ -13,7 +13,9 @@ namespace llarp::dns { - using ReplyFunction = std::function; + using ReplyFunction = + std::function buf, size_t size)>; + using FailFunction = std::function; class UnboundResolver : public std::enable_shared_from_this { @@ -24,6 +26,7 @@ namespace llarp::dns llarp_ev_loop_ptr eventLoop; ReplyFunction replyFunc; + FailFunction failFunc; void Reset(); @@ -34,7 +37,7 @@ namespace llarp::dns RegisterPollFD(); public: - UnboundResolver(llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc); + UnboundResolver(llarp_ev_loop_ptr eventLoop, ReplyFunction replyFunc, FailFunction failFunc); static void Callback(void* data, int err, ub_result* result); @@ -47,7 +50,7 @@ namespace llarp::dns AddUpstreamResolver(const std::string& upstreamResolverIP); void - Lookup(const SockAddr& source, Message& msg); + Lookup(const SockAddr& source, Message msg); }; } // namespace llarp::dns From 8f0330c9f22eaf120efe0c85e1fadd5c3306ac3f Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 15 Jun 2020 14:22:52 -0400 Subject: [PATCH 08/22] std::vector instead of std::array --- llarp/dns/server.cpp | 10 ++++------ llarp/dns/server.hpp | 2 +- llarp/dns/unbound_resolver.cpp | 4 ++-- llarp/dns/unbound_resolver.hpp | 3 +-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 6c56846d8..b2c7ca58d 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -106,12 +106,11 @@ namespace llarp } }; - auto replyFunc = [self = weak_from_this()]( - SockAddr to, std::array buf, size_t len) { + auto replyFunc = [self = weak_from_this()](SockAddr to, std::vector buf) { auto this_ptr = self.lock(); if (this_ptr) { - this_ptr->HandleUpstreamResponse(to, std::move(buf), len); + this_ptr->HandleUpstreamResponse(to, std::move(buf)); } }; @@ -166,12 +165,11 @@ namespace llarp } void - Proxy::HandleUpstreamResponse(SockAddr to, std::array buf, size_t len) + Proxy::HandleUpstreamResponse(SockAddr to, std::vector buf) { auto self = shared_from_this(); - LogicCall(m_ServerLogic, [to, buffer = std::move(buf), self, len]() { + LogicCall(m_ServerLogic, [to, buffer = std::move(buf), self]() { llarp_buffer_t buf(buffer); - buf.sz = len; self->SendServerMessageBufferTo(to, buf); }); } diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index fb91cbdbb..5ecaee124 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -72,7 +72,7 @@ namespace llarp SendServerMessageTo(const SockAddr& to, Message msg); void - HandleUpstreamResponse(SockAddr to, std::array buf, size_t len); + HandleUpstreamResponse(SockAddr to, std::vector buf); void HandleUpstreamFailure(const SockAddr& to, Message msg); diff --git a/llarp/dns/unbound_resolver.cpp b/llarp/dns/unbound_resolver.cpp index 6b02e8b32..e8192c990 100644 --- a/llarp/dns/unbound_resolver.cpp +++ b/llarp/dns/unbound_resolver.cpp @@ -77,10 +77,10 @@ namespace llarp::dns buf.cur = buf.base; hdr.Encode(&buf); - std::array buf_copy; + std::vector buf_copy(buf.sz); std::copy_n(buf.base, buf.sz, buf_copy.begin()); - this_ptr->replyFunc(lookup->source, std::move(buf_copy), buf.sz); + this_ptr->replyFunc(lookup->source, std::move(buf_copy)); ub_resolve_free(result); } diff --git a/llarp/dns/unbound_resolver.hpp b/llarp/dns/unbound_resolver.hpp index 1e7ffb235..24c7594e6 100644 --- a/llarp/dns/unbound_resolver.hpp +++ b/llarp/dns/unbound_resolver.hpp @@ -13,8 +13,7 @@ namespace llarp::dns { - using ReplyFunction = - std::function buf, size_t size)>; + using ReplyFunction = std::function buf)>; using FailFunction = std::function; class UnboundResolver : public std::enable_shared_from_this From 32843510bbaa1cdfd8c297774c21d68204ca7255 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 15 Jun 2020 18:44:59 -0400 Subject: [PATCH 09/22] libunbound can now be built as a static dep --- CMakeLists.txt | 12 ++++++------ llarp/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 146aadeda..526261a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,12 +225,12 @@ endif() string(REGEX REPLACE "^fatal.*$" nogit GIT_VERSION_REAL "${GIT_VERSION}") - -find_package(PkgConfig REQUIRED) - -pkg_check_modules(UNBOUND libunbound REQUIRED IMPORTED_TARGET) - -add_library(libunbound INTERFACE) +if (NOT BUILD_STATIC_DEPS) + find_package(PkgConfig REQUIRED) + pkg_check_modules(UNBOUND libunbound REQUIRED IMPORTED_TARGET) + add_library(libunbound INTERFACE) + target_link_libraries(libunbound INTERFACE PkgConfig::UNBOUND) +endif() pkg_check_modules(SD libsystemd) # Default WITH_SYSTEMD to true if we found it diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index d7ba67482..becf08cf9 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -223,7 +223,7 @@ endif() target_link_libraries(liblokinet PUBLIC cxxopts abyss lokinet-platform lokinet-util lokinet-cryptography) -target_link_libraries(liblokinet PRIVATE PkgConfig::UNBOUND) +target_link_libraries(liblokinet PRIVATE libunbound) if(BUILD_SHARED_LIBS) install(TARGETS lokinet-util lokinet-platform liblokinet LIBRARY DESTINATION lib) From 0ecdf607778f28ed12e2bd7c5c96f790d6e2675c Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 16 Jun 2020 18:17:41 -0400 Subject: [PATCH 10/22] static build fixes in cmake stuff I hate cmake so much. --- .drone.jsonnet | 2 +- CMakeLists.txt | 5 +++-- StaticBuild.cmake => cmake/StaticBuild.cmake | 0 crypto/CMakeLists.txt | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) rename StaticBuild.cmake => cmake/StaticBuild.cmake (100%) diff --git a/.drone.jsonnet b/.drone.jsonnet index fb568ff7e..0858e303d 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -235,7 +235,7 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra // Static build (on bionic) which gets uploaded to builds.lokinet.dev: debian_pipeline("Static (bionic amd64)", "ubuntu:bionic", deps='g++-8 python3-dev', lto=true, - cmake_extra='-DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ' + + cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ' + '-DDOWNLOAD_SODIUM=ON -DDOWNLOAD_CURL=ON -DDOWNLOAD_UV=ON -DWITH_SYSTEMD=OFF', extra_cmds=[ '../contrib/ci/drone-check-static-libs.sh', diff --git a/CMakeLists.txt b/CMakeLists.txt index 526261a72..880bf6dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,9 @@ if(RELEASE_MOTTO) endif() +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + + # Core options option(USE_AVX2 "enable avx2 code" OFF) option(USE_NETNS "enable networking namespace support. Linux only" OFF) @@ -94,8 +97,6 @@ endif() include(cmake/solaris.cmake) include(cmake/win32.cmake) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") - # No in-source building include(MacroEnsureOutOfSourceBuild) macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'.") diff --git a/StaticBuild.cmake b/cmake/StaticBuild.cmake similarity index 100% rename from StaticBuild.cmake rename to cmake/StaticBuild.cmake diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index dc62d83ff..b28426d2d 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -70,11 +70,11 @@ endif() option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF) # Allow -DDOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium -if(NOT DOWNLOAD_SODIUM STREQUAL "FORCE") +if((NOT BUILD_STATIC_DEPS) AND (NOT DOWNLOAD_SODIUM STREQUAL "FORCE")) find_package(Sodium 1.0.18) endif() -if(sodium_FOUND) +if(sodium_FOUND OR BUILD_STATIC_DEPS) target_link_libraries(lokinet-cryptography PUBLIC sodium) elseif(DOWNLOAD_SODIUM) message(STATUS "Sodium >= 1.0.18 not found, but DOWNLOAD_SODIUM specified, so downloading it") From cdd57ac09bde2341bd4395565dcd8edfd094e6c7 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 16 Jun 2020 21:18:13 -0300 Subject: [PATCH 11/22] fix unbound ssl linking --- cmake/StaticBuild.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 1c24bff27..a07a0fa2d 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -178,8 +178,10 @@ build_external(unbound "CC=${deps_cc}" "CFLAGS=-O2 ${flto}" ) add_static_target(libunbound unbound_external libunbound.a) -if(WIN32) - set_target_properties(libunbound PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32;crypt32;iphlpapi") +if(NOT WIN32) + set_target_properties(libunbound PROPERTIES INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto") +else() + set_target_properties(libunbound PROPERTIES INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto;ws2_32;crypt32;iphlpapi") endif() From 9905a2bd4be1a8965e5b4b50557c8958d3f8ce95 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 16 Jun 2020 20:36:18 -0400 Subject: [PATCH 12/22] static build flag for win/mac static builds in drone config --- .drone.jsonnet | 6 +++--- CMakeLists.txt | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 0858e303d..2fa46475e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -230,8 +230,8 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", cmake_extra='-DDOWNLOAD_SODIUM=ON'), // Windows builds (WOW64 and native) - alpine_win32_pipeline("win32 on alpine (amd64)", "alpine:edge", cmake_extra="-DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), - alpine_wow64_pipeline("win32 on alpine (i386)", "i386/alpine:edge", cmake_extra="-DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), + alpine_win32_pipeline("win32 on alpine (amd64)", "alpine:edge", cmake_extra="-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), + alpine_wow64_pipeline("win32 on alpine (i386)", "i386/alpine:edge", cmake_extra="-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), // Static build (on bionic) which gets uploaded to builds.lokinet.dev: debian_pipeline("Static (bionic amd64)", "ubuntu:bionic", deps='g++-8 python3-dev', lto=true, @@ -255,7 +255,7 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra // Macos builds: mac_builder('macOS (Release)'), mac_builder('macOS (Debug)', build_type='Debug'), - mac_builder('macOS (Static)', cmake_extra='-DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DDOWNLOAD_SODIUM=FORCE -DDOWNLOAD_CURL=FORCE -DDOWNLOAD_UV=FORCE', + mac_builder('macOS (Static)', cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DDOWNLOAD_SODIUM=FORCE -DDOWNLOAD_CURL=FORCE -DDOWNLOAD_UV=FORCE', extra_cmds=[ '../contrib/ci/drone-check-static-libs.sh', '../contrib/ci/drone-static-upload.sh' diff --git a/CMakeLists.txt b/CMakeLists.txt index 880bf6dd6..c917eff0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,8 +226,9 @@ endif() string(REGEX REPLACE "^fatal.*$" nogit GIT_VERSION_REAL "${GIT_VERSION}") +find_package(PkgConfig REQUIRED) + if (NOT BUILD_STATIC_DEPS) - find_package(PkgConfig REQUIRED) pkg_check_modules(UNBOUND libunbound REQUIRED IMPORTED_TARGET) add_library(libunbound INTERFACE) target_link_libraries(libunbound INTERFACE PkgConfig::UNBOUND) From 2e806cc145e5c154d94696466563e71dbda33c8b Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 09:10:50 -0400 Subject: [PATCH 13/22] set CMAKE_CROSSCOMPILE to on so we are cross compiling in ci --- contrib/cross/mingw_core.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/cross/mingw_core.cmake b/contrib/cross/mingw_core.cmake index 4308542da..e37723784 100644 --- a/contrib/cross/mingw_core.cmake +++ b/contrib/cross/mingw_core.cmake @@ -23,3 +23,4 @@ else() endif() set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) +set(CMAKE_CROSSCOMPILE ON) From 48c7d6fbe5a516d555c2a3fa692f051927645886 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 09:42:11 -0400 Subject: [PATCH 14/22] consolidate windows ci drone jizz --- .drone.jsonnet | 62 +++++++++---------------------- contrib/ci/drone-static-upload.sh | 7 +++- 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 2fa46475e..8566477f3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -2,6 +2,9 @@ local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1- local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement +local default_windows_deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads perl'; // deps for windows cross compile + + local submodules = { name: 'submodules', image: 'drone/git', @@ -50,14 +53,15 @@ local debian_pipeline(name, image, ], }; -// 32-bit windows build on alpine: -local alpine_wow64_pipeline(name, image, +// windows cross compile on alpine linux +local windows_cross_pipeline(name, image, arch='amd64', - deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads', + deps=default_windows_deps, build_type='Release', - lto=false, + lto=true, werror=false, cmake_extra='', + toolchain='mingw32', extra_cmds=[], allow_fail=false) = { kind: 'pipeline', @@ -77,46 +81,10 @@ local alpine_wow64_pipeline(name, image, 'git clone https://github.com/despair86/libuv.git win32-setup/libuv', 'mkdir build', 'cd build', - 'cmake .. -G Ninja -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DLIBUV_ROOT=$PWD/../win32-setup/libuv -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw32.cmake -DCMAKE_BUILD_TYPE='+build_type+' ' + - (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + - (if lto then '' else '-DWITH_LTO=OFF ') + - cmake_extra, - 'ninja -v', - ] + extra_cmds, - } - ], -}; - -// 64-bit windows build on alpine: -local alpine_win32_pipeline(name, image, - arch='amd64', - deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads', - build_type='Release', - lto=false, - werror=false, - cmake_extra='', - extra_cmds=[], - allow_fail=false) = { - kind: 'pipeline', - type: 'docker', - name: name, - platform: { arch: arch }, - trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } }, - steps: [ - submodules, - { - name: 'build', - image: image, - [if allow_fail then "failure"]: "ignore", - environment: { SSH_KEY: { from_secret: "SSH_KEY" } }, - commands: [ - 'apk add cmake git ninja pkgconf ccache patch make ' + deps, - 'git clone https://github.com/despair86/libuv.git win32-setup/libuv', - 'mkdir build', - 'cd build', - 'cmake .. -G Ninja -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DLIBUV_ROOT=$PWD/../win32-setup/libuv -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw64.cmake -DCMAKE_BUILD_TYPE='+build_type+' ' + + 'cmake .. -G Ninja -DCMAKE_CROSSCOMPILE=ON -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DLIBUV_ROOT=$PWD/../win32-setup/libuv -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/'+toolchain+'.cmake -DCMAKE_BUILD_TYPE='+build_type+' ' + (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + (if lto then '' else '-DWITH_LTO=OFF ') + + "-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON" + cmake_extra, 'ninja -v', ] + extra_cmds, @@ -230,8 +198,14 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", cmake_extra='-DDOWNLOAD_SODIUM=ON'), // Windows builds (WOW64 and native) - alpine_win32_pipeline("win32 on alpine (amd64)", "alpine:edge", cmake_extra="-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), - alpine_wow64_pipeline("win32 on alpine (i386)", "i386/alpine:edge", cmake_extra="-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON", lto=false), + windows_cross_pipeline("win32 on alpine (amd64)", "alpine:edge", + toolchain='mingw64', extra_cmds=[ + '../contrib/ci/drone-static-upload.sh' + ]), + windows_cross_pipeline("win32 on alpine (i386)", "i386/alpine:edge", + toolchain='mingw32', extra_cmds=[ + '../contrib/ci/drone-static-upload.sh' + ]), // Static build (on bionic) which gets uploaded to builds.lokinet.dev: debian_pipeline("Static (bionic amd64)", "ubuntu:bionic", deps='g++-8 python3-dev', lto=true, diff --git a/contrib/ci/drone-static-upload.sh b/contrib/ci/drone-static-upload.sh index c639e0506..fd609da21 100755 --- a/contrib/ci/drone-static-upload.sh +++ b/contrib/ci/drone-static-upload.sh @@ -29,8 +29,11 @@ else fi mkdir -v "$base" -mv -v daemon/lokinet "$base" -cp -av ../lokinet-bootstrap "$base" +# copy lokinet-bootstrap.ps1 and lokinet.exe if we are a windows build +test -e daemon/lokinet.exe && cp -av daemon/lokinet.exe ../lokinet-bootstrap.ps1 "$base" +# copy lokinet-bootstrap shell script and built binary if we aren't a windows build +test -e daemon/lokinet && cp -av daemon/lokinet ../lokinet-bootstrap "$base" +# tar dat shiz up yo tar cJvf "${base}.tar.xz" "$base" upload_to="builds.lokinet.dev/${DRONE_REPO// /_}/${DRONE_BRANCH// /_}" From ba1265d94f044827fc3c63e0350b8e8e42b6925c Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 09:48:57 -0400 Subject: [PATCH 15/22] set ARCH_TRIPLET to CROSS_TARGET to please the cmake cross compile god --- contrib/cross/mingw_core.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/cross/mingw_core.cmake b/contrib/cross/mingw_core.cmake index e37723784..d4702c74e 100644 --- a/contrib/cross/mingw_core.cmake +++ b/contrib/cross/mingw_core.cmake @@ -24,3 +24,4 @@ endif() set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_CROSSCOMPILE ON) +set(ARCH_TRIPLET ${CROSS_TARGET}) From 26a2f54b0b068ddfca335ce2e36588a0d7520c4c Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 10:20:14 -0400 Subject: [PATCH 16/22] set ar and ranlib on openssl cross compile to appease the cmake god --- cmake/StaticBuild.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index a07a0fa2d..f8b875e32 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -139,9 +139,9 @@ endfunction() set(openssl_system_env "") if(CMAKE_CROSSCOMPILING) if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32) - set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER}) + set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER} AR="${ARCH_TRIPLET}-ar r" RANLIB=${ARCH_TRIPLET}-ranlib) elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32) - set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER}) + set(openssl_system_env SYSTEM=MINGW32 RC=${CMAKE_RC_COMPILER} AR="${ARCH_TRIPLET}-ar r" RANLIB=${ARCH_TRIPLET}-ranlib) endif() endif() build_external(openssl From db3d43a5136d6326faa40a8a09b5f4fc51878d2e Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 10:23:41 -0400 Subject: [PATCH 17/22] fix typo --- cmake/StaticBuild.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index f8b875e32..9727ba4a5 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -139,9 +139,9 @@ endfunction() set(openssl_system_env "") if(CMAKE_CROSSCOMPILING) if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32) - set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER} AR="${ARCH_TRIPLET}-ar r" RANLIB=${ARCH_TRIPLET}-ranlib) + set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib) elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32) - set(openssl_system_env SYSTEM=MINGW32 RC=${CMAKE_RC_COMPILER} AR="${ARCH_TRIPLET}-ar r" RANLIB=${ARCH_TRIPLET}-ranlib) + set(openssl_system_env SYSTEM=MINGW32 RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib) endif() endif() build_external(openssl From fdfdd2a1d2a031f80bd1fb956e494e826c88ac75 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 10:37:41 -0400 Subject: [PATCH 18/22] turn off lto, add patches --- .drone.jsonnet | 2 +- cmake/StaticBuild.cmake | 4 +- .../libzmq-pr3601-mingw-build-fix.patch | 69 +++++++++++++++++++ .../libzmq-pr3613-fix-funcptr-call.patch | 43 ++++++++++++ 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 contrib/cross/patches/libzmq-pr3601-mingw-build-fix.patch create mode 100644 contrib/cross/patches/libzmq-pr3613-fix-funcptr-call.patch diff --git a/.drone.jsonnet b/.drone.jsonnet index 8566477f3..6000543d3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -58,7 +58,7 @@ local windows_cross_pipeline(name, image, arch='amd64', deps=default_windows_deps, build_type='Release', - lto=true, + lto=false, werror=false, cmake_extra='', toolchain='mingw32', diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 9727ba4a5..e78151cc9 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -191,8 +191,8 @@ add_static_target(sodium sodium_external libsodium.a) if(ZMQ_VERSION VERSION_LESS 4.3.3 AND CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw) - set(zmq_patch PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/utils/build_scripts/libzmq-pr3601-mingw-build-fix.patch - COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/utils/build_scripts/libzmq-pr3613-fix-funcptr-call.patch) + set(zmq_patch PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/contrib/cross/patches/libzmq-pr3601-mingw-build-fix.patch + COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/contrib/cross/patches/libzmq-pr3613-fix-funcptr-call.patch) endif() build_external(zmq DEPENDS sodium_external diff --git a/contrib/cross/patches/libzmq-pr3601-mingw-build-fix.patch b/contrib/cross/patches/libzmq-pr3601-mingw-build-fix.patch new file mode 100644 index 000000000..0693ed92d --- /dev/null +++ b/contrib/cross/patches/libzmq-pr3601-mingw-build-fix.patch @@ -0,0 +1,69 @@ +diff --git a/src/thread.cpp b/src/thread.cpp +index b14d70757..3675899be 100644 +--- a/src/thread.cpp ++++ b/src/thread.cpp +@@ -32,6 +32,10 @@ + #include "thread.hpp" + #include "err.hpp" + ++#ifdef ZMQ_HAVE_WINDOWS ++#include ++#endif ++ + bool zmq::thread_t::get_started () const + { + return _started; +@@ -113,10 +117,22 @@ struct thread_info_t + #pragma pack(pop) + } + ++typedef struct _MY_EXCEPTION_REGISTRATION_RECORD ++{ ++ struct _MY_EXCEPTION_REGISTRATION_RECORD *Next; ++ void *Handler; ++} MY_EXCEPTION_REGISTRATION_RECORD; ++ ++static EXCEPTION_DISPOSITION NTAPI continue_execution (EXCEPTION_RECORD *rec, ++ void *frame, CONTEXT *ctx, void *disp) ++{ ++ return ExceptionContinueExecution; ++} ++ + void zmq::thread_t:: + applyThreadName () // to be called in secondary thread context + { +- if (!_name[0]) ++ if (!_name[0] || !IsDebuggerPresent()) + return; + + thread_info_t thread_info; +@@ -125,17 +141,19 @@ void zmq::thread_t:: + thread_info._thread_id = -1; + thread_info._flags = 0; + +-#pragma warning(push) +-#pragma warning(disable : 6320 6322) +- __try { +- DWORD MS_VC_EXCEPTION = 0x406D1388; ++ NT_TIB *tib = ((NT_TIB*)NtCurrentTeb()); ++ ++ MY_EXCEPTION_REGISTRATION_RECORD rec; ++ rec.Next = (MY_EXCEPTION_REGISTRATION_RECORD *)tib->ExceptionList; ++ rec.Handler = continue_execution; ++ ++ // push our handler, raise, and finally pop our handler ++ tib->ExceptionList = (_EXCEPTION_REGISTRATION_RECORD *)&rec; ++ DWORD MS_VC_EXCEPTION = 0x406D1388; + RaiseException (MS_VC_EXCEPTION, 0, +- sizeof (thread_info) / sizeof (ULONG_PTR), +- (ULONG_PTR *) &thread_info); +- } +- __except (EXCEPTION_CONTINUE_EXECUTION) { +- } +-#pragma warning(pop) ++ sizeof (thread_info) / sizeof (ULONG_PTR), ++ (ULONG_PTR *) &thread_info); ++ tib->ExceptionList = (_EXCEPTION_REGISTRATION_RECORD *)(((MY_EXCEPTION_REGISTRATION_RECORD *)tib->ExceptionList)->Next); + } + + #elif defined ZMQ_HAVE_VXWORKS diff --git a/contrib/cross/patches/libzmq-pr3613-fix-funcptr-call.patch b/contrib/cross/patches/libzmq-pr3613-fix-funcptr-call.patch new file mode 100644 index 000000000..a17252823 --- /dev/null +++ b/contrib/cross/patches/libzmq-pr3613-fix-funcptr-call.patch @@ -0,0 +1,43 @@ +diff --git a/RELICENSE/tomzbench.md b/RELICENSE/tomzbench.md +new file mode 100644 +index 000000000..1cbcc4fdb +--- /dev/null ++++ b/RELICENSE/tomzbench.md +@@ -0,0 +1,14 @@ ++# Permission to Relicense under MPLv2 ++ ++This is a statement by Thomas Chiantia ++that grants permission to relicense its copyrights in the libzmq C++ ++library (ZeroMQ) under the Mozilla Public License v2 (MPLv2). ++ ++A portion of the commits made by the Github handle "tomzbench", with ++commit author "Thomas", are copyright of ++Thomas Chiantia. ++This document hereby grants the libzmq project team to relicense libzmq, ++including all past, present and future contributions of the author listed above. ++ ++Thomas Chiantia ++2019/08/10 +diff --git a/src/thread.cpp b/src/thread.cpp +index 2cad2adaa..6f07e9cee 100644 +--- a/src/thread.cpp ++++ b/src/thread.cpp +@@ -117,11 +117,14 @@ struct thread_info_t + #pragma pack(pop) + } + +-typedef struct _MY_EXCEPTION_REGISTRATION_RECORD ++struct MY_EXCEPTION_REGISTRATION_RECORD + { +- struct _MY_EXCEPTION_REGISTRATION_RECORD *Next; +- void *Handler; +-} MY_EXCEPTION_REGISTRATION_RECORD; ++ typedef EXCEPTION_DISPOSITION (NTAPI *HandlerFunctionType) ( ++ EXCEPTION_RECORD *, void *, CONTEXT *, void *); ++ ++ MY_EXCEPTION_REGISTRATION_RECORD *Next; ++ HandlerFunctionType Handler; ++}; + + static EXCEPTION_DISPOSITION NTAPI continue_execution (EXCEPTION_RECORD *rec, + void *frame, From c66e925fb2c7fd2971e08d0868bf3e87a6b40451 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 11:06:12 -0400 Subject: [PATCH 19/22] add more cmake incantations for windows cross compile --- cmake/StaticBuild.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index e78151cc9..106b8a7e6 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -156,6 +156,10 @@ build_external(openssl ) add_static_target(OpenSSL::SSL openssl_external libssl.a) add_static_target(OpenSSL::Crypto openssl_external libcrypto.a) +if(WIN32) + set_target_properties(OpenSSL::Crypto INTERFACE "ws2_32;crypt32;iphlpapi") +endif() + set(OPENSSL_INCLUDE_DIR ${DEPS_DESTDIR}/include) set(OPENSSL_VERSION 1.1.1) From a9de1ad277f9f68a0172f68516df80edd184c365 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 11:09:22 -0400 Subject: [PATCH 20/22] fix typo --- cmake/StaticBuild.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 106b8a7e6..36cac7f71 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -157,7 +157,7 @@ build_external(openssl add_static_target(OpenSSL::SSL openssl_external libssl.a) add_static_target(OpenSSL::Crypto openssl_external libcrypto.a) if(WIN32) - set_target_properties(OpenSSL::Crypto INTERFACE "ws2_32;crypt32;iphlpapi") + target_link_libraries(OpenSSL::Crypto INTERFACE "ws2_32;crypt32;iphlpapi") endif() set(OPENSSL_INCLUDE_DIR ${DEPS_DESTDIR}/include) From 0dad53100a6bd068a9bc2224b4aceb39536a48a3 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 11:13:57 -0400 Subject: [PATCH 21/22] add bash and sftp so exe uploads werk --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 6000543d3..52faf61a2 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -2,7 +2,7 @@ local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1- local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement -local default_windows_deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads perl'; // deps for windows cross compile +local default_windows_deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads perl sftp bash'; // deps for windows cross compile local submodules = { From 52b5da33a34a0248c8f62fe65f2f1da8c38fb01d Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 17 Jun 2020 11:20:19 -0400 Subject: [PATCH 22/22] fix dep --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 52faf61a2..3e4d9da65 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -2,7 +2,7 @@ local default_deps_base='libsystemd-dev python3-dev libcurl4-openssl-dev libuv1- local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18 local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement -local default_windows_deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads perl sftp bash'; // deps for windows cross compile +local default_windows_deps='mingw-w64-binutils mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads perl openssh bash'; // deps for windows cross compile local submodules = {