be slightly less annoying

check build rules
pull/36/head
despair 6 years ago
parent c5d1b32286
commit 38f2a6b2c9

@ -500,22 +500,17 @@ set(ALL_SRC ${CLIENT_SRC} ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${
if(USE_LIBABYSS) if(USE_LIBABYSS)
set(ABYSS libabyss) set(ABYSS libabyss)
set(ABYSS_LIB abyss) set(ABYSS_LIB abyss)
set(ABYSS_EXE ${ABYSS_LIB}-main) set(ABYSS_EXE ${ABYSS_LIB}-main)
include_directories(${ABYSS}/include) include_directories(${ABYSS}/include)
set(ABYSS_SRC set(ABYSS_SRC
${ABYSS}/src/http.cpp ${ABYSS}/src/http.cpp
${ABYSS}/src/client.cpp ${ABYSS}/src/client.cpp
${ABYSS}/src/server.cpp ${ABYSS}/src/server.cpp
${ABYSS}/src/json.cpp) ${ABYSS}/src/json.cpp)
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC}) set(ALL_SRC ${ALL_SRC} ${ABYSS_SRC} ${ABYSS}/main.cpp)
endif()
set(ALL_SRC ${CLIENT_SRC} ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${LIB_SRC} ${TEST_SRC} ${ABYSS_SRC} ${ABYSS}/main.cpp)
foreach(F ${ALL_SRC}) foreach(F ${ALL_SRC})
set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\") set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\")
@ -553,14 +548,12 @@ if(WITH_STATIC)
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB}) target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB}) target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB})
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB}) target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB})
target_link_libraries(${ABYSS_EXE} ${STATIC_LIB})
if (WIN32) if (WIN32)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi) target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi) target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi) target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi) target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB} ws2_32 iphlpapi) target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB} ws2_32 iphlpapi)
target_link_libraries(${ABYSS_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
endif(WIN32) endif(WIN32)
endif(NOT WITH_SHARED) endif(NOT WITH_SHARED)
endif(WITH_STATIC) endif(WITH_STATIC)

@ -35,9 +35,6 @@ startWinsock()
{ {
WSADATA wsockd; WSADATA wsockd;
int err; int err;
// We used to defer starting winsock until
// we got to the iocp event loop
// but getaddrinfo(3) requires that winsock be in core already
err = ::WSAStartup(MAKEWORD(2, 2), &wsockd); err = ::WSAStartup(MAKEWORD(2, 2), &wsockd);
if(err) if(err)
{ {
@ -83,7 +80,9 @@ main(int argc, char *argv[])
break; break;
case 'r': case 'r':
#ifdef _WIN32 #ifdef _WIN32
llarp::LogError("we will not run as relay because you're running windows, install a real operating system please"); llarp::LogError(
"please don't try this at home, the relay feature is untested on "
"windows server --R.");
return 1; return 1;
#endif #endif
asRouter = true; asRouter = true;

@ -26,7 +26,17 @@ namespace abyss
#endif #endif
namespace abyss namespace abyss
{ {
#if __cplusplus >= 201703L // the code assumes C++11, if you _actually have_ C++17
// and have the ability to switch it on, then some of the code
// using string_view fails since it was made with the assumption
// that string_view is an alias for string!
//
// Specifically, one cannot use std::transform() on _real_ string_views
// since _those_ are read-only at all times - iterator and const_iterator
// are _exactly_ alike -rick
/* #if __cplusplus >= 201703L */
#if 0
typedef std::string_view string_view; typedef std::string_view string_view;
#else #else
typedef std::string string_view; typedef std::string string_view;

@ -13,10 +13,10 @@
#include <pthread_np.h> #include <pthread_np.h>
#endif #endif
/*#if _WIN32 || __sun #if _WIN32 || __sun
#define wmin(x, y) (((x) < (y)) ? (x) : (y)) #define wmin(x, y) (((x) < (y)) ? (x) : (y))
#define MIN wmin #define MIN wmin
#endif*/ #endif
namespace llarp namespace llarp
{ {

@ -1,3 +1,8 @@
// saves us some calculation in the sodium bits
#if defined(_WIN32) || defined(_M_IX86) || defined(_M_X64) \
|| defined(__i386__) || defined(__amd64__)
#define NATIVE_LITTLE_ENDIAN 1
#endif
#include <assert.h> #include <assert.h>
#include <llarp/crypto.h> #include <llarp/crypto.h>
#include <sodium/crypto_generichash.h> #include <sodium/crypto_generichash.h>

@ -245,6 +245,9 @@ namespace llarp
} // namespace llarp } // namespace llarp
// they're effectively alike, save for the fact that we must not
// get file descriptors below zero
#ifndef _WIN32
llarp::ev_io * llarp::ev_io *
llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr) llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
{ {
@ -274,3 +277,42 @@ llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
tcp->impl = serv; tcp->impl = serv;
return serv; return serv;
} }
#else
llarp::ev_io *
llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
{
DWORD on = 1;
SOCKET fd = ::socket(bindaddr->sa_family, SOCK_STREAM, 0);
if(fd == INVALID_SOCKET)
return nullptr;
socklen_t sz = sizeof(sockaddr_in);
if(bindaddr->sa_family == AF_INET6)
{
sz = sizeof(sockaddr_in6);
}
// keep. inexplicably, windows now has unix domain sockets
// for now, use the ID numbers directly until this comes out of
// beta
else if(bindaddr->sa_family == AF_UNIX)
{
sz = 110; // current size in 10.0.17763, verify each time the beta PSDK
// is updated
}
if(::bind(fd, bindaddr, sz) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
if(::listen(fd, 5) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
llarp::ev_io *serv = new llarp::tcp_serv(this, fd, tcp);
tcp->impl = serv;
// We're non-blocking now, but can't really make use of it
// until we cut over to WSA* functions
ioctlsocket(fd, FIONBIO, &on);
return serv;
}
#endif

@ -289,44 +289,6 @@ struct llarp_win32_loop : public llarp_ev_loop
return result; return result;
} }
llarp::ev_io*
bind_tcp(llarp_tcp_acceptor* tcp, const sockaddr* bindaddr)
{
DWORD on = 1;
SOCKET fd = ::socket(bindaddr->sa_family, SOCK_STREAM, 0);
if(fd == INVALID_SOCKET)
return nullptr;
socklen_t sz = sizeof(sockaddr_in);
if(bindaddr->sa_family == AF_INET6)
{
sz = sizeof(sockaddr_in6);
}
// keep. inexplicably, windows now has unix domain sockets
// for now, use the ID numbers directly until this comes out of
// beta
else if(bindaddr->sa_family == AF_UNIX)
{
sz = 110; // current size in 10.0.17763, verify each time the beta PSDK
// is updated
}
if(::bind(fd, bindaddr, sz) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
if(::listen(fd, 5) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
llarp::ev_io* serv = new llarp::tcp_serv(this, fd, tcp);
tcp->impl = serv;
// We're non-blocking now, but can't really make use of it
// until we cut over to WSA* functions
ioctlsocket(fd, FIONBIO, &on);
return serv;
}
SOCKET SOCKET
udp_bind(const sockaddr* addr) udp_bind(const sockaddr* addr)
{ {

@ -108,15 +108,15 @@ namespace llarp
#else #else
struct ServerImpl struct ServerImpl
{ {
ServerImpl(llarp_router * r) {}; ServerImpl(llarp_router* r){};
bool Start(const std::string & addr) bool
Start(const std::string& addr)
{ {
return true; return true;
} }
}; };
#endif #endif
Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r)) Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r))
{ {
} }

Loading…
Cancel
Save