mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
this should get things going on UNIX :D
This commit is contained in:
parent
6c5873c441
commit
bbe0634edc
10 changed files with 119 additions and 37 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -33,4 +33,5 @@ shadow.config.xml
|
||||||
testnet_tmp
|
testnet_tmp
|
||||||
|
|
||||||
|
|
||||||
*.pid
|
*.pid
|
||||||
|
vsproject/
|
||||||
|
|
112
CMakeLists.txt
112
CMakeLists.txt
|
@ -13,10 +13,13 @@ endmacro(add_cxxflags)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||||
if(COMPILER_SUPPORTS_CXX11)
|
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
||||||
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
add_cxxflags("-std=c++11")
|
add_cxxflags("-std=c++11")
|
||||||
|
elseif(COMPILER_SUPPORTS_CXX17)
|
||||||
|
add_cxxflags("-std=c++17")
|
||||||
else()
|
else()
|
||||||
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++17 support. Please use a different C++ compiler.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(THREAD_LIB "-pthread")
|
set(THREAD_LIB "-pthread")
|
||||||
|
@ -97,9 +100,9 @@ if(SODIUM_LIBRARIES)
|
||||||
set(SODIUM_LIB ${SODIUM_LIBRARIES})
|
set(SODIUM_LIB ${SODIUM_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
find_library (
|
find_library (
|
||||||
SODIUM_LIB
|
SODIUM_LIB
|
||||||
NAMES sodium libsodium
|
NAMES sodium libsodium
|
||||||
HINTS "/usr/local/lib"
|
HINTS "/usr/local/lib"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -222,6 +225,7 @@ set(LIB_SRC
|
||||||
llarp/service.cpp
|
llarp/service.cpp
|
||||||
llarp/transit_hop.cpp
|
llarp/transit_hop.cpp
|
||||||
llarp/testnet.c
|
llarp/testnet.c
|
||||||
|
llarp/win32_inet.c
|
||||||
llarp/dht/context.cpp
|
llarp/dht/context.cpp
|
||||||
llarp/dht/decode.cpp
|
llarp/dht/decode.cpp
|
||||||
llarp/dht/dht_immediate.cpp
|
llarp/dht/dht_immediate.cpp
|
||||||
|
@ -310,29 +314,85 @@ else()
|
||||||
|
|
||||||
if(WITH_STATIC)
|
if(WITH_STATIC)
|
||||||
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
||||||
add_library(libbackport-static STATIC ${CPP_BACKPORT_SRC})
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
add_library(libllarpplatform-static STATIC ${LIB_PLATFORM_SRC})
|
add_library(backport-static STATIC ${CPP_BACKPORT_SRC})
|
||||||
target_link_libraries(libllarpplatform-static ${THREAD_LIB})
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
target_link_libraries(${STATIC_LIB} ${LIBS} libbackport-static libllarpplatform-static)
|
add_library(llarpplatform-static STATIC ${LIB_PLATFORM_SRC})
|
||||||
|
target_link_libraries(llarpplatform-static ${THREAD_LIB})
|
||||||
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
|
target_link_libraries(${STATIC_LIB} ${LIBS} backport-static llarpplatform-static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${STATIC_LIB} ${LIBS} llarpplatform-static)
|
||||||
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
if(NOT WITH_SHARED)
|
if(NOT WITH_SHARED)
|
||||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
||||||
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
||||||
target_link_libraries(dns libllarpplatform-static pthread)
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
||||||
endif()
|
if (MINGW)
|
||||||
endif()
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
||||||
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
||||||
|
endif(MINGW)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
||||||
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
||||||
|
if (MINGW)
|
||||||
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
||||||
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
||||||
|
endif(MINGW)
|
||||||
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
|
if (MINGW)
|
||||||
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32 stdc++fs)
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32)
|
||||||
|
endif(MINGW)
|
||||||
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread)
|
||||||
|
endif(NOT WITH_SHARED)
|
||||||
|
endif(WITH_STATIC)
|
||||||
|
|
||||||
if(WITH_SHARED)
|
if(WITH_SHARED)
|
||||||
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
|
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
|
||||||
add_library(libbackport SHARED ${CPP_BACKPORT_SRC})
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
add_library(libllarpplatform SHARED ${LIB_PLATFORM_SRC})
|
add_library(backport SHARED ${CPP_BACKPORT_SRC})
|
||||||
target_link_libraries(${SHARED_LIB} ${LIBS} libbackport libllarpplatform)
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
|
add_library(llarpplatform SHARED ${LIB_PLATFORM_SRC})
|
||||||
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform)
|
||||||
|
if (MINGW)
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32 stdc++fs)
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32)
|
||||||
|
endif(MINGW)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform)
|
||||||
|
if (MINGW)
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32 stdc++fs)
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32)
|
||||||
|
endif(MINGW)
|
||||||
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
if(NOT WITH_STATIC)
|
if(NOT WITH_STATIC)
|
||||||
target_link_libraries(${EXE} ${SHARED_LIB} libbackport libllarpplatform)
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} libbackport libllarpplatform)
|
target_link_libraries(${EXE} ${SHARED_LIB} backport llarpplatform)
|
||||||
target_link_libraries(rcutil ${SHARED_LIB} libbackport libllarpplatform)
|
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} backport llarpplatform)
|
||||||
target_link_libraries(dns libllarpplatform pthread)
|
target_link_libraries(rcutil ${SHARED_LIB} backport llarpplatform)
|
||||||
endif()
|
else()
|
||||||
endif()
|
target_link_libraries(${EXE} ${SHARED_LIB} llarpplatform)
|
||||||
|
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} llarpplatform)
|
||||||
endif()
|
target_link_libraries(rcutil ${SHARED_LIB} llarpplatform)
|
||||||
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
|
target_link_libraries(dns ${SHARED_LIB} llarpplatform pthread)
|
||||||
|
endif(NOT WITH_STATIC)
|
||||||
|
endif(WITH_SHARED)
|
||||||
|
endif(SHADOW)
|
|
@ -12,6 +12,10 @@
|
||||||
#include <thread> // for multithreaded version
|
#include <thread> // for multithreaded version
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -29,7 +33,7 @@ hookChecker(std::string name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: make configurable
|
// FIXME: make configurable
|
||||||
#define SERVER "8.8.8.8"
|
#define SERVER "1.1.1.1"
|
||||||
#define PORT 53
|
#define PORT 53
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -85,7 +89,7 @@ main(int argc, char *argv[])
|
||||||
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
|
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
|
||||||
#if(__APPLE__ && __MACH__)
|
#if(__APPLE__ && __MACH__)
|
||||||
|
|
||||||
#elif(__FreeBSD__)
|
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
pthread_set_name_np(netio_threads.back().native_handle(),
|
pthread_set_name_np(netio_threads.back().native_handle(),
|
||||||
"llarp-netio");
|
"llarp-netio");
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "router.hpp"
|
#include "router.hpp"
|
||||||
|
|
||||||
#if(__FreeBSD__)
|
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
#include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ namespace llarp
|
||||||
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
|
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
|
||||||
#if(__APPLE__ && __MACH__)
|
#if(__APPLE__ && __MACH__)
|
||||||
|
|
||||||
#elif(__FreeBSD__)
|
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
pthread_set_name_np(netio_threads.back().native_handle(),
|
pthread_set_name_np(netio_threads.back().native_handle(),
|
||||||
"llarp-"
|
"llarp-"
|
||||||
"netio");
|
"netio");
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#if(__APPLE__ && __MACH__)
|
#if(__APPLE__ && __MACH__)
|
||||||
#include "ev_kqueue.hpp"
|
#include "ev_kqueue.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
#include "ev_kqueue.hpp"
|
#include "ev_kqueue.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
|
||||||
#if(__APPLE__ && __MACH__)
|
#if(__APPLE__ && __MACH__)
|
||||||
*ev = new llarp_kqueue_loop;
|
*ev = new llarp_kqueue_loop;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
*ev = new llarp_kqueue_loop;
|
*ev = new llarp_kqueue_loop;
|
||||||
#endif
|
#endif
|
||||||
(*ev)->init();
|
(*ev)->init();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <llarp/buffer.h>
|
#include <llarp/buffer.h>
|
||||||
#include <llarp/net.h>
|
#include <llarp/net.h>
|
||||||
|
|
||||||
#if __FreeBSD__
|
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
|
||||||
// kqueue / kevent
|
// kqueue / kevent
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
|
@ -8,6 +8,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
#if !defined(CPP17) || defined(__OpenBSD__)
|
||||||
namespace fs = cpp17::filesystem;
|
namespace fs = cpp17::filesystem;
|
||||||
|
#else
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
#else
|
||||||
|
namespace fs = std::experimental::filesystem;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -182,8 +182,13 @@ struct llarp_nodedb
|
||||||
{
|
{
|
||||||
ssize_t sz = 0;
|
ssize_t sz = 0;
|
||||||
fs::directory_iterator i(dir);
|
fs::directory_iterator i(dir);
|
||||||
|
#if defined(CPP17) && !defined(__OpenBSD__)
|
||||||
|
auto itr = fs::begin(i);
|
||||||
|
while(itr != fs::end(i))
|
||||||
|
#else
|
||||||
auto itr = i.begin();
|
auto itr = i.begin();
|
||||||
while(itr != itr.end())
|
while(itr != itr.end())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if(fs::is_regular_file(itr->symlink_status()) && loadfile(*itr))
|
if(fs::is_regular_file(itr->symlink_status()) && loadfile(*itr))
|
||||||
sz++;
|
sz++;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
|
|
||||||
#if(__FreeBSD__)
|
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
#include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace llarp
|
||||||
{
|
{
|
||||||
#if(__APPLE__ && __MACH__)
|
#if(__APPLE__ && __MACH__)
|
||||||
pthread_setname_np(name);
|
pthread_setname_np(name);
|
||||||
#elif(__FreeBSD__)
|
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
|
||||||
pthread_set_name_np(pthread_self(), name);
|
pthread_set_name_np(pthread_self(), name);
|
||||||
#else
|
#else
|
||||||
pthread_setname_np(pthread_self(), name);
|
pthread_setname_np(pthread_self(), name);
|
||||||
|
|
6
vendor/cppbackport-master/lib/filesystem.h
vendored
6
vendor/cppbackport-master/lib/filesystem.h
vendored
|
@ -32,8 +32,12 @@
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#if defined(CPP17)
|
#if defined(CPP17) && !defined(__OpenBSD__)
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
#else
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include "fs/absolute.h"
|
#include "fs/absolute.h"
|
||||||
#include "fs/basename.h"
|
#include "fs/basename.h"
|
||||||
|
|
Loading…
Reference in a new issue