mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
752879d712
Refactors how quic packets get handled: the actual tunnels now live in tunnel.hpp's TunnelManager which holds and manages all the quic<->tcp tunnelling. service::Endpoint now holds a TunnelManager rather than a quic::Server. We only need one quic server, but we need a separate quic client instance per outgoing quic tunnel, and TunnelManager handles all that glue now. Adds QUIC packet handling to get to the right tunnel code. This required multiplexing incoming quic packets, as follows: Adds a very small quic tunnel packet header of 4 bytes: [1, SPORT, ECN] for client->server packets, where SPORT is our source "port" (really: just a uint16_t unique quic instance identifier) or [2, DPORT, ECN] for server->client packets where the DPORT is the SPORT from above. (This also reworks ECN bits to get properly carried over lokinet.) We don't need a destination/source port for the server-side because there is only ever one quic server (and we know we're going to it when the first byte of the header is 1). Removes the config option for quic exposing ports; a full lokinet will simply accept anything incoming on quic and tunnel it to the requested port on the the local endpoint IP (this handler will come in a following commit). Replace ConvoTags with full addresses: we need to carry the port, as well, which the ConvoTag can't give us, so change those to more general SockAddrs from which we can extract both the ConvoTag *and* the port. Add a pending connection queue along with new quic-side handlers to call when a stream becomes available (TunnelManager uses this to wire up pending incoming conns with quic streams as streams open up). Completely get rid of tunnel_server/tunnel_client.cpp code; it is now moved to tunnel.hpp. Add listen()/forget() methods in TunnelManager for setting up quic listening sockets (for liblokinet usage). Add open()/close() methods in TunnelManager for spinning up new quic clients for outgoing quic connections.
263 lines
6.1 KiB
CMake
263 lines
6.1 KiB
CMake
include(Version)
|
|
|
|
add_library(lokinet-util
|
|
STATIC
|
|
${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp
|
|
util/bencode.cpp
|
|
util/buffer.cpp
|
|
util/fs.cpp
|
|
util/json.cpp
|
|
util/logging/android_logger.cpp
|
|
util/logging/buffer.cpp
|
|
util/logging/file_logger.cpp
|
|
util/logging/json_logger.cpp
|
|
util/logging/logger.cpp
|
|
util/logging/logger_internal.cpp
|
|
util/logging/loglevel.cpp
|
|
util/logging/ostream_logger.cpp
|
|
util/logging/syslog_logger.cpp
|
|
util/logging/win32_logger.cpp
|
|
util/lokinet_init.c
|
|
util/mem.cpp
|
|
util/printer.cpp
|
|
util/str.cpp
|
|
util/thread/queue_manager.cpp
|
|
util/thread/threading.cpp
|
|
util/time.cpp
|
|
)
|
|
add_dependencies(lokinet-util genversion)
|
|
|
|
target_include_directories(lokinet-util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR})
|
|
|
|
target_link_libraries(lokinet-util PUBLIC
|
|
lokinet-cryptography
|
|
nlohmann_json::nlohmann_json
|
|
filesystem
|
|
date::date
|
|
oxenmq::oxenmq
|
|
)
|
|
|
|
if(ANDROID)
|
|
target_link_libraries(lokinet-util PUBLIC log)
|
|
endif()
|
|
|
|
add_library(lokinet-platform
|
|
STATIC
|
|
# for networking
|
|
ev/ev.cpp
|
|
ev/ev_libuv.cpp
|
|
net/ip.cpp
|
|
net/ip_address.cpp
|
|
net/ip_packet.cpp
|
|
net/ip_range.cpp
|
|
net/net.cpp
|
|
net/net_int.cpp
|
|
net/route.cpp
|
|
net/sock_addr.cpp
|
|
vpn/packet_router.cpp
|
|
vpn/platform.cpp
|
|
)
|
|
|
|
target_link_libraries(lokinet-platform PUBLIC lokinet-cryptography lokinet-util Threads::Threads base_libs uvw)
|
|
|
|
|
|
if (ANDROID)
|
|
target_sources(lokinet-platform PRIVATE android/ifaddrs.c)
|
|
endif()
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
target_sources(lokinet-platform PRIVATE linux/netns.cpp)
|
|
|
|
if(NON_PC_TARGET)
|
|
add_import_library(rt)
|
|
target_link_libraries(lokinet-platform PUBLIC rt)
|
|
endif()
|
|
endif()
|
|
|
|
if (WIN32)
|
|
target_sources(lokinet-platform PRIVATE
|
|
win32/win32_inet.c
|
|
win32/win32_intrnl.c)
|
|
|
|
target_link_libraries(lokinet-platform PUBLIC iphlpapi)
|
|
endif()
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
target_include_directories(lokinet-platform SYSTEM PUBLIC /usr/local/include)
|
|
endif()
|
|
|
|
add_library(lokinet-quic
|
|
quic/address.cpp
|
|
quic/client.cpp
|
|
quic/connection.cpp
|
|
quic/endpoint.cpp
|
|
quic/null_crypto.cpp
|
|
quic/server.cpp
|
|
quic/stream.cpp
|
|
quic/tunnel.cpp
|
|
)
|
|
|
|
target_link_libraries(lokinet-quic PRIVATE lokinet-platform ngtcp2)
|
|
|
|
add_library(liblokinet
|
|
STATIC
|
|
config/config.cpp
|
|
config/definition.cpp
|
|
config/ini.cpp
|
|
config/key_manager.cpp
|
|
|
|
dns/message.cpp
|
|
dns/name.cpp
|
|
dns/question.cpp
|
|
dns/rr.cpp
|
|
dns/serialize.cpp
|
|
dns/server.cpp
|
|
dns/srv_data.cpp
|
|
dns/unbound_resolver.cpp
|
|
|
|
consensus/table.cpp
|
|
|
|
bootstrap.cpp
|
|
context.cpp
|
|
crypto/crypto_libsodium.cpp
|
|
crypto/crypto.cpp
|
|
crypto/encrypted_frame.cpp
|
|
crypto/types.cpp
|
|
dht/context.cpp
|
|
dht/dht.cpp
|
|
dht/explorenetworkjob.cpp
|
|
dht/localtaglookup.cpp
|
|
dht/localrouterlookup.cpp
|
|
dht/localserviceaddresslookup.cpp
|
|
dht/message.cpp
|
|
dht/messages/findintro.cpp
|
|
dht/messages/findrouter.cpp
|
|
dht/messages/gotintro.cpp
|
|
dht/messages/gotrouter.cpp
|
|
dht/messages/pubintro.cpp
|
|
dht/messages/findname.cpp
|
|
dht/messages/gotname.cpp
|
|
dht/publishservicejob.cpp
|
|
dht/recursiverouterlookup.cpp
|
|
dht/serviceaddresslookup.cpp
|
|
dht/taglookup.cpp
|
|
exit/context.cpp
|
|
exit/endpoint.cpp
|
|
exit/exit_messages.cpp
|
|
exit/policy.cpp
|
|
exit/session.cpp
|
|
handlers/exit.cpp
|
|
handlers/tun.cpp
|
|
hook/shell.cpp
|
|
iwp/iwp.cpp
|
|
iwp/linklayer.cpp
|
|
iwp/message_buffer.cpp
|
|
iwp/session.cpp
|
|
link/link_manager.cpp
|
|
link/session.cpp
|
|
link/server.cpp
|
|
messages/dht_immediate.cpp
|
|
messages/link_intro.cpp
|
|
messages/link_message_parser.cpp
|
|
messages/relay.cpp
|
|
messages/relay_commit.cpp
|
|
messages/relay_status.cpp
|
|
net/address_info.cpp
|
|
net/exit_info.cpp
|
|
nodedb.cpp
|
|
path/ihophandler.cpp
|
|
path/path_context.cpp
|
|
path/path.cpp
|
|
path/pathbuilder.cpp
|
|
path/pathset.cpp
|
|
path/transit_hop.cpp
|
|
peerstats/peer_db.cpp
|
|
peerstats/types.cpp
|
|
pow.cpp
|
|
profiling.cpp
|
|
router/outbound_message_handler.cpp
|
|
router/outbound_session_maker.cpp
|
|
router/rc_lookup_handler.cpp
|
|
router/rc_gossiper.cpp
|
|
router/router.cpp
|
|
router/route_poker.cpp
|
|
router_contact.cpp
|
|
router_id.cpp
|
|
router_version.cpp
|
|
routing/dht_message.cpp
|
|
routing/message_parser.cpp
|
|
routing/path_confirm_message.cpp
|
|
routing/path_latency_message.cpp
|
|
routing/path_transfer_message.cpp
|
|
routing/transfer_traffic_message.cpp
|
|
rpc/lokid_rpc_client.cpp
|
|
rpc/rpc_server.cpp
|
|
rpc/endpoint_rpc.cpp
|
|
service/address.cpp
|
|
service/async_key_exchange.cpp
|
|
service/auth.cpp
|
|
service/convotag.cpp
|
|
service/context.cpp
|
|
service/endpoint_state.cpp
|
|
service/endpoint_util.cpp
|
|
service/endpoint.cpp
|
|
service/hidden_service_address_lookup.cpp
|
|
service/identity.cpp
|
|
service/info.cpp
|
|
service/intro_set.cpp
|
|
service/intro.cpp
|
|
service/lns_tracker.cpp
|
|
service/lookup.cpp
|
|
service/name.cpp
|
|
service/outbound_context.cpp
|
|
service/protocol.cpp
|
|
service/router_lookup_job.cpp
|
|
service/sendcontext.cpp
|
|
service/session.cpp
|
|
service/tag.cpp
|
|
)
|
|
|
|
set_target_properties(liblokinet PROPERTIES OUTPUT_NAME lokinet)
|
|
|
|
enable_lto(lokinet-util lokinet-platform lokinet-quic liblokinet)
|
|
|
|
if(TRACY_ROOT)
|
|
target_sources(liblokinet PRIVATE ${TRACY_ROOT}/TracyClient.cpp)
|
|
endif()
|
|
|
|
if(TESTNET)
|
|
target_sources(liblokinet PRIVATE testnet.c)
|
|
endif()
|
|
|
|
if(WITH_HIVE)
|
|
target_sources(liblokinet PRIVATE
|
|
tooling/router_hive.cpp
|
|
tooling/hive_router.cpp
|
|
tooling/hive_context.cpp
|
|
)
|
|
endif()
|
|
|
|
target_link_libraries(liblokinet PUBLIC cxxopts lokinet-platform lokinet-util lokinet-cryptography lokinet-quic sqlite_orm ngtcp2)
|
|
target_link_libraries(liblokinet PRIVATE libunbound)
|
|
|
|
|
|
if(BUILD_LIBLOKINET)
|
|
include(GNUInstallDirs)
|
|
add_library(lokinet-shared SHARED lokinet_shared.cpp)
|
|
set_target_properties(lokinet-shared PROPERTIES OUTPUT_NAME lokinet)
|
|
target_link_libraries(lokinet-shared PUBLIC liblokinet)
|
|
install(TARGETS lokinet-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
if(WIN32)
|
|
target_link_libraries(lokinet-shared PUBLIC ws2_32 iphlpapi -fstack-protector)
|
|
endif()
|
|
add_log_tag(lokinet-shared)
|
|
endif()
|
|
|
|
foreach(lokinet_lib liblokinet lokinet-platform lokinet-util lokinet-cryptography)
|
|
add_log_tag(${lokinet_lib})
|
|
endforeach()
|
|
|
|
file(GLOB_RECURSE docs_SRC */*.hpp *.hpp)
|
|
|
|
set(DOCS_SRC ${docs_SRC} PARENT_SCOPE)
|