mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
62c37825b0
- disable reachability testing with config option; required to be done on testnet - reachability testing pipeline through link_manager executes pings similar to storage server. connection established hook reports successful reachability, while connection closed callback (with non-default error code) reports unsuccessful testing
303 lines
8.8 KiB
CMake
303 lines
8.8 KiB
CMake
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.
|
|
# lokinet_add_library(lokinet-foo foo/source1.cpp foo/source2.cpp)
|
|
function(lokinet_add_library libname)
|
|
add_library(${libname} STATIC ${ARGN})
|
|
target_link_libraries(${libname} PUBLIC lokinet-base)
|
|
enable_lto(${libname})
|
|
endfunction()
|
|
|
|
lokinet_add_library(lokinet-cryptography
|
|
crypto/crypto.cpp
|
|
crypto/types.cpp
|
|
)
|
|
|
|
# Functional objects use by lokinet-core and other libraries
|
|
# needed by vpn/ router/ rpc/ handlers/ net/ link/
|
|
lokinet_add_library(lokinet-core-utils
|
|
endpoint_base.cpp
|
|
exit/context.cpp
|
|
exit/endpoint.cpp # handlers/exit.hpp
|
|
exit/policy.cpp # net/
|
|
handlers/exit.cpp # link/ exit/
|
|
handlers/tun.cpp
|
|
service/auth.cpp # config/
|
|
service/context.cpp
|
|
service/identity.cpp
|
|
service/info.cpp
|
|
service/intro.cpp # path
|
|
service/lns_tracker.cpp
|
|
service/name.cpp
|
|
service/session.cpp
|
|
service/tag.cpp
|
|
vpn/egres_packet_router.cpp
|
|
)
|
|
|
|
lokinet_add_library(lokinet-core
|
|
context.cpp
|
|
consensus/reachability_testing.cpp
|
|
exit/session.cpp
|
|
link/link_manager.cpp
|
|
router/router.cpp
|
|
router/route_poker.cpp
|
|
service/async_key_exchange.cpp
|
|
service/endpoint_util.cpp
|
|
service/endpoint.cpp
|
|
service/endpoint_state.cpp
|
|
service/name.cpp
|
|
service/outbound_context.cpp
|
|
service/protocol.cpp
|
|
)
|
|
|
|
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
|
|
)
|
|
|
|
lokinet_add_library(lokinet-wire
|
|
link/connection.cpp
|
|
link/contacts.cpp
|
|
link/link_manager.cpp
|
|
# link/tunnel.cpp
|
|
)
|
|
|
|
# config, crypto, timeplace, nodedb, bootstrap.cpp, net, router
|
|
lokinet_add_library(lokinet-utils
|
|
${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp
|
|
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
|
|
)
|
|
|
|
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
|
|
ev/ev.cpp
|
|
ev/libuv.cpp
|
|
net/ip.cpp
|
|
net/ip_address.cpp
|
|
net/ip_packet.cpp
|
|
net/ip_range.cpp
|
|
net/net_int.cpp
|
|
net/sock_addr.cpp
|
|
router_contact.cpp
|
|
router_contact_local.cpp
|
|
router_contact_remote.cpp
|
|
router_id.cpp
|
|
router_version.cpp # to be deleted shortly
|
|
service/address.cpp
|
|
service/convotag.cpp
|
|
service/intro_set.cpp
|
|
)
|
|
|
|
# lokinet-platform holds all platform specific code
|
|
lokinet_add_library(lokinet-platform
|
|
net/interface_info.cpp
|
|
vpn/packet_router.cpp
|
|
vpn/platform.cpp
|
|
)
|
|
|
|
if (ANDROID)
|
|
target_sources(lokinet-platform PRIVATE android/ifaddrs.c util/nop_service_manager.cpp)
|
|
endif()
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
target_sources(lokinet-platform PRIVATE linux/dbus.cpp)
|
|
if(WITH_SYSTEMD)
|
|
target_sources(lokinet-platform PRIVATE linux/sd_service_manager.cpp)
|
|
else()
|
|
target_sources(lokinet-platform PRIVATE util/nop_service_manager.cpp)
|
|
endif()
|
|
endif()
|
|
|
|
if (WIN32)
|
|
target_sources(lokinet-platform PRIVATE
|
|
net/win32.cpp
|
|
vpn/win32.cpp
|
|
win32/service_manager.cpp
|
|
win32/exec.cpp
|
|
win32/dll.cpp
|
|
win32/exception.cpp
|
|
win32/wintun.cpp
|
|
win32/windivert.cpp)
|
|
target_include_directories(lokinet-platform PRIVATE ${CMAKE_BINARY_DIR}/wintun/include/ ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/include/)
|
|
else()
|
|
target_sources(lokinet-platform PRIVATE
|
|
net/posix.cpp)
|
|
endif()
|
|
|
|
if(APPLE)
|
|
add_subdirectory(apple)
|
|
target_sources(lokinet-platform PRIVATE util/nop_service_manager.cpp)
|
|
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
|
|
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
|
|
dns/server.cpp # handlers/exit+tun and service/endpoint
|
|
dns/srv_data.cpp
|
|
)
|
|
|
|
# platform specific bits and bobs for setting dns
|
|
add_library(lokinet-dns-platform INTERFACE)
|
|
if(WITH_SYSTEMD)
|
|
lokinet_add_library(lokinet-dns-systemd dns/nm_platform.cpp dns/sd_platform.cpp)
|
|
target_link_libraries(lokinet-dns-platform INTERFACE lokinet-dns-systemd)
|
|
endif()
|
|
|
|
# lokinet-nodedb holds all types and logic for storing parsing and constructing
|
|
# 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
|
|
)
|
|
|
|
set(BOOTSTRAP_FALLBACKS)
|
|
foreach(bs IN ITEMS MAINNET TESTNET)
|
|
if(BOOTSTRAP_FALLBACK_${bs})
|
|
message(STATUS "Building with ${bs} fallback bootstrap path \"${BOOTSTRAP_FALLBACK_${bs}}\"")
|
|
file(READ "${BOOTSTRAP_FALLBACK_${bs}}" bs_data HEX)
|
|
if(bs STREQUAL TESTNET)
|
|
set(network "testnet")
|
|
elseif(bs STREQUAL MAINNET)
|
|
set(network "lokinet")
|
|
else()
|
|
string(TOLOWER "${bs}" network)
|
|
endif()
|
|
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "\\\\x\\1" bs_data "${bs_data}")
|
|
set(BOOTSTRAP_FALLBACKS "${BOOTSTRAP_FALLBACKS}{\"${network}\"s, \"${bs_data}\"sv},\n")
|
|
endif()
|
|
endforeach()
|
|
configure_file("bootstrap-fallbacks.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/bootstrap-fallbacks.cpp" @ONLY)
|
|
target_sources(lokinet-nodedb PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/bootstrap-fallbacks.cpp")
|
|
|
|
# lokinet-config is for all configuration types and parsers
|
|
lokinet_add_library(lokinet-config
|
|
config/config.cpp
|
|
config/definition.cpp
|
|
config/ini.cpp
|
|
config/key_manager.cpp
|
|
)
|
|
|
|
# All path objects; link directly to lokinet-core
|
|
lokinet_add_library(lokinet-path
|
|
path/abstracthophandler.cpp
|
|
path/path.cpp
|
|
path/path_context.cpp
|
|
path/pathbuilder.cpp
|
|
path/pathset.cpp
|
|
path/transit_hop.cpp
|
|
)
|
|
|
|
# Link libraries to their internals
|
|
target_link_libraries(lokinet-core-utils PUBLIC lokinet-dns)
|
|
target_link_libraries(lokinet-core PUBLIC lokinet-core-utils)
|
|
|
|
# Link lokinet-dns to alternate libraries
|
|
target_link_libraries(lokinet-dns PUBLIC lokinet-dns-platform)
|
|
|
|
target_link_libraries(lokinet-wire PUBLIC lokinet-time-place)
|
|
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)
|
|
target_link_libraries(lokinet-wire PUBLIC lokinet-cryptography)
|
|
target_link_libraries(lokinet-config PUBLIC lokinet-cryptography)
|
|
|
|
target_link_libraries(lokinet-dns
|
|
PUBLIC
|
|
lokinet-time-place
|
|
)
|
|
|
|
target_link_libraries(lokinet-path
|
|
PUBLIC
|
|
lokinet-time-place
|
|
)
|
|
|
|
target_link_libraries(lokinet-core-utils
|
|
PUBLIC
|
|
lokinet-config
|
|
lokinet-platform
|
|
lokinet-rpc
|
|
lokinet-wire
|
|
)
|
|
|
|
target_link_libraries(lokinet-cryptography
|
|
PUBLIC
|
|
lokinet-libcrypt
|
|
lokinet-libntrup
|
|
)
|
|
|
|
target_link_libraries(lokinet-utils
|
|
PUBLIC
|
|
lokinet-cryptography
|
|
)
|
|
|
|
# cross linkage
|
|
target_link_libraries(lokinet-core
|
|
PUBLIC
|
|
lokinet-cryptography
|
|
lokinet-nodedb
|
|
lokinet-path
|
|
lokinet-rpc
|
|
lokinet-wire
|
|
)
|
|
|
|
target_link_libraries(lokinet-base INTERFACE oxenc::oxenc oxen::logging)
|
|
|
|
target_link_libraries(lokinet-rpc PUBLIC oxenmq::oxenmq)
|
|
target_link_libraries(lokinet-core PUBLIC oxenmq::oxenmq)
|
|
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 uvw)
|
|
target_link_libraries(lokinet-cryptography PUBLIC sodium)
|
|
target_link_libraries(lokinet-dns PUBLIC libunbound)
|
|
target_link_libraries(lokinet-utils PUBLIC nlohmann_json::nlohmann_json)
|
|
target_link_libraries(lokinet-wire PUBLIC oxenmq::oxenmq quic)
|
|
|
|
if(WITH_EMBEDDED_LOKINET)
|
|
include(GNUInstallDirs)
|
|
add_library(lokinet-shared SHARED lokinet_shared.cpp)
|
|
# target_link_libraries(lokinet-shared PUBLIC lokinet-amalgum)
|
|
target_link_libraries(lokinet-shared PUBLIC lokinet-core)
|
|
if(WIN32)
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX_CXX "")
|
|
endif()
|
|
set_target_properties(lokinet-shared PROPERTIES OUTPUT_NAME lokinet)
|
|
if(WIN32)
|
|
target_link_libraries(lokinet-shared PUBLIC ws2_32 iphlpapi -fstack-protector)
|
|
install(TARGETS lokinet-shared DESTINATION bin COMPONENT liblokinet)
|
|
elseif(NOT APPLE)
|
|
install(TARGETS lokinet-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT liblokinet)
|
|
endif()
|
|
endif()
|
|
|
|
file(GLOB_RECURSE docs_SRC */*.hpp *.hpp)
|
|
set(DOCS_SRC ${docs_SRC} PARENT_SCOPE)
|