mirror of https://github.com/oxen-io/lokinet
Make libabyss mandatory
This commit is contained in:
parent
de13ab3adc
commit
4132f883a7
|
@ -5,7 +5,6 @@ set(PROJECT_NAME lokinet)
|
|||
project(${PROJECT_NAME} C CXX ASM)
|
||||
|
||||
# Core options
|
||||
option(USE_LIBABYSS "enable libabyss" )
|
||||
option(USE_AVX2 "enable avx2 code" )
|
||||
option(USE_NETNS "enable networking namespace support. Linux only" )
|
||||
option(AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" )
|
||||
|
@ -21,6 +20,7 @@ option(WITH_COVERAGE "generate coverage data")
|
|||
|
||||
# Basic definitions
|
||||
get_filename_component(CORE_INCLUDE include ABSOLUTE)
|
||||
get_filename_component(ABYSS_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/${ABYSS}/include" ABSOLUTE CACHE)
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
|
@ -310,39 +310,33 @@ function(add_log_tag target)
|
|||
endforeach(F)
|
||||
endfunction()
|
||||
|
||||
if(USE_LIBABYSS)
|
||||
add_definitions(-DUSE_ABYSS=1)
|
||||
|
||||
set(ABYSS_SRC
|
||||
${ABYSS}/src/http.cpp
|
||||
${ABYSS}/src/client.cpp
|
||||
${ABYSS}/src/server.cpp)
|
||||
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
|
||||
endif(USE_LIBABYSS)
|
||||
set(ABYSS_SRC
|
||||
${ABYSS}/src/http.cpp
|
||||
${ABYSS}/src/client.cpp
|
||||
${ABYSS}/src/server.cpp)
|
||||
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
|
||||
|
||||
add_subdirectory(crypto)
|
||||
add_subdirectory(libutp)
|
||||
add_subdirectory(llarp)
|
||||
|
||||
if(USE_LIBABYSS)
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB})
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB})
|
||||
|
||||
if (NOT WIN32)
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} Threads::Threads)
|
||||
else()
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp llarp/win32/abyss.rc)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
endif(NOT WIN32)
|
||||
target_include_directories(${ABYSS_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include")
|
||||
target_include_directories(${ABYSS_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include")
|
||||
# for freebsd
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_include_directories(${ABYSS_LIB} /usr/local/include)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
add_log_tag(${ABYSS_EXE})
|
||||
add_log_tag(${ABYSS_LIB})
|
||||
endif(USE_LIBABYSS)
|
||||
if (NOT WIN32)
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} Threads::Threads)
|
||||
else()
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp llarp/win32/abyss.rc)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
endif(NOT WIN32)
|
||||
target_include_directories(${ABYSS_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include")
|
||||
target_include_directories(${ABYSS_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include")
|
||||
# for freebsd
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_include_directories(${ABYSS_LIB} /usr/local/include)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
add_log_tag(${ABYSS_EXE})
|
||||
add_log_tag(${ABYSS_LIB})
|
||||
|
||||
if(SHADOW)
|
||||
add_shadow_plugin(shadow-plugin-${SHARED_LIB} ${EXE_SRC} ${LIB_SRC} ${UTP_SRC} ${LIB_PLATFORM_SRC} ${CPP_BACKPORT_SRC} ${ABYSS_SRC} ${CRYPTOGRAPHY_SRC})
|
||||
|
|
|
@ -201,12 +201,7 @@ set(LIB_SRC
|
|||
)
|
||||
|
||||
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
||||
target_link_libraries(${STATIC_LIB} PUBLIC ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB} libutp ${LIBS})
|
||||
|
||||
if(USE_LIBABYSS)
|
||||
add_definitions(-DUSE_ABYSS=1)
|
||||
target_link_libraries(${STATIC_LIB} PUBLIC ${ABYSS_LIB})
|
||||
endif()
|
||||
target_link_libraries(${STATIC_LIB} PUBLIC ${ABYSS_LIB} ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB} libutp ${LIBS})
|
||||
|
||||
if(TESTNET)
|
||||
target_sources(${STATIC_LIB} PUBLIC testnet.c)
|
||||
|
@ -214,18 +209,10 @@ endif()
|
|||
|
||||
if(WITH_SHARED)
|
||||
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
|
||||
target_link_libraries(${SHARED_LIB} PUBLIC ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} Threads::Threads)
|
||||
if (WIN32)
|
||||
if(USE_LIBABYSS)
|
||||
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
|
||||
endif()
|
||||
target_link_libraries(${SHARED_LIB} PUBLIC ws2_32 iphlpapi)
|
||||
else()
|
||||
if(USE_LIBABYSS)
|
||||
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
|
||||
endif()
|
||||
install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib)
|
||||
endif()
|
||||
add_log_tag(${SHARED_LIB})
|
||||
|
|
|
@ -5,16 +5,13 @@
|
|||
#include <router_id.hpp>
|
||||
#include <exit/context.hpp>
|
||||
|
||||
#ifdef USE_ABYSS
|
||||
#include <util/encode.hpp>
|
||||
#include <libabyss.hpp>
|
||||
#endif
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace rpc
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
|
||||
struct CallerHandler : public ::abyss::http::IRPCClientHandler
|
||||
{
|
||||
|
@ -341,57 +338,6 @@ namespace llarp
|
|||
(const sockaddr*)&saddr);
|
||||
}
|
||||
};
|
||||
#else
|
||||
struct ServerImpl
|
||||
{
|
||||
ServerImpl(__attribute__((unused)) AbstractRouter* r){};
|
||||
|
||||
bool
|
||||
Start(__attribute__((unused)) const std::string& addr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Stop()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct CallerImpl
|
||||
{
|
||||
CallerImpl(__attribute__((unused)) AbstractRouter* r)
|
||||
{
|
||||
}
|
||||
|
||||
~CallerImpl()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
Start(const std::string&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Stop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Tick(llarp_time_t now)
|
||||
{
|
||||
(void)now;
|
||||
}
|
||||
|
||||
void
|
||||
SetBasicAuth(const std::string&, const std::string&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Caller::Caller(AbstractRouter* r)
|
||||
: m_Impl(std::make_unique< CallerImpl >(r))
|
||||
|
|
|
@ -6,20 +6,14 @@ namespace llarp
|
|||
{
|
||||
StatusObject::StatusObject(const StatusObject& other)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
Impl.SetObject();
|
||||
auto& a = Impl.GetAllocator();
|
||||
Impl.CopyFrom(other.Impl, a);
|
||||
#else
|
||||
(void)other;
|
||||
#endif
|
||||
}
|
||||
|
||||
StatusObject::~StatusObject()
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
Impl.RemoveAllMembers();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -48,39 +42,29 @@ namespace llarp
|
|||
void
|
||||
StatusObject::PutBool(String_t name, bool val)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetBool(val);
|
||||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)val;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
StatusObject::PutInt(String_t name, uint64_t val)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetUint64(val);
|
||||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)val;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
StatusObject::PutObject(String_t name, const StatusObject& val)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetObject();
|
||||
|
@ -88,17 +72,12 @@ namespace llarp
|
|||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)val;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
StatusObject::PutObjectArray(String_t name,
|
||||
const std::vector< StatusObject >& arr)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetArray();
|
||||
|
@ -110,17 +89,12 @@ namespace llarp
|
|||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)arr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
StatusObject::PutStringArray(String_t name,
|
||||
const std::vector< std::string >& arr)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetArray();
|
||||
|
@ -132,26 +106,17 @@ namespace llarp
|
|||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)arr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
StatusObject::PutString(String_t name, const std::string& val)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
auto& a = Impl.GetAllocator();
|
||||
Value_t v;
|
||||
v.SetString(val.c_str(), a);
|
||||
auto s = llarp::string_view_string(name);
|
||||
Value_t k(s.c_str(), a);
|
||||
Impl.AddMember(k, v, a);
|
||||
#else
|
||||
(void)name;
|
||||
(void)val;
|
||||
#endif
|
||||
}
|
||||
} // namespace util
|
||||
} // namespace llarp
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LLARP_UTIL_STATUS_HPP
|
||||
#define LLARP_UTIL_STATUS_HPP
|
||||
#ifdef USE_ABYSS
|
||||
|
||||
#include <util/json.hpp>
|
||||
#endif
|
||||
#include <util/string_view.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
@ -13,17 +13,8 @@ namespace llarp
|
|||
{
|
||||
namespace util
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
using StatusObject_Impl = json::Document;
|
||||
using Value_t = json::Value;
|
||||
#else
|
||||
struct StatusObject_Impl
|
||||
{
|
||||
};
|
||||
struct Value_t
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
struct StatusObject
|
||||
{
|
||||
|
@ -38,9 +29,7 @@ namespace llarp
|
|||
|
||||
StatusObject(std::initializer_list< value_type > vals)
|
||||
{
|
||||
#ifdef USE_ABYSS
|
||||
Impl.SetObject();
|
||||
#endif
|
||||
std::for_each(vals.begin(), vals.end(),
|
||||
[&](const value_type& item) { Put(item); });
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ list(APPEND TEST_SRC
|
|||
routing/test_llarp_routing_obtainexitmessage.cpp
|
||||
service/test_llarp_service_address.cpp
|
||||
service/test_llarp_service_identity.cpp
|
||||
test_libabyss.cpp
|
||||
test_llarp_dns.cpp
|
||||
test_llarp_dnsd.cpp
|
||||
test_llarp_encrypted_frame.cpp
|
||||
|
@ -57,9 +58,3 @@ else()
|
|||
target_sources(${TEST_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/win32/test.rc")
|
||||
target_link_libraries(${TEST_EXE} PUBLIC ws2_32 iphlpapi)
|
||||
endif(NOT WIN32)
|
||||
|
||||
|
||||
if(USE_LIBABYSS)
|
||||
target_sources(${TEST_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/test_libabyss.cpp")
|
||||
target_link_libraries(${TEST_EXE} PUBLIC ${ABYSS_LIB})
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue