2019-12-12 02:32:27 +00:00
|
|
|
include(Version)
|
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
# 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
|
2023-01-10 15:58:26 +00:00
|
|
|
crypto/crypto.cpp
|
|
|
|
crypto/encrypted_frame.cpp
|
|
|
|
crypto/types.cpp
|
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# Functional objects use by lokinet-core and other libraries
|
|
|
|
# needed by vpn/ router/ rpc/ handlers/ net/ link/
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-core-utils
|
2023-10-19 21:59:57 +00:00
|
|
|
endpoint_base.cpp
|
|
|
|
exit/context.cpp
|
|
|
|
exit/endpoint.cpp # handlers/exit.hpp
|
|
|
|
exit/policy.cpp # net/
|
2023-10-23 22:58:58 +00:00
|
|
|
handlers/exit.cpp # link/ exit/
|
|
|
|
handlers/tun.cpp
|
|
|
|
router/rc_gossiper.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
service/auth.cpp # config/
|
|
|
|
service/context.cpp
|
|
|
|
service/identity.cpp
|
2023-10-23 22:58:58 +00:00
|
|
|
service/info.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
service/intro.cpp # path
|
2023-10-23 22:58:58 +00:00
|
|
|
service/lns_tracker.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
service/name.cpp
|
2023-10-23 22:58:58 +00:00
|
|
|
service/session.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
service/tag.cpp
|
2023-10-23 22:58:58 +00:00
|
|
|
vpn/egres_packet_router.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
)
|
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-core
|
2023-10-19 21:59:57 +00:00
|
|
|
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
|
|
|
|
)
|
2023-10-23 22:58:58 +00:00
|
|
|
|
|
|
|
lokinet_add_library(lokinet-rpc
|
2023-10-24 13:18:03 +00:00
|
|
|
rpc/endpoint_rpc.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
rpc/json_binary_proxy.cpp
|
|
|
|
rpc/json_conversions.cpp
|
|
|
|
rpc/lokid_rpc_client.cpp
|
|
|
|
rpc/rpc_request_parser.cpp
|
|
|
|
rpc/rpc_server.cpp
|
|
|
|
)
|
2023-10-23 22:58:58 +00:00
|
|
|
|
|
|
|
lokinet_add_library(lokinet-wire
|
2023-10-19 21:59:57 +00:00
|
|
|
link/connection.cpp
|
|
|
|
link/contacts.cpp
|
|
|
|
link/link_manager.cpp
|
|
|
|
# link/tunnel.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# config, crypto, timeplace, nodedb, bootstrap.cpp, net, router
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-utils
|
2020-03-27 00:49:05 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp
|
2019-02-09 16:16:00 +00:00
|
|
|
util/bencode.cpp
|
|
|
|
util/buffer.cpp
|
2022-10-05 18:05:25 +00:00
|
|
|
util/file.cpp
|
2023-10-24 13:18:03 +00:00
|
|
|
util/logging/buffer.cpp
|
2019-02-09 16:16:00 +00:00
|
|
|
util/mem.cpp
|
|
|
|
util/str.cpp
|
2019-09-01 13:26:16 +00:00
|
|
|
util/thread/threading.cpp
|
2023-10-23 22:58:58 +00:00
|
|
|
util/thread/queue_manager.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
util/time.cpp
|
|
|
|
)
|
2023-10-23 22:58:58 +00:00
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
add_dependencies(lokinet-utils genversion)
|
2019-02-09 16:16:00 +00:00
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# Addressing and event loop files used by lokinet-core and other libraries
|
|
|
|
# needed by rpc/ link/ service/ config/ path/ dht/
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-time-place
|
2019-02-09 16:16:00 +00:00
|
|
|
ev/ev.cpp
|
2022-07-28 16:07:38 +00:00
|
|
|
ev/libuv.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
net/exit_info.cpp # only router_contact
|
2020-05-20 19:14:05 +00:00
|
|
|
net/ip.cpp
|
2020-05-20 19:25:57 +00:00
|
|
|
net/ip_address.cpp
|
2020-05-20 19:02:48 +00:00
|
|
|
net/ip_packet.cpp
|
2020-05-20 19:14:05 +00:00
|
|
|
net/ip_range.cpp
|
2019-06-11 16:44:05 +00:00
|
|
|
net/net_int.cpp
|
2020-05-20 19:25:57 +00:00
|
|
|
net/sock_addr.cpp
|
2023-10-24 13:18:03 +00:00
|
|
|
router_contact.cpp
|
|
|
|
router_id.cpp
|
|
|
|
router_version.cpp # to be deleted shortly
|
2023-10-19 21:59:57 +00:00
|
|
|
service/address.cpp
|
|
|
|
service/convotag.cpp
|
|
|
|
service/intro_set.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# lokinet-platform holds all platform specific code
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-platform
|
2023-10-19 21:59:57 +00:00
|
|
|
net/interface_info.cpp
|
2023-10-24 13:18:03 +00:00
|
|
|
router/rc_lookup_handler.cpp
|
2021-03-02 18:18:22 +00:00
|
|
|
vpn/packet_router.cpp
|
2021-01-11 23:13:22 +00:00
|
|
|
vpn/platform.cpp
|
2019-02-09 16:16:00 +00:00
|
|
|
)
|
|
|
|
|
2020-05-17 19:41:48 +00:00
|
|
|
if (ANDROID)
|
2022-10-27 17:51:45 +00:00
|
|
|
target_sources(lokinet-platform PRIVATE android/ifaddrs.c util/nop_service_manager.cpp)
|
2020-05-17 19:41:48 +00:00
|
|
|
endif()
|
2019-03-05 16:21:56 +00:00
|
|
|
|
2020-05-17 19:41:48 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2022-05-23 16:45:06 +00:00
|
|
|
target_sources(lokinet-platform PRIVATE linux/dbus.cpp)
|
2022-10-27 17:51:45 +00:00
|
|
|
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()
|
2019-02-11 00:02:20 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-17 19:41:48 +00:00
|
|
|
if (WIN32)
|
|
|
|
target_sources(lokinet-platform PRIVATE
|
2022-07-28 16:07:38 +00:00
|
|
|
net/win32.cpp
|
2022-09-13 16:25:27 +00:00
|
|
|
vpn/win32.cpp
|
2022-10-27 17:51:45 +00:00
|
|
|
win32/service_manager.cpp
|
2023-01-10 15:58:26 +00:00
|
|
|
win32/exec.cpp
|
2022-07-28 16:07:38 +00:00
|
|
|
win32/dll.cpp
|
2023-01-10 15:58:26 +00:00
|
|
|
win32/exception.cpp
|
|
|
|
win32/wintun.cpp
|
2022-07-28 16:07:38 +00:00
|
|
|
win32/windivert.cpp)
|
2023-01-10 15:58:26 +00:00
|
|
|
target_include_directories(lokinet-platform PRIVATE ${CMAKE_BINARY_DIR}/wintun/include/ ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/include/)
|
2022-07-28 16:07:38 +00:00
|
|
|
else()
|
|
|
|
target_sources(lokinet-platform PRIVATE
|
|
|
|
net/posix.cpp)
|
2020-05-17 19:41:48 +00:00
|
|
|
endif()
|
|
|
|
|
2023-01-10 15:58:26 +00:00
|
|
|
if(APPLE)
|
|
|
|
add_subdirectory(apple)
|
|
|
|
target_sources(lokinet-platform PRIVATE util/nop_service_manager.cpp)
|
2019-02-11 00:02:20 +00:00
|
|
|
endif()
|
2020-05-17 19:41:48 +00:00
|
|
|
|
2023-01-10 15:58:26 +00:00
|
|
|
# lokinet-dns is the dns parsing and hooking library that we use to
|
|
|
|
# parse modify and reconstitute dns wire proto, dns queries and RR
|
2023-10-24 13:18:03 +00:00
|
|
|
lokinet_add_library(lokinet-dns
|
|
|
|
dns/message.cpp # dns/server
|
2023-10-19 21:59:57 +00:00
|
|
|
dns/name.cpp # srv_data, question, rr
|
2022-07-28 16:07:38 +00:00
|
|
|
dns/platform.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
dns/question.cpp # message
|
2019-02-09 16:16:00 +00:00
|
|
|
dns/rr.cpp
|
|
|
|
dns/serialize.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
dns/server.cpp # handlers/exit+tun and service/endpoint
|
|
|
|
dns/srv_data.cpp
|
|
|
|
)
|
2022-07-28 16:07:38 +00:00
|
|
|
|
2023-01-10 15:58:26 +00:00
|
|
|
# platform specific bits and bobs for setting dns
|
|
|
|
add_library(lokinet-dns-platform INTERFACE)
|
2022-07-28 16:07:38 +00:00
|
|
|
if(WITH_SYSTEMD)
|
2023-10-24 20:33:40 +00:00
|
|
|
lokinet_add_library(lokinet-dns-systemd dns/nm_platform.cpp dns/sd_platform.cpp)
|
2023-01-10 15:58:26 +00:00
|
|
|
target_link_libraries(lokinet-dns-platform INTERFACE lokinet-dns-systemd)
|
2022-07-28 16:07:38 +00:00
|
|
|
endif()
|
|
|
|
|
2023-01-10 15:58:26 +00:00
|
|
|
# lokinet-nodedb holds all types and logic for storing parsing and constructing
|
|
|
|
# nodedb data published to the network and versions of it stored locally
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-nodedb
|
2023-10-19 21:59:57 +00:00
|
|
|
bootstrap.cpp # config, router.hpp
|
2023-10-24 13:18:03 +00:00
|
|
|
net/traffic_policy.cpp # config, intro_set
|
2023-01-10 15:58:26 +00:00
|
|
|
nodedb.cpp
|
2023-10-19 21:59:57 +00:00
|
|
|
profiling.cpp # path, router, service::endpoint
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(BOOTSTRAP_FALLBACKS)
|
|
|
|
foreach(bs IN ITEMS MAINNET TESTNET)
|
|
|
|
if(BOOTSTRAP_FALLBACK_${bs})
|
|
|
|
message(STATUS "Building with ${bs} fallback boostrap path \"${BOOTSTRAP_FALLBACK_${bs}}\"")
|
|
|
|
file(READ "${BOOTSTRAP_FALLBACK_${bs}}" bs_data HEX)
|
|
|
|
if(bs STREQUAL TESTNET)
|
|
|
|
set(network "gamma")
|
|
|
|
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
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-config
|
2022-07-28 16:07:38 +00:00
|
|
|
config/config.cpp
|
|
|
|
config/definition.cpp
|
|
|
|
config/ini.cpp
|
2023-10-12 20:37:45 +00:00
|
|
|
config/key_manager.cpp
|
|
|
|
)
|
2019-02-09 16:16:00 +00:00
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# All path objects; link directly to lokinet-core
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet_add_library(lokinet-path
|
2023-10-24 13:18:03 +00:00
|
|
|
messages/relay.cpp
|
2023-09-18 21:50:07 +00:00
|
|
|
path/abstracthophandler.cpp
|
2023-01-10 15:58:26 +00:00
|
|
|
path/path.cpp
|
2023-10-24 13:18:03 +00:00
|
|
|
path/path_context.cpp
|
2023-01-10 15:58:26 +00:00
|
|
|
path/pathbuilder.cpp
|
|
|
|
path/pathset.cpp
|
|
|
|
path/transit_hop.cpp
|
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# Link libraries to their internals
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-core-utils PUBLIC lokinet-dns)
|
|
|
|
target_link_libraries(lokinet-core PUBLIC lokinet-core-utils)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# Link lokinet-dns to alternate libraries
|
|
|
|
target_link_libraries(lokinet-dns PUBLIC lokinet-dns-platform)
|
2023-01-10 15:58:26 +00:00
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-wire PUBLIC lokinet-time-place)
|
2023-10-24 13:18:03 +00:00
|
|
|
target_link_libraries(lokinet-dns PUBLIC lokinet-utils lokinet-cryptography lokinet-config)
|
|
|
|
target_link_libraries(lokinet-nodedb PUBLIC lokinet-time-place lokinet-cryptography)
|
2023-10-19 21:59:57 +00:00
|
|
|
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)
|
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-dns
|
|
|
|
PUBLIC
|
|
|
|
lokinet-time-place
|
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
target_link_libraries(lokinet-path
|
|
|
|
PUBLIC
|
|
|
|
lokinet-time-place
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
target_link_libraries(lokinet-core-utils
|
|
|
|
PUBLIC
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet-config
|
2023-01-10 15:58:26 +00:00
|
|
|
lokinet-platform
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet-rpc
|
|
|
|
lokinet-wire
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
target_link_libraries(lokinet-cryptography
|
|
|
|
PUBLIC
|
|
|
|
lokinet-libcrypt
|
|
|
|
lokinet-libntrup
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
target_link_libraries(lokinet-utils
|
|
|
|
PUBLIC
|
|
|
|
lokinet-cryptography
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
2023-10-19 21:59:57 +00:00
|
|
|
# cross linkage
|
|
|
|
target_link_libraries(lokinet-core
|
|
|
|
PUBLIC
|
2023-10-24 13:18:03 +00:00
|
|
|
lokinet-cryptography
|
2023-10-23 22:58:58 +00:00
|
|
|
lokinet-nodedb
|
|
|
|
lokinet-path
|
2023-10-24 13:18:03 +00:00
|
|
|
lokinet-rpc
|
|
|
|
lokinet-wire
|
2023-01-10 15:58:26 +00:00
|
|
|
)
|
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-base INTERFACE oxenc::oxenc oxen::logging)
|
2023-01-10 15:58:26 +00:00
|
|
|
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-rpc PUBLIC oxenmq::oxenmq)
|
|
|
|
target_link_libraries(lokinet-core PUBLIC oxenmq::oxenmq)
|
2023-01-10 15:58:26 +00:00
|
|
|
target_link_libraries(lokinet-config PUBLIC oxenmq::oxenmq)
|
2023-10-23 22:58:58 +00:00
|
|
|
target_link_libraries(lokinet-nodedb PUBLIC oxenmq::oxenmq)
|
2023-10-19 21:59:57 +00:00
|
|
|
target_link_libraries(lokinet-path PUBLIC oxenmq::oxenmq)
|
2023-10-23 22:58:58 +00:00
|
|
|
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)
|