Skip to content

Commit

Permalink
support build by VS
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Jan 17, 2019
1 parent 88815fc commit 0352bf2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

set(CMAKE_C_FLAGS_DEBUG
"-g3 -ggdb -g"
)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_C_FLAGS_DEBUG
"-g3 -ggdb -g"
)
endif()

include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
Expand Down
1 change: 1 addition & 0 deletions cmake/FindPCAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (WIN32)
URL "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip"
URL_MD5 "bae2236af062b0900ad1416b2c4878b9"
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_DIR "" INSTALL_COMMAND ""
BUILD_BYPRODUCTS <SOURCE_DIR>/Lib/x64/wpcap.lib <SOURCE_DIR>/Lib/wpcap.lib
# LOG_DOWNLOAD ON
)
ExternalProject_Get_Property(winpcap SOURCE_DIR)
Expand Down
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ add_executable(lan-play ${src})

target_compile_options(
lan-play
PRIVATE "-Wall"
PRIVATE "-Wno-unused-function"
PRIVATE "-DLANPLAY_VERSION=\"${LANPLAY_VERSION}\""
)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
target_compile_options(
lan-play
PRIVATE "-Wall"
PRIVATE "-Wno-unused-function"
)
endif()

set_target_properties(lan-play PROPERTIES CXX_STANDARD 17)

Expand Down
2 changes: 2 additions & 0 deletions src/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ int parse_addr(const char *str, struct sockaddr_in *addr)
}

#if defined(_WIN32)
#ifndef _MSC_VER
static void win32_init_winsocket() __attribute__((constructor));
#endif
static void win32_init_winsocket()
{
int result;
Expand Down
5 changes: 4 additions & 1 deletion src/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#else
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#endif
#include <pcap.h>
#include <unistd.h>
#include <string.h>
// #define HTONS(a) ( (((a) & 0xff) << 8) | (((a) >> 8) & 0xff) )
#define LMIN(a, b) ((a) < (b) ? (a) : (b))
Expand Down
4 changes: 2 additions & 2 deletions src/proxy_socks5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ class Socks5ProxyUdp {
});
protocol.onUDPReady([this](struct sockaddr addr) {
this->isReady = true;
udp->recv();
this->udp->recv();
this->visit();
if (waitingData) {
udp->send(cfg.server, std::move(waitingData), waitingLength);
this->udp->send(cfg.server, std::move(waitingData), waitingLength);
}
});
struct sockaddr addr = {0};
Expand Down

0 comments on commit 0352bf2

Please sign in to comment.