From 46ad8d40589fa012222ff0afb322ad3f134f5c6c Mon Sep 17 00:00:00 2001 From: dr7ana Date: Tue, 24 Oct 2023 06:18:03 -0700 Subject: [PATCH] Clang format include sorting + CMake - includes are now sorted in consistent, logical order; first step in an attempt to fix the tomfoolery (no relation to Tom) brought in by include-what-you-use - shuffled around some cmake linking to simplify dependency graph - superfluous files removed --- .clang-format | 26 +- CMakeLists.txt | 2 +- cmake/CMakeGraphVizOptions.cmake | 2 - crypto/libntrup/src/ntru.cpp | 3 +- daemon/lokinet-bootstrap.cpp | 10 +- daemon/lokinet-vpn.cpp | 13 +- daemon/lokinet.cpp | 94 ++-- include/lokinet.h | 4 +- jni/lokinet_config.cpp | 3 +- jni/lokinet_daemon.cpp | 3 +- jni/lokinet_jni_common.hpp | 3 +- llarp/CMakeLists.txt | 45 +- llarp/android/ifaddrs.c | 16 +- llarp/android/ifaddrs.h | 5 +- llarp/apple/DNSTrampoline.h | 2 +- llarp/apple/DNSTrampoline.m | 1 + llarp/apple/PacketTunnelProvider.m | 5 +- llarp/apple/context.hpp | 5 +- llarp/apple/context_wrapper.cpp | 21 +- llarp/apple/context_wrapper.h | 2 +- llarp/apple/route_manager.cpp | 4 +- llarp/apple/route_manager.hpp | 3 +- llarp/apple/vpn_interface.cpp | 2 + llarp/apple/vpn_interface.hpp | 3 +- llarp/apple/vpn_platform.cpp | 1 + llarp/apple/vpn_platform.hpp | 5 +- llarp/bootstrap-fallbacks.cpp.in | 2 +- llarp/bootstrap.hpp | 7 +- llarp/bootstrap_fallbacks.cpp | 3 +- llarp/config/config.cpp | 11 +- llarp/config/config.hpp | 29 +- llarp/config/definition.cpp | 3 +- llarp/config/definition.hpp | 14 +- llarp/config/ini.cpp | 2 +- llarp/config/ini.hpp | 5 +- llarp/config/key_manager.cpp | 6 +- llarp/config/key_manager.hpp | 5 +- llarp/consensus/reachability_testing.cpp | 2 +- llarp/consensus/reachability_testing.hpp | 3 +- llarp/constants/evloop.hpp | 7 - llarp/constants/files.hpp | 2 +- llarp/constants/link_layer.hpp | 2 +- llarp/constants/path.hpp | 6 +- llarp/constants/version.hpp | 2 +- llarp/context.cpp | 10 +- llarp/crypto/constants.hpp | 4 +- llarp/crypto/crypto.cpp | 11 +- llarp/crypto/crypto.hpp | 10 +- llarp/crypto/encrypted.hpp | 2 +- llarp/crypto/encrypted_frame.cpp | 4 +- llarp/crypto/encrypted_frame.hpp | 7 +- llarp/crypto/types.cpp | 3 + llarp/crypto/types.hpp | 7 +- llarp/dht/bucket.hpp | 1 + llarp/dht/context.cpp | 662 ----------------------- llarp/dht/dht.cpp | 52 -- llarp/dht/dht.h | 61 --- llarp/dht/kademlia.hpp | 1 + llarp/dht/key.hpp | 2 +- llarp/dht/node.hpp | 2 + llarp/dht/tx.hpp | 79 --- llarp/dht/txholder.hpp | 212 -------- llarp/dht/txowner.hpp | 61 --- llarp/dns/message.cpp | 12 +- llarp/dns/message.hpp | 4 +- llarp/dns/name.cpp | 3 +- llarp/dns/name.hpp | 3 +- llarp/dns/nm_platform.hpp | 1 + llarp/dns/platform.hpp | 3 +- llarp/dns/question.cpp | 4 +- llarp/dns/question.hpp | 2 +- llarp/dns/rr.hpp | 7 +- llarp/dns/sd_platform.hpp | 1 + llarp/dns/serialize.hpp | 1 + llarp/dns/server.cpp | 19 +- llarp/dns/server.hpp | 9 +- llarp/dns/srv_data.cpp | 6 +- llarp/dns/srv_data.hpp | 9 +- llarp/endpoint_base.cpp | 2 +- llarp/endpoint_base.hpp | 28 +- llarp/ev/ev.cpp | 5 +- llarp/ev/ev.hpp | 12 +- llarp/ev/libuv.cpp | 6 +- llarp/ev/libuv.hpp | 15 +- llarp/ev/udp_handle.hpp | 2 +- llarp/exit/context.cpp | 1 + llarp/exit/context.hpp | 5 +- llarp/exit/endpoint.hpp | 1 + llarp/exit/policy.hpp | 3 +- llarp/exit/session.cpp | 3 +- llarp/exit/session.hpp | 5 +- llarp/handlers/exit.cpp | 3 +- llarp/handlers/exit.hpp | 7 +- llarp/handlers/null.hpp | 4 +- llarp/handlers/tun.cpp | 14 +- llarp/handlers/tun.hpp | 1 + llarp/link/connection.hpp | 3 +- llarp/link/link_manager.cpp | 5 +- llarp/link/link_manager.hpp | 16 +- llarp/link/tunnel.cpp | 6 +- llarp/link/tunnel.hpp | 4 +- llarp/linux/sd_service_manager.cpp | 7 +- llarp/lokinet_shared.cpp | 12 +- llarp/messages/link_message.hpp | 8 +- llarp/messages/relay.hpp | 9 +- llarp/net/exit_info.cpp | 5 +- llarp/net/exit_info.hpp | 5 +- llarp/net/interface_info.hpp | 5 +- llarp/net/ip.cpp | 1 + llarp/net/ip_address.cpp | 1 + llarp/net/ip_address.hpp | 9 +- llarp/net/ip_packet.cpp | 5 +- llarp/net/ip_packet.hpp | 12 +- llarp/net/ip_range.cpp | 4 +- llarp/net/ip_range.hpp | 12 +- llarp/net/ip_range_map.hpp | 2 + llarp/net/net.h | 1 + llarp/net/net.hpp | 19 +- llarp/net/net_int.cpp | 6 +- llarp/net/net_int.hpp | 13 +- llarp/net/posix.cpp | 6 +- llarp/net/sock_addr.cpp | 13 +- llarp/net/sock_addr.hpp | 13 +- llarp/net/traffic_policy.hpp | 10 +- llarp/net/uint128.hpp | 6 +- llarp/net/win32.cpp | 11 +- llarp/nodedb.cpp | 10 +- llarp/nodedb.hpp | 25 +- llarp/path/abstracthophandler.cpp | 1 + llarp/path/abstracthophandler.hpp | 9 +- llarp/path/path.hpp | 9 +- llarp/path/path_context.cpp | 3 +- llarp/path/path_context.hpp | 12 +- llarp/path/path_types.hpp | 2 +- llarp/path/pathbuilder.cpp | 8 +- llarp/path/pathbuilder.hpp | 3 +- llarp/path/pathset.cpp | 3 +- llarp/path/pathset.hpp | 7 +- llarp/path/transit_hop.cpp | 4 +- llarp/pow.cpp | 4 +- llarp/profiling.cpp | 4 +- llarp/profiling.hpp | 6 +- llarp/router/rc_gossiper.hpp | 2 +- llarp/router/rc_lookup_handler.cpp | 16 +- llarp/router/rc_lookup_handler.hpp | 5 +- llarp/router/route_poker.cpp | 4 +- llarp/router/route_poker.hpp | 8 +- llarp/router/router.cpp | 8 +- llarp/router/router.hpp | 16 +- llarp/router_contact.cpp | 6 +- llarp/router_contact.hpp | 24 +- llarp/router_id.cpp | 1 + llarp/router_version.hpp | 8 +- llarp/rpc/endpoint_rpc.hpp | 1 + llarp/rpc/json_binary_proxy.cpp | 3 +- llarp/rpc/json_binary_proxy.hpp | 3 +- llarp/rpc/json_conversions.cpp | 1 + llarp/rpc/json_conversions.hpp | 5 +- llarp/rpc/lokid_rpc_client.cpp | 4 +- llarp/rpc/lokid_rpc_client.hpp | 7 +- llarp/rpc/param_parser.hpp | 6 +- llarp/rpc/rpc_request.hpp | 15 +- llarp/rpc/rpc_request_decorators.hpp | 11 +- llarp/rpc/rpc_request_definitions.hpp | 9 +- llarp/rpc/rpc_request_parser.cpp | 5 +- llarp/rpc/rpc_request_parser.hpp | 10 +- llarp/rpc/rpc_server.cpp | 3 +- llarp/rpc/rpc_server.hpp | 13 +- llarp/service/address.cpp | 3 + llarp/service/address.hpp | 2 +- llarp/service/async_key_exchange.cpp | 2 + llarp/service/async_key_exchange.hpp | 4 +- llarp/service/auth.cpp | 3 +- llarp/service/auth.hpp | 7 +- llarp/service/context.cpp | 5 +- llarp/service/context.hpp | 7 +- llarp/service/convotag.hpp | 4 +- llarp/service/endpoint.cpp | 21 +- llarp/service/endpoint.hpp | 14 +- llarp/service/endpoint_state.hpp | 16 +- llarp/service/endpoint_types.hpp | 1 + llarp/service/identity.hpp | 9 +- llarp/service/info.cpp | 4 +- llarp/service/info.hpp | 10 +- llarp/service/intro.cpp | 1 + llarp/service/intro.hpp | 4 +- llarp/service/intro_set.cpp | 1 + llarp/service/intro_set.hpp | 21 +- llarp/service/lns_tracker.hpp | 8 +- llarp/service/name.cpp | 1 + llarp/service/name.hpp | 4 +- llarp/service/outbound_context.cpp | 9 +- llarp/service/outbound_context.hpp | 1 + llarp/service/pendingbuffer.hpp | 2 + llarp/service/protocol.cpp | 7 +- llarp/service/protocol.hpp | 14 +- llarp/service/protocol_type.hpp | 4 +- llarp/service/router_lookup_job.cpp | 1 + llarp/service/session.hpp | 6 +- llarp/service/tag.hpp | 1 + llarp/simulation/sim_context.cpp | 1 + llarp/util/aligned.hpp | 5 +- llarp/util/bencode.cpp | 2 +- llarp/util/bencode.h | 9 +- llarp/util/bencode.hpp | 14 +- llarp/util/bits.hpp | 7 +- llarp/util/buffer.cpp | 1 + llarp/util/buffer.hpp | 18 +- llarp/util/decaying_hashset.hpp | 1 + llarp/util/decaying_hashtable.hpp | 1 + llarp/util/file.cpp | 2 + llarp/util/file.hpp | 4 +- llarp/util/formattable.hpp | 1 + llarp/util/logging.hpp | 9 +- llarp/util/logging/buffer.hpp | 5 +- llarp/util/logging/callback_sink.hpp | 3 +- llarp/util/mem.cpp | 1 + llarp/util/meta/memfn.hpp | 2 +- llarp/util/str.cpp | 5 +- llarp/util/str.hpp | 7 +- llarp/util/thread/barrier.hpp | 2 +- llarp/util/thread/queue.hpp | 2 +- llarp/util/thread/queue_manager.hpp | 2 +- llarp/util/thread/threading.cpp | 1 + llarp/util/thread/threading.hpp | 11 +- llarp/util/time.hpp | 9 +- llarp/util/types.hpp | 6 +- llarp/vpn/android.hpp | 9 +- llarp/vpn/common.hpp | 7 +- llarp/vpn/egres_packet_router.hpp | 5 +- llarp/vpn/i_packet_io.hpp | 3 +- llarp/vpn/linux.hpp | 29 +- llarp/vpn/packet_intercept.hpp | 3 +- llarp/vpn/packet_router.hpp | 3 +- llarp/vpn/platform.hpp | 10 +- llarp/vpn/win32.cpp | 2 + llarp/vpn/win32.hpp | 10 +- llarp/win32/dll.cpp | 1 + llarp/win32/dll.hpp | 4 +- llarp/win32/exception.cpp | 5 +- llarp/win32/exception.hpp | 3 +- llarp/win32/exec.cpp | 2 + llarp/win32/exec.hpp | 4 +- llarp/win32/guid.hpp | 2 + llarp/win32/service_manager.cpp | 9 +- llarp/win32/service_manager.hpp | 3 +- llarp/win32/win32_inet.c | 5 +- llarp/win32/windivert.cpp | 11 +- llarp/win32/windivert.hpp | 6 +- llarp/win32/wintun.cpp | 15 +- pybind/common.hpp | 6 +- pybind/llarp/config.cpp | 2 +- pybind/llarp/context.cpp | 7 +- pybind/llarp/crypto/types.cpp | 1 + pybind/llarp/handlers/pyhandler.hpp | 5 +- pybind/llarp/logger.cpp | 4 +- pybind/llarp/path/path_hop_config.cpp | 1 + pybind/llarp/peerstats.cpp | 2 +- pybind/llarp/router.cpp | 4 +- pybind/llarp/router_contact.cpp | 4 +- pybind/llarp/router_id.cpp | 4 +- pybind/llarp/service/address.cpp | 3 +- pybind/llarp/tooling/router_event.cpp | 13 +- pybind/llarp/tooling/router_hive.cpp | 10 +- pybind/module.cpp | 1 + 265 files changed, 971 insertions(+), 1894 deletions(-) delete mode 100644 llarp/constants/evloop.hpp delete mode 100644 llarp/dht/context.cpp delete mode 100644 llarp/dht/dht.cpp delete mode 100644 llarp/dht/dht.h delete mode 100644 llarp/dht/tx.hpp delete mode 100644 llarp/dht/txholder.hpp delete mode 100644 llarp/dht/txowner.hpp diff --git a/.clang-format b/.clang-format index 3f18c4219..ef24da8a0 100644 --- a/.clang-format +++ b/.clang-format @@ -33,10 +33,12 @@ BraceWrapping: SplitEmptyNamespace: false BreakBeforeTernaryOperators: 'true' BreakConstructorInitializersBeforeComma: 'true' +ColumnLimit: 100 Cpp11BracedListStyle: 'true' KeepEmptyLinesAtTheStartOfBlocks: 'false' NamespaceIndentation: All PenaltyBreakString: '3' +SortIncludes: CaseInsensitive SpaceBeforeParens: ControlStatements SpacesInAngles: 'false' SpacesInContainerLiterals: 'false' @@ -44,8 +46,6 @@ SpacesInParentheses: 'false' SpacesInSquareBrackets: 'false' Standard: Cpp11 UseTab: Never -SortIncludes: false -ColumnLimit: 100 # treat pointers and reference declarations as if part of the type DerivePointerAlignment: false @@ -55,7 +55,21 @@ PointerAlignment: Left BinPackParameters: 'false' BinPackArguments: 'false' -# TODO: uncomment me when we are reading to rearrange the header includes -# IncludeBlocks: Regroup -# IncludeCategories: 'llarp/' - +# Include block sorting in the following order: +# - Main header for source file (clang-format default prioritizes this first) +# - Relative path includes in quotation marks +# - Absolute path includes in angle brackets +# - External dependencies +# - System dependencies +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '".+\.h' + Priority: 2 + - Regex: '^' + Priority: 4 + - Regex: '^<.*\.h(pp)?>$' + Priority: 5 + - Regex: '(<)(.)+(>)' + Priority: 6 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e68a2426..9f50d4b31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,7 +262,7 @@ add_subdirectory(external) # interface library for setting common includes, linkage and flags add_library(lokinet-base INTERFACE) target_include_directories(lokinet-base INTERFACE . include) -target_link_libraries(lokinet-base INTERFACE quic) +target_link_libraries(lokinet-base INTERFACE quic nlohmann_json::nlohmann_json) if(WITH_SYSTEMD AND (NOT ANDROID)) if(NOT SD_FOUND) diff --git a/cmake/CMakeGraphVizOptions.cmake b/cmake/CMakeGraphVizOptions.cmake index 4d9740171..322db57e3 100644 --- a/cmake/CMakeGraphVizOptions.cmake +++ b/cmake/CMakeGraphVizOptions.cmake @@ -1,6 +1,4 @@ set(GRAPHVIZ_GRAPH_NAME "graph.dot" CACHE STRING "") -# set(GRAPHVIZ_MODULE_LIBS OFF CACHE BOOL "") -# set(GRAPHVIZ_EXTERNAL_LIBS OFF CACHE BOOL "") set(GRAPHVIZ_GENERATE_PER_TARGET FALSE CACHE BOOL "") set(GRAPHVIZ_GENERATE_DEPENDERS FALSE CACHE BOOL "") set(GRAPHVIZ_OBJECT_LIBS OFF CACHE BOOL "") diff --git a/crypto/libntrup/src/ntru.cpp b/crypto/libntrup/src/ntru.cpp index c3fab075f..44b95cd4e 100644 --- a/crypto/libntrup/src/ntru.cpp +++ b/crypto/libntrup/src/ntru.cpp @@ -1,6 +1,5 @@ #include - -#include "libntrup/ntru_api.h" +#include #ifdef __x86_64__ #include diff --git a/daemon/lokinet-bootstrap.cpp b/daemon/lokinet-bootstrap.cpp index 435934cdd..e1ad9cb4d 100644 --- a/daemon/lokinet-bootstrap.cpp +++ b/daemon/lokinet-bootstrap.cpp @@ -1,9 +1,9 @@ -#include - #include #include #include +#include + #include #include #include @@ -93,9 +93,9 @@ main(int argc, char* argv[]) { return fail("failed to fetch '" + bootstrap_url + "' HTTP " + std::to_string(resp.status_code)); } - std::stringstream ss; - ss << resp.text; - std::string data{ss.str()}; + + const auto& data = resp.text; + if (data[0] == 'l' or data[0] == 'd') { try diff --git a/daemon/lokinet-vpn.cpp b/daemon/lokinet-vpn.cpp index aae574cba..2444ab536 100644 --- a/daemon/lokinet-vpn.cpp +++ b/daemon/lokinet-vpn.cpp @@ -1,18 +1,19 @@ -#include -#include -#include - -#include #include +#include #include #include +#include +#include +#include + #ifdef _WIN32 // add the unholy windows headers for iphlpapi #include -#include + #include #include +#include #else #endif diff --git a/daemon/lokinet.cpp b/daemon/lokinet.cpp index b57e28449..b3cb416c8 100644 --- a/daemon/lokinet.cpp +++ b/daemon/lokinet.cpp @@ -1,49 +1,35 @@ +#include #include // for ensure_config +#include +#include #include -#include -#include +#include #include -#include - -#ifdef _WIN32 -#include -#include -#else -#include -#endif +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include #include -#include -#include -#include +#include #include #include #include +#include +#include #include -#include "CLI/Error.hpp" -#include "CLI/Option.hpp" -#include "CLI/impl/App_inl.hpp" -#include "CLI/impl/Option_inl.hpp" -#include "fmt/core.h" -#include "llarp/constants/files.hpp" -#include "llarp/constants/platform.hpp" -#include "llarp/ev/ev.hpp" -#include "llarp/util/logging.hpp" -#include "llarp/util/thread/threading.hpp" -#include "oxen/log.hpp" -#include "oxen/log/catlogger.hpp" -#include "oxen/log/level.hpp" -#include "oxen/log/ring_buffer_sink.hpp" -#include "oxen/log/type.hpp" -#include "spdlog/common.h" +#ifdef _WIN32 +#include + +#include +#else +#include +#endif namespace { @@ -290,9 +276,8 @@ namespace const auto flags = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithFullMemoryInfo | MiniDumpWithHandleData | MiniDumpWithUnloadedModules | MiniDumpWithThreadInfo); - std::stringstream ss; - ss << "C:\\ProgramData\\lokinet\\crash-" << llarp::time_now_ms().count() << ".dmp"; - const std::string fname = ss.str(); + const std::string fname = + "C:\\ProgramData\\lokinet\\crash-{}.dump"_format(llarp::time_now_ms().count()); HANDLE hDumpFile; SYSTEMTIME stLocalTime; GetLocalTime(&stLocalTime); @@ -525,30 +510,8 @@ namespace 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 mascot of the deadlocked router.", - "⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠄⠄⠄⠄", - "⠄⠄⠄⠄⠄⢀⣀⣀⡀⠄⠄⠄⡠⢲⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄", - "⠄⠄⠄⠔⣈⣀⠄⢔⡒⠳⡴⠊⠄⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣧⠄⠄", - "⠄⢜⡴⢑⠖⠊⢐⣤⠞⣩⡇⠄⠄⠄⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠝⠛⠋⠐", - "⢸⠏⣷⠈⠄⣱⠃⠄⢠⠃⠐⡀⠄⠄⠄⠄⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠸⠄⠄⠄⠄", - "⠈⣅⠞⢁⣿⢸⠘⡄⡆⠄⠄⠈⠢⡀⠄⠄⠄⠄⠄⠄⠉⠙⠛⠛⠛⠉⠉⡀⠄⠡⢀⠄⣀", - "⠄⠙⡎⣹⢸⠄⠆⢘⠁⠄⠄⠄⢸⠈⠢⢄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠃⠄⠄⠄⠄⠄", - "⠄⠄⠑⢿⠈⢆⠘⢼⠄⠄⠄⠄⠸⢐⢾⠄⡘⡏⠲⠆⠠⣤⢤⢤⡤⠄⣖⡇⠄⠄⠄⠄⠄", - "⣴⣶⣿⣿⣣⣈⣢⣸⠄⠄⠄⠄⡾⣷⣾⣮⣤⡏⠁⠘⠊⢠⣷⣾⡛⡟⠈⠄⠄⠄⠄⠄⠄", - "⣿⣿⣿⣿⣿⠉⠒⢽⠄⠄⠄⠄⡇⣿⣟⣿⡇⠄⠄⠄⠄⢸⣻⡿⡇⡇⠄⠄⠄⠄⠄⠄⠄", - "⠻⣿⣿⣿⣿⣄⠰⢼⠄⠄⠄⡄⠁⢻⣍⣯⠃⠄⠄⠄⠄⠈⢿⣻⠃⠈⡆⡄⠄⠄⠄⠄⠄", - "⠄⠙⠿⠿⠛⣿⣶⣤⡇⠄⠄⢣⠄⠄⠈⠄⢠⠂⠄⠁⠄⡀⠄⠄⣀⠔⢁⠃⠄⠄⠄⠄⠄", - "⠄⠄⠄⠄⠄⣿⣿⣿⣿⣾⠢⣖⣶⣦⣤⣤⣬⣤⣤⣤⣴⣶⣶⡏⠠⢃⠌⠄⠄⠄⠄⠄⠄", - "⠄⠄⠄⠄⠄⠿⠿⠟⠛⡹⠉⠛⠛⠿⠿⣿⣿⣿⣿⣿⡿⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄", - "⠠⠤⠤⠄⠄⣀⠄⠄⠄⠑⠠⣤⣀⣀⣀⡘⣿⠿⠙⠻⡍⢀⡈⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄", - "⠄⠄⠄⠄⠄⠄⠑⠠⣠⣴⣾⣿⣿⣿⣿⣿⣿⣇⠉⠄⠻⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄", - "file a bug report now or be cursed with this " - "annoying image in your syslog for all time."}) - { - llarp::log::critical(deadlock_cat, wtf); - llarp::log::flush(); - } + llarp::log::critical(deadlock_cat, "Router is deadlocked!"); + llarp::log::flush(); llarp::sys::service_manager->failed(); std::abort(); } @@ -669,6 +632,17 @@ main(int argc, char* argv[]) #ifndef _WIN32 return lokinet_main(argc, argv); #else + if (auto hntdll = GetModuleHandle("ntdll.dll")) + { + if (GetProcAddress(hntdll, "wine_get_version")) + { + static const char* text = "Don't run lokinet in wine, aborting startup"; + static const char* title = "Lokinet Wine Error"; + MessageBoxA(NULL, text, title, MB_ICONHAND); + abort(); + } + } + SERVICE_TABLE_ENTRY DispatchTable[] = { {strdup("lokinet"), (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry}, {NULL, NULL}}; diff --git a/include/lokinet.h b/include/lokinet.h index 4cda5b53f..26b57a9ff 100644 --- a/include/lokinet.h +++ b/include/lokinet.h @@ -1,8 +1,8 @@ #pragma once +#include "lokinet/lokinet_addr.h" #include "lokinet/lokinet_context.h" -#include "lokinet/lokinet_srv.h" #include "lokinet/lokinet_misc.h" -#include "lokinet/lokinet_addr.h" +#include "lokinet/lokinet_srv.h" #include "lokinet/lokinet_stream.h" #include "lokinet/lokinet_udp.h" diff --git a/jni/lokinet_config.cpp b/jni/lokinet_config.cpp index 5313743c3..09489f1a5 100644 --- a/jni/lokinet_config.cpp +++ b/jni/lokinet_config.cpp @@ -1,7 +1,8 @@ +#include "lokinet_jni_common.hpp" #include "network_loki_lokinet_LokinetConfig.h" + #include #include -#include "lokinet_jni_common.hpp" extern "C" { diff --git a/jni/lokinet_daemon.cpp b/jni/lokinet_daemon.cpp index 98b6e8b5a..92e13d832 100644 --- a/jni/lokinet_daemon.cpp +++ b/jni/lokinet_daemon.cpp @@ -1,5 +1,6 @@ -#include "network_loki_lokinet_LokinetDaemon.h" #include "lokinet_jni_common.hpp" +#include "network_loki_lokinet_LokinetDaemon.h" + #include #include #include diff --git a/jni/lokinet_jni_common.hpp b/jni/lokinet_jni_common.hpp index 8eb77069c..0a8452de8 100644 --- a/jni/lokinet_jni_common.hpp +++ b/jni/lokinet_jni_common.hpp @@ -1,8 +1,9 @@ #pragma once #include -#include + #include +#include /// visit string as native bytes /// jvm uses some unholy encoding internally so we convert it to utf-8 diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index a3c698a2f..831836ce9 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -1,6 +1,5 @@ include(Version) - # Add an internal lokinet static library target, enables LTO (if enabled) on the target, # and links it to the common lokinet-base interface. # Invoke with the target/library name (e.g. "lokinet-foo") and list of source files, e.g. @@ -11,7 +10,6 @@ function(lokinet_add_library libname) enable_lto(${libname}) endfunction() - lokinet_add_library(lokinet-cryptography crypto/crypto.cpp crypto/encrypted_frame.cpp @@ -57,12 +55,12 @@ lokinet_add_library(lokinet-core ) lokinet_add_library(lokinet-rpc + rpc/endpoint_rpc.cpp rpc/json_binary_proxy.cpp rpc/json_conversions.cpp rpc/lokid_rpc_client.cpp rpc/rpc_request_parser.cpp rpc/rpc_server.cpp - rpc/endpoint_rpc.cpp ) lokinet_add_library(lokinet-wire @@ -78,12 +76,12 @@ lokinet_add_library(lokinet-utils util/bencode.cpp util/buffer.cpp util/file.cpp + util/logging/buffer.cpp util/mem.cpp util/str.cpp util/thread/threading.cpp util/thread/queue_manager.cpp util/time.cpp - util/logging/buffer.cpp ) add_dependencies(lokinet-utils genversion) @@ -91,10 +89,6 @@ add_dependencies(lokinet-utils genversion) # Addressing and event loop files used by lokinet-core and other libraries # needed by rpc/ link/ service/ config/ path/ dht/ lokinet_add_library(lokinet-time-place - pow.cpp # only intro_set - router_contact.cpp - router_id.cpp - router_version.cpp # to be deleted shortly ev/ev.cpp ev/libuv.cpp net/exit_info.cpp # only router_contact @@ -104,6 +98,10 @@ lokinet_add_library(lokinet-time-place net/ip_range.cpp net/net_int.cpp net/sock_addr.cpp + pow.cpp # only intro_set + router_contact.cpp + router_id.cpp + router_version.cpp # to be deleted shortly service/address.cpp service/convotag.cpp service/intro_set.cpp @@ -111,8 +109,8 @@ lokinet_add_library(lokinet-time-place # lokinet-platform holds all platform specific code lokinet_add_library(lokinet-platform - router/rc_lookup_handler.cpp net/interface_info.cpp + router/rc_lookup_handler.cpp vpn/packet_router.cpp vpn/platform.cpp ) @@ -153,18 +151,13 @@ endif() # lokinet-dns is the dns parsing and hooking library that we use to # parse modify and reconstitute dns wire proto, dns queries and RR -# should have no concept of dns caching, this is left as an implementation -# detail of dns resolvers (LATER: make separate lib for dns resolvers) -add_library(lokinet-dns-internal +lokinet_add_library(lokinet-dns + dns/message.cpp # dns/server dns/name.cpp # srv_data, question, rr dns/platform.cpp dns/question.cpp # message dns/rr.cpp dns/serialize.cpp -) - -lokinet_add_library(lokinet-dns - dns/message.cpp # dns/server dns/server.cpp # handlers/exit+tun and service/endpoint dns/srv_data.cpp ) @@ -180,9 +173,9 @@ endif() # nodedb data published to the network and versions of it stored locally lokinet_add_library(lokinet-nodedb bootstrap.cpp # config, router.hpp + net/traffic_policy.cpp # config, intro_set nodedb.cpp profiling.cpp # path, router, service::endpoint - net/traffic_policy.cpp # config, intro_set ) set(BOOTSTRAP_FALLBACKS) @@ -214,21 +207,19 @@ lokinet_add_library(lokinet-config # All path objects; link directly to lokinet-core lokinet_add_library(lokinet-path + messages/relay.cpp path/abstracthophandler.cpp - path/path_context.cpp path/path.cpp + path/path_context.cpp path/pathbuilder.cpp path/pathset.cpp path/transit_hop.cpp - messages/relay.cpp ) # Link libraries to their internals target_link_libraries(lokinet-core-utils PUBLIC lokinet-dns) target_link_libraries(lokinet-core PUBLIC lokinet-core-utils) -target_link_libraries(lokinet-dns PRIVATE lokinet-dns-internal) - # Link lokinet-dns to alternate libraries target_link_libraries(lokinet-dns PUBLIC lokinet-dns-platform) if (TARGET lokinet-dns-systemd) @@ -236,9 +227,8 @@ if (TARGET lokinet-dns-systemd) endif() target_link_libraries(lokinet-wire PUBLIC lokinet-time-place) -target_link_libraries(lokinet-dns-internal PUBLIC lokinet-utils) -target_link_libraries(lokinet-dns PUBLIC lokinet-cryptography lokinet-config) -target_link_libraries(lokinet-nodedb PUBLIC lokinet-cryptography) +target_link_libraries(lokinet-dns PUBLIC lokinet-utils lokinet-cryptography lokinet-config) +target_link_libraries(lokinet-nodedb PUBLIC lokinet-time-place lokinet-cryptography) target_link_libraries(lokinet-platform PUBLIC lokinet-cryptography) target_link_libraries(lokinet-rpc PUBLIC lokinet-wire) target_link_libraries(lokinet-time-place PUBLIC lokinet-utils lokinet-cryptography) @@ -277,11 +267,11 @@ target_link_libraries(lokinet-utils # cross linkage target_link_libraries(lokinet-core PUBLIC - lokinet-rpc - lokinet-wire + lokinet-cryptography lokinet-nodedb lokinet-path - lokinet-cryptography + lokinet-rpc + lokinet-wire ) target_link_libraries(lokinet-base INTERFACE oxenc::oxenc oxen::logging) @@ -292,7 +282,6 @@ target_link_libraries(lokinet-config PUBLIC oxenmq::oxenmq) target_link_libraries(lokinet-nodedb PUBLIC oxenmq::oxenmq) target_link_libraries(lokinet-path PUBLIC oxenmq::oxenmq) target_link_libraries(lokinet-time-place PUBLIC uvw) -# target_link_libraries(lokinet-platform PUBLIC oxenmq::oxenmq Threads::Threads base_libs uvw) target_link_libraries(lokinet-platform PUBLIC oxenmq::oxenmq Threads::Threads uvw) target_link_libraries(lokinet-cryptography PUBLIC sodium) target_link_libraries(lokinet-dns PUBLIC libunbound) diff --git a/llarp/android/ifaddrs.c b/llarp/android/ifaddrs.c index 8702feca8..af0a439e2 100644 --- a/llarp/android/ifaddrs.c +++ b/llarp/android/ifaddrs.c @@ -24,17 +24,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ifaddrs.h" -#include -#include -#include #include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include typedef struct NetlinkList { diff --git a/llarp/android/ifaddrs.h b/llarp/android/ifaddrs.h index 73d3d2877..03a9fbe93 100644 --- a/llarp/android/ifaddrs.h +++ b/llarp/android/ifaddrs.h @@ -23,8 +23,7 @@ * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp */ -#ifndef _IFADDRS_H_ -#define _IFADDRS_H_ +#pragma once struct ifaddrs { @@ -53,5 +52,3 @@ getifaddrs(struct ifaddrs** ifap); extern void freeifaddrs(struct ifaddrs* ifa); __END_DECLS - -#endif diff --git a/llarp/apple/DNSTrampoline.h b/llarp/apple/DNSTrampoline.h index 117d567b2..e691caf75 100644 --- a/llarp/apple/DNSTrampoline.h +++ b/llarp/apple/DNSTrampoline.h @@ -1,6 +1,6 @@ #pragma once -#include #include +#include extern NSString* error_domain; diff --git a/llarp/apple/DNSTrampoline.m b/llarp/apple/DNSTrampoline.m index 9ef950c4e..8ccbb1d2e 100644 --- a/llarp/apple/DNSTrampoline.m +++ b/llarp/apple/DNSTrampoline.m @@ -1,4 +1,5 @@ #include "DNSTrampoline.h" + #include NSString* error_domain = @"org.lokinet"; diff --git a/llarp/apple/PacketTunnelProvider.m b/llarp/apple/PacketTunnelProvider.m index dfcf20311..1981b0b81 100644 --- a/llarp/apple/PacketTunnelProvider.m +++ b/llarp/apple/PacketTunnelProvider.m @@ -1,8 +1,9 @@ -#include -#include #include "context_wrapper.h" #include "DNSTrampoline.h" +#include +#include + #define LLARP_APPLE_PACKET_BUF_SIZE 64 @interface LLARPPacketTunnel : NEPacketTunnelProvider diff --git a/llarp/apple/context.hpp b/llarp/apple/context.hpp index 4fc808874..cc7db2996 100644 --- a/llarp/apple/context.hpp +++ b/llarp/apple/context.hpp @@ -1,8 +1,9 @@ #pragma once -#include -#include "vpn_platform.hpp" #include "route_manager.hpp" +#include "vpn_platform.hpp" + +#include namespace llarp::apple { diff --git a/llarp/apple/context_wrapper.cpp b/llarp/apple/context_wrapper.cpp index e30c6c5d6..2cb727f60 100644 --- a/llarp/apple/context_wrapper.cpp +++ b/llarp/apple/context_wrapper.cpp @@ -1,17 +1,22 @@ -#include -#include -#include -#include +#include "context_wrapper.h" + +#include "context.hpp" +#include "vpn_interface.hpp" + #include #include +#include +#include #include -#include #include #include #include -#include "vpn_interface.hpp" -#include "context_wrapper.h" -#include "context.hpp" + +// #include + +#include +#include +#include namespace { diff --git a/llarp/apple/context_wrapper.h b/llarp/apple/context_wrapper.h index 1f09a46d3..a64df18c0 100644 --- a/llarp/apple/context_wrapper.h +++ b/llarp/apple/context_wrapper.h @@ -8,8 +8,8 @@ extern "C" { #endif -#include #include +#include #include // Port (on localhost) for our DNS trampoline for bouncing DNS requests through the exit route diff --git a/llarp/apple/route_manager.cpp b/llarp/apple/route_manager.cpp index 5cfc2c0a4..b1ac9bce2 100644 --- a/llarp/apple/route_manager.cpp +++ b/llarp/apple/route_manager.cpp @@ -1,7 +1,9 @@ #include "route_manager.hpp" + +#include #include #include -#include + #include namespace llarp::apple diff --git a/llarp/apple/route_manager.hpp b/llarp/apple/route_manager.hpp index e247b4755..cd3e418a1 100644 --- a/llarp/apple/route_manager.hpp +++ b/llarp/apple/route_manager.hpp @@ -1,8 +1,9 @@ #pragma once +#include "context_wrapper.h" + #include #include -#include "context_wrapper.h" namespace llarp::apple { diff --git a/llarp/apple/vpn_interface.cpp b/llarp/apple/vpn_interface.cpp index 3f128ad17..03964d403 100644 --- a/llarp/apple/vpn_interface.cpp +++ b/llarp/apple/vpn_interface.cpp @@ -1,6 +1,8 @@ #include "vpn_interface.hpp" + #include "context.hpp" + #include namespace llarp::apple diff --git a/llarp/apple/vpn_interface.hpp b/llarp/apple/vpn_interface.hpp index 787eb4ebb..ee5dfc8dc 100644 --- a/llarp/apple/vpn_interface.hpp +++ b/llarp/apple/vpn_interface.hpp @@ -1,8 +1,9 @@ #pragma once #include -#include #include +#include + #include namespace llarp::apple diff --git a/llarp/apple/vpn_platform.cpp b/llarp/apple/vpn_platform.cpp index 1f94e6e6d..7e05cbb05 100644 --- a/llarp/apple/vpn_platform.cpp +++ b/llarp/apple/vpn_platform.cpp @@ -1,4 +1,5 @@ #include "vpn_platform.hpp" + #include "context.hpp" namespace llarp::apple diff --git a/llarp/apple/vpn_platform.hpp b/llarp/apple/vpn_platform.hpp index 5cbe2858f..1f5bb1ef6 100644 --- a/llarp/apple/vpn_platform.hpp +++ b/llarp/apple/vpn_platform.hpp @@ -1,8 +1,9 @@ #pragma once -#include -#include "vpn_interface.hpp" #include "route_manager.hpp" +#include "vpn_interface.hpp" + +#include namespace llarp::apple { diff --git a/llarp/bootstrap-fallbacks.cpp.in b/llarp/bootstrap-fallbacks.cpp.in index 5c81ea716..baeb4be3a 100644 --- a/llarp/bootstrap-fallbacks.cpp.in +++ b/llarp/bootstrap-fallbacks.cpp.in @@ -1,5 +1,5 @@ #include -#include "llarp/bootstrap.hpp" +#include namespace llarp { diff --git a/llarp/bootstrap.hpp b/llarp/bootstrap.hpp index 6c657a4b1..e72e12fcc 100644 --- a/llarp/bootstrap.hpp +++ b/llarp/bootstrap.hpp @@ -1,11 +1,12 @@ #pragma once +#include "router_contact.hpp" + +#include + #include #include -#include "router_contact.hpp" -#include "llarp/util/fs.hpp" - namespace llarp { struct BootstrapList final : public std::set diff --git a/llarp/bootstrap_fallbacks.cpp b/llarp/bootstrap_fallbacks.cpp index 5be002098..458444f63 100644 --- a/llarp/bootstrap_fallbacks.cpp +++ b/llarp/bootstrap_fallbacks.cpp @@ -1,5 +1,6 @@ +#include + #include -#include "llarp/bootstrap.hpp" namespace llarp { diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 9df0d7c4c..e28652d9d 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -1,19 +1,20 @@ #include "config.hpp" +#include "definition.hpp" +#include "ini.hpp" + #include #include #include -#include #include +#include #include +#include #include #include #include -#include -#include -#include "definition.hpp" -#include "ini.hpp" +#include namespace llarp { diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index ee357a3cf..f91c131c2 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -1,32 +1,33 @@ #pragma once -#include -#include +#include "definition.hpp" +#include "ini.hpp" + #include -#include -#include -#include -#include -#include #include +#include +#include #include -#include #include +#include +#include +#include +#include #include #include -#include -#include +#include +#include +#include + #include + #include #include #include #include #include +#include #include #include -#include - -#include "ini.hpp" -#include "definition.hpp" namespace llarp { diff --git a/llarp/config/definition.cpp b/llarp/config/definition.cpp index 76177603c..b27e4b2e5 100644 --- a/llarp/config/definition.cpp +++ b/llarp/config/definition.cpp @@ -1,9 +1,10 @@ #include "definition.hpp" + #include +#include #include #include -#include namespace llarp { diff --git a/llarp/config/definition.hpp b/llarp/config/definition.hpp index c49b5161a..2d0ed0818 100644 --- a/llarp/config/definition.hpp +++ b/llarp/config/definition.hpp @@ -1,20 +1,22 @@ #pragma once -#include -#include #include +#include + +#include + +#include +#include #include -#include #include #include +#include #include #include #include +#include #include #include -#include -#include -#include namespace llarp { diff --git a/llarp/config/ini.cpp b/llarp/config/ini.cpp index b6fbb6166..66b55dd4c 100644 --- a/llarp/config/ini.cpp +++ b/llarp/config/ini.cpp @@ -1,7 +1,7 @@ #include "ini.hpp" -#include #include +#include #include #include diff --git a/llarp/config/ini.hpp b/llarp/config/ini.hpp index 3d72ee8cc..bb22cda8c 100644 --- a/llarp/config/ini.hpp +++ b/llarp/config/ini.hpp @@ -1,10 +1,11 @@ #pragma once #include -#include -#include + #include #include +#include +#include #include #include diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 96b73fb79..3df661847 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -1,10 +1,12 @@ #include "key_manager.hpp" -#include -#include #include "config.hpp" + #include #include +#include + +#include namespace llarp { diff --git a/llarp/config/key_manager.hpp b/llarp/config/key_manager.hpp index 060f13df9..20a45d0c9 100644 --- a/llarp/config/key_manager.hpp +++ b/llarp/config/key_manager.hpp @@ -1,10 +1,11 @@ #pragma once +#include "config.hpp" + #include #include -#include -#include "config.hpp" +#include namespace llarp { diff --git a/llarp/consensus/reachability_testing.cpp b/llarp/consensus/reachability_testing.cpp index adaf82136..a248f9cd7 100644 --- a/llarp/consensus/reachability_testing.cpp +++ b/llarp/consensus/reachability_testing.cpp @@ -1,9 +1,9 @@ #include "reachability_testing.hpp" +#include #include #include -#include using std::chrono::steady_clock; diff --git a/llarp/consensus/reachability_testing.hpp b/llarp/consensus/reachability_testing.hpp index 8ac363605..9ee79ef22 100644 --- a/llarp/consensus/reachability_testing.hpp +++ b/llarp/consensus/reachability_testing.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include +#include + #include #include #include diff --git a/llarp/constants/evloop.hpp b/llarp/constants/evloop.hpp deleted file mode 100644 index 4824f1b9c..000000000 --- a/llarp/constants/evloop.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace llarp -{ - /// default queue length for logic jobs - constexpr std::size_t event_loop_queue_size = 1024; -} // namespace llarp diff --git a/llarp/constants/files.hpp b/llarp/constants/files.hpp index 6e0085121..c6a3a4aa5 100644 --- a/llarp/constants/files.hpp +++ b/llarp/constants/files.hpp @@ -6,8 +6,8 @@ #include #ifndef _WIN32 -#include #include +#include #endif namespace llarp diff --git a/llarp/constants/link_layer.hpp b/llarp/constants/link_layer.hpp index 39eb38449..fabc0747c 100644 --- a/llarp/constants/link_layer.hpp +++ b/llarp/constants/link_layer.hpp @@ -1,6 +1,6 @@ #pragma once -#include #include +#include #include diff --git a/llarp/constants/path.hpp b/llarp/constants/path.hpp index 9b066adb3..20851255f 100644 --- a/llarp/constants/path.hpp +++ b/llarp/constants/path.hpp @@ -1,11 +1,11 @@ #pragma once +#include +#include + #include #include -#include -#include - namespace llarp::path { /// maximum path length diff --git a/llarp/constants/version.hpp b/llarp/constants/version.hpp index caa58b0af..1bfd68d31 100644 --- a/llarp/constants/version.hpp +++ b/llarp/constants/version.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace llarp { diff --git a/llarp/context.cpp b/llarp/context.cpp index ec2377844..be4f61d97 100644 --- a/llarp/context.cpp +++ b/llarp/context.cpp @@ -1,18 +1,18 @@ +#include "nodedb.hpp" + #include -#include -#include #include +#include #include #include #include #include #include -#include + #include +#include #include -#include "nodedb.hpp" - #if (__FreeBSD__) || (__OpenBSD__) || (__NetBSD__) #include #endif diff --git a/llarp/crypto/constants.hpp b/llarp/crypto/constants.hpp index 7f8eef90f..32cb142e9 100644 --- a/llarp/crypto/constants.hpp +++ b/llarp/crypto/constants.hpp @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include + static constexpr uint32_t PUBKEYSIZE = 32; static constexpr uint32_t SECKEYSIZE = 64; static constexpr uint32_t NONCESIZE = 24; diff --git a/llarp/crypto/crypto.cpp b/llarp/crypto/crypto.cpp index 9ef4a3a42..81b9cd57d 100644 --- a/llarp/crypto/crypto.cpp +++ b/llarp/crypto/crypto.cpp @@ -1,15 +1,16 @@ #include "crypto.hpp" +#include #include +#include +#include #include -#include +#include #include +#include #include -#include -#include -#include #include -#include + #include #include #ifdef HAVE_CRYPT diff --git a/llarp/crypto/crypto.hpp b/llarp/crypto/crypto.hpp index 2aae6a7ec..370b23e34 100644 --- a/llarp/crypto/crypto.hpp +++ b/llarp/crypto/crypto.hpp @@ -1,18 +1,18 @@ #pragma once -#include -#include -#include - #include "constants.hpp" #include "types.hpp" +#include + +#include +#include + namespace llarp { /* TODO: - make uint8_t pointers const where needed - - */ namespace crypto diff --git a/llarp/crypto/encrypted.hpp b/llarp/crypto/encrypted.hpp index 0dbf77278..8522e2447 100644 --- a/llarp/crypto/encrypted.hpp +++ b/llarp/crypto/encrypted.hpp @@ -6,8 +6,8 @@ #include #include -#include #include +#include namespace llarp { diff --git a/llarp/crypto/encrypted_frame.cpp b/llarp/crypto/encrypted_frame.cpp index 7171c5eb2..64b0ccbd8 100644 --- a/llarp/crypto/encrypted_frame.cpp +++ b/llarp/crypto/encrypted_frame.cpp @@ -1,9 +1,9 @@ #include "encrypted_frame.hpp" -#include - #include "crypto.hpp" +#include + namespace llarp { bool diff --git a/llarp/crypto/encrypted_frame.hpp b/llarp/crypto/encrypted_frame.hpp index 5c1c2ebea..19a6ab1c2 100644 --- a/llarp/crypto/encrypted_frame.hpp +++ b/llarp/crypto/encrypted_frame.hpp @@ -1,11 +1,12 @@ #pragma once +#include "encrypted.hpp" +#include "types.hpp" + #include #include -#include -#include "encrypted.hpp" -#include "types.hpp" +#include namespace llarp { diff --git a/llarp/crypto/types.cpp b/llarp/crypto/types.cpp index bf375eda7..30d4a3a9a 100644 --- a/llarp/crypto/types.cpp +++ b/llarp/crypto/types.cpp @@ -2,7 +2,10 @@ #include #include + #include +#include +#include namespace llarp { diff --git a/llarp/crypto/types.hpp b/llarp/crypto/types.hpp index 92bdd64f9..e4188c35d 100644 --- a/llarp/crypto/types.hpp +++ b/llarp/crypto/types.hpp @@ -1,16 +1,15 @@ #pragma once -#include +#include "constants.hpp" #include #include -#include #include +#include + #include #include -#include "constants.hpp" - namespace llarp { using SharedSecret = AlignedBuffer; diff --git a/llarp/dht/bucket.hpp b/llarp/dht/bucket.hpp index fd3e9ff35..0f4c0fe09 100644 --- a/llarp/dht/bucket.hpp +++ b/llarp/dht/bucket.hpp @@ -2,6 +2,7 @@ #include "kademlia.hpp" #include "key.hpp" + #include #include diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp deleted file mode 100644 index bec9eda83..000000000 --- a/llarp/dht/context.cpp +++ /dev/null @@ -1,662 +0,0 @@ - -#include "explorenetworkjob.hpp" -#include "localrouterlookup.hpp" -#include "localserviceaddresslookup.hpp" -#include "localtaglookup.hpp" -#include "node.hpp" -#include "publishservicejob.hpp" -#include "recursiverouterlookup.hpp" -#include "serviceaddresslookup.hpp" -#include "taglookup.hpp" -#include -#include -#include -#include -#include -#include -#include - -namespace llarp::dht -{ - AbstractDHTMessageHandler::~AbstractDHTMessageHandler() = default; - - struct DHTMessageHandler final : public AbstractDHTMessageHandler - { - DHTMessageHandler(); - - ~DHTMessageHandler() override = default; - - util::StatusObject - ExtractStatus() const override; - - void - StoreRC(const RouterContact rc) const override - { - GetRouter()->rc_lookup_handler().check_rc(rc); - } - - // void - // LookupIntroSetRelayed( - // const Key_t& target, - // const Key_t& whoasked, - // uint64_t whoaskedTX, - // const Key_t& askpeer, - // uint64_t relayOrder, - // service::EncryptedIntroSetLookupHandler result = nullptr) override; - - // void - // LookupIntroSetDirect( - // const Key_t& target, - // const Key_t& whoasked, - // uint64_t whoaskedTX, - // const Key_t& askpeer, - // service::EncryptedIntroSetLookupHandler result = nullptr) override; - - /// on behalf of whoasked request router with public key target from dht - /// router with key askpeer - void - LookupRouterRecursive( - const RouterID& target, - const Key_t& whoasked, - uint64_t whoaskedTX, - const Key_t& askpeer, - RouterLookupHandler result = nullptr) override; - - bool - LookupRouter(const RouterID& target, RouterLookupHandler result) override - { - Key_t askpeer; - if (!_nodes->FindClosest(Key_t(target), askpeer)) - { - return false; - } - LookupRouterRecursive(target, OurKey(), 0, askpeer, result); - return true; - } - - bool - HasRouterLookup(const RouterID& target) const override - { - return pendingRouterLookups().HasLookupFor(target); - } - - /// issue dht lookup for router via askpeer and send reply to local path - void - LookupRouterForPath( - const RouterID& target, uint64_t txid, const PathID_t& path, const Key_t& askpeer) override; - - /// issue dht lookup for introset for addr via askpeer and send reply to - /// local path - void - LookupIntroSetForPath( - const Key_t& addr, - uint64_t txid, - const llarp::PathID_t& path, - const Key_t& askpeer, - uint64_t relayOrder) override; - - /// send a dht message to peer, if keepalive is true then keep the session - /// with that peer alive for 10 seconds - void - DHTSendTo(const RouterID& peer, AbstractDHTMessage* msg, bool keepalive = true) override; - - /// get routers closest to target excluding requester - bool - HandleExploritoryRouterLookup( - const Key_t& requester, - uint64_t txid, - const RouterID& target, - std::vector>& reply) override; - - /// handle rc lookup from requester for target - void - LookupRouterRelayed( - const Key_t& requester, - uint64_t txid, - const Key_t& target, - bool recursive, - std::vector>& replies) override; - - /// relay a dht message from a local path to the main network - bool - RelayRequestForPath(const llarp::PathID_t& localPath, const AbstractDHTMessage& msg) override; - - /// send introset to peer as R/S - void - PropagateLocalIntroSet( - const PathID_t& from, - uint64_t txid, - const service::EncryptedIntroSet& introset, - const Key_t& tellpeer, - uint64_t relayOrder) override; - - /// send introset to peer from source with S counter and excluding peers - void - PropagateIntroSetTo( - const Key_t& from, - uint64_t txid, - const service::EncryptedIntroSet& introset, - const Key_t& tellpeer, - uint64_t relayOrder) override; - - /// initialize dht context and explore every exploreInterval milliseconds - void - Init(const Key_t& us, Router* router) override; - - /// get localally stored introset by service address - std::optional - GetIntroSetByLocation(const Key_t& location) const override; - - void - handle_cleaner_timer(); - - /// explore dht for new routers - void - Explore(size_t N = 3); - - llarp::Router* router{nullptr}; - // for router contacts - std::unique_ptr> _nodes; - - // for introduction sets - std::unique_ptr> _services; - - Bucket* - services() override - { - return _services.get(); - } - - bool allowTransit{false}; - - bool& - AllowTransit() override - { - return allowTransit; - } - const bool& - AllowTransit() const override - { - return allowTransit; - } - - Bucket* - Nodes() const override - { - return _nodes.get(); - } - - void - PutRCNodeAsync(const RCNode& val) override - { - router->loop()->call([nodes = Nodes(), val] { nodes->PutNode(val); }); - } - - void - DelRCNodeAsync(const Key_t& val) override - { - router->loop()->call([nodes = Nodes(), val] { nodes->DelNode(val); }); - } - - const Key_t& - OurKey() const override - { - return ourKey; - } - - llarp::Router* - GetRouter() const override - { - return router; - } - - bool - GetRCFromNodeDB(const Key_t& k, llarp::RouterContact& rc) const override - { - if (const auto maybe = router->node_db()->Get(k.as_array()); maybe.has_value()) - { - rc = *maybe; - return true; - } - return false; - } - - PendingIntrosetLookups _pendingIntrosetLookups; - PendingRouterLookups _pendingRouterLookups; - PendingExploreLookups _pendingExploreLookups; - - PendingIntrosetLookups& - pendingIntrosetLookups() override - { - return _pendingIntrosetLookups; - } - - const PendingIntrosetLookups& - pendingIntrosetLookups() const override - { - return _pendingIntrosetLookups; - } - - PendingRouterLookups& - pendingRouterLookups() override - { - return _pendingRouterLookups; - } - - const PendingRouterLookups& - pendingRouterLookups() const override - { - return _pendingRouterLookups; - } - - PendingExploreLookups& - pendingExploreLookups() override - { - return _pendingExploreLookups; - } - - const PendingExploreLookups& - pendingExploreLookups() const override - { - return _pendingExploreLookups; - } - - uint64_t - NextID() - { - return ++ids; - } - - llarp_time_t - Now() const override; - - void - ExploreNetworkVia(const Key_t& peer) override; - - bool - handle_message( - const AbstractDHTMessage&, std::vector>&) override; - - private: - std::shared_ptr _timer_keepalive; - - void - CleanupTX(); - - uint64_t ids; - - Key_t ourKey; - }; - - DHTMessageHandler::DHTMessageHandler() - { - randombytes((byte_t*)&ids, sizeof(uint64_t)); - } - - void - DHTMessageHandler::Explore(size_t N) - { - // ask N random peers for new routers - llarp::LogDebug("Exploring network via ", N, " peers"); - std::set peers; - - if (_nodes->GetManyRandom(peers, N)) - { - for (const auto& peer : peers) - ExploreNetworkVia(peer); - } - else - llarp::LogError("failed to select ", N, " random nodes for exploration"); - } - - void - DHTMessageHandler::ExploreNetworkVia(const Key_t& askpeer) - { - uint64_t txid = ++ids; - const TXOwner peer(askpeer, txid); - const TXOwner whoasked(OurKey(), txid); - const RouterID K(askpeer.as_array()); - pendingExploreLookups().NewTX( - peer, whoasked, K, new ExploreNetworkJob(askpeer.as_array(), this)); - } - - void - DHTMessageHandler::handle_cleaner_timer() - { - // clean up transactions - CleanupTX(); - const llarp_time_t now = Now(); - - if (_nodes) - { - // expire router contacts in memory - auto& nodes = _nodes->nodes; - auto itr = nodes.begin(); - while (itr != nodes.end()) - { - if (itr->second.rc.IsExpired(now)) - { - itr = nodes.erase(itr); - } - else - ++itr; - } - } - - if (_services) - { - // expire intro sets - auto& nodes = _services->nodes; - auto itr = nodes.begin(); - while (itr != nodes.end()) - { - if (itr->second.introset.IsExpired(now)) - { - itr = nodes.erase(itr); - } - else - ++itr; - } - } - } - - void - DHTMessageHandler::LookupRouterRelayed( - const Key_t& requester, - uint64_t txid, - const Key_t& target, - bool recursive, - std::vector>& replies) - { - if (target == ourKey) - { - // we are the target, give them our RC - replies.emplace_back(new GotRouterMessage(requester, txid, {router->rc()}, false)); - return; - } - if (not GetRouter()->SessionToRouterAllowed(target.as_array())) - { - // explicitly not allowed - replies.emplace_back(new GotRouterMessage(requester, txid, {}, false)); - return; - } - const auto rc = GetRouter()->node_db()->FindClosestTo(target); - const Key_t next(rc.pubkey); - { - if (next == target) - { - // we know the target - if (rc.ExpiresSoon(llarp::time_now_ms())) - { - // ask target for their rc to keep it updated - LookupRouterRecursive(target.as_array(), requester, txid, next); - } - else - { - // send reply with rc we know of - replies.emplace_back(new GotRouterMessage(requester, txid, {rc}, false)); - } - } - else if (recursive) // are we doing a recursive lookup? - { - // is the next peer we ask closer to the target than us? - if ((next ^ target) < (ourKey ^ target)) - { - // yes it is closer, ask neighbour recursively - LookupRouterRecursive(target.as_array(), requester, txid, next); - } - else - { - // no we are closer to the target so tell requester it's not there - // so they switch to iterative lookup - replies.emplace_back(new GotRouterMessage(requester, txid, {}, false)); - } - } - else - { - // iterative lookup and we don't have it tell them who is closer - replies.emplace_back(new GotRouterMessage(requester, next, txid, false)); - } - } - } - - std::optional - DHTMessageHandler::GetIntroSetByLocation(const Key_t& key) const - { - auto itr = _services->nodes.find(key); - if (itr == _services->nodes.end()) - return {}; - return itr->second.introset; - } - - void - DHTMessageHandler::CleanupTX() - { - auto now = Now(); - llarp::LogTrace("DHT tick"); - - pendingRouterLookups().Expire(now); - _pendingIntrosetLookups.Expire(now); - pendingExploreLookups().Expire(now); - } - - util::StatusObject - DHTMessageHandler::ExtractStatus() const - { - util::StatusObject obj{ - {"pendingRouterLookups", pendingRouterLookups().ExtractStatus()}, - {"pendingIntrosetLookups", _pendingIntrosetLookups.ExtractStatus()}, - {"pendingExploreLookups", pendingExploreLookups().ExtractStatus()}, - {"nodes", _nodes->ExtractStatus()}, - {"services", _services->ExtractStatus()}, - {"ourKey", ourKey.ToHex()}}; - return obj; - } - - bool - DHTMessageHandler::handle_message( - const AbstractDHTMessage& msg, std::vector>& replies) - { - return msg.handle_message(*this, replies); - } - - void - DHTMessageHandler::Init(const Key_t& us, Router* r) - { - router = r; - ourKey = us; - _nodes = std::make_unique>(ourKey, llarp::randint); - _services = std::make_unique>(ourKey, llarp::randint); - llarp::LogDebug("initialize dht with key ", ourKey); - // start cleanup timer - _timer_keepalive = std::make_shared(0); - router->loop()->call_every(1s, _timer_keepalive, [this] { handle_cleaner_timer(); }); - } - - void - DHTMessageHandler::DHTSendTo(const RouterID& peer, AbstractDHTMessage* msg, bool) - { - router->SendToOrQueue(peer, msg); - auto now = Now(); - router->PersistSessionUntil(peer, now + 1min); - } - - // this function handles incoming DHT messages sent down a path by a client - // note that IMessage here is different than that found in the routing - // namespace. by the time this is called, we are inside - // llarp::routing::DHTMessage::HandleMessage() - bool - DHTMessageHandler::RelayRequestForPath(const llarp::PathID_t& id, const AbstractDHTMessage& msg) - { - routing::PathDHTMessage reply; - if (not handle_message(msg, reply.dht_msgs)) - return false; - if (not reply.dht_msgs.empty()) - { - auto path = router->path_context().GetByUpstream(router->pubkey(), id); - return path && path->SendRoutingMessage(reply, router); - } - return true; - } - - void - DHTMessageHandler::LookupIntroSetForPath( - const Key_t& addr, - uint64_t txid, - const llarp::PathID_t& path, - const Key_t& askpeer, - uint64_t relayOrder) - { - const TXOwner asker(OurKey(), txid); - const TXOwner peer(askpeer, ++ids); - _pendingIntrosetLookups.NewTX( - peer, - asker, - asker, - new LocalServiceAddressLookup(path, txid, relayOrder, addr, this, askpeer)); - } - - void - DHTMessageHandler::PropagateIntroSetTo( - const Key_t& from, - uint64_t txid, - const service::EncryptedIntroSet& introset, - const Key_t& tellpeer, - uint64_t relayOrder) - { - const TXOwner asker(from, txid); - const TXOwner peer(tellpeer, ++ids); - _pendingIntrosetLookups.NewTX( - peer, asker, asker, new PublishServiceJob(asker, introset, this, relayOrder)); - } - - void - DHTMessageHandler::PropagateLocalIntroSet( - const PathID_t& from, - uint64_t txid, - const service::EncryptedIntroSet& introset, - const Key_t& tellpeer, - uint64_t relayOrder) - { - const TXOwner asker(OurKey(), txid); - const TXOwner peer(tellpeer, ++ids); - _pendingIntrosetLookups.NewTX( - peer, - asker, - peer, - new LocalPublishServiceJob(peer, from, txid, introset, this, relayOrder)); - } - - void - DHTMessageHandler::LookupIntroSetRelayed( - const Key_t& addr, - const Key_t& whoasked, - uint64_t txid, - const Key_t& askpeer, - uint64_t relayOrder, - service::EncryptedIntroSetLookupHandler handler) - { - const TXOwner asker(whoasked, txid); - const TXOwner peer(askpeer, ++ids); - _pendingIntrosetLookups.NewTX( - peer, asker, asker, new ServiceAddressLookup(asker, addr, this, relayOrder, handler)); - } - - void - DHTMessageHandler::LookupIntroSetDirect( - const Key_t& addr, - const Key_t& whoasked, - uint64_t txid, - const Key_t& askpeer, - service::EncryptedIntroSetLookupHandler handler) - { - const TXOwner asker(whoasked, txid); - const TXOwner peer(askpeer, ++ids); - _pendingIntrosetLookups.NewTX( - peer, asker, asker, new ServiceAddressLookup(asker, addr, this, 0, handler), 1s); - } - - bool - DHTMessageHandler::HandleExploritoryRouterLookup( - const Key_t& requester, - uint64_t txid, - const RouterID& target, - std::vector>& reply) - { - std::vector closer; - const Key_t t(target.as_array()); - std::set foundRouters; - if (!_nodes) - return false; - - const size_t nodeCount = _nodes->size(); - if (nodeCount == 0) - { - llarp::LogError("cannot handle exploritory router lookup, no dht peers"); - return false; - } - llarp::LogDebug("We have ", _nodes->size(), " connected nodes into the DHT"); - // ourKey should never be in the connected list - // requester is likely in the connected list - // 4 or connection nodes (minus a potential requestor), whatever is less - if (!_nodes->GetManyNearExcluding( - t, foundRouters, std::min(nodeCount, size_t{4}), std::set{ourKey, requester})) - { - llarp::LogError( - "not enough dht nodes to handle exploritory router lookup, " - "have ", - nodeCount, - " dht peers"); - return false; - } - for (const auto& f : foundRouters) - { - const RouterID id = f.as_array(); - // discard shit routers - if (router->router_profiling().IsBadForConnect(id)) - continue; - closer.emplace_back(id); - } - llarp::LogDebug("Gave ", closer.size(), " routers for exploration"); - reply.emplace_back(new GotRouterMessage(txid, closer, false)); - return true; - } - - void - DHTMessageHandler::LookupRouterForPath( - const RouterID& target, uint64_t txid, const llarp::PathID_t& path, const Key_t& askpeer) - - { - const TXOwner peer(askpeer, ++ids); - const TXOwner whoasked(OurKey(), txid); - _pendingRouterLookups.NewTX( - peer, whoasked, target, new LocalRouterLookup(path, txid, target, this)); - } - - void - DHTMessageHandler::LookupRouterRecursive( - const RouterID& target, - const Key_t& whoasked, - uint64_t txid, - const Key_t& askpeer, - RouterLookupHandler handler) - { - const TXOwner asker(whoasked, txid); - const TXOwner peer(askpeer, ++ids); - _pendingRouterLookups.NewTX( - peer, asker, target, new RecursiveRouterLookup(asker, target, this, handler)); - } - - llarp_time_t - DHTMessageHandler::Now() const - { - return router->now(); - } - - std::unique_ptr - make_handler() - { - return std::make_unique(); - } - -} // namespace llarp::dht diff --git a/llarp/dht/dht.cpp b/llarp/dht/dht.cpp deleted file mode 100644 index ba8149fec..000000000 --- a/llarp/dht/dht.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "dht.h" -#include - -// llarp_dht_context::llarp_dht_context(llarp::Router* router) -// { -// parent = router; -// impl = llarp::dht::make_handler(); -// } - -// struct llarp_dht_context* -// llarp_dht_context_new(llarp::Router* router) -// { -// return new llarp_dht_context(router); -// } - -// void -// llarp_dht_context_free(struct llarp_dht_context* ctx) -// { -// delete ctx; -// } - -// void -// __llarp_dht_remove_peer(struct llarp_dht_context* ctx, const byte_t* id) -// { -// ctx->impl->Nodes()->DelNode(llarp::dht::Key_t(id)); -// } - -// void -// llarp_dht_allow_transit(llarp_dht_context* ctx) -// { -// ctx->impl->AllowTransit() = true; -// } - -// void -// llarp_dht_context_start(struct llarp_dht_context* ctx, const byte_t* key) -// { -// ctx->impl->Init(llarp::dht::Key_t(key), ctx->parent); -// } - -void -llarp_dht_lookup_router(struct llarp_dht_context* ctx, struct llarp_router_lookup_job* job) -{ - job->dht = ctx; - job->found = false; - job->result.Clear(); - // llarp_rc_clear(&job->result); - llarp::LogError("implement me llarp_dht_lookup_router"); - /* - ctx->parent->logic->queue_job( - {job, &llarp::dht::Context::queue_router_lookup}); - */ -} diff --git a/llarp/dht/dht.h b/llarp/dht/dht.h deleted file mode 100644 index 618b11350..000000000 --- a/llarp/dht/dht.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include -#include -#include - -/** - * dht.h - * - * DHT functions - */ - -struct llarp_dht_context; - -namespace llarp -{ - struct Router; -} - -/// allocator -struct llarp_dht_context* -llarp_dht_context_new(llarp::Router* parent); - -/// deallocator -void -llarp_dht_context_free(struct llarp_dht_context* dht); - -/// start dht context with our location in keyspace -void -llarp_dht_context_start(struct llarp_dht_context* ctx, const byte_t* key); - -// remove this? dns needs it atm -struct llarp_router_lookup_job; - -using llarp_router_lookup_handler = void (*)(struct llarp_router_lookup_job*); - -struct llarp_router_lookup_job -{ - /// can be anything but usually a class context for hook - void* user; - llarp_router_lookup_handler hook; - struct llarp_dht_context* dht; - llarp::PubKey target; - bool found; - // make sure you initialize addr and exits - llarp::RouterContact result; - bool iterative; -}; -// end dns requirement - -/// start allowing dht participation on a context -void -llarp_dht_allow_transit(struct llarp_dht_context* ctx); - -/// remove router from tracked dht peer list -/// internal function do not use -void -__llarp_dht_remove_peer(struct llarp_dht_context* ctx, const byte_t* id); - -void -llarp_dht_lookup_router(struct llarp_dht_context* ctx, struct llarp_router_lookup_job* job); diff --git a/llarp/dht/kademlia.hpp b/llarp/dht/kademlia.hpp index b2889ac6a..776d8cb37 100644 --- a/llarp/dht/kademlia.hpp +++ b/llarp/dht/kademlia.hpp @@ -1,6 +1,7 @@ #pragma once #include "key.hpp" + #include namespace llarp::dht diff --git a/llarp/dht/key.hpp b/llarp/dht/key.hpp index 006bd9ff5..97fa8162e 100644 --- a/llarp/dht/key.hpp +++ b/llarp/dht/key.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include #include diff --git a/llarp/dht/node.hpp b/llarp/dht/node.hpp index 001229870..0f2deecc2 100644 --- a/llarp/dht/node.hpp +++ b/llarp/dht/node.hpp @@ -1,8 +1,10 @@ #pragma once #include "key.hpp" + #include #include + #include namespace llarp::dht diff --git a/llarp/dht/tx.hpp b/llarp/dht/tx.hpp deleted file mode 100644 index b2c3ebc87..000000000 --- a/llarp/dht/tx.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef LLARP_DHT_TX -#define LLARP_DHT_TX - -#include "key.hpp" -#include "txowner.hpp" - -#include -#include - -#include -#include - -namespace llarp -{ - struct Router; - - namespace dht - { - template - struct TX - { - K target; - Router* router; - std::set peersAsked; - std::vector valuesFound; - TXOwner whoasked; - - TX(const TXOwner& asker, const K& k, Router* r) : target(k), router{r}, whoasked(asker) - {} - - virtual ~TX() = default; - - void - OnFound(const Key_t& askedPeer, const V& value); - - util::StatusObject - ExtractStatus() const - { - util::StatusObject obj{ - {"whoasked", whoasked.ExtractStatus()}, {"target", target.ExtractStatus()}}; - std::vector foundObjs; - std::transform( - valuesFound.begin(), - valuesFound.end(), - std::back_inserter(foundObjs), - [](const auto& item) -> util::StatusObject { return item.ExtractStatus(); }); - - obj["found"] = foundObjs; - std::vector asked; - std::transform( - peersAsked.begin(), - peersAsked.end(), - std::back_inserter(asked), - [](const auto& item) -> std::string { return item.ToString(); }); - obj["asked"] = asked; - return obj; - } - - virtual bool - Validate(const V& value) const = 0; - - virtual void - Start(const TXOwner& peer) = 0; - }; - - template - inline void - TX::OnFound(const Key_t& askedPeer, const V& value) - { - peersAsked.insert(askedPeer); - if (Validate(value)) - { - valuesFound.push_back(value); - } - } - } // namespace dht -} // namespace llarp - -#endif diff --git a/llarp/dht/txholder.hpp b/llarp/dht/txholder.hpp deleted file mode 100644 index c75effe71..000000000 --- a/llarp/dht/txholder.hpp +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef LLARP_DHT_TXHOLDER -#define LLARP_DHT_TXHOLDER - -#include "tx.hpp" -#include "txowner.hpp" -#include -#include - -#include -#include - -namespace llarp::dht -{ - template - struct TXHolder - { - using TXPtr = std::unique_ptr>; - // tx who are waiting for a reply for each key - std::unordered_multimap waiting; - // tx timesouts by key - std::unordered_map timeouts; - // maps remote peer with tx to handle reply from them - std::unordered_map tx; - - const TX* - GetPendingLookupFrom(const TXOwner& owner) const; - - util::StatusObject - ExtractStatus() const - { - util::StatusObject obj{}; - std::vector txObjs, timeoutsObjs, waitingObjs; - std::transform( - tx.begin(), - tx.end(), - std::back_inserter(txObjs), - [](const auto& item) -> util::StatusObject { - return util::StatusObject{ - {"owner", item.first.ExtractStatus()}, {"tx", item.second->ExtractStatus()}}; - }); - obj["tx"] = txObjs; - std::transform( - timeouts.begin(), - timeouts.end(), - std::back_inserter(timeoutsObjs), - [](const auto& item) -> util::StatusObject { - return util::StatusObject{ - {"time", to_json(item.second)}, {"target", item.first.ExtractStatus()}}; - }); - obj["timeouts"] = timeoutsObjs; - std::transform( - waiting.begin(), - waiting.end(), - std::back_inserter(waitingObjs), - [](const auto& item) -> util::StatusObject { - return util::StatusObject{ - {"target", item.first.ExtractStatus()}, {"whoasked", item.second.ExtractStatus()}}; - }); - obj["waiting"] = waitingObjs; - return obj; - } - - bool - HasLookupFor(const K& target) const - { - return timeouts.find(target) != timeouts.end(); - } - - bool - HasPendingLookupFrom(const TXOwner& owner) const - { - return GetPendingLookupFrom(owner) != nullptr; - } - - void - NewTX( - const TXOwner& askpeer, - const TXOwner& whoasked, - const K& k, - TX* t, - llarp_time_t requestTimeoutMS = 15s); - - /// mark tx as not fond - void - NotFound(const TXOwner& from, const std::unique_ptr& next); - - void - Found(const TXOwner& from, const K& k, const std::vector& values) - { - Inform(from, k, values, true); - } - - /// inform all watches for key of values found - void - Inform( - TXOwner from, - K key, - std::vector values, - bool sendreply = false, - bool removeTimeouts = true); - - void - Expire(llarp_time_t now); - }; - - template - const TX* - TXHolder::GetPendingLookupFrom(const TXOwner& owner) const - { - auto itr = tx.find(owner); - if (itr == tx.end()) - { - return nullptr; - } - - return itr->second.get(); - } - - template - void - TXHolder::NewTX( - const TXOwner& askpeer, - const TXOwner& whoasked, - const K& k, - TX* t, - llarp_time_t requestTimeoutMS) - { - (void)whoasked; - tx.emplace(askpeer, std::unique_ptr>(t)); - auto count = waiting.count(k); - waiting.emplace(k, askpeer); - - auto itr = timeouts.find(k); - if (itr == timeouts.end()) - { - timeouts.emplace(k, time_now_ms() + requestTimeoutMS); - } - if (count == 0) - { - t->Start(askpeer); - } - } - - template - void - TXHolder::NotFound(const TXOwner& from, const std::unique_ptr&) - { - auto txitr = tx.find(from); - if (txitr == tx.end()) - { - return; - } - Inform(from, txitr->second->target, {}, true, true); - } - - template - void - TXHolder::Inform( - TXOwner from, K key, std::vector values, bool sendreply, bool removeTimeouts) - { - auto range = waiting.equal_range(key); - auto itr = range.first; - while (itr != range.second) - { - auto txitr = tx.find(itr->second); - if (txitr != tx.end()) - { - for (const auto& value : values) - { - txitr->second->OnFound(from.node, value); - } - if (sendreply) - { - txitr->second->SendReply(); - tx.erase(txitr); - } - } - ++itr; - } - - if (sendreply) - { - waiting.erase(key); - } - - if (removeTimeouts) - { - timeouts.erase(key); - } - } - - template - void - TXHolder::Expire(llarp_time_t now) - { - auto itr = timeouts.begin(); - while (itr != timeouts.end()) - { - if (now >= itr->second) - { - Inform(TXOwner{}, itr->first, {}, true, false); - itr = timeouts.erase(itr); - } - else - { - ++itr; - } - } - } -} // namespace llarp::dht - -#endif diff --git a/llarp/dht/txowner.hpp b/llarp/dht/txowner.hpp deleted file mode 100644 index 0fb7b2519..000000000 --- a/llarp/dht/txowner.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "key.hpp" -#include -#include - -namespace llarp::dht -{ - struct TXOwner - { - Key_t node; - uint64_t txid = 0; - - TXOwner() = default; - TXOwner(const TXOwner&) = default; - TXOwner(TXOwner&&) = default; - - TXOwner& - operator=(const TXOwner&) = default; - - TXOwner(const Key_t& k, uint64_t id) : node(k), txid(id) - {} - - util::StatusObject - ExtractStatus() const - { - util::StatusObject obj{ - {"txid", txid}, - {"node", node.ToHex()}, - }; - return obj; - } - - bool - operator==(const TXOwner& other) const - { - return std::tie(txid, node) == std::tie(other.txid, other.node); - } - - bool - operator<(const TXOwner& other) const - { - return std::tie(txid, node) < std::tie(other.txid, other.node); - } - }; -} // namespace llarp::dht - -namespace std -{ - template <> - struct hash - { - std::size_t - operator()(const llarp::dht::TXOwner& o) const noexcept - { - std::size_t sz2; - memcpy(&sz2, o.node.data(), sizeof(std::size_t)); - return o.txid ^ (sz2 << 1); - } - }; -} // namespace std diff --git a/llarp/dns/message.cpp b/llarp/dns/message.cpp index d527b03dd..a05f32857 100644 --- a/llarp/dns/message.cpp +++ b/llarp/dns/message.cpp @@ -1,13 +1,15 @@ #include "message.hpp" -#include -#include -#include -#include - #include "dns.hpp" #include "srv_data.hpp" +#include +#include + +#include + +#include + namespace llarp::dns { static auto logcat = log::Cat("dns"); diff --git a/llarp/dns/message.hpp b/llarp/dns/message.hpp index 6140d307c..852f3408d 100644 --- a/llarp/dns/message.hpp +++ b/llarp/dns/message.hpp @@ -1,8 +1,8 @@ #pragma once -#include "serialize.hpp" -#include "rr.hpp" #include "question.hpp" +#include "rr.hpp" +#include "serialize.hpp" namespace llarp { diff --git a/llarp/dns/name.cpp b/llarp/dns/name.cpp index e78a8cf9d..6741a38db 100644 --- a/llarp/dns/name.cpp +++ b/llarp/dns/name.cpp @@ -1,8 +1,9 @@ #include "name.hpp" #include -#include #include +#include + #include namespace llarp::dns diff --git a/llarp/dns/name.hpp b/llarp/dns/name.hpp index 718ebb0fc..deb4b344d 100644 --- a/llarp/dns/name.hpp +++ b/llarp/dns/name.hpp @@ -2,8 +2,9 @@ #include #include -#include + #include +#include namespace llarp::dns { diff --git a/llarp/dns/nm_platform.hpp b/llarp/dns/nm_platform.hpp index 593cfaa28..650e35365 100644 --- a/llarp/dns/nm_platform.hpp +++ b/llarp/dns/nm_platform.hpp @@ -2,6 +2,7 @@ #include "platform.hpp" #include + #include #include diff --git a/llarp/dns/platform.hpp b/llarp/dns/platform.hpp index e1db57ba1..55abd93b2 100644 --- a/llarp/dns/platform.hpp +++ b/llarp/dns/platform.hpp @@ -1,9 +1,10 @@ #pragma once #include #include -#include + #include #include +#include #ifndef _WIN32 #include diff --git a/llarp/dns/question.cpp b/llarp/dns/question.cpp index baa4c1d34..d7bd7b210 100644 --- a/llarp/dns/question.cpp +++ b/llarp/dns/question.cpp @@ -1,9 +1,9 @@ #include "question.hpp" -#include - #include "dns.hpp" +#include + namespace llarp::dns { static auto logcat = log::Cat("dns"); diff --git a/llarp/dns/question.hpp b/llarp/dns/question.hpp index a5a1330e3..7bad74f51 100644 --- a/llarp/dns/question.hpp +++ b/llarp/dns/question.hpp @@ -1,7 +1,7 @@ #pragma once -#include "serialize.hpp" #include "name.hpp" +#include "serialize.hpp" #include diff --git a/llarp/dns/rr.hpp b/llarp/dns/rr.hpp index b1c0b152c..ec19032fa 100644 --- a/llarp/dns/rr.hpp +++ b/llarp/dns/rr.hpp @@ -1,12 +1,13 @@ #pragma once +#include "name.hpp" +#include "serialize.hpp" + #include + #include #include -#include "name.hpp" -#include "serialize.hpp" - namespace llarp::dns { using RRClass_t = uint16_t; diff --git a/llarp/dns/sd_platform.hpp b/llarp/dns/sd_platform.hpp index 27db6d6fa..d3d850eee 100644 --- a/llarp/dns/sd_platform.hpp +++ b/llarp/dns/sd_platform.hpp @@ -2,6 +2,7 @@ #include "platform.hpp" #include + #include namespace llarp::dns diff --git a/llarp/dns/serialize.hpp b/llarp/dns/serialize.hpp index 5ae8d15fc..a75c447e5 100644 --- a/llarp/dns/serialize.hpp +++ b/llarp/dns/serialize.hpp @@ -2,6 +2,7 @@ #include #include + #include namespace llarp::dns diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 995f10a5d..49deb212a 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -1,19 +1,20 @@ #include "server.hpp" -#include +#include "nm_platform.hpp" +#include "sd_platform.hpp" + #include +#include #include + +#include #include +#include + +#include +#include #include #include -#include -#include - -#include "oxen/log.hpp" -#include "sd_platform.hpp" -#include "nm_platform.hpp" - -#include namespace llarp::dns { diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index d4baef55c..dc2eec473 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -1,14 +1,15 @@ #pragma once +#include "message.hpp" +#include "platform.hpp" + #include #include #include -#include #include -#include +#include -#include "message.hpp" -#include "platform.hpp" +#include namespace llarp::dns { diff --git a/llarp/dns/srv_data.cpp b/llarp/dns/srv_data.cpp index d5189856a..695955b67 100644 --- a/llarp/dns/srv_data.cpp +++ b/llarp/dns/srv_data.cpp @@ -1,10 +1,10 @@ #include "srv_data.hpp" -#include - #include -#include #include +#include + +#include namespace llarp::dns { diff --git a/llarp/dns/srv_data.hpp b/llarp/dns/srv_data.hpp index 59b260309..c1b864c3d 100644 --- a/llarp/dns/srv_data.hpp +++ b/llarp/dns/srv_data.hpp @@ -1,12 +1,13 @@ #pragma once -#include -#include - #include "dns.hpp" #include "name.hpp" #include "serialize.hpp" -#include "llarp/util/status.hpp" + +#include + +#include +#include namespace llarp::dns { diff --git a/llarp/endpoint_base.cpp b/llarp/endpoint_base.cpp index a8c687766..0e74cdbc5 100644 --- a/llarp/endpoint_base.cpp +++ b/llarp/endpoint_base.cpp @@ -1,6 +1,6 @@ #include "endpoint_base.hpp" -#include "llarp/util/algorithm.hpp" +#include namespace llarp { diff --git a/llarp/endpoint_base.hpp b/llarp/endpoint_base.hpp index a6629f7b4..3c1773dad 100644 --- a/llarp/endpoint_base.hpp +++ b/llarp/endpoint_base.hpp @@ -1,22 +1,24 @@ #pragma once +#include "router_id.hpp" + +#include +#include #include +#include +#include +#include + +#include #include + #include #include +#include +#include #include #include -#include #include -#include - -#include "llarp/service/address.hpp" -#include "llarp/service/convotag.hpp" -#include "llarp/service/protocol_type.hpp" -#include "router_id.hpp" -#include "llarp/ev/ev.hpp" -#include "llarp/dns/srv_data.hpp" -#include "oxenc/variant.h" namespace llarp { @@ -25,6 +27,12 @@ namespace llarp class Server; } + // TODO: add forward declaration of TunnelManager + // namespace link + // { + // class TunneLManager; + // } + class EndpointBase { std::unordered_set m_SRVRecords; diff --git a/llarp/ev/ev.cpp b/llarp/ev/ev.cpp index 04362f41b..08b084a64 100644 --- a/llarp/ev/ev.cpp +++ b/llarp/ev/ev.cpp @@ -1,9 +1,10 @@ #include "ev.hpp" +#include "libuv.hpp" + #include -#include -#include "libuv.hpp" +#include namespace llarp { diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index 329a49b28..33c5724d9 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -1,14 +1,16 @@ #pragma once +#include #include -#include #include -#include -#include +#include + +#include + #include #include -#include #include +#include #include using oxen::log::slns::source_location; @@ -20,6 +22,8 @@ namespace uvw namespace llarp { + constexpr std::size_t event_loop_queue_size = 1024; + struct SockAddr; struct UDPHandle; diff --git a/llarp/ev/libuv.cpp b/llarp/ev/libuv.cpp index e76e58611..0961b9d4d 100644 --- a/llarp/ev/libuv.cpp +++ b/llarp/ev/libuv.cpp @@ -3,12 +3,12 @@ #include #include +#include + +#include #include #include #include -#include - -#include namespace llarp::uv { diff --git a/llarp/ev/libuv.hpp b/llarp/ev/libuv.hpp index d83865de1..2d9cff015 100644 --- a/llarp/ev/libuv.hpp +++ b/llarp/ev/libuv.hpp @@ -1,17 +1,16 @@ #pragma once -#include +#include "ev.hpp" +#include "udp_handle.hpp" + #include -#include -#include -#include -#include +#include + +// #include + #include #include #include -#include "ev.hpp" -#include "udp_handle.hpp" - namespace llarp::uv { class UVWakeup; diff --git a/llarp/ev/udp_handle.hpp b/llarp/ev/udp_handle.hpp index 9e8425cd5..aaf50c923 100644 --- a/llarp/ev/udp_handle.hpp +++ b/llarp/ev/udp_handle.hpp @@ -1,5 +1,5 @@ -#include "ev.hpp" #include "../util/buffer.hpp" +#include "ev.hpp" namespace llarp { diff --git a/llarp/exit/context.cpp b/llarp/exit/context.cpp index fdf0a3118..aa3761cc9 100644 --- a/llarp/exit/context.cpp +++ b/llarp/exit/context.cpp @@ -1,4 +1,5 @@ #include "context.hpp" + #include #include diff --git a/llarp/exit/context.hpp b/llarp/exit/context.hpp index 923106ebd..31a9e766f 100644 --- a/llarp/exit/context.hpp +++ b/llarp/exit/context.hpp @@ -1,10 +1,11 @@ #pragma once +#include "policy.hpp" + #include + #include #include -#include "policy.hpp" - namespace llarp::exit { /// owner of all the exit endpoints diff --git a/llarp/exit/endpoint.hpp b/llarp/exit/endpoint.hpp index 547e697ab..7405ce1f9 100644 --- a/llarp/exit/endpoint.hpp +++ b/llarp/exit/endpoint.hpp @@ -5,6 +5,7 @@ #include #include #include + #include namespace llarp diff --git a/llarp/exit/policy.hpp b/llarp/exit/policy.hpp index 60b20d95a..c45da613c 100644 --- a/llarp/exit/policy.hpp +++ b/llarp/exit/policy.hpp @@ -1,8 +1,9 @@ #pragma once -#include #include +#include + namespace { static auto policy_cat = llarp::log::Cat("lokinet.policy"); diff --git a/llarp/exit/session.cpp b/llarp/exit/session.cpp index 6920c750c..158b02651 100644 --- a/llarp/exit/session.cpp +++ b/llarp/exit/session.cpp @@ -2,9 +2,10 @@ #include #include -#include #include +#include #include + #include namespace llarp::exit diff --git a/llarp/exit/session.hpp b/llarp/exit/session.hpp index a95f2baf4..435151743 100644 --- a/llarp/exit/session.hpp +++ b/llarp/exit/session.hpp @@ -1,9 +1,10 @@ #pragma once -#include +#include #include #include -#include +#include + #include #include diff --git a/llarp/handlers/exit.cpp b/llarp/handlers/exit.cpp index 20578e510..3702c3f2a 100644 --- a/llarp/handlers/exit.cpp +++ b/llarp/handlers/exit.cpp @@ -3,9 +3,10 @@ #include #include #include -#include #include +#include #include + #include namespace llarp::handlers diff --git a/llarp/handlers/exit.hpp b/llarp/handlers/exit.hpp index 8354bdb93..b1b97f3f4 100644 --- a/llarp/handlers/exit.hpp +++ b/llarp/handlers/exit.hpp @@ -1,10 +1,11 @@ #pragma once -#include +#include "tun.hpp" + #include -#include +#include -#include "tun.hpp" +#include namespace llarp { diff --git a/llarp/handlers/null.hpp b/llarp/handlers/null.hpp index ecf1f61fe..4f473c851 100644 --- a/llarp/handlers/null.hpp +++ b/llarp/handlers/null.hpp @@ -1,10 +1,10 @@ #pragma once +#include #include +#include #include #include -#include -#include #include namespace llarp::handlers diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index 80aca87ff..468e138a7 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -1,26 +1,26 @@ +#include "tun.hpp" + #include #include #include - -#include "tun.hpp" #ifndef _WIN32 #include #endif +#include #include #include #include -#include +#include #include +#include +#include #include -#include #include #include +#include #include -#include -#include #include -#include namespace llarp::handlers { diff --git a/llarp/handlers/tun.hpp b/llarp/handlers/tun.hpp index 846e11dd2..f4241d901 100644 --- a/llarp/handlers/tun.hpp +++ b/llarp/handlers/tun.hpp @@ -11,6 +11,7 @@ #include #include #include + #include #include #include diff --git a/llarp/link/connection.hpp b/llarp/link/connection.hpp index 69f88896b..fe8b0961a 100644 --- a/llarp/link/connection.hpp +++ b/llarp/link/connection.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include +#include + #include namespace llarp::link diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index d9fe5583b..f3f504795 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -1,13 +1,14 @@ #include "link_manager.hpp" + #include "connection.hpp" #include "contacts.hpp" #include #include #include -#include -#include #include +#include +#include #include #include diff --git a/llarp/link/link_manager.hpp b/llarp/link/link_manager.hpp index 6788447b8..d2b8cc8c9 100644 --- a/llarp/link/link_manager.hpp +++ b/llarp/link/link_manager.hpp @@ -1,19 +1,21 @@ #pragma once +#include "connection.hpp" + #include -#include +#include #include #include -#include #include -#include +#include #include #include -#include -#include -#include -#include "connection.hpp" +#include + +#include +#include +#include namespace { diff --git a/llarp/link/tunnel.cpp b/llarp/link/tunnel.cpp index 0c5fa5bb4..f873eed30 100644 --- a/llarp/link/tunnel.cpp +++ b/llarp/link/tunnel.cpp @@ -1,12 +1,14 @@ #include "tunnel.hpp" + +#include #include #include #include -#include #include #include #include -#include + +#include #include #include #include diff --git a/llarp/link/tunnel.hpp b/llarp/link/tunnel.hpp index 4d5abca8e..0abd97284 100644 --- a/llarp/link/tunnel.hpp +++ b/llarp/link/tunnel.hpp @@ -3,13 +3,13 @@ #include #include -#include #include +#include #include #include -#include #include #include +#include // #include diff --git a/llarp/linux/sd_service_manager.cpp b/llarp/linux/sd_service_manager.cpp index 43d9ec47e..cf9666754 100644 --- a/llarp/linux/sd_service_manager.cpp +++ b/llarp/linux/sd_service_manager.cpp @@ -1,10 +1,11 @@ +#include +#include +#include #include #include + #include -#include -#include -#include namespace llarp::sys { diff --git a/llarp/lokinet_shared.cpp b/llarp/lokinet_shared.cpp index e93303325..9b8c64c4e 100644 --- a/llarp/lokinet_shared.cpp +++ b/llarp/lokinet_shared.cpp @@ -1,22 +1,20 @@ -#include #include #include #include - -#include -#include #include #include - +#include +#include #include #include #include +#include #include -#include -#include #include +#include +#include #include #ifdef _WIN32 diff --git a/llarp/messages/link_message.hpp b/llarp/messages/link_message.hpp index 7a60b880d..e05fa33b3 100644 --- a/llarp/messages/link_message.hpp +++ b/llarp/messages/link_message.hpp @@ -2,9 +2,9 @@ #include "common.hpp" +#include #include #include -#include #include @@ -60,10 +60,4 @@ namespace llarp "Error: Link messages should not encode directly to a bt list producer!"}; } }; - - struct AbstractDataMessage : public AbstractLinkMessage - { - using AbstractLinkMessage::AbstractLinkMessage; - }; - } // namespace llarp diff --git a/llarp/messages/relay.hpp b/llarp/messages/relay.hpp index 22cbb162f..e6064e2f9 100644 --- a/llarp/messages/relay.hpp +++ b/llarp/messages/relay.hpp @@ -1,11 +1,12 @@ #pragma once +#include "link_message.hpp" + #include #include #include -#include -#include "link_message.hpp" +#include namespace llarp { @@ -13,7 +14,7 @@ namespace llarp Data messages to be sent via quic datagrams */ - struct RelayUpstreamMessage final : public AbstractDataMessage + struct RelayUpstreamMessage final : public AbstractLinkMessage { Encrypted enc; TunnelNonce nonce; @@ -42,7 +43,7 @@ namespace llarp } }; - struct RelayDownstreamMessage final : public AbstractDataMessage + struct RelayDownstreamMessage final : public AbstractLinkMessage { Encrypted enc; TunnelNonce nonce; diff --git a/llarp/net/exit_info.cpp b/llarp/net/exit_info.cpp index 20b8cce98..69d297cca 100644 --- a/llarp/net/exit_info.cpp +++ b/llarp/net/exit_info.cpp @@ -2,10 +2,11 @@ #include #endif +#include "exit_info.hpp" + #include -#include -#include "exit_info.hpp" +#include namespace llarp { diff --git a/llarp/net/exit_info.hpp b/llarp/net/exit_info.hpp index 0ea3fac34..5c1c92736 100644 --- a/llarp/net/exit_info.hpp +++ b/llarp/net/exit_info.hpp @@ -1,10 +1,11 @@ #pragma once +#include "ip_address.hpp" + #include #include -#include -#include "ip_address.hpp" +#include /** * exit_info.h diff --git a/llarp/net/interface_info.hpp b/llarp/net/interface_info.hpp index 107f7bf90..f720090dc 100644 --- a/llarp/net/interface_info.hpp +++ b/llarp/net/interface_info.hpp @@ -1,12 +1,13 @@ #pragma once +#include "ip_range.hpp" + #include + #include #include #include -#include "ip_range.hpp" - namespace llarp::net { /// info about a network interface lokinet does not own diff --git a/llarp/net/ip.cpp b/llarp/net/ip.cpp index ed30a42de..ef87da31b 100644 --- a/llarp/net/ip.cpp +++ b/llarp/net/ip.cpp @@ -1,4 +1,5 @@ #include "ip.hpp" + #include namespace llarp::net diff --git a/llarp/net/ip_address.cpp b/llarp/net/ip_address.cpp index 741c0b344..d37aee133 100644 --- a/llarp/net/ip_address.cpp +++ b/llarp/net/ip_address.cpp @@ -1,4 +1,5 @@ #include "ip_address.hpp" + #include "ip_range.hpp" namespace llarp diff --git a/llarp/net/ip_address.hpp b/llarp/net/ip_address.hpp index 1730008fd..e4cf26f1b 100644 --- a/llarp/net/ip_address.hpp +++ b/llarp/net/ip_address.hpp @@ -1,12 +1,13 @@ #pragma once +#include "net_int.hpp" +#include "sock_addr.hpp" + #include + #include -#include #include - -#include "sock_addr.hpp" -#include "net_int.hpp" +#include namespace llarp { diff --git a/llarp/net/ip_packet.cpp b/llarp/net/ip_packet.cpp index 2065e6929..fc69d8c17 100644 --- a/llarp/net/ip_packet.cpp +++ b/llarp/net/ip_packet.cpp @@ -1,15 +1,16 @@ #include "ip_packet.hpp" +#include "ip.hpp" + #include #include #include - -#include "ip.hpp" #ifndef _WIN32 #include #endif #include + #include namespace llarp::net diff --git a/llarp/net/ip_packet.hpp b/llarp/net/ip_packet.hpp index f38187395..ad6e208e0 100644 --- a/llarp/net/ip_packet.hpp +++ b/llarp/net/ip_packet.hpp @@ -1,15 +1,17 @@ #pragma once -#include -#include +#include "net.hpp" + +// #include +#include #include #include -#include + +#include + #include #include -#include "net.hpp" - namespace llarp::net { struct ip_header_le diff --git a/llarp/net/ip_range.cpp b/llarp/net/ip_range.cpp index 23fe8b1c0..363b2c2e6 100644 --- a/llarp/net/ip_range.cpp +++ b/llarp/net/ip_range.cpp @@ -1,8 +1,8 @@ #include "ip_range.hpp" -#include "oxenc/bt_serialize.h" +#include -#include "llarp/util/bencode.h" +#include namespace llarp { diff --git a/llarp/net/ip_range.hpp b/llarp/net/ip_range.hpp index 8c5d7aaed..0dcc5a6f7 100644 --- a/llarp/net/ip_range.hpp +++ b/llarp/net/ip_range.hpp @@ -1,19 +1,21 @@ #pragma once -#include +#include "ip.hpp" +#include "net_bits.hpp" + #include #include -#include #include +#include + +#include #include + #include #include #include #include -#include "ip.hpp" -#include "net_bits.hpp" - namespace { static auto net_cat = llarp::log::Cat("lokinet.net"); diff --git a/llarp/net/ip_range_map.hpp b/llarp/net/ip_range_map.hpp index d38bcf83e..51083388c 100644 --- a/llarp/net/ip_range_map.hpp +++ b/llarp/net/ip_range_map.hpp @@ -1,7 +1,9 @@ #pragma once #include "ip_range.hpp" + #include + #include #include diff --git a/llarp/net/net.h b/llarp/net/net.h index cc0a56741..bbc647ac9 100644 --- a/llarp/net/net.h +++ b/llarp/net/net.h @@ -1,6 +1,7 @@ #pragma once #if defined(_WIN32) || defined(__MINGW32__) #include + #include #include // because this shit is not defined for Windows NT reeeee diff --git a/llarp/net/net.hpp b/llarp/net/net.hpp index f21531029..0c4b50700 100644 --- a/llarp/net/net.hpp +++ b/llarp/net/net.hpp @@ -1,26 +1,27 @@ #pragma once -#include "uint128.hpp" +#include "interface_info.hpp" #include "ip_address.hpp" -#include "net_int.hpp" -#include "net.h" #include "ip_range.hpp" -#include -#include +#include "net.h" +#include "net_int.hpp" +#include "uint128.hpp" -#include "interface_info.hpp" +#include +#include -#include #include // for itoa +#include #include // for addrinfo #ifndef _WIN32 -#include -#include #include +#include +#include #else #include + #include #include #endif diff --git a/llarp/net/net_int.cpp b/llarp/net/net_int.cpp index 2628200ec..bfc0ceac4 100644 --- a/llarp/net/net_int.cpp +++ b/llarp/net/net_int.cpp @@ -1,10 +1,12 @@ #include "net_int.hpp" + #include "ip.hpp" -#include -#include #include +#include +#include + namespace llarp { namespace net diff --git a/llarp/net/net_int.hpp b/llarp/net/net_int.hpp index 447dc4e32..e70347112 100644 --- a/llarp/net/net_int.hpp +++ b/llarp/net/net_int.hpp @@ -2,25 +2,28 @@ // for addrinfo #ifndef _WIN32 -#include -#include #include +#include +#include #else #include + #include #define inet_aton(x, y) inet_pton(AF_INET, x, y) #endif +#include "net.h" +#include "uint128.hpp" + #include + #include + #include // for itoa #include #include -#include "net.h" -#include "uint128.hpp" - namespace llarp { template diff --git a/llarp/net/posix.cpp b/llarp/net/posix.cpp index e20243d20..5bf8c85f1 100644 --- a/llarp/net/posix.cpp +++ b/llarp/net/posix.cpp @@ -1,8 +1,8 @@ -#include - +#include "ip_range.hpp" #include "net.hpp" #include "net_if.hpp" -#include "ip_range.hpp" + +#include #ifdef ANDROID #include diff --git a/llarp/net/sock_addr.cpp b/llarp/net/sock_addr.cpp index 5f25830e0..288fba9a1 100644 --- a/llarp/net/sock_addr.cpp +++ b/llarp/net/sock_addr.cpp @@ -1,13 +1,14 @@ #include "sock_addr.hpp" -#include -#include -#include - -#include "ip_range.hpp" #include "ip.hpp" -#include "net_bits.hpp" +#include "ip_range.hpp" #include "net.hpp" +#include "net_bits.hpp" + +#include +#include + +#include namespace llarp { diff --git a/llarp/net/sock_addr.hpp b/llarp/net/sock_addr.hpp index b44d49f1c..fe0db0f61 100644 --- a/llarp/net/sock_addr.hpp +++ b/llarp/net/sock_addr.hpp @@ -1,20 +1,23 @@ #pragma once #ifndef _WIN32 -#include #include +#include #else #include + #include #include #endif -#include +#include "net_int.hpp" + #include -#include -#include -#include "net_int.hpp" +#include + +#include +#include namespace llarp { diff --git a/llarp/net/traffic_policy.hpp b/llarp/net/traffic_policy.hpp index ebdaa539d..b0f4e74c8 100644 --- a/llarp/net/traffic_policy.hpp +++ b/llarp/net/traffic_policy.hpp @@ -1,11 +1,13 @@ #pragma once +#include "ip_packet.hpp" +#include "ip_range.hpp" + +#include + #include -#include -#include "ip_range.hpp" -#include "ip_packet.hpp" -#include "llarp/util/status.hpp" +#include namespace llarp::net { diff --git a/llarp/net/uint128.hpp b/llarp/net/uint128.hpp index dde7c83af..c6534798e 100644 --- a/llarp/net/uint128.hpp +++ b/llarp/net/uint128.hpp @@ -1,11 +1,11 @@ #pragma once +#include + +#include #include #include -#include #include -#include - namespace llarp { /// 128-bit unsigned integer. Does *not* support diff --git a/llarp/net/win32.cpp b/llarp/net/win32.cpp index 1bcaa86df..b48798885 100644 --- a/llarp/net/win32.cpp +++ b/llarp/net/win32.cpp @@ -1,19 +1,18 @@ +#include "ip.hpp" +#include "ip_range.hpp" #include "net.hpp" - #include "net_if.hpp" -#include -#include -#include "ip.hpp" -#include "ip_range.hpp" +#include #include #include +#include #include -#include #include #include +#include #include namespace llarp::net diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index c12c2f731..5ea66233e 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -1,14 +1,14 @@ #include "nodedb.hpp" +#include "crypto/types.hpp" +#include "dht/kademlia.hpp" +#include "router_contact.hpp" +#include "util/time.hpp" + #include #include #include -#include "router_contact.hpp" -#include "crypto/types.hpp" -#include "util/time.hpp" -#include "dht/kademlia.hpp" - static const char skiplist_subdirs[] = "0123456789abcdef"; static const std::string RC_FILE_EXT = ".signed"; diff --git a/llarp/nodedb.hpp b/llarp/nodedb.hpp index 10eb83613..b81d89693 100644 --- a/llarp/nodedb.hpp +++ b/llarp/nodedb.hpp @@ -1,22 +1,23 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - +#include "crypto/crypto.hpp" +#include "dht/key.hpp" #include "router_contact.hpp" #include "router_id.hpp" #include "util/common.hpp" #include "util/fs.hpp" -#include "dht/key.hpp" -#include "crypto/crypto.hpp" -#include "util/thread/threading.hpp" #include "util/thread/annotations.hpp" +#include "util/thread/threading.hpp" + +#include + +#include +#include +#include +#include +#include +#include +#include namespace llarp { diff --git a/llarp/path/abstracthophandler.cpp b/llarp/path/abstracthophandler.cpp index b4d88bccb..1c53fd304 100644 --- a/llarp/path/abstracthophandler.cpp +++ b/llarp/path/abstracthophandler.cpp @@ -1,4 +1,5 @@ #include "abstracthophandler.hpp" + #include namespace llarp::path diff --git a/llarp/path/abstracthophandler.hpp b/llarp/path/abstracthophandler.hpp index f60011671..0c9963bb9 100644 --- a/llarp/path/abstracthophandler.hpp +++ b/llarp/path/abstracthophandler.hpp @@ -1,12 +1,13 @@ #pragma once -#include -#include #include -#include +#include #include -#include +#include +#include + #include +#include struct llarp_buffer_t; diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index 42aa214ab..4af30f54f 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -1,5 +1,9 @@ #pragma once +#include "abstracthophandler.hpp" +#include "path_types.hpp" +#include "pathset.hpp" + #include #include #include @@ -10,6 +14,7 @@ #include #include #include + #include #include #include @@ -18,10 +23,6 @@ #include #include -#include "abstracthophandler.hpp" -#include "path_types.hpp" -#include "pathset.hpp" - namespace llarp { struct Router; diff --git a/llarp/path/path_context.cpp b/llarp/path/path_context.cpp index ef4ebbe7a..e7fd3364d 100644 --- a/llarp/path/path_context.cpp +++ b/llarp/path/path_context.cpp @@ -1,6 +1,7 @@ -#include "path.hpp" #include "path_context.hpp" +#include "path.hpp" + #include namespace llarp::path diff --git a/llarp/path/path_context.hpp b/llarp/path/path_context.hpp index 88911ab8f..cc2137dde 100644 --- a/llarp/path/path_context.hpp +++ b/llarp/path/path_context.hpp @@ -1,18 +1,20 @@ #pragma once +#include "abstracthophandler.hpp" +#include "path_types.hpp" +#include "pathset.hpp" +#include "transit_hop.hpp" + #include +#include #include #include #include #include + #include #include -#include "abstracthophandler.hpp" -#include "path_types.hpp" -#include "pathset.hpp" -#include "transit_hop.hpp" - namespace llarp { struct Router; diff --git a/llarp/path/path_types.hpp b/llarp/path/path_types.hpp index 1a356e063..374660e55 100644 --- a/llarp/path/path_types.hpp +++ b/llarp/path/path_types.hpp @@ -2,9 +2,9 @@ #include #include -#include #include #include +#include namespace { diff --git a/llarp/path/pathbuilder.cpp b/llarp/path/pathbuilder.cpp index e3d312c3c..7b78ead31 100644 --- a/llarp/path/pathbuilder.cpp +++ b/llarp/path/pathbuilder.cpp @@ -1,17 +1,17 @@ #include "pathbuilder.hpp" +#include "path.hpp" +#include "path_context.hpp" + #include #include #include #include #include -#include #include +#include #include -#include "path.hpp" -#include "path_context.hpp" - namespace llarp { namespace diff --git a/llarp/path/pathbuilder.hpp b/llarp/path/pathbuilder.hpp index 1886e57d2..480f7df6d 100644 --- a/llarp/path/pathbuilder.hpp +++ b/llarp/path/pathbuilder.hpp @@ -1,8 +1,9 @@ #pragma once #include "pathset.hpp" -#include + #include +#include #include #include diff --git a/llarp/path/pathset.cpp b/llarp/path/pathset.cpp index df92ef7c1..f17baae56 100644 --- a/llarp/path/pathset.cpp +++ b/llarp/path/pathset.cpp @@ -1,6 +1,7 @@ -#include "path.hpp" #include "pathset.hpp" +#include "path.hpp" + namespace llarp::path { PathSet::PathSet(size_t num) : numDesiredPaths(num) diff --git a/llarp/path/pathset.hpp b/llarp/path/pathset.hpp index 9c9828127..914c97da1 100644 --- a/llarp/path/pathset.hpp +++ b/llarp/path/pathset.hpp @@ -1,20 +1,21 @@ #pragma once +#include "path_types.hpp" + #include -#include #include #include +#include #include #include #include + #include #include #include #include #include -#include "path_types.hpp" - namespace std { template <> diff --git a/llarp/path/transit_hop.cpp b/llarp/path/transit_hop.cpp index a228516c7..76081d50c 100644 --- a/llarp/path/transit_hop.cpp +++ b/llarp/path/transit_hop.cpp @@ -1,8 +1,8 @@ +#include "transit_hop.hpp" + #include #include -#include "transit_hop.hpp" - namespace llarp::path { std::string diff --git a/llarp/pow.cpp b/llarp/pow.cpp index b0ae27898..2051fbc7a 100644 --- a/llarp/pow.cpp +++ b/llarp/pow.cpp @@ -1,9 +1,9 @@ #include "pow.hpp" -#include - #include "crypto/crypto.hpp" +#include + namespace llarp { PoW::~PoW() = default; diff --git a/llarp/profiling.cpp b/llarp/profiling.cpp index e1fcc9121..3ae00f387 100644 --- a/llarp/profiling.cpp +++ b/llarp/profiling.cpp @@ -1,10 +1,10 @@ #include "profiling.hpp" +#include "util/file.hpp" + #include #include -#include "util/file.hpp" - using oxenc::bt_dict_consumer; using oxenc::bt_dict_producer; diff --git a/llarp/profiling.hpp b/llarp/profiling.hpp index 4e4c7a8c4..b375ff7e5 100644 --- a/llarp/profiling.hpp +++ b/llarp/profiling.hpp @@ -1,12 +1,12 @@ #pragma once -#include - #include "path/path.hpp" #include "router_id.hpp" #include "util/bencode.hpp" -#include "util/thread/threading.hpp" #include "util/thread/annotations.hpp" +#include "util/thread/threading.hpp" + +#include namespace oxenc { diff --git a/llarp/router/rc_gossiper.hpp b/llarp/router/rc_gossiper.hpp index bd580646e..3678f0632 100644 --- a/llarp/router/rc_gossiper.hpp +++ b/llarp/router/rc_gossiper.hpp @@ -1,9 +1,9 @@ #pragma once +#include #include #include -#include "llarp/router_id.hpp" namespace llarp { diff --git a/llarp/router/rc_lookup_handler.cpp b/llarp/router/rc_lookup_handler.cpp index ac705a88a..e10684a79 100644 --- a/llarp/router/rc_lookup_handler.cpp +++ b/llarp/router/rc_lookup_handler.cpp @@ -1,15 +1,17 @@ +#include "rc_lookup_handler.hpp" + +#include "router.hpp" + +#include #include #include -#include -#include +#include #include +#include #include -#include -#include -#include -#include "rc_lookup_handler.hpp" -#include "router.hpp" +#include +#include namespace llarp { diff --git a/llarp/router/rc_lookup_handler.hpp b/llarp/router/rc_lookup_handler.hpp index 5c1ea079f..5d224f2f9 100644 --- a/llarp/router/rc_lookup_handler.hpp +++ b/llarp/router/rc_lookup_handler.hpp @@ -2,11 +2,12 @@ #include #include + #include -#include +#include #include +#include #include -#include struct llarp_dht_context; diff --git a/llarp/router/route_poker.cpp b/llarp/router/route_poker.cpp index 5bb33a133..76c948d1c 100644 --- a/llarp/router/route_poker.cpp +++ b/llarp/router/route_poker.cpp @@ -1,9 +1,9 @@ #include "route_poker.hpp" -#include - #include "router.hpp" +#include + namespace llarp { static auto logcat = log::Cat("route-poker"); diff --git a/llarp/router/route_poker.hpp b/llarp/router/route_poker.hpp index c272a2883..bbc281f03 100644 --- a/llarp/router/route_poker.hpp +++ b/llarp/router/route_poker.hpp @@ -1,11 +1,13 @@ #pragma once #include -#include -#include -#include + +#include + #include #include +#include +#include namespace llarp { diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 7aad6ca2e..1aa99d9a1 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -1,6 +1,5 @@ #include "router.hpp" -#include #include #include #include @@ -10,15 +9,17 @@ #include #include #include +#include #include #include #include -#include + #include #include +#include +#include #include #include -#include #if defined(ANDROID) || defined(IOS) #include #endif @@ -28,6 +29,7 @@ #endif #include + #include static constexpr std::chrono::milliseconds ROUTER_TICK_INTERVAL = 250ms; diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index f622ccde4..6354b37c6 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -1,8 +1,13 @@ #pragma once +#include "rc_gossiper.hpp" +#include "rc_lookup_handler.hpp" +#include "route_poker.hpp" + #include #include #include +#include #include #include #include @@ -12,31 +17,28 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include -#include + #include -#include + #include #include #include #include #include +#include #include #include -#include "rc_gossiper.hpp" -#include "rc_lookup_handler.hpp" -#include "route_poker.hpp" - /* TONUKE: - hidden_service_context diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index e5396af49..c87251adb 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -1,14 +1,14 @@ #include "router_contact.hpp" -#include - #include "constants/version.hpp" #include "crypto/crypto.hpp" #include "net/net.hpp" #include "util/bencode.hpp" #include "util/buffer.hpp" -#include "util/time.hpp" #include "util/file.hpp" +#include "util/time.hpp" + +#include namespace llarp { diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index fc8a00925..7e8e1fdce 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -1,20 +1,22 @@ #pragma once -#include -#include +#include "router_version.hpp" + +#include +#include +#include +#include +#include +#include +#include + #include +#include +#include + #include #include -#include "llarp/constants/version.hpp" -#include "llarp/crypto/types.hpp" -#include "llarp/net/exit_info.hpp" -#include "llarp/util/aligned.hpp" -#include "llarp/util/bencode.hpp" -#include "llarp/util/status.hpp" -#include "router_version.hpp" -#include "llarp/dns/srv_data.hpp" - #define MAX_RC_SIZE (1024) namespace oxenc diff --git a/llarp/router_id.cpp b/llarp/router_id.cpp index 987525137..d8f1e1581 100644 --- a/llarp/router_id.cpp +++ b/llarp/router_id.cpp @@ -1,4 +1,5 @@ #include "router_id.hpp" + #include namespace llarp diff --git a/llarp/router_version.hpp b/llarp/router_version.hpp index d9fa72200..97e2a7bd4 100644 --- a/llarp/router_version.hpp +++ b/llarp/router_version.hpp @@ -1,12 +1,12 @@ #pragma once -#include - -#include "util/bencode.hpp" -#include "constants/version.hpp" #include "constants/proto.hpp" +#include "constants/version.hpp" +#include "util/bencode.hpp" #include "util/formattable.hpp" +#include + namespace { static auto llarp_cat = llarp::log::Cat("lokinet.llarp"); diff --git a/llarp/rpc/endpoint_rpc.hpp b/llarp/rpc/endpoint_rpc.hpp index 3663e3ac4..73cfd1270 100644 --- a/llarp/rpc/endpoint_rpc.hpp +++ b/llarp/rpc/endpoint_rpc.hpp @@ -2,6 +2,7 @@ #include #include + #include namespace llarp::service diff --git a/llarp/rpc/json_binary_proxy.cpp b/llarp/rpc/json_binary_proxy.cpp index cc766dc22..2cbdcbbec 100644 --- a/llarp/rpc/json_binary_proxy.cpp +++ b/llarp/rpc/json_binary_proxy.cpp @@ -1,6 +1,7 @@ #include "json_binary_proxy.hpp" -#include + #include +#include namespace llarp::rpc { diff --git a/llarp/rpc/json_binary_proxy.hpp b/llarp/rpc/json_binary_proxy.hpp index dc4800dfb..08b3c4b8b 100644 --- a/llarp/rpc/json_binary_proxy.hpp +++ b/llarp/rpc/json_binary_proxy.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include + +#include #include using namespace std::literals; diff --git a/llarp/rpc/json_conversions.cpp b/llarp/rpc/json_conversions.cpp index d3e036468..838d285f8 100644 --- a/llarp/rpc/json_conversions.cpp +++ b/llarp/rpc/json_conversions.cpp @@ -1,4 +1,5 @@ #include "json_conversions.hpp" + #include namespace llarp diff --git a/llarp/rpc/json_conversions.hpp b/llarp/rpc/json_conversions.hpp index 50d2426eb..f4e98cccb 100644 --- a/llarp/rpc/json_conversions.hpp +++ b/llarp/rpc/json_conversions.hpp @@ -1,9 +1,10 @@ #pragma once +#include "json_binary_proxy.hpp" + #include -#include -#include "json_binary_proxy.hpp" +#include namespace llarp { diff --git a/llarp/rpc/lokid_rpc_client.cpp b/llarp/rpc/lokid_rpc_client.cpp index 65c2df893..dfbcb253f 100644 --- a/llarp/rpc/lokid_rpc_client.cpp +++ b/llarp/rpc/lokid_rpc_client.cpp @@ -1,9 +1,11 @@ #include "lokid_rpc_client.hpp" -#include #include +#include + #include #include + #include namespace llarp::rpc diff --git a/llarp/rpc/lokid_rpc_client.hpp b/llarp/rpc/lokid_rpc_client.hpp index bc13e18ad..ebd6f9e79 100644 --- a/llarp/rpc/lokid_rpc_client.hpp +++ b/llarp/rpc/lokid_rpc_client.hpp @@ -1,12 +1,13 @@ #pragma once -#include -#include -#include #include #include +#include #include +#include +#include + namespace llarp { struct Router; diff --git a/llarp/rpc/param_parser.hpp b/llarp/rpc/param_parser.hpp index 2347e297a..4aaeb348e 100644 --- a/llarp/rpc/param_parser.hpp +++ b/llarp/rpc/param_parser.hpp @@ -3,12 +3,14 @@ #include "json_binary_proxy.hpp" #include "json_bt.hpp" #include "json_conversions.hpp" -#include + #include +#include + +#include #include #include #include -#include namespace llarp::rpc { diff --git a/llarp/rpc/rpc_request.hpp b/llarp/rpc/rpc_request.hpp index 8801298c8..ef63bb734 100644 --- a/llarp/rpc/rpc_request.hpp +++ b/llarp/rpc/rpc_request.hpp @@ -1,16 +1,19 @@ #pragma once -#include "rpc_server.hpp" -#include "rpc_request_parser.hpp" +#include "json_bt.hpp" #include "rpc_request_decorators.hpp" #include "rpc_request_definitions.hpp" -#include "json_bt.hpp" -#include +#include "rpc_request_parser.hpp" +#include "rpc_server.hpp" + #include #include -#include -#include + #include +#include +#include + +#include namespace llarp::rpc { diff --git a/llarp/rpc/rpc_request_decorators.hpp b/llarp/rpc/rpc_request_decorators.hpp index 5973c06dc..3093de930 100644 --- a/llarp/rpc/rpc_request_decorators.hpp +++ b/llarp/rpc/rpc_request_decorators.hpp @@ -2,12 +2,15 @@ #include "json_binary_proxy.hpp" #include "json_bt.hpp" -#include -#include + #include -#include -#include + +#include #include +#include +#include + +#include namespace tools { diff --git a/llarp/rpc/rpc_request_definitions.hpp b/llarp/rpc/rpc_request_definitions.hpp index 01b4a8872..0c6b43442 100644 --- a/llarp/rpc/rpc_request_definitions.hpp +++ b/llarp/rpc/rpc_request_definitions.hpp @@ -2,17 +2,18 @@ #include "rpc_request_decorators.hpp" +#include #include #include #include #include #include -#include -#include -#include -#include #include +#include +#include + +#include #include #include diff --git a/llarp/rpc/rpc_request_parser.cpp b/llarp/rpc/rpc_request_parser.cpp index 3cb40bffd..92bafbf4f 100644 --- a/llarp/rpc/rpc_request_parser.cpp +++ b/llarp/rpc/rpc_request_parser.cpp @@ -1,8 +1,9 @@ #include "rpc_request_parser.hpp" -#include "llarp/rpc/rpc_request_definitions.hpp" #include "param_parser.hpp" +#include + namespace llarp::rpc { using nlohmann::json; @@ -103,4 +104,4 @@ namespace llarp::rpc config.request.ini); } -} // namespace llarp::rpc \ No newline at end of file +} // namespace llarp::rpc diff --git a/llarp/rpc/rpc_request_parser.hpp b/llarp/rpc/rpc_request_parser.hpp index 788bad17d..71ca0d009 100644 --- a/llarp/rpc/rpc_request_parser.hpp +++ b/llarp/rpc/rpc_request_parser.hpp @@ -1,12 +1,14 @@ #pragma once +#include "rpc_request_definitions.hpp" + #include -#include -#include + #include -#include +#include +#include -#include "rpc_request_definitions.hpp" +#include namespace llarp::rpc { diff --git a/llarp/rpc/rpc_server.cpp b/llarp/rpc/rpc_server.cpp index 4b646914d..9e7581e50 100644 --- a/llarp/rpc/rpc_server.cpp +++ b/llarp/rpc/rpc_server.cpp @@ -1,4 +1,5 @@ #include "rpc_server.hpp" + #include "rpc_request.hpp" #include @@ -7,8 +8,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/llarp/rpc/rpc_server.hpp b/llarp/rpc/rpc_server.hpp index 9be896255..895b3120e 100644 --- a/llarp/rpc/rpc_server.hpp +++ b/llarp/rpc/rpc_server.hpp @@ -1,18 +1,19 @@ #pragma once +#include "json_bt.hpp" +#include "rpc_request_definitions.hpp" + #include #include -#include -#include -#include #include +#include +#include +#include + #include #include -#include "rpc_request_definitions.hpp" -#include "json_bt.hpp" - namespace llarp { struct Router; diff --git a/llarp/service/address.cpp b/llarp/service/address.cpp index 704b193c9..2f18907de 100644 --- a/llarp/service/address.cpp +++ b/llarp/service/address.cpp @@ -1,6 +1,9 @@ #include "address.hpp" + #include + #include + #include namespace llarp::service diff --git a/llarp/service/address.hpp b/llarp/service/address.hpp index e65b4c683..bef3365c4 100644 --- a/llarp/service/address.hpp +++ b/llarp/service/address.hpp @@ -6,10 +6,10 @@ #include #include +#include #include #include #include -#include namespace llarp { diff --git a/llarp/service/async_key_exchange.cpp b/llarp/service/async_key_exchange.cpp index fbb42423c..d5d8bd140 100644 --- a/llarp/service/async_key_exchange.cpp +++ b/llarp/service/async_key_exchange.cpp @@ -1,9 +1,11 @@ #include "async_key_exchange.hpp" + #include "endpoint.hpp" #include #include #include + #include namespace llarp::service diff --git a/llarp/service/async_key_exchange.hpp b/llarp/service/async_key_exchange.hpp index 3ab0b8f4e..254818e34 100644 --- a/llarp/service/async_key_exchange.hpp +++ b/llarp/service/async_key_exchange.hpp @@ -1,10 +1,10 @@ #pragma once -#include - #include "identity.hpp" #include "protocol.hpp" +#include + namespace llarp::service { struct AsyncKeyExchange : public std::enable_shared_from_this diff --git a/llarp/service/auth.cpp b/llarp/service/auth.cpp index 71e2f1509..b5a6c97e8 100644 --- a/llarp/service/auth.cpp +++ b/llarp/service/auth.cpp @@ -1,9 +1,10 @@ #include "auth.hpp" + #include "protocol.hpp" #include -#include #include +#include #include diff --git a/llarp/service/auth.hpp b/llarp/service/auth.hpp index 7f18e3104..85b7d0951 100644 --- a/llarp/service/auth.hpp +++ b/llarp/service/auth.hpp @@ -1,10 +1,11 @@ #pragma once +#include "address.hpp" + #include + +#include #include #include -#include - -#include "address.hpp" namespace llarp { diff --git a/llarp/service/context.cpp b/llarp/service/context.cpp index abea6ca49..16b58afbf 100644 --- a/llarp/service/context.cpp +++ b/llarp/service/context.cpp @@ -1,10 +1,11 @@ #include "context.hpp" +#include "endpoint.hpp" + #include #include -#include -#include "endpoint.hpp" +#include namespace llarp::service { diff --git a/llarp/service/context.hpp b/llarp/service/context.hpp index d975697d3..cf459273c 100644 --- a/llarp/service/context.hpp +++ b/llarp/service/context.hpp @@ -1,11 +1,12 @@ #pragma once +#include "endpoint.hpp" + +#include #include #include -#include -#include -#include "endpoint.hpp" +#include /* TODO: diff --git a/llarp/service/convotag.hpp b/llarp/service/convotag.hpp index 431d4546e..e74ffca64 100644 --- a/llarp/service/convotag.hpp +++ b/llarp/service/convotag.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include namespace llarp::service { diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index ae124233d..3b1a4dc44 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -1,30 +1,31 @@ #include "endpoint.hpp" +#include "auth.hpp" +#include "endpoint_state.hpp" +#include "endpoint_util.hpp" +#include "info.hpp" +#include "outbound_context.hpp" +#include "protocol.hpp" +#include "protocol_type.hpp" + #include #include #include #include #include #include -#include #include -#include +#include #include +#include #include #include + #include #include #include #include -#include "endpoint_state.hpp" -#include "endpoint_util.hpp" -#include "auth.hpp" -#include "outbound_context.hpp" -#include "protocol.hpp" -#include "info.hpp" -#include "protocol_type.hpp" - namespace llarp::service { static auto logcat = log::Cat("endpoint"); diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index b974fa4eb..63bedc6d7 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -1,26 +1,24 @@ #pragma once +#include #include #include #include #include #include #include -#include -// --- begin kitchen sink headers ---- #include +#include +#include #include #include #include #include #include -#include -#include -#include -// ----- end kitchen sink headers ----- +#include +#include #include -#include -#include + #include #include #include diff --git a/llarp/service/endpoint_state.hpp b/llarp/service/endpoint_state.hpp index ba42a22bf..cc57e4b8f 100644 --- a/llarp/service/endpoint_state.hpp +++ b/llarp/service/endpoint_state.hpp @@ -1,22 +1,24 @@ #pragma once +#include "address.hpp" +#include "endpoint_types.hpp" +#include "lns_tracker.hpp" +#include "pendingbuffer.hpp" +#include "router_lookup_job.hpp" +#include "session.hpp" + #include #include #include #include + #include + #include #include #include #include -#include "address.hpp" -#include "pendingbuffer.hpp" -#include "router_lookup_job.hpp" -#include "session.hpp" -#include "endpoint_types.hpp" -#include "lns_tracker.hpp" - namespace llarp::service { struct EndpointState diff --git a/llarp/service/endpoint_types.hpp b/llarp/service/endpoint_types.hpp index 299934474..3b191a2b3 100644 --- a/llarp/service/endpoint_types.hpp +++ b/llarp/service/endpoint_types.hpp @@ -3,6 +3,7 @@ #include "pendingbuffer.hpp" #include "router_lookup_job.hpp" #include "session.hpp" + #include #include diff --git a/llarp/service/identity.hpp b/llarp/service/identity.hpp index 9c53cba6f..70b1919f3 100644 --- a/llarp/service/identity.hpp +++ b/llarp/service/identity.hpp @@ -1,16 +1,17 @@ #pragma once +#include "info.hpp" +#include "intro_set.hpp" +#include "vanity.hpp" + #include #include #include #include + #include #include -#include "info.hpp" -#include "intro_set.hpp" -#include "vanity.hpp" - namespace llarp::service { // private keys diff --git a/llarp/service/info.cpp b/llarp/service/info.cpp index f45f5b93d..3c9a9f024 100644 --- a/llarp/service/info.cpp +++ b/llarp/service/info.cpp @@ -1,9 +1,9 @@ #include "info.hpp" -#include - #include "address.hpp" +#include + namespace llarp::service { bool diff --git a/llarp/service/info.hpp b/llarp/service/info.hpp index 5e97e34ad..893e1fe64 100644 --- a/llarp/service/info.hpp +++ b/llarp/service/info.hpp @@ -1,12 +1,14 @@ #pragma once -#include +#include "address.hpp" +#include "vanity.hpp" + #include #include -#include -#include "address.hpp" -#include "vanity.hpp" +#include + +#include namespace { diff --git a/llarp/service/intro.cpp b/llarp/service/intro.cpp index c239da5ab..5e25e6b62 100644 --- a/llarp/service/intro.cpp +++ b/llarp/service/intro.cpp @@ -1,4 +1,5 @@ #include "intro.hpp" + #include namespace llarp::service diff --git a/llarp/service/intro.hpp b/llarp/service/intro.hpp index 0ec46b35d..3c4326e36 100644 --- a/llarp/service/intro.hpp +++ b/llarp/service/intro.hpp @@ -1,10 +1,12 @@ #pragma once -#include #include #include #include #include + +#include + #include namespace diff --git a/llarp/service/intro_set.cpp b/llarp/service/intro_set.cpp index bc2db09da..93cd5af30 100644 --- a/llarp/service/intro_set.cpp +++ b/llarp/service/intro_set.cpp @@ -1,6 +1,7 @@ #include "intro_set.hpp" #include + #include namespace llarp::service diff --git a/llarp/service/intro_set.hpp b/llarp/service/intro_set.hpp index 352d98f2c..de11118f8 100644 --- a/llarp/service/intro_set.hpp +++ b/llarp/service/intro_set.hpp @@ -1,24 +1,25 @@ #pragma once +#include "info.hpp" +#include "intro.hpp" +#include "protocol_type.hpp" +#include "tag.hpp" + #include -#include -#include -#include -#include #include #include #include -#include +#include +#include +#include +#include + #include #include #include +#include #include -#include "info.hpp" -#include "intro.hpp" -#include "tag.hpp" -#include "protocol_type.hpp" - namespace llarp::service { constexpr std::size_t MAX_INTROSET_SIZE = 4096; diff --git a/llarp/service/lns_tracker.hpp b/llarp/service/lns_tracker.hpp index 64fb1a3cd..c1dab8a21 100644 --- a/llarp/service/lns_tracker.hpp +++ b/llarp/service/lns_tracker.hpp @@ -1,14 +1,16 @@ #pragma once +#include "address.hpp" + #include + #include + #include #include +#include #include #include -#include - -#include "address.hpp" namespace llarp::service { diff --git a/llarp/service/name.cpp b/llarp/service/name.cpp index 37c0afb1e..45c76c512 100644 --- a/llarp/service/name.cpp +++ b/llarp/service/name.cpp @@ -1,4 +1,5 @@ #include "name.hpp" + #include #include diff --git a/llarp/service/name.hpp b/llarp/service/name.hpp index 76e203b3c..a34969f72 100644 --- a/llarp/service/name.hpp +++ b/llarp/service/name.hpp @@ -1,8 +1,8 @@ #pragma once -#include - #include "address.hpp" +#include + namespace llarp::service { struct EncryptedName diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index 5588de118..9c0537915 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -1,14 +1,15 @@ #include "outbound_context.hpp" -#include -#include -#include - #include "async_key_exchange.hpp" #include "endpoint.hpp" #include "endpoint_util.hpp" #include "protocol_type.hpp" +#include + +#include +#include + namespace llarp::service { bool diff --git a/llarp/service/outbound_context.hpp b/llarp/service/outbound_context.hpp index 802d6a910..2b66715ee 100644 --- a/llarp/service/outbound_context.hpp +++ b/llarp/service/outbound_context.hpp @@ -4,6 +4,7 @@ #include #include #include + #include #include diff --git a/llarp/service/pendingbuffer.hpp b/llarp/service/pendingbuffer.hpp index 827b2fab1..f32e66cd3 100644 --- a/llarp/service/pendingbuffer.hpp +++ b/llarp/service/pendingbuffer.hpp @@ -1,7 +1,9 @@ #pragma once #include "protocol.hpp" + #include + #include namespace llarp::service diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index 1ec6783a6..755554a24 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -1,11 +1,12 @@ #include "protocol.hpp" +#include "endpoint.hpp" + #include -#include #include -#include +#include -#include "endpoint.hpp" +#include namespace llarp::service { diff --git a/llarp/service/protocol.hpp b/llarp/service/protocol.hpp index bc85f0c28..d3d656e2a 100644 --- a/llarp/service/protocol.hpp +++ b/llarp/service/protocol.hpp @@ -1,17 +1,19 @@ #pragma once +#include "identity.hpp" +#include "info.hpp" +#include "intro.hpp" +#include "protocol_type.hpp" + #include #include +#include +#include #include #include #include -#include -#include -#include "protocol_type.hpp" -#include "identity.hpp" -#include "info.hpp" -#include "intro.hpp" +#include struct llarp_threadpool; diff --git a/llarp/service/protocol_type.hpp b/llarp/service/protocol_type.hpp index 3864717be..fc85b9e2c 100644 --- a/llarp/service/protocol_type.hpp +++ b/llarp/service/protocol_type.hpp @@ -1,9 +1,9 @@ #pragma once -#include +#include +#include #include -#include namespace llarp::service { diff --git a/llarp/service/router_lookup_job.cpp b/llarp/service/router_lookup_job.cpp index 517baac70..3c988a73b 100644 --- a/llarp/service/router_lookup_job.cpp +++ b/llarp/service/router_lookup_job.cpp @@ -1,6 +1,7 @@ #include "router_lookup_job.hpp" #include "endpoint.hpp" + #include namespace llarp diff --git a/llarp/service/session.hpp b/llarp/service/session.hpp index a811e2c4f..b9d4b051e 100644 --- a/llarp/service/session.hpp +++ b/llarp/service/session.hpp @@ -1,13 +1,13 @@ #pragma once +#include "info.hpp" +#include "intro.hpp" + #include #include #include #include -#include "info.hpp" -#include "intro.hpp" - namespace llarp::service { static constexpr auto SessionLifetime = path::DEFAULT_LIFETIME * 2; diff --git a/llarp/service/tag.hpp b/llarp/service/tag.hpp index 64a949340..a4e3dba4e 100644 --- a/llarp/service/tag.hpp +++ b/llarp/service/tag.hpp @@ -3,6 +3,7 @@ #include #include #include + #include namespace llarp diff --git a/llarp/simulation/sim_context.cpp b/llarp/simulation/sim_context.cpp index 329e8f849..c36afdefa 100644 --- a/llarp/simulation/sim_context.cpp +++ b/llarp/simulation/sim_context.cpp @@ -1,4 +1,5 @@ #include "sim_context.hpp" + #include namespace llarp diff --git a/llarp/util/aligned.hpp b/llarp/util/aligned.hpp index b28199d19..f62485978 100644 --- a/llarp/util/aligned.hpp +++ b/llarp/util/aligned.hpp @@ -1,11 +1,13 @@ #pragma once #include "bencode.h" -#include + #include +#include #include +#include #include #include #include @@ -13,7 +15,6 @@ #include #include #include -#include extern "C" { diff --git a/llarp/util/bencode.cpp b/llarp/util/bencode.cpp index 2b94c52fb..6426e15de 100644 --- a/llarp/util/bencode.cpp +++ b/llarp/util/bencode.cpp @@ -1,7 +1,7 @@ #include "bencode.hpp" -#include #include +#include bool bencode_read_integer(struct llarp_buffer_t* buffer, uint64_t* result) diff --git a/llarp/util/bencode.h b/llarp/util/bencode.h index 7770fc8eb..b017da110 100644 --- a/llarp/util/bencode.h +++ b/llarp/util/bencode.h @@ -1,12 +1,13 @@ #pragma once -#include -#include -#include - #include "buffer.hpp" #include "common.hpp" +#include + +#include +#include + /** * bencode.h * diff --git a/llarp/util/bencode.hpp b/llarp/util/bencode.hpp index f54f19889..aae0fe3b1 100644 --- a/llarp/util/bencode.hpp +++ b/llarp/util/bencode.hpp @@ -1,16 +1,18 @@ #pragma once +#include "bencode.h" +#include "buffer.hpp" +#include "file.hpp" +#include "mem.hpp" + #include + #include -#include + #include +#include #include -#include "buffer.hpp" -#include "bencode.h" -#include "file.hpp" -#include "mem.hpp" - namespace llarp { static auto ben_cat = log::Cat("stupid.bencode"); diff --git a/llarp/util/bits.hpp b/llarp/util/bits.hpp index 5aae7e47c..2a1240ecb 100644 --- a/llarp/util/bits.hpp +++ b/llarp/util/bits.hpp @@ -1,12 +1,13 @@ #pragma once +#include +#include + #include #include +#include #include #include -#include -#include -#include namespace llarp { diff --git a/llarp/util/buffer.cpp b/llarp/util/buffer.cpp index 7dc3d747c..1d2de0042 100644 --- a/llarp/util/buffer.cpp +++ b/llarp/util/buffer.cpp @@ -1,4 +1,5 @@ #include "buffer.hpp" + #include #include diff --git a/llarp/util/buffer.hpp b/llarp/util/buffer.hpp index d9f87d8e7..2cfa8f3a6 100644 --- a/llarp/util/buffer.hpp +++ b/llarp/util/buffer.hpp @@ -1,20 +1,20 @@ #pragma once -#include +#include "common.hpp" +#include "mem.h" +#include "types.hpp" + +#include #include -#include #include #include #include -#include -#include +#include #include -#include #include - -#include "common.hpp" -#include "mem.h" -#include "types.hpp" +#include +#include +#include namespace llarp { diff --git a/llarp/util/decaying_hashset.hpp b/llarp/util/decaying_hashset.hpp index e7c0a0a72..36bf4f1a9 100644 --- a/llarp/util/decaying_hashset.hpp +++ b/llarp/util/decaying_hashset.hpp @@ -1,6 +1,7 @@ #pragma once #include "time.hpp" + #include namespace llarp diff --git a/llarp/util/decaying_hashtable.hpp b/llarp/util/decaying_hashtable.hpp index 1a6b23953..ea00092eb 100644 --- a/llarp/util/decaying_hashtable.hpp +++ b/llarp/util/decaying_hashtable.hpp @@ -1,6 +1,7 @@ #pragma once #include "time.hpp" + #include namespace llarp::util diff --git a/llarp/util/file.cpp b/llarp/util/file.cpp index a207b2288..ff929d016 100644 --- a/llarp/util/file.cpp +++ b/llarp/util/file.cpp @@ -1,8 +1,10 @@ #include "file.hpp" + #include "formattable.hpp" #include "logging.hpp" #include + #include #include #include diff --git a/llarp/util/file.hpp b/llarp/util/file.hpp index d6cd9dfa4..a66b1555f 100644 --- a/llarp/util/file.hpp +++ b/llarp/util/file.hpp @@ -1,11 +1,11 @@ #pragma once +#include "fs.hpp" + #include #include #include #include -#include "fs.hpp" - #ifndef _MSC_VER #include #endif diff --git a/llarp/util/formattable.hpp b/llarp/util/formattable.hpp index a2b1e8a37..85fe3fb36 100644 --- a/llarp/util/formattable.hpp +++ b/llarp/util/formattable.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include // Formattable types can specialize this to true and will get automatic fmt formattering support via diff --git a/llarp/util/logging.hpp b/llarp/util/logging.hpp index 40f1dbaf1..683233c68 100644 --- a/llarp/util/logging.hpp +++ b/llarp/util/logging.hpp @@ -2,13 +2,12 @@ // Header for making actual log statements such as llarp::log::Info and so on work. -#include -#include -#include - #include #include -#include "oxen/log/internal.hpp" + +#include +#include +#include namespace llarp { diff --git a/llarp/util/logging/buffer.hpp b/llarp/util/logging/buffer.hpp index a6c46cf36..ad8f98c8c 100644 --- a/llarp/util/logging/buffer.hpp +++ b/llarp/util/logging/buffer.hpp @@ -2,10 +2,11 @@ #include #include -#include -#include + #include #include +#include +#include namespace llarp { diff --git a/llarp/util/logging/callback_sink.hpp b/llarp/util/logging/callback_sink.hpp index 9b5538562..599a97e9e 100644 --- a/llarp/util/logging/callback_sink.hpp +++ b/llarp/util/logging/callback_sink.hpp @@ -1,6 +1,7 @@ #include -#include #include +#include + #include namespace llarp::logging diff --git a/llarp/util/mem.cpp b/llarp/util/mem.cpp index 1fe7a389c..66ab9e357 100644 --- a/llarp/util/mem.cpp +++ b/llarp/util/mem.cpp @@ -1,5 +1,6 @@ #define NO_JEMALLOC #include "mem.h" + #include namespace llarp diff --git a/llarp/util/meta/memfn.hpp b/llarp/util/meta/memfn.hpp index 4ec196b8c..b7a408560 100644 --- a/llarp/util/meta/memfn.hpp +++ b/llarp/util/meta/memfn.hpp @@ -1,9 +1,9 @@ #ifndef LLARP_UTIL_MEMFN #define LLARP_UTIL_MEMFN +#include #include #include -#include namespace llarp::util { diff --git a/llarp/util/str.cpp b/llarp/util/str.cpp index 0270f63dc..3fed7ea44 100644 --- a/llarp/util/str.cpp +++ b/llarp/util/str.cpp @@ -4,9 +4,10 @@ #include #ifdef _WIN32 -#include -#include #include + +#include +#include #endif namespace llarp diff --git a/llarp/util/str.hpp b/llarp/util/str.hpp index 0c120cbc2..0ea783898 100644 --- a/llarp/util/str.hpp +++ b/llarp/util/str.hpp @@ -1,11 +1,12 @@ #pragma once #include -#include -#include + +#include #include #include -#include +#include +#include namespace llarp { diff --git a/llarp/util/thread/barrier.hpp b/llarp/util/thread/barrier.hpp index 369b2b3fa..dabd5e5fc 100644 --- a/llarp/util/thread/barrier.hpp +++ b/llarp/util/thread/barrier.hpp @@ -1,6 +1,6 @@ #pragma once -#include #include +#include namespace llarp { diff --git a/llarp/util/thread/queue.hpp b/llarp/util/thread/queue.hpp index 96e6c158e..954abd325 100644 --- a/llarp/util/thread/queue.hpp +++ b/llarp/util/thread/queue.hpp @@ -3,8 +3,8 @@ #include "queue_manager.hpp" #include "threading.hpp" -#include #include +#include #include namespace llarp diff --git a/llarp/util/thread/queue_manager.hpp b/llarp/util/thread/queue_manager.hpp index 6389d9e78..b572803eb 100644 --- a/llarp/util/thread/queue_manager.hpp +++ b/llarp/util/thread/queue_manager.hpp @@ -1,8 +1,8 @@ #pragma once -#include #include #include #include +#include #include #include #include diff --git a/llarp/util/thread/threading.cpp b/llarp/util/thread/threading.cpp index c61639366..b62e41c34 100644 --- a/llarp/util/thread/threading.cpp +++ b/llarp/util/thread/threading.cpp @@ -1,6 +1,7 @@ #include "threading.hpp" #include + #include #ifdef POSIX diff --git a/llarp/util/thread/threading.hpp b/llarp/util/thread/threading.hpp index d50a63042..7fb31e4c3 100644 --- a/llarp/util/thread/threading.hpp +++ b/llarp/util/thread/threading.hpp @@ -1,15 +1,14 @@ #pragma once -#include -#include -#include +#include "annotations.hpp" + #include -#include #include +#include +#include +#include #include -#include "annotations.hpp" - #if defined(WIN32) && !defined(__GNUC__) #include diff --git a/llarp/util/time.hpp b/llarp/util/time.hpp index 773083ba2..2a312090d 100644 --- a/llarp/util/time.hpp +++ b/llarp/util/time.hpp @@ -1,11 +1,12 @@ #pragma once -#include -#include +#include "types.hpp" + #include -#include +#include +#include -#include "types.hpp" +#include using namespace std::chrono_literals; diff --git a/llarp/util/types.hpp b/llarp/util/types.hpp index 1944bd905..f0f4cf243 100644 --- a/llarp/util/types.hpp +++ b/llarp/util/types.hpp @@ -1,9 +1,9 @@ #pragma once +#include + +#include #include #include -#include - -#include "oxen/log/format.hpp" using byte_t = uint8_t; using llarp_proto_version_t = std::uint8_t; diff --git a/llarp/vpn/android.hpp b/llarp/vpn/android.hpp index 1ab0abfb2..402c91ada 100644 --- a/llarp/vpn/android.hpp +++ b/llarp/vpn/android.hpp @@ -1,12 +1,13 @@ #pragma once -#include -#include - -#include "platform.hpp" #include "common.hpp" +#include "platform.hpp" + #include +#include +#include + namespace llarp::vpn { class AndroidInterface : public NetworkInterface diff --git a/llarp/vpn/common.hpp b/llarp/vpn/common.hpp index 8db945636..715ae296a 100644 --- a/llarp/vpn/common.hpp +++ b/llarp/vpn/common.hpp @@ -1,9 +1,14 @@ #pragma once -#include +#include #include #include +#include +#include + #include +#include +#include namespace llarp::vpn { diff --git a/llarp/vpn/egres_packet_router.hpp b/llarp/vpn/egres_packet_router.hpp index 8b074267d..bc4a1fec6 100644 --- a/llarp/vpn/egres_packet_router.hpp +++ b/llarp/vpn/egres_packet_router.hpp @@ -1,7 +1,8 @@ #pragma once -#include -#include #include +#include +#include + #include #include diff --git a/llarp/vpn/i_packet_io.hpp b/llarp/vpn/i_packet_io.hpp index 5789b193c..2c29fd64c 100644 --- a/llarp/vpn/i_packet_io.hpp +++ b/llarp/vpn/i_packet_io.hpp @@ -1,8 +1,9 @@ #pragma once -#include #include #include +#include + namespace llarp::vpn { class I_Packet_IO diff --git a/llarp/vpn/linux.hpp b/llarp/vpn/linux.hpp index 6283f3be8..6f734a956 100644 --- a/llarp/vpn/linux.hpp +++ b/llarp/vpn/linux.hpp @@ -1,27 +1,26 @@ #pragma once -#include "platform.hpp" -#include -#include -#include -#include #include "common.hpp" -#include -#include +#include "platform.hpp" -#include -#include -#include +#include #include +#include +#include #include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include -#include -#include - -#include +#include +#include namespace llarp::vpn { diff --git a/llarp/vpn/packet_intercept.hpp b/llarp/vpn/packet_intercept.hpp index eac310a24..3fb8e4b17 100644 --- a/llarp/vpn/packet_intercept.hpp +++ b/llarp/vpn/packet_intercept.hpp @@ -1,7 +1,8 @@ #pragma once +#include + #include #include -#include namespace llarp::vpn { diff --git a/llarp/vpn/packet_router.hpp b/llarp/vpn/packet_router.hpp index 635df7925..41def5b33 100644 --- a/llarp/vpn/packet_router.hpp +++ b/llarp/vpn/packet_router.hpp @@ -1,6 +1,7 @@ #pragma once -#include #include +#include + #include #include diff --git a/llarp/vpn/platform.hpp b/llarp/vpn/platform.hpp index 62534d33c..9294ed122 100644 --- a/llarp/vpn/platform.hpp +++ b/llarp/vpn/platform.hpp @@ -1,12 +1,14 @@ #pragma once -#include +#include "i_packet_io.hpp" + #include +#include + #include -#include -#include +#include -#include "i_packet_io.hpp" +#include namespace llarp { diff --git a/llarp/vpn/win32.cpp b/llarp/vpn/win32.cpp index 900231490..1e8dee467 100644 --- a/llarp/vpn/win32.cpp +++ b/llarp/vpn/win32.cpp @@ -1,6 +1,8 @@ #include "win32.hpp" + #include #include + #include namespace llarp::win32 diff --git a/llarp/vpn/win32.hpp b/llarp/vpn/win32.hpp index a14852e79..ac0f5e01a 100644 --- a/llarp/vpn/win32.hpp +++ b/llarp/vpn/win32.hpp @@ -1,13 +1,15 @@ #pragma once -#include +#include "platform.hpp" + #include +#include #include + #include -#include -#include -#include "platform.hpp" +#include +#include namespace llarp::win32 { diff --git a/llarp/win32/dll.cpp b/llarp/win32/dll.cpp index 66071e9cb..398dbe3d8 100644 --- a/llarp/win32/dll.cpp +++ b/llarp/win32/dll.cpp @@ -1,4 +1,5 @@ #include "dll.hpp" + #include #include diff --git a/llarp/win32/dll.hpp b/llarp/win32/dll.hpp index d99a65346..d385de18d 100644 --- a/llarp/win32/dll.hpp +++ b/llarp/win32/dll.hpp @@ -1,8 +1,10 @@ #pragma once -#include #include "exception.hpp" + #include +#include + namespace llarp::win32 { namespace detail diff --git a/llarp/win32/exception.cpp b/llarp/win32/exception.cpp index 4b74e0584..240172db9 100644 --- a/llarp/win32/exception.cpp +++ b/llarp/win32/exception.cpp @@ -1,6 +1,9 @@ -#include "windows.h" #include "exception.hpp" + +#include "windows.h" + #include + #include namespace llarp::win32 diff --git a/llarp/win32/exception.hpp b/llarp/win32/exception.hpp index 21c8b0415..871de8a06 100644 --- a/llarp/win32/exception.hpp +++ b/llarp/win32/exception.hpp @@ -1,7 +1,8 @@ #pragma once #include -#include + #include +#include namespace llarp::win32 { diff --git a/llarp/win32/exec.cpp b/llarp/win32/exec.cpp index 4f17b8f04..d0f4d5fe1 100644 --- a/llarp/win32/exec.cpp +++ b/llarp/win32/exec.cpp @@ -1,5 +1,7 @@ #include "exec.hpp" + #include "exception.hpp" + #include #include diff --git a/llarp/win32/exec.hpp b/llarp/win32/exec.hpp index f77e009df..337d0fc0d 100644 --- a/llarp/win32/exec.hpp +++ b/llarp/win32/exec.hpp @@ -1,8 +1,10 @@ #pragma once +#include + #include + #include -#include namespace llarp::win32 { diff --git a/llarp/win32/guid.hpp b/llarp/win32/guid.hpp index 40e0cae09..06de11b1e 100644 --- a/llarp/win32/guid.hpp +++ b/llarp/win32/guid.hpp @@ -1,7 +1,9 @@ #pragma once #include + #include + #include namespace llarp::win32 diff --git a/llarp/win32/service_manager.cpp b/llarp/win32/service_manager.cpp index 986b0c024..df682e518 100644 --- a/llarp/win32/service_manager.cpp +++ b/llarp/win32/service_manager.cpp @@ -1,10 +1,13 @@ -#include -#include +#include "service_manager.hpp" + #include #include -#include "service_manager.hpp" + #include +#include + #include +#include #include #include diff --git a/llarp/win32/service_manager.hpp b/llarp/win32/service_manager.hpp index 6896e69e0..37a8f54c6 100644 --- a/llarp/win32/service_manager.hpp +++ b/llarp/win32/service_manager.hpp @@ -1,8 +1,9 @@ #pragma once -#include #include #include +#include + namespace llarp::sys { diff --git a/llarp/win32/win32_inet.c b/llarp/win32/win32_inet.c index 394923bb3..835794751 100644 --- a/llarp/win32/win32_inet.c +++ b/llarp/win32/win32_inet.c @@ -9,11 +9,12 @@ */ // these need to be in a specific order +#include + #include +#include #include -#include #include -#include const char* inet_ntop(int af, const void* src, char* dst, size_t size) diff --git a/llarp/win32/windivert.cpp b/llarp/win32/windivert.cpp index 48f5c27b5..ea8381f8e 100644 --- a/llarp/win32/windivert.cpp +++ b/llarp/win32/windivert.cpp @@ -1,11 +1,16 @@ -#include -#include #include "windivert.hpp" + #include "dll.hpp" #include "handle.hpp" -#include + #include #include +#include + +#include + +#include + #include extern "C" { diff --git a/llarp/win32/windivert.hpp b/llarp/win32/windivert.hpp index af71acfee..7f92c1acd 100644 --- a/llarp/win32/windivert.hpp +++ b/llarp/win32/windivert.hpp @@ -1,8 +1,10 @@ #pragma once +#include + +#include + #include #include -#include -#include namespace llarp::win32::WinDivert { diff --git a/llarp/win32/wintun.cpp b/llarp/win32/wintun.cpp index 10569a69e..f2e8643a9 100644 --- a/llarp/win32/wintun.cpp +++ b/llarp/win32/wintun.cpp @@ -3,19 +3,22 @@ extern "C" #include } -#include -#include "wintun.hpp" -#include "exception.hpp" #include "dll.hpp" +#include "exception.hpp" #include "guid.hpp" -#include -#include +#include "wintun.hpp" + #include +#include #include #include -#include #include +#include + +#include +#include + namespace llarp::win32 { namespace diff --git a/pybind/common.hpp b/pybind/common.hpp index 655dccf06..367345f4a 100644 --- a/pybind/common.hpp +++ b/pybind/common.hpp @@ -1,12 +1,12 @@ #pragma once +#include + +#include #include #include -#include #include -#include - namespace py = pybind11; namespace llarp diff --git a/pybind/llarp/config.cpp b/pybind/llarp/config.cpp index 8ca1a8da4..1109f96bf 100644 --- a/pybind/llarp/config.cpp +++ b/pybind/llarp/config.cpp @@ -1,6 +1,6 @@ -#include #include +#include #include namespace llarp diff --git a/pybind/llarp/context.cpp b/pybind/llarp/context.cpp index 9a1cf194b..86f6aea54 100644 --- a/pybind/llarp/context.cpp +++ b/pybind/llarp/context.cpp @@ -1,9 +1,10 @@ -#include #include -#include -#include #include +#include #include +#include + +#include namespace llarp { diff --git a/pybind/llarp/crypto/types.cpp b/pybind/llarp/crypto/types.cpp index c866791b7..e2ac0e743 100644 --- a/pybind/llarp/crypto/types.cpp +++ b/pybind/llarp/crypto/types.cpp @@ -1,4 +1,5 @@ #include + #include namespace llarp diff --git a/pybind/llarp/handlers/pyhandler.hpp b/pybind/llarp/handlers/pyhandler.hpp index db90076af..20bc5587f 100644 --- a/pybind/llarp/handlers/pyhandler.hpp +++ b/pybind/llarp/handlers/pyhandler.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include +#include #include #include -#include + +#include namespace llarp { diff --git a/pybind/llarp/logger.cpp b/pybind/llarp/logger.cpp index 891847acf..947ad1af7 100644 --- a/pybind/llarp/logger.cpp +++ b/pybind/llarp/logger.cpp @@ -1,6 +1,8 @@ +#include + #include + #include -#include namespace llarp { diff --git a/pybind/llarp/path/path_hop_config.cpp b/pybind/llarp/path/path_hop_config.cpp index 7a539e4c9..b5e562db9 100644 --- a/pybind/llarp/path/path_hop_config.cpp +++ b/pybind/llarp/path/path_hop_config.cpp @@ -1,4 +1,5 @@ #include + #include namespace llarp diff --git a/pybind/llarp/peerstats.cpp b/pybind/llarp/peerstats.cpp index 9ce84d13a..6ced63beb 100644 --- a/pybind/llarp/peerstats.cpp +++ b/pybind/llarp/peerstats.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include #include namespace llarp diff --git a/pybind/llarp/router.cpp b/pybind/llarp/router.cpp index c32d51e9f..edc9be78f 100644 --- a/pybind/llarp/router.cpp +++ b/pybind/llarp/router.cpp @@ -1,8 +1,8 @@ -#include - #include #include +#include + namespace llarp { void diff --git a/pybind/llarp/router_contact.cpp b/pybind/llarp/router_contact.cpp index 0597a172d..ab1048c3d 100644 --- a/pybind/llarp/router_contact.cpp +++ b/pybind/llarp/router_contact.cpp @@ -1,8 +1,8 @@ -#include +#include "common.hpp" #include +#include #include -#include "common.hpp" namespace llarp { diff --git a/pybind/llarp/router_id.cpp b/pybind/llarp/router_id.cpp index 1cb2c56b7..d23d47937 100644 --- a/pybind/llarp/router_id.cpp +++ b/pybind/llarp/router_id.cpp @@ -1,7 +1,7 @@ -#include - #include +#include + namespace llarp { void diff --git a/pybind/llarp/service/address.cpp b/pybind/llarp/service/address.cpp index 276911c08..b3c10f84d 100644 --- a/pybind/llarp/service/address.cpp +++ b/pybind/llarp/service/address.cpp @@ -1,6 +1,7 @@ -#include #include +#include + namespace llarp { namespace service diff --git a/pybind/llarp/tooling/router_event.cpp b/pybind/llarp/tooling/router_event.cpp index 73a110aaa..edd1f226a 100644 --- a/pybind/llarp/tooling/router_event.cpp +++ b/pybind/llarp/tooling/router_event.cpp @@ -1,14 +1,13 @@ -#include -#include - -#include +#include +#include #include #include -#include #include +#include +#include -#include -#include +#include +#include namespace tooling { diff --git a/pybind/llarp/tooling/router_hive.cpp b/pybind/llarp/tooling/router_hive.cpp index 0eabc7e33..e96b87895 100644 --- a/pybind/llarp/tooling/router_hive.cpp +++ b/pybind/llarp/tooling/router_hive.cpp @@ -1,10 +1,10 @@ +#include +#include +#include + #include -#include #include - -#include -#include -#include +#include namespace tooling { diff --git a/pybind/module.cpp b/pybind/module.cpp index dc75ace23..50b16ca0b 100644 --- a/pybind/module.cpp +++ b/pybind/module.cpp @@ -1,4 +1,5 @@ #include "common.hpp" + #include PYBIND11_MODULE(pyllarp, m)