Merge pull request #1030 from loki-project/dev

Dev into master for 0.6.2 release
pull/1032/head v0.6.2
Jeff 4 years ago committed by GitHub
commit 71bed2e52d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,7 +11,6 @@ project(${PROJECT_NAME} C CXX)
# Core options
option(USE_AVX2 "enable avx2 code" OFF)
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
option(AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" OFF)
option(NATIVE_BUILD "optimise for host system and FPU" ON)
option(EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF)
if (NOT MSVC)
@ -162,25 +161,17 @@ endif(WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
if(DEBIAN)
add_definitions(-DDEBIAN)
elseif(NATIVE_BUILD)
set(CRYPTO_FLAGS -march=native -mtune=native)
elseif(NOT NON_PC_TARGET)
if (USE_AVX2)
set(CRYPTO_FLAGS -march=haswell -mtune=native -mfpmath=sse)
set(CRYPTO_FLAGS -march=haswell -mtune=haswell -mfpmath=sse)
else()
# Public binary releases
set(CRYPTO_FLAGS -march=nocona -mtune=core2 -mfpmath=sse)
set(CRYPTO_FLAGS -march=nocona -mtune=haswell -mfpmath=sse)
endif()
endif()
# only needed if using AVX2
if(AMD_RYZEN_HACK AND USE_AVX2)
set(CRYPTO_FLAGS -march=native -mfpmath=sse -mavx -mavx2 -mfma)
message(WARNING "This option may be removed in a future release. Contact your computer manufacturer for updated ROMs or microcode patches.")
endif(AMD_RYZEN_HACK AND USE_AVX2)
if(NATIVE_BUILD AND NOT DEBIAN)
set(CRYPTO_FLAGS -march=native -mtune=native)
endif()
if(EMBEDDED_CFG)
message(WARNING "This configuration is optimised for older hardware and/or constrained node operation, may result in poor performance on desktop systems")
message(WARNING "For deployment on such systems, all external code (currently, libuv) must also be compiled for the target!")

@ -45,6 +45,11 @@ SHADOW_OPTS ?=
LIBUV_VERSION ?= v1.30.1
LIBUV_PREFIX = $(BUILD_ROOT)/libuv
LIBCURL_PREFIX = $(BUILD_ROOT)/curl
LIBCURL_VERSION = 7.67.0
LIBCURL_URL = https://github.com/curl/curl/releases/download/curl-7_67_0/curl-7.67.0.tar.xz
LIBCURL_SHA256 = f5d2e7320379338c3952dcc7566a140abb49edb575f9f99272455785c40e536c
TESTNET_ROOT=/tmp/lokinet_testnet_tmp
TESTNET_CONF=$(TESTNET_ROOT)/supervisor.conf
TESTNET_LOG=$(TESTNET_ROOT)/testnet.log
@ -212,7 +217,19 @@ $(TEST_EXE): debug
test: $(TEST_EXE)
test x$(CROSS) = xOFF && $(TEST_EXE) || test x$(CROSS) = xON
static-configure: $(LIBUV_PREFIX) $(LIBCURL_PREFIX)
(test x$(TOOLCHAIN) = x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' ) || (test x$(TOOLCHAIN) != x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN) -DNATIVE_BUILD=OFF )
static: static-configure
$(MAKE) -C '$(BUILD_ROOT)'
cp $(EXE) $(REPO)/lokinet-static
$(LIBCURL_PREFIX):
mkdir -p '$(BUILD_ROOT)'
wget '$(LIBCURL_URL)' -O '$(BUILD_ROOT)/curl.tar.xz'
bash -c 'sha256sum -c <<<"$(LIBCURL_SHA256) $(BUILD_ROOT)/curl.tar.xz"'
tar -xJf '$(BUILD_ROOT)/curl.tar.xz' -C '$(BUILD_ROOT)'
mv '$(BUILD_ROOT)/curl-$(LIBCURL_VERSION)' '$(LIBCURL_PREFIX)'
$(LIBUV_PREFIX):
mkdir -p $(BUILD_ROOT)

@ -22,7 +22,7 @@ if(NOT IOS AND NOT ANDROID AND NOT WIN32)
set(CURL_LIBRARIES libcurl)
set(CURL_FOUND TRUE)
else()
find_package(CURL REQUIRED)
include(FindCURL)
endif()
endif()

@ -37,7 +37,6 @@ set(NTRU_REF_SRC
)
set(NTRU_SRC
${NTRU_AVX_SRC}
${NTRU_REF_SRC}
libntrup/src/ntru.cpp
)
@ -47,21 +46,42 @@ set(CRYPTOGRAPHY_SRC ${NTRU_SRC})
add_library(${CRYPTOGRAPHY_LIB} STATIC ${CRYPTOGRAPHY_SRC})
add_log_tag(${CRYPTOGRAPHY_LIB})
# The avx implementation uses runtime CPU feature detection to enable itself, so we *always* want to
# compile it with avx2 support even if we aren't compiling with AVX2 enabled.
add_library(cryptography_avx_lib STATIC ${NTRU_AVX_SRC})
if(USE_AVX2)
# Assume cxxflags are already enabling AVX2
else()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-mavx2 COMPILER_SUPPORTS_AVX2)
check_cxx_compiler_flag(-mfma COMPILER_SUPPORTS_FMA)
if(COMPILER_SUPPORTS_AVX2 AND COMPILER_SUPPORTS_FMA)
target_compile_options(cryptography_avx_lib PRIVATE -mavx2 -mfma)
message(STATUS "Building libntrup with runtime AVX2/FMA support")
else()
message(STATUS "Not building with libntrup runtime AVX2/FMA support (can't figure out how to compile with AVX2/FMA: -mavx2 -mfma didn't work)")
endif()
endif()
target_link_libraries(${CRYPTOGRAPHY_LIB} PRIVATE cryptography_avx_lib)
option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF)
find_package(Sodium 1.0.17)
if(sodium_FOUND)
target_include_directories(${CRYPTOGRAPHY_LIB} PUBLIC ${sodium_INCLUDE_DIR})
target_link_libraries(${CRYPTOGRAPHY_LIB} ${sodium_LIBRARY_RELEASE})
target_include_directories(cryptography_avx_lib PUBLIC ${sodium_INCLUDE_DIR})
target_link_libraries(${CRYPTOGRAPHY_LIB} PUBLIC ${sodium_LIBRARY_RELEASE})
elseif(DOWNLOAD_SODIUM)
message(STATUS "Sodium >= 1.0.17 not found, but DOWNLOAD_SODIUM specified, so downloading it")
include(DownloadLibSodium)
target_link_libraries(${CRYPTOGRAPHY_LIB} sodium_vendor)
target_link_libraries(${CRYPTOGRAPHY_LIB} PUBLIC sodium_vendor)
target_link_libraries(cryptography_avx_lib PUBLIC sodium_vendor)
else()
message(FATAL_ERROR "Could not find libsodium >= 1.0.17; either install it on your system or use -DDOWNLOAD_SODIUM=ON to download and build an internal copy")
endif()
target_include_directories(${CRYPTOGRAPHY_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libntrup/include")
target_include_directories(cryptography_avx_lib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libntrup/include")

@ -63,13 +63,12 @@ add_library(${UTIL_LIB} STATIC ${LIB_UTIL_SRC})
add_dependencies(${UTIL_LIB} genversion)
target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${CURL_INCLUDE_DIRS})
if(ANDROID)
set(LOG_LIB log)
endif()
target_link_libraries(${UTIL_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${LOG_LIB})
target_link_libraries(${UTIL_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${LOG_LIB} ${CURL_LIBRARIES})
target_link_libraries_system(${UTIL_LIB} absl::synchronization absl::hash absl::container nlohmann_json::nlohmann_json)
# cut back on fluff
@ -254,7 +253,7 @@ endif()
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
target_include_directories(${STATIC_LIB} PUBLIC ${CURL_INCLUDE_DIRS})
target_link_libraries(${STATIC_LIB} PUBLIC cxxopts ${ABYSS_LIB} ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB} ${CURL_LIBRARIES})
target_link_libraries(${STATIC_LIB} PUBLIC cxxopts ${ABYSS_LIB} ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB})
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_include_directories(${PLATFORM_LIB} SYSTEM PUBLIC /usr/local/include)

@ -20,7 +20,7 @@ namespace llarp
, m_ExitRouter(routerId)
, m_WritePacket(std::move(writepkt))
, m_Counter(0)
, m_LastUse(0)
, m_LastUse(r->Now())
, m_BundleRC(bundleRC)
{
CryptoManager::instance()->identity_keygen(m_ExitIdentity);
@ -127,7 +127,6 @@ namespace llarp
bool
BaseSession::HandleGotExit(llarp::path::Path_ptr p, llarp_time_t b)
{
m_LastUse = m_router->Now();
if(b == 0)
{
llarp::LogInfo("obtained an exit via ", p->Endpoint());
@ -202,11 +201,10 @@ namespace llarp
llarp::net::IPPacket pkt;
if(!pkt.Load(buf))
return false;
m_Downstream.emplace(counter, pkt);
m_LastUse = m_router->Now();
m_Downstream.emplace(counter, pkt);
return true;
}
return false;
}
@ -255,7 +253,7 @@ namespace llarp
bool
BaseSession::IsExpired(llarp_time_t now) const
{
return m_LastUse && now > m_LastUse && now - m_LastUse > LifeSpan;
return now > m_LastUse && now - m_LastUse > LifeSpan;
}
bool
@ -282,8 +280,7 @@ namespace llarp
if(path)
{
msg.S = path->NextSeqNo();
if(path->SendRoutingMessage(msg, m_router))
m_LastUse = now;
path->SendRoutingMessage(msg, m_router);
}
queue.pop_front();

@ -230,7 +230,7 @@ _llarp_nt_getadaptersinfo(struct llarp_nt_ifaddrs_t** ifap)
struct _llarp_nt_ifaddrs_t* ifa =
llarp_nt_new0(struct _llarp_nt_ifaddrs_t, n);
struct _llarp_nt_ifaddrs_t* ift = ifa;
int val = 0;
/* now populate list */
for(pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next)
{
@ -243,9 +243,9 @@ _llarp_nt_getadaptersinfo(struct llarp_nt_ifaddrs_t** ifap)
/* address */
ift->_ifa.ifa_addr = (struct sockaddr*)&ift->_addr;
assert(1
== llarp_nt_sockaddr_pton(pIPAddr->IpAddress.String,
ift->_ifa.ifa_addr));
val =
llarp_nt_sockaddr_pton(pIPAddr->IpAddress.String, ift->_ifa.ifa_addr);
assert(1 == val);
/* name */
#ifdef DEBUG
@ -262,9 +262,9 @@ _llarp_nt_getadaptersinfo(struct llarp_nt_ifaddrs_t** ifap)
/* netmask */
ift->_ifa.ifa_netmask = (sockaddr*)&ift->_netmask;
assert(1
== llarp_nt_sockaddr_pton(pIPAddr->IpMask.String,
ift->_ifa.ifa_netmask));
val =
llarp_nt_sockaddr_pton(pIPAddr->IpMask.String, ift->_ifa.ifa_netmask);
assert(1 == val);
/* next */
if(k++ < (n - 1))

@ -93,6 +93,17 @@ alternatively make a debian package with:
this puts the built packages in `../`
#### Static Linux
static native optimized:
$ make static STATIC_LINK=ON
cross compile fully static armhf (rpi 2 and up)
$ make static STATIC_LINK=ON DOWNLOAD_SODIUM=ON TOOLCHAIN=contrib/cross/armhf.toolchain.cmake
### MacOS
build:

Loading…
Cancel
Save