mirror of https://github.com/oxen-io/lokinet
Merge remote-tracking branch 'upstream/dev' into vpn-api-2019-10-03
This commit is contained in:
commit
869ab0b652
|
@ -133,6 +133,7 @@ addons:
|
|||
- gcc-mingw-w64-base
|
||||
- git
|
||||
- libcap-dev
|
||||
- libcurl4-openssl-dev
|
||||
- libuv1-dev
|
||||
- mingw-w64 mingw-w64-common
|
||||
- ninja-build
|
||||
|
@ -140,6 +141,7 @@ addons:
|
|||
packages:
|
||||
- ccache
|
||||
- cmake
|
||||
- curl
|
||||
- libuv
|
||||
- llvm
|
||||
- make
|
||||
|
@ -148,7 +150,7 @@ addons:
|
|||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then
|
||||
choco install make ninja;
|
||||
choco install curl make ninja;
|
||||
choco upgrade cmake.install;
|
||||
export CC="/c/Program Files/LLVM/bin/clang-cl";
|
||||
export CXX="/c/Program Files/LLVM/bin/clang-cl";
|
||||
|
|
104
CMakeLists.txt
104
CMakeLists.txt
|
@ -1,5 +1,4 @@
|
|||
# Lowest version - android ndk 3.6.0
|
||||
cmake_minimum_required(VERSION 3.6.0)
|
||||
cmake_minimum_required(VERSION 3.5.1) # xenial's cmake version
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
|
@ -103,6 +102,11 @@ endif(WITH_SHELLHOOKS)
|
|||
# Always build PIC
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(TRACY_ROOT)
|
||||
include_directories(${TRACY_ROOT})
|
||||
add_definitions(-DTRACY_ENABLE)
|
||||
endif()
|
||||
|
||||
set(ABSEIL_DIR vendor/abseil-cpp)
|
||||
include_directories(SYSTEM ${ABSEIL_DIR})
|
||||
add_subdirectory(vendor/cxxopts)
|
||||
|
@ -199,14 +203,6 @@ endif(NOT GIT_VERSION)
|
|||
string(REGEX REPLACE "^fatal.*$" nogit GIT_VERSION_REAL "${GIT_VERSION}")
|
||||
add_definitions("-DGIT_REV=\"${GIT_VERSION_REAL}\"")
|
||||
|
||||
set(EXE lokinet)
|
||||
set(EXE_SRC daemon/main.cpp)
|
||||
if(TRACY_ROOT)
|
||||
include_directories(${TRACY_ROOT})
|
||||
add_definitions(-DTRACY_ENABLE)
|
||||
list(APPEND EXE_SRC ${TRACY_ROOT}/TracyClient.cpp)
|
||||
endif()
|
||||
|
||||
# HeapAlloc(2) on Windows was significantly revamped in 2009
|
||||
# but the old algorithm isn't too bad either
|
||||
# this is _the_ system allocator on BSD UNIX
|
||||
|
@ -222,17 +218,6 @@ if(ANDROID)
|
|||
set(ANDROID_PLATFORM_SRC android/ifaddrs.c)
|
||||
endif(ANDROID)
|
||||
|
||||
set(LIBTUNTAP_SRC_BASE
|
||||
${TT_ROOT}/tuntap.cpp
|
||||
${TT_ROOT}/tuntap_log.cpp
|
||||
${LIBTUNTAP_IMPL})
|
||||
|
||||
if(UNIX)
|
||||
set(LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix.c ${LIBTUNTAP_SRC_BASE})
|
||||
else()
|
||||
set(LIBTUNTAP_SRC ${LIBTUNTAP_SRC_BASE})
|
||||
endif()
|
||||
|
||||
set(LIBS ${MALLOC_LIB} ${FS_LIB} ${LIBUV_LIBRARY})
|
||||
if(TRACY_ROOT)
|
||||
list(APPEND LIBS -ldl)
|
||||
|
@ -241,82 +226,13 @@ endif()
|
|||
add_subdirectory(crypto)
|
||||
add_subdirectory(llarp)
|
||||
add_subdirectory(libabyss)
|
||||
|
||||
if (NOT WIN32)
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} Threads::Threads ${LIBS})
|
||||
elseif(NOT MSVC_VERSION)
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp llarp/win32/abyss.rc)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
else()
|
||||
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
endif(NOT WIN32)
|
||||
|
||||
|
||||
# Why does abyss not inherit the existing include folders?
|
||||
target_include_directories(${ABYSS_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include" llarp vendor/nlohmann/include include crypto/include)
|
||||
target_include_directories(${ABYSS_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include" llarp vendor/nlohmann/include include crypto/include)
|
||||
|
||||
# for freebsd
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_link_directories(${ABYSS_EXE} PRIVATE /usr/local/lib)
|
||||
target_include_directories(${ABYSS_LIB} SYSTEM PUBLIC /usr/local/include)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
add_log_tag(${ABYSS_EXE})
|
||||
add_log_tag(${ABYSS_LIB})
|
||||
|
||||
|
||||
if(SHADOW)
|
||||
set(LOKINET_SHADOW shadow-plugin-${SHARED_LIB})
|
||||
set(LOKINET_SHADOW_LIBS ${SHARED_LIB})
|
||||
add_shadow_plugin(${LOKINET_SHADOW} ${EXE_SRC})
|
||||
target_link_libraries(${LOKINET_SHADOW} ${LOKINET_SHADOW_LIBS})
|
||||
target_include_directories(${LOKINET_SHADOW} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/llarp ${PROJECT_SOURCE_DIR}/crypto/include)
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
add_executable(${EXE} ${EXE_SRC})
|
||||
if(TRACY_ROOT)
|
||||
add_executable(lokinet-rcutil daemon/rcutil.cpp ${TRACY_ROOT}/TracyClient.cpp)
|
||||
else()
|
||||
add_executable(lokinet-rcutil daemon/rcutil.cpp)
|
||||
endif()
|
||||
elseif(NOT MSVC_VERSION)
|
||||
add_executable(${EXE} ${EXE_SRC} llarp/win32/version.rc)
|
||||
add_executable(lokinet-rcutil daemon/rcutil.cpp llarp/win32/version.rc)
|
||||
else()
|
||||
add_executable(${EXE} ${EXE_SRC})
|
||||
add_executable(lokinet-rcutil daemon/rcutil.cpp)
|
||||
endif(NOT WIN32)
|
||||
|
||||
add_log_tag(${EXE})
|
||||
add_log_tag(lokinet-rcutil)
|
||||
|
||||
install(TARGETS ${EXE} RUNTIME DESTINATION bin)
|
||||
install(TARGETS lokinet-rcutil RUNTIME DESTINATION bin)
|
||||
if(WIN32)
|
||||
install(PROGRAMS ${CMAKE_SOURCE_DIR}/lokinet-bootstrap.exe DESTINATION bin)
|
||||
else()
|
||||
install(PROGRAMS ${CMAKE_SOURCE_DIR}/lokinet-bootstrap DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
install(CODE "execute_process(COMMAND setcap cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_link_directories(${EXE} PRIVATE /usr/local/lib)
|
||||
target_link_directories(lokinet-rcutil PRIVATE /usr/local/lib)
|
||||
endif()
|
||||
target_link_libraries(${EXE} PUBLIC ${EXE_LIBS} ${LIBS})
|
||||
target_link_libraries(lokinet-rcutil PUBLIC ${EXE_LIBS} ${LIBS})
|
||||
|
||||
if(ANDROID)
|
||||
add_subdirectory(jni)
|
||||
endif(ANDROID)
|
||||
endif(SHADOW)
|
||||
add_subdirectory(daemon)
|
||||
|
||||
enable_testing()
|
||||
|
||||
if (NOT SHADOW)
|
||||
add_subdirectory(test)
|
||||
if(ANDROID)
|
||||
add_subdirectory(jni)
|
||||
endif(ANDROID)
|
||||
endif()
|
||||
|
|
2
Makefile
2
Makefile
|
@ -120,7 +120,7 @@ endif
|
|||
|
||||
TARGETS = $(REPO)/lokinet
|
||||
SIGS = $(TARGETS:=.sig)
|
||||
EXE = $(BUILD_ROOT)/lokinet
|
||||
EXE = $(BUILD_ROOT)/daemon/lokinet
|
||||
TEST_EXE = $(BUILD_ROOT)/test/testAll
|
||||
ABYSS_EXE = $(BUILD_ROOT)/abyss-main
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
function(add_log_tag target)
|
||||
get_target_property(TARGET_SRCS ${target} SOURCES)
|
||||
foreach(F ${TARGET_SRCS})
|
||||
set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\")
|
||||
endforeach(F)
|
||||
if(TARGET ${target})
|
||||
get_target_property(TARGET_SRCS ${target} SOURCES)
|
||||
foreach(F ${TARGET_SRCS})
|
||||
set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\")
|
||||
endforeach(F)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -9,8 +9,12 @@ set(ANDROID_LIB ${LIB}android)
|
|||
set(ABYSS libabyss)
|
||||
set(ABYSS_LIB abyss)
|
||||
set(ABYSS_EXE ${ABYSS_LIB}-main)
|
||||
get_filename_component(TT_ROOT "vendor/libtuntap-master" ABSOLUTE)
|
||||
get_filename_component(TT_ROOT "${CMAKE_CURRENT_LIST_DIR}/../vendor/libtuntap-master" ABSOLUTE)
|
||||
add_definitions(-D${CMAKE_SYSTEM_NAME})
|
||||
|
||||
get_filename_component(CORE_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include" ABSOLUTE)
|
||||
get_filename_component(ABYSS_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include" ABSOLUTE)
|
||||
|
||||
set(LIBTUNTAP_SRC
|
||||
${TT_ROOT}/tuntap.cpp
|
||||
${TT_ROOT}/tuntap_log.cpp)
|
||||
|
|
|
@ -7,6 +7,7 @@ include(CheckLibraryExists)
|
|||
|
||||
add_definitions(-DUNIX)
|
||||
add_definitions(-DPOSIX)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix.c)
|
||||
|
||||
if (STATIC_LINK_RUNTIME OR STATIC_LINK)
|
||||
set(LIBUV_USE_STATIC ON)
|
||||
|
@ -30,7 +31,7 @@ endif()
|
|||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FS_LIB stdc++fs)
|
||||
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c ABSOLUTE)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-linux.c)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
find_library(FS_LIB NAMES c++fs c++experimental stdc++fs)
|
||||
if(FS_LIB STREQUAL FS_LIB-NOTFOUND)
|
||||
|
@ -38,14 +39,14 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|||
add_definitions(-DLOKINET_USE_CPPBACKPORT)
|
||||
set(FS_LIB cppbackport)
|
||||
endif()
|
||||
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c ABSOLUTE)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-linux.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-openbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-openbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-netbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-netbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
|
||||
find_library(FS_LIB NAMES c++experimental)
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-freebsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-freebsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "iOS")
|
||||
find_library(FS_LIB NAMES c++fs c++experimental stdc++fs)
|
||||
if(FS_LIB STREQUAL FS_LIB-NOTFOUND)
|
||||
|
@ -53,9 +54,9 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "i
|
|||
add_definitions(-DLOKINET_USE_CPPBACKPORT)
|
||||
set(FS_LIB cppbackport)
|
||||
endif()
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-darwin.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-darwin.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-sunos.c)
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-sunos.c)
|
||||
# Apple C++ screws up name decorations in stdc++fs, causing link to fail
|
||||
# Samsung does not build c++experimental or c++fs in their Apple libc++ pkgsrc build
|
||||
if (LIBUV_USE_STATIC)
|
||||
|
|
|
@ -21,17 +21,17 @@ if(NOT MSVC_VERSION)
|
|||
# to .r[o]data section one after the other!
|
||||
add_compile_options(-fno-ident -Wa,-mbig-obj)
|
||||
link_libraries( -lws2_32 -liphlpapi -lshlwapi -ldbghelp )
|
||||
add_definitions(-DWINVER=0x0500 -D_WIN32_WINNT=0x0500)
|
||||
# Wait a minute, if we're not Microsoft C++, nor a Clang paired with Microsoft C++,
|
||||
# then the only possible option has to be GNU or a GNU-linked Clang!
|
||||
add_definitions(-DWINVER=0x0500 -D_WIN32_WINNT=0x0500)
|
||||
# Wait a minute, if we're not Microsoft C++, nor a Clang paired with Microsoft C++,
|
||||
# then the only possible option has to be GNU or a GNU-linked Clang!
|
||||
set(FS_LIB stdc++fs)
|
||||
endif()
|
||||
|
||||
if(EMBEDDED_CFG)
|
||||
link_libatomic()
|
||||
|
||||
if(EMBEDDED_CFG)
|
||||
link_libatomic()
|
||||
endif()
|
||||
|
||||
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-windows.c ABSOLUTE)
|
||||
|
||||
list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-windows.c)
|
||||
get_filename_component(EV_SRC "llarp/ev/ev_win32.cpp" ABSOLUTE)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x0500)
|
||||
set(EXE_LIBS ${STATIC_LIB} ${FS_LIB} ws2_32 iphlpapi)
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
set(EXE lokinet)
|
||||
set(EXE_SRC main.cpp)
|
||||
set(CTL lokinetctl)
|
||||
set(CTL_SRC lokinetctl.cpp)
|
||||
|
||||
if(TRACY_ROOT)
|
||||
list(APPEND EXE_SRC ${TRACY_ROOT}/TracyClient.cpp)
|
||||
endif()
|
||||
|
||||
if(SHADOW)
|
||||
set(LOKINET_SHADOW shadow-plugin-${SHARED_LIB})
|
||||
set(LOKINET_SHADOW_LIBS ${SHARED_LIB})
|
||||
add_shadow_plugin(${LOKINET_SHADOW} ${EXE_SRC})
|
||||
target_link_libraries(${LOKINET_SHADOW} ${LOKINET_SHADOW_LIBS})
|
||||
target_include_directories(${LOKINET_SHADOW} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/llarp ${PROJECT_SOURCE_DIR}/crypto/include)
|
||||
else()
|
||||
if(WIN32 AND NOT MSVC_VERSION)
|
||||
list(APPEND ${EXE_SRC} llarp/win32/version.rc)
|
||||
list(APPEND ${CTL_SRC} llarp/win32/version.rc)
|
||||
endif()
|
||||
|
||||
add_executable(${EXE} ${EXE_SRC})
|
||||
add_executable(${CTL} ${CTL_SRC})
|
||||
|
||||
add_log_tag(${EXE})
|
||||
add_log_tag(${CTL})
|
||||
|
||||
install(TARGETS ${EXE} RUNTIME DESTINATION bin)
|
||||
install(TARGETS ${CTL} RUNTIME DESTINATION bin)
|
||||
if(WIN32)
|
||||
install(PROGRAMS ${CMAKE_SOURCE_DIR}/lokinet-bootstrap.exe DESTINATION bin)
|
||||
else()
|
||||
install(PROGRAMS ${CMAKE_SOURCE_DIR}/lokinet-bootstrap DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
install(CODE "execute_process(COMMAND setcap cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_link_directories(${EXE} PRIVATE /usr/local/lib)
|
||||
target_link_directories(${CTL} PRIVATE /usr/local/lib)
|
||||
endif()
|
||||
target_link_libraries(${EXE} PUBLIC ${EXE_LIBS} ${LIBS})
|
||||
target_link_libraries(${CTL} PUBLIC ${EXE_LIBS} ${LIBS})
|
||||
|
||||
find_package(CURL)
|
||||
|
||||
if(CURL_FOUND)
|
||||
target_include_directories(${CTL} PRIVATE ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(${CTL} PRIVATE ${CURL_LIBRARIES})
|
||||
target_compile_definitions(${CTL} PRIVATE -DWITH_CURL=1)
|
||||
endif(CURL_FOUND)
|
||||
|
||||
endif(SHADOW)
|
301
daemon/dns.cpp
301
daemon/dns.cpp
|
@ -1,301 +0,0 @@
|
|||
#include <config.hpp>
|
||||
#include <dns_dotlokilookup.hpp>
|
||||
#include <dns_iptracker.hpp>
|
||||
#include <dnsd.hpp>
|
||||
#include <llarp.h>
|
||||
#include <threading.hpp> // for multithreaded version (multiplatorm)
|
||||
|
||||
#include <signal.h> // Linux needs this for SIGINT
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define uint UINT
|
||||
#endif
|
||||
|
||||
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
// CHECK: is multiprocess still a thing?
|
||||
#ifndef TESTNET
|
||||
#define TESTNET 0
|
||||
#endif
|
||||
|
||||
struct llarp_main *ctx = 0;
|
||||
bool done = false;
|
||||
|
||||
void
|
||||
handle_signal(int sig)
|
||||
{
|
||||
printf("got SIGINT\n");
|
||||
done = true;
|
||||
// if using router, signal it
|
||||
if(ctx)
|
||||
llarp_main_signal(ctx, sig);
|
||||
}
|
||||
|
||||
struct dns_relay_config
|
||||
{
|
||||
std::string upstream_host;
|
||||
uint16_t upstream_port;
|
||||
|
||||
void
|
||||
dns_iter_config(const char *section, const char *key, const char *val)
|
||||
{
|
||||
if(!strcmp(section, "dns"))
|
||||
{
|
||||
if(!strcmp(key, "upstream-server"))
|
||||
{
|
||||
upstream_host = strdup(val);
|
||||
llarp::LogDebug("Config file setting dns server to ", upstream_host);
|
||||
}
|
||||
if(!strcmp(key, "upstream-port"))
|
||||
{
|
||||
upstream_port = atoi(val);
|
||||
llarp::LogDebug("Config file setting dns server port to ",
|
||||
upstream_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int code = 1;
|
||||
char cwd[1024];
|
||||
char *ptr = getcwd(cwd, sizeof(cwd));
|
||||
llarp::LogInfo("Starting up server at ", ptr);
|
||||
|
||||
const char *conffname = handleBaseCmdLineArgs(argc, argv);
|
||||
dns_relay_config dnsr_config;
|
||||
dnsr_config.upstream_host = "8.8.8.8";
|
||||
dnsr_config.upstream_port = 53;
|
||||
llarp::Config config_reader;
|
||||
|
||||
if(config_reader.load(conffname))
|
||||
{
|
||||
llarp::LogError("failed to load config file ", conffname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
using namespace std::placeholders;
|
||||
config_reader.visit(
|
||||
std::bind(&dns_relay_config::dns_iter_config, &dnsr_config, _1, _2, _3));
|
||||
llarp::LogInfo("config [", conffname, "] loaded");
|
||||
|
||||
const uint16_t server_port = 53;
|
||||
|
||||
dns_iptracker_init();
|
||||
|
||||
// llarp::SetLogLevel(llarp::eLogDebug);
|
||||
|
||||
bool enableDLL = false;
|
||||
bool useLlarp = true;
|
||||
|
||||
if(enableDLL)
|
||||
{
|
||||
// libev version w/router context
|
||||
ctx = llarp_main_init(conffname, !TESTNET);
|
||||
if(!ctx)
|
||||
{
|
||||
llarp::LogError("Cant set up context");
|
||||
return 0;
|
||||
}
|
||||
llarp_main_setup(ctx);
|
||||
signal(SIGINT, handle_signal);
|
||||
|
||||
// we can't programmatic force a client
|
||||
// but we'll need to be one...
|
||||
|
||||
/*
|
||||
struct dnsd_context dnsd;
|
||||
llarp::Addr dnsd_sockaddr(127, 0, 0, 1, 53);
|
||||
llarp::Addr dnsc_sockaddr(dnsr_config.upstream_host,
|
||||
dnsr_config.upstream_port);
|
||||
// server_port, (const char *)dnsr_config.upstream_host.c_str(),
|
||||
// dnsr_config.upstream_port
|
||||
if(!llarp_main_init_dnsd(ctx, &dnsd, dnsd_sockaddr, dnsc_sockaddr))
|
||||
{
|
||||
llarp::LogError("Couldnt init dns daemon");
|
||||
}
|
||||
// Configure intercept
|
||||
dnsd.intercept = &llarp_dotlokilookup_handler;
|
||||
dotLokiLookup dll;
|
||||
*/
|
||||
// should be a function...
|
||||
// dll.tunEndpoint = main_router_getFirstTunEndpoint(ctx);
|
||||
// dll.ip_tracker = &g_dns_iptracker;
|
||||
/*
|
||||
llarp_main_init_dotLokiLookup(ctx, &dll);
|
||||
dnsd.user = &dll;
|
||||
|
||||
// check tun set up
|
||||
llarp_tun_io *tun = main_router_getRange(ctx);
|
||||
llarp::LogDebug("TunNetmask: ", tun->netmask);
|
||||
llarp::LogDebug("TunIfAddr: ", tun->ifaddr);
|
||||
|
||||
// configure dns_ip_tracker to use this
|
||||
// well our routes table should already be set up
|
||||
|
||||
// mark our TunIfAddr as used
|
||||
if(tun)
|
||||
{
|
||||
dll.user = tun;
|
||||
struct sockaddr_in addr;
|
||||
addr.sin_addr.s_addr = inet_addr(tun->ifaddr);
|
||||
addr.sin_family = AF_INET;
|
||||
|
||||
llarp::Addr tunIp(addr);
|
||||
llarp::LogDebug("llarp::TunIfAddr: ", tunIp);
|
||||
dns_iptracker_setup_dotLokiLookup(&dll, tunIp);
|
||||
dns_iptracker_setup(tunIp);
|
||||
}
|
||||
else
|
||||
{
|
||||
llarp::LogWarn("No tun interface, can't look up .loki");
|
||||
}
|
||||
*/
|
||||
|
||||
// run system and wait
|
||||
llarp_main_run(ctx);
|
||||
llarp_main_free(ctx);
|
||||
}
|
||||
else if(useLlarp)
|
||||
{
|
||||
// libev version
|
||||
llarp_ev_loop *netloop = nullptr;
|
||||
llarp_threadpool *worker = nullptr;
|
||||
llarp::Logic *logic = nullptr;
|
||||
|
||||
llarp_ev_loop_alloc(&netloop); // set up netio worker
|
||||
worker = llarp_init_same_process_threadpool();
|
||||
logic = new llarp::Logic(worker); // set up logic worker
|
||||
|
||||
// configure main netloop
|
||||
struct dnsd_context dnsd;
|
||||
llarp::Addr dnsd_sockaddr(127, 0, 0, 1, 53);
|
||||
llarp::Addr dnsc_sockaddr(dnsr_config.upstream_host,
|
||||
dnsr_config.upstream_port);
|
||||
llarp::LogInfo("dnsd_sockaddr init: ", dnsd_sockaddr);
|
||||
llarp::LogInfo("dnsc_sockaddr init: ", dnsc_sockaddr);
|
||||
if(!llarp_dnsd_init(&dnsd, logic, netloop, dnsd_sockaddr, dnsc_sockaddr))
|
||||
{
|
||||
// llarp::LogError("failed to initialize dns subsystem");
|
||||
llarp::LogError("Couldnt init dns daemon");
|
||||
return 0;
|
||||
}
|
||||
// Configure intercept
|
||||
dnsd.intercept = &llarp_dotlokilookup_handler;
|
||||
|
||||
llarp::LogInfo("singlethread start");
|
||||
llarp_ev_loop_run_single_process(netloop, worker, logic);
|
||||
llarp::LogInfo("singlethread end");
|
||||
|
||||
llarp_ev_loop_free(&netloop);
|
||||
}
|
||||
else
|
||||
{
|
||||
// need this for timer stuff
|
||||
llarp_threadpool *worker = llarp_init_same_process_threadpool();
|
||||
llarp::Logic *logic = new llarp::Logic(worker);
|
||||
|
||||
// configure main netloop
|
||||
struct dnsd_context dnsd;
|
||||
llarp::Addr dnsd_sockaddr(127, 0, 0, 1, 53);
|
||||
llarp::Addr dnsc_sockaddr(dnsr_config.upstream_host,
|
||||
dnsr_config.upstream_port);
|
||||
if(!llarp_dnsd_init(&dnsd, logic, nullptr, dnsd_sockaddr, dnsc_sockaddr))
|
||||
{
|
||||
// llarp::LogError("failed to initialize dns subsystem");
|
||||
llarp::LogError("Couldnt init dns daemon");
|
||||
return 0;
|
||||
}
|
||||
// Configure intercept
|
||||
dnsd.intercept = &llarp_dotlokilookup_handler;
|
||||
|
||||
struct sockaddr_in m_address;
|
||||
int m_sockfd;
|
||||
|
||||
#ifndef _WIN32
|
||||
m_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
#else
|
||||
m_sockfd =
|
||||
WSASocket(AF_INET, SOCK_DGRAM, 0, nullptr, 0, WSA_FLAG_OVERLAPPED);
|
||||
#endif
|
||||
m_address.sin_family = AF_INET;
|
||||
m_address.sin_addr.s_addr = INADDR_ANY;
|
||||
m_address.sin_port = htons(server_port);
|
||||
int rbind = bind(m_sockfd, (struct sockaddr *)&m_address,
|
||||
sizeof(struct sockaddr_in));
|
||||
|
||||
if(rbind != 0)
|
||||
{
|
||||
llarp::LogError("Could not bind: ", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const size_t BUFFER_SIZE = 1024;
|
||||
char buffer[BUFFER_SIZE]; // 1024 is buffer size
|
||||
struct sockaddr_in clientAddress;
|
||||
socklen_t addrLen = sizeof(struct sockaddr_in);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100 * 1000; // 1 sec
|
||||
#ifndef _WIN32
|
||||
if(setsockopt(m_sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
|
||||
#else
|
||||
if(setsockopt(m_sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv,
|
||||
sizeof(tv))
|
||||
< 0)
|
||||
#endif
|
||||
{
|
||||
perror("Error");
|
||||
}
|
||||
|
||||
signal(SIGINT, handle_signal);
|
||||
while(!done)
|
||||
{
|
||||
// sigint quits after next packet
|
||||
int nbytes = recvfrom(m_sockfd, buffer, BUFFER_SIZE, 0,
|
||||
(struct sockaddr *)&clientAddress, &addrLen);
|
||||
if(nbytes == -1)
|
||||
continue;
|
||||
llarp::LogInfo("Received Bytes ", nbytes);
|
||||
|
||||
llarp_buffer_t lbuffer;
|
||||
lbuffer.base = (byte_t *)buffer;
|
||||
lbuffer.cur = lbuffer.base;
|
||||
lbuffer.sz = nbytes;
|
||||
|
||||
dns_msg_header hdr;
|
||||
if(!decode_hdr(&lbuffer, &hdr))
|
||||
{
|
||||
llarp::LogError("failed to decode dns header");
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we sent this out, then there's an id
|
||||
struct dns_tracker *tracker = (struct dns_tracker *)dnsd.client.tracker;
|
||||
struct dnsc_answer_request *request =
|
||||
tracker->client_request[hdr.id].get();
|
||||
|
||||
if(request)
|
||||
{
|
||||
request->packet.header = hdr;
|
||||
generic_handle_dnsc_recvfrom(tracker->client_request[hdr.id].get(),
|
||||
lbuffer, &hdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
llarp::LogWarn("Ignoring multiple responses on ID #", hdr.id);
|
||||
}
|
||||
|
||||
// raw_handle_recvfrom(&m_sockfd, (const struct sockaddr *)&clientAddress,
|
||||
// buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
#include <config/config.hpp>
|
||||
#include <router_contact.hpp>
|
||||
#include <util/logging/logger.hpp>
|
||||
#include <util/logging/ostream_logger.hpp>
|
||||
|
||||
#include <absl/synchronization/mutex.h>
|
||||
#include <cxxopts.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef WITH_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
bool
|
||||
dumpRc(const std::vector< std::string >& files)
|
||||
{
|
||||
nlohmann::json result;
|
||||
for(const auto& file : files)
|
||||
{
|
||||
llarp::RouterContact rc;
|
||||
const bool ret = rc.Read(file.c_str());
|
||||
|
||||
if(ret)
|
||||
{
|
||||
result[file] = rc.ToJson();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "file = " << file << " was not a valid rc file\n";
|
||||
}
|
||||
}
|
||||
std::cout << result << "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_CURL
|
||||
|
||||
size_t
|
||||
curlCallback(void* contents, size_t size, size_t nmemb, void* userp) noexcept
|
||||
{
|
||||
auto* str = static_cast< std::string* >(userp);
|
||||
size_t realsize = size * nmemb;
|
||||
|
||||
char* asChar = static_cast< char* >(contents);
|
||||
|
||||
std::copy(asChar, asChar + realsize, std::back_inserter(*str));
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
bool
|
||||
executeJsonRpc(const std::string& command, const std::string& configFile)
|
||||
{
|
||||
// Do init (on windows this will do socket initialisation)
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
llarp::Config config;
|
||||
if(!config.Load(configFile.c_str()))
|
||||
{
|
||||
llarp::LogError("Failed to load from config file: ", configFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!config.api.enableRPCServer())
|
||||
{
|
||||
llarp::LogError("Config does not have RPC enabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string address = config.api.rpcBindAddr() + "/jsonrpc";
|
||||
|
||||
const nlohmann::json request{{"method", command},
|
||||
{"params", nlohmann::json::object()},
|
||||
{"id", "foo"}};
|
||||
|
||||
const std::string requestStr = request.dump();
|
||||
|
||||
std::unique_ptr< curl_slist, void (*)(curl_slist*) > chunk(
|
||||
curl_slist_append(nullptr, "content-type: application/json"),
|
||||
&curl_slist_free_all);
|
||||
|
||||
std::unique_ptr< CURL, void (*)(CURL*) > curl(curl_easy_init(),
|
||||
&curl_easy_cleanup);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_URL, address.c_str());
|
||||
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS, requestStr.c_str());
|
||||
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDSIZE, requestStr.size());
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, chunk.get());
|
||||
|
||||
std::string result;
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, curlCallback);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &result);
|
||||
|
||||
auto res = curl_easy_perform(curl.get());
|
||||
if(res != CURLE_OK)
|
||||
{
|
||||
llarp::LogError("Failed to curl endpoint, ", curl_easy_strerror(res));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << result << "\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef LOKINET_DEBUG
|
||||
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
cxxopts::Options options(
|
||||
"lokinetctl",
|
||||
"LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network"
|
||||
);
|
||||
|
||||
options.add_options()
|
||||
("v,verbose", "Verbose", cxxopts::value<bool>())
|
||||
("h,help", "help", cxxopts::value<bool>())
|
||||
("c,config", "config file", cxxopts::value<std::string>()->default_value(llarp::GetDefaultConfigPath().string()))
|
||||
#ifdef WITH_CURL
|
||||
("j,jsonrpc", "hit json rpc endpoint", cxxopts::value<std::string>())
|
||||
#endif
|
||||
("dump", "dump rc file", cxxopts::value<std::vector<std::string> >(), "FILE");
|
||||
// clang-format on
|
||||
|
||||
try
|
||||
{
|
||||
const auto result = options.parse(argc, argv);
|
||||
|
||||
if(result.count("verbose") > 0)
|
||||
{
|
||||
SetLogLevel(llarp::eLogDebug);
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique< llarp::OStreamLogStream >(true, std::cerr);
|
||||
llarp::LogDebug("debug logging activated");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLogLevel(llarp::eLogError);
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique< llarp::OStreamLogStream >(true, std::cerr);
|
||||
}
|
||||
|
||||
if(result.count("help") > 0)
|
||||
{
|
||||
std::cout << options.help() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(result.count("dump") > 0)
|
||||
{
|
||||
if(!dumpRc(result["dump"].as< std::vector< std::string > >()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_CURL
|
||||
if(result.count("jsonrpc") > 0)
|
||||
{
|
||||
if(!executeJsonRpc(result["jsonrpc"].as< std::string >(),
|
||||
result["config"].as< std::string >()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch(const cxxopts::OptionParseException& ex)
|
||||
{
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -282,14 +282,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
// no explicit config file provided
|
||||
#ifdef _WIN32
|
||||
fs::path homedir = fs::path(getenv("APPDATA"));
|
||||
#else
|
||||
fs::path homedir = fs::path(getenv("HOME"));
|
||||
#endif
|
||||
fs::path basepath = homedir / fs::path(".lokinet");
|
||||
fs::path fpath = basepath / "lokinet.ini";
|
||||
auto basepath = llarp::GetDefaultConfigDir();
|
||||
// I don't think this is necessary with this condition
|
||||
// conffname = resolvePath(conffname);
|
||||
|
||||
|
@ -307,6 +300,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
auto fpath = llarp::GetDefaultConfigPath();
|
||||
|
||||
// if using default INI file, we're create it even if you don't ask us too
|
||||
if(!llarp_ensure_config(fpath.string().c_str(), basepath.string().c_str(),
|
||||
overWrite, asRouter))
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
#include <router_contact.hpp>
|
||||
#include <util/logging/logger.hpp>
|
||||
#include <util/logging/ostream_logger.hpp>
|
||||
|
||||
#include <absl/synchronization/mutex.h>
|
||||
#include <cxxopts.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool
|
||||
dumpRc(const std::vector< std::string >& files, bool json)
|
||||
{
|
||||
nlohmann::json result;
|
||||
for(const auto& file : files)
|
||||
{
|
||||
llarp::RouterContact rc;
|
||||
const bool ret = rc.Read(file.c_str());
|
||||
|
||||
if(ret)
|
||||
{
|
||||
if(json)
|
||||
{
|
||||
result[file] = rc.ToJson();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "file = " << file << "\n";
|
||||
std::cout << rc << "\n\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "file = " << file << " was not a valid rc file\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(json)
|
||||
std::cout << result << "\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef LOKINET_DEBUG
|
||||
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
cxxopts::Options options(
|
||||
"lokinet-rcutil",
|
||||
"LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network"
|
||||
);
|
||||
|
||||
options.add_options()
|
||||
("v,verbose", "Verbose", cxxopts::value<bool>())
|
||||
("c,colour", "colour output", cxxopts::value<bool>()->default_value("true"))
|
||||
("h,help", "help", cxxopts::value<bool>())
|
||||
("j,json", "output in json", cxxopts::value<bool>())
|
||||
("dump", "dump rc file", cxxopts::value<std::vector<std::string> >(), "FILE");
|
||||
// clang-format on
|
||||
|
||||
try
|
||||
{
|
||||
const auto result = options.parse(argc, argv);
|
||||
|
||||
const bool json = result["json"].as< bool >();
|
||||
|
||||
if(result.count("verbose") > 0)
|
||||
{
|
||||
SetLogLevel(llarp::eLogDebug);
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique< llarp::OStreamLogStream >(
|
||||
result["colour"].as< bool >(), std::cerr);
|
||||
llarp::LogDebug("debug logging activated");
|
||||
}
|
||||
|
||||
if(result.count("help") > 0)
|
||||
{
|
||||
std::cout << options.help() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(result.count("dump") > 0)
|
||||
{
|
||||
if(!dumpRc(result["dump"].as< std::vector< std::string > >(), json))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const cxxopts::OptionParseException& ex)
|
||||
{
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -12,5 +12,5 @@ RUN make NINJA=ninja STATIC_LINK=ON BUILD_TYPE=Release
|
|||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY --from=builder /src/build/lokinet /
|
||||
COPY --from=builder /src/build/lokinet-rcutil /
|
||||
COPY --from=builder /src/build/daemon/lokinet /
|
||||
COPY --from=builder /src/build/daemon/lokinet-ctl /
|
||||
|
|
|
@ -13,7 +13,7 @@ RUN ./lokinet-bootstrap ${bootstrap}
|
|||
FROM alpine:latest
|
||||
|
||||
COPY lokinet-docker.ini /root/.lokinet/lokinet.ini
|
||||
COPY --from=builder /src/build/lokinet .
|
||||
COPY --from=builder /src/build/daemon/lokinet .
|
||||
COPY --from=builder /root/.lokinet/bootstrap.signed /root/.lokinet/
|
||||
|
||||
CMD ["./lokinet"]
|
||||
|
|
|
@ -4,6 +4,25 @@ add_library(${ABYSS_LIB} "${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp"
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/src/server.cpp")
|
||||
|
||||
target_include_directories(${ABYSS_LIB} PUBLIC include)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB} ${LIBUV_LIBRARY})
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB})
|
||||
|
||||
if(NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${LIBUV_LIBRARY})
|
||||
add_executable(${ABYSS_EXE} main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} Threads::Threads ${LIBS})
|
||||
elseif(MSVC_VERSION)
|
||||
add_executable(${ABYSS_EXE} main.cpp)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
add_executable(${ABYSS_EXE} main.cpp llarp/win32/abyss.rc)
|
||||
target_link_libraries(${ABYSS_EXE} PUBLIC ${ABYSS_LIB} ${STATIC_LIB} ws2_32)
|
||||
endif()
|
||||
|
||||
# for freebsd
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
target_link_directories(${ABYSS_EXE} PRIVATE /usr/local/lib)
|
||||
target_include_directories(${ABYSS_LIB} SYSTEM PUBLIC /usr/local/include)
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
|
||||
add_log_tag(${ABYSS_EXE})
|
||||
add_log_tag(${ABYSS_LIB})
|
||||
|
|
|
@ -475,6 +475,23 @@ namespace llarp
|
|||
return true;
|
||||
}
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigDir()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const fs::path homedir = fs::path(getenv("APPDATA"));
|
||||
#else
|
||||
const fs::path homedir = fs::path(getenv("HOME"));
|
||||
#endif
|
||||
return homedir / fs::path(".lokinet");
|
||||
}
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigPath()
|
||||
{
|
||||
return GetDefaultConfigDir() / "lokinet.ini";
|
||||
}
|
||||
|
||||
} // namespace llarp
|
||||
|
||||
/// fname should be a relative path (from CWD) or absolute path to the config
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace llarp
|
|||
std::string transportKeyfile() const { return fromEnv(m_transportKeyfile, "TRANSPORT_KEYFILE"); }
|
||||
std::string identKeyfile() const { return fromEnv(m_identKeyfile, "IDENT_KEYFILE"); }
|
||||
std::string netId() const { return fromEnv(m_netId, "NETID"); }
|
||||
std::string nickname() const { return fromEnv(m_nickname, "NICKNAME"); }
|
||||
std::string nickname() const { return fromEnv(m_nickname, "NICKNAME"); }
|
||||
bool publicOverride() const { return fromEnv(m_publicOverride, "PUBLIC_OVERRIDE"); }
|
||||
const struct sockaddr_in& ip4addr() const { return m_ip4addr; }
|
||||
const AddressInfo& addrInfo() const { return m_addrInfo; }
|
||||
|
@ -326,6 +326,12 @@ namespace llarp
|
|||
LoadFromStr(string_view str);
|
||||
};
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigDir();
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigPath();
|
||||
|
||||
} // namespace llarp
|
||||
|
||||
void
|
||||
|
|
|
@ -110,7 +110,8 @@ namespace libuv
|
|||
if(nread >= 0)
|
||||
{
|
||||
auto* conn = static_cast< conn_glue* >(stream->data);
|
||||
conn->Read(buf->base, nread);
|
||||
Call(stream, std::bind(&conn_glue::Read, conn, buf->base, nread));
|
||||
return;
|
||||
}
|
||||
else if(nread < 0)
|
||||
{
|
||||
|
@ -135,6 +136,7 @@ namespace libuv
|
|||
const llarp_buffer_t buf(ptr, sz);
|
||||
m_Conn.read(&m_Conn, buf);
|
||||
}
|
||||
delete[] ptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -465,8 +465,10 @@ namespace llarp
|
|||
ILinkLayer* link = static_cast< ILinkLayer* >(udp->user);
|
||||
auto pkts = std::make_shared< llarp_pkt_list >();
|
||||
llarp_ev_udp_recvmany(&link->m_udp, pkts.get());
|
||||
|
||||
link->logic()->queue_func([pkts, link]() {
|
||||
auto logic = link->logic();
|
||||
if(logic == nullptr)
|
||||
return;
|
||||
logic->queue_func([pkts, link]() {
|
||||
auto itr = pkts->begin();
|
||||
while(itr != pkts->end())
|
||||
{
|
||||
|
|
|
@ -9,8 +9,24 @@
|
|||
#ifndef ANDROID
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
// Work around for broken glibc/linux header definitions in xenial that makes
|
||||
// including both net/if.h (which we need for if_nametoindex) and linux/if.h
|
||||
// (which tuntap.h includes) impossible. When we stop supporting xenial we can
|
||||
// remove this mess and just include net/if.h here.
|
||||
#if defined(Linux) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 23
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) \
|
||||
&& LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
|
||||
#define _NET_IF_H 1
|
||||
#include <linux/if.h>
|
||||
extern "C" unsigned int
|
||||
if_nametoindex(const char* __ifname) __THROW;
|
||||
#endif
|
||||
#else
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <net/net_addr.hpp>
|
||||
#include <net/ip.hpp>
|
||||
|
|
|
@ -113,6 +113,8 @@ namespace llarp
|
|||
if(_running)
|
||||
{
|
||||
return util::StatusObject{
|
||||
{"running", true},
|
||||
{"numNodesKnown", _nodedb->num_loaded()},
|
||||
{"dht", _dht->impl->ExtractStatus()},
|
||||
{"services", _hiddenServiceContext.ExtractStatus()},
|
||||
{"exit", _exitContext.ExtractStatus()},
|
||||
|
@ -120,7 +122,7 @@ namespace llarp
|
|||
}
|
||||
else
|
||||
{
|
||||
return util::StatusObject{{"notRunning", true}};
|
||||
return util::StatusObject{{"running", false}};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1029,7 +1031,9 @@ namespace llarp
|
|||
}
|
||||
|
||||
LogInfo("have ", _nodedb->num_loaded(), " routers");
|
||||
|
||||
_netloop->add_ticker(std::bind(&Router::PumpLL, this));
|
||||
|
||||
ScheduleTicker(1000);
|
||||
_running.store(true);
|
||||
_startedAt = Now();
|
||||
|
|
|
@ -188,8 +188,21 @@ namespace llarp
|
|||
struct Handler : public ::abyss::httpd::IRPCHandler
|
||||
{
|
||||
AbstractRouter* router;
|
||||
std::unordered_map< absl::string_view, std::function< Response() >,
|
||||
absl::Hash< absl::string_view > >
|
||||
m_dispatch;
|
||||
Handler(::abyss::httpd::ConnImpl* conn, AbstractRouter* r)
|
||||
: ::abyss::httpd::IRPCHandler(conn), router(r)
|
||||
: ::abyss::httpd::IRPCHandler(conn)
|
||||
, router(r)
|
||||
, m_dispatch{
|
||||
{"llarp.admin.wakeup", [=]() { return StartRouter(); }},
|
||||
{"llarp.admin.link.neighbor",
|
||||
[=]() { return ListNeighbors(); }},
|
||||
{"llarp.admin.exit.list", [=]() { return ListExitLevels(); }},
|
||||
{"llarp.admin.dumpstate", [=]() { return DumpState(); }},
|
||||
{"llarp.admin.status", [=]() { return DumpStatus(); }},
|
||||
{"llarp.our.addresses", [=]() { return OurAddresses(); }},
|
||||
{"llarp.version", [=]() { return DumpVersion(); }}}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -227,7 +240,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
Response
|
||||
ListNeighboors() const
|
||||
ListNeighbors() const
|
||||
{
|
||||
Response resp = Response::array();
|
||||
router->ForEachPeer(
|
||||
|
@ -267,6 +280,21 @@ namespace llarp
|
|||
return resp;
|
||||
}
|
||||
|
||||
Response
|
||||
OurAddresses() const
|
||||
{
|
||||
Response services;
|
||||
router->hiddenServiceContext().ForEachService(
|
||||
[&](const std::string&,
|
||||
const std::shared_ptr< service::Endpoint >& service) {
|
||||
const service::Address addr = service->GetIdentity().pub.Addr();
|
||||
services.push_back(addr.ToString());
|
||||
return true;
|
||||
});
|
||||
|
||||
return Response{{"services", services}};
|
||||
}
|
||||
|
||||
Response
|
||||
DumpVersion() const
|
||||
{
|
||||
|
@ -278,29 +306,10 @@ namespace llarp
|
|||
HandleJSONRPC(Method_t method,
|
||||
ABSL_ATTRIBUTE_UNUSED const Params& params) override
|
||||
{
|
||||
if(method == "llarp.admin.start")
|
||||
auto it = m_dispatch.find(method);
|
||||
if(it != m_dispatch.end())
|
||||
{
|
||||
return StartRouter();
|
||||
}
|
||||
if(method == "llarp.admin.link.neighboors")
|
||||
{
|
||||
return ListNeighboors();
|
||||
}
|
||||
if(method == "llarp.admin.exit.list")
|
||||
{
|
||||
return ListExitLevels();
|
||||
}
|
||||
if(method == "llarp.admin.dumpstate")
|
||||
{
|
||||
return DumpState();
|
||||
}
|
||||
if(method == "llarp.admin.status")
|
||||
{
|
||||
return DumpStatus();
|
||||
}
|
||||
if(method == "llarp.version")
|
||||
{
|
||||
return DumpVersion();
|
||||
return it->second();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR})
|
|||
|
||||
include("${LOKINET_ROOT}/cmake/basic_definitions.cmake")
|
||||
set(LIBUV_IN_SOURCE ON)
|
||||
set(LIBUV_LIBRARY uv_a)
|
||||
include("${LOKINET_ROOT}/cmake/unix.cmake")
|
||||
unset(LIBTUNTAP_SRC)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
|
@ -51,6 +53,10 @@ include_directories("${libuv_SOURCE_DIR}/include")
|
|||
add_loki_dir(vendor/gtest)
|
||||
add_subdirectory(${ABSEIL_DIR} "vendor/abseil-cpp")
|
||||
|
||||
if (FS_LIB STREQUAL "cppbackport")
|
||||
add_loki_dir(vendor)
|
||||
endif()
|
||||
|
||||
add_loki_dir(crypto)
|
||||
add_loki_dir(llarp)
|
||||
add_loki_dir(libabyss)
|
||||
|
|
|
@ -1,67 +1,67 @@
|
|||
; Script generated by the Inno Script Studio Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Lokinet"
|
||||
#define MyAppVersion "0.5.2"
|
||||
#define MyAppPublisher "Loki Project"
|
||||
#define MyAppURL "https://lokinet.org"
|
||||
#define MyAppExeName "lokinetui.exe"
|
||||
; Script generated by the Inno Script Studio Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Lokinet"
|
||||
#define MyAppVersion "0.5.2"
|
||||
#define MyAppPublisher "Loki Project"
|
||||
#define MyAppURL "https://lokinet.org"
|
||||
#define MyAppExeName "lokinetui.exe"
|
||||
; change this to avoid compiler errors -despair
|
||||
#ifndef DevPath
|
||||
#ifndef DevPath
|
||||
#define DevPath "D:\dev\external\llarp\"
|
||||
#endif
|
||||
#endif
|
||||
#include <idp.iss>
|
||||
#include "version.txt"
|
||||
|
||||
|
||||
; see ../LICENSE
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application.
|
||||
; Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{11335EAC-0385-4C78-A3AA-67731326B653}}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application.
|
||||
; Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{11335EAC-0385-4C78-A3AA-67731326B653}}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
#ifndef RELEASE
|
||||
AppVerName={#MyAppName} {#MyAppVersion}-dev
|
||||
#else
|
||||
AppVerName={#MyAppName} {#MyAppVersion}
|
||||
#endif
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
AllowNoIcons=yes
|
||||
LicenseFile={#DevPath}LICENSE
|
||||
OutputDir={#DevPath}win32-setup
|
||||
OutputBaseFilename=lokinet-win32
|
||||
Compression=lzma2/ultra64
|
||||
SolidCompression=yes
|
||||
VersionInfoVersion=0.5.2
|
||||
VersionInfoCompany=Loki Project
|
||||
VersionInfoDescription=LokiNET for Microsoft® Windows® NT™
|
||||
#ifndef RELEASE
|
||||
#endif
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
AllowNoIcons=yes
|
||||
LicenseFile={#DevPath}LICENSE
|
||||
OutputDir={#DevPath}win32-setup
|
||||
OutputBaseFilename=lokinet-win32
|
||||
Compression=lzma2/ultra64
|
||||
SolidCompression=yes
|
||||
VersionInfoVersion=0.5.2
|
||||
VersionInfoCompany=Loki Project
|
||||
VersionInfoDescription=LokiNET for Microsoft<EFBFBD> Windows<77> NT<4E>
|
||||
#ifndef RELEASE
|
||||
VersionInfoTextVersion=0.5.2-dev-{#VCSRev}
|
||||
VersionInfoProductTextVersion=0.5.2-dev-{#VCSRev}
|
||||
#else
|
||||
VersionInfoTextVersion=0.5.2
|
||||
VersionInfoProductTextVersion=0.5.2 ({#Codename})
|
||||
#endif
|
||||
VersionInfoProductName=LokiNET
|
||||
VersionInfoProductVersion=0.5.2
|
||||
#endif
|
||||
VersionInfoProductName=LokiNET
|
||||
VersionInfoProductVersion=0.5.2
|
||||
InternalCompressLevel=ultra64
|
||||
MinVersion=0,5.0
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
VersionInfoCopyright=Copyright ©2018-2019 Loki Project
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
|
||||
MinVersion=0,5.0
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
VersionInfoCopyright=Copyright <EFBFBD>2018-2019 Loki Project
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
|
||||
|
||||
[Files]
|
||||
; only one of these is installed
|
||||
|
@ -89,7 +89,7 @@ Source: "{#DevPath}ui-win32\bin\release\lokinetui.pdb"; DestDir: "{app}"; Flags:
|
|||
#endif
|
||||
; eh, might as well ship the 32-bit port of everything else
|
||||
Source: "{#DevPath}build\testAll.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#DevPath}build\lokinet-rcutil.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#DevPath}build\lokinetctl.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "lokinet-bootstrap.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "rootcerts.pem"; DestDir: "{app}"; Flags: ignoreversion
|
||||
|
@ -144,7 +144,7 @@ Filename: "{app}\tap-windows-9.9.2\remove.bat"; WorkingDir: "{app}\tap-windows-9
|
|||
Name: "{userappdata}\.lokinet"
|
||||
|
||||
[Code]
|
||||
var
|
||||
var
|
||||
TapInstalled: Boolean;
|
||||
|
||||
function reg_query_helper(): Integer;
|
||||
|
@ -212,13 +212,13 @@ begin
|
|||
idpDownloadAfter(wpReady);
|
||||
end;
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; OnlyBelowVersion: 0, 6.1
|
||||
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; MinVersion: 0, 6.1
|
||||
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; MinVersion: 0, 6.1
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"
|
||||
|
@ -233,4 +233,4 @@ Filename: "{app}\tap-windows-9.21.2\install.bat"; WorkingDir: "{app}\tap-windows
|
|||
; install inet6 if not present. (I'd assume netsh displays something helpful if inet6 is already set up and configured.)
|
||||
; if it doesn't exist, then the inet6 driver appears to be installed
|
||||
Filename: "{app}\inet6_driver\setup\hotfix.exe"; Parameters: "/m /z"; WorkingDir: "{app}\inet6_driver\setup\"; Flags: runascurrentuser waituntilterminated skipifdoesntexist; Description: "Install IPv6 driver"; StatusMsg: "Installing IPv6..."; OnlyBelowVersion: 0, 5.1; Check: not FileExists(ExpandConstant('{sys}\drivers\tcpip6.sys'))
|
||||
Filename: "{sys}\netsh.exe"; Parameters: "int ipv6 install"; Flags: runascurrentuser waituntilterminated; Description: "install ipv6 on whistler"; StatusMsg: "Installing IPv6..."; MinVersion: 0,5.1; OnlyBelowVersion: 0,6.0
|
||||
Filename: "{sys}\netsh.exe"; Parameters: "int ipv6 install"; Flags: runascurrentuser waituntilterminated; Description: "install ipv6 on whistler"; StatusMsg: "Installing IPv6..."; MinVersion: 0,5.1; OnlyBelowVersion: 0,6.0
|
||||
|
|
Loading…
Reference in New Issue