Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Apr 10, 2020
1 parent a040b36 commit c8b9631
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 29 deletions.
23 changes: 13 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ endif()

project(socks_server)

if (USE_HUNTER)
hunter_add_package(Boost COMPONENTS thread system filesystem coroutine context date_time regex program_options)
endif()


include(CheckCXXCompilerFlag)

CHECK_CXX_COMPILER_FLAG(-std=c++17 LIBCXX_HAS_STDCXX17_FLAG)
Expand All @@ -40,29 +35,37 @@ else()
CMAKE_C_FLAGS_RELWITHDEBINFO
)

foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
#foreach(CompilerFlag ${CompilerFlags})
# string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
#endforeach()

add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_WIN32_WINNT=0x0501)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()


set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_RUNTIME ON)

find_package(Boost COMPONENTS thread system filesystem coroutine context date_time regex program_options REQUIRED)
if (USE_HUNTER)
hunter_add_package(Boost COMPONENTS thread system filesystem coroutine context program_options)
endif()

find_package(Boost CONFIG REQUIRED COMPONENTS thread system filesystem coroutine context program_options)

message(STATUS "Find boost version: ${Boost_VERSION}")

if (NOT Boost_VERSION VERSION_LESS 106700)
message(STATUS "Use boost coroutines v2")
add_definitions(-DBOOST_COROUTINES_V2)
endif()

if (USE_HUNTER AND MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()

link_libraries(${Boost_LIBRARIES})
include_directories(${Boost_INCLUDE_DIRS})

Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,3 @@ socks_server.exe --address 0.0.0.0 --port 4567

do_auth.js必须实现do_auth/do_auth4函数, 参考项目所带的 do_auth.js


##### TODO:

1. BIND支持.
2. GSS-API认证支持.

14 changes: 7 additions & 7 deletions src/client.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <iostream>

#include "socks_client.hpp"

#include <boost/smart_ptr.hpp>

#include <boost/program_options.hpp>
namespace po = boost::program_options;

Expand All @@ -12,10 +12,10 @@ using boost::asio::ip::tcp;
class client
{
public:
client(boost::asio::io_service& io_service,
client(boost::asio::io_context& io_context,
const std::string& server, const std::string& path, const std::string& socks_server)
: resolver_(io_service)
, socket_(io_service)
: resolver_(io_context)
, socket_(io_context)
, server_(server)
{
// Form the request. We specify the "Connection: close" header so that the
Expand Down Expand Up @@ -224,9 +224,9 @@ int main(int argc, char **argv)
return 0;
}

boost::asio::io_service io_service;
client c(io_service, http_server, http_path, socks_server);
io_service.run();
boost::asio::io_context io_context;
client c(io_context, http_server, http_path, socks_server);
io_context.run();
}
catch (std::exception& e)
{
Expand Down
13 changes: 10 additions & 3 deletions src/socks_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@
#include <deque>
#include <cstring> // for std::memcpy


#include <boost/utility/string_view.hpp>


#include <boost/logic/tribool.hpp>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/array.hpp>
#include <boost/date_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

#include <boost/system/system_error.hpp>
#include <boost/system/error_code.hpp>

#include <boost/asio.hpp>
#include <boost/asio/placeholders.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read_until.hpp>

#include "io.hpp"

Expand Down
17 changes: 14 additions & 3 deletions src/socks_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,27 @@
#include <atomic>
#include <deque>
#include <cstring> // for std::memcpy
#include <fstream> // std::ifstream
#include <unordered_map>

#include <boost/logic/tribool.hpp>
#include <boost/asio.hpp>

#include <boost/asio/placeholders.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/asio/deadline_timer.hpp>

#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/array.hpp>
#include <boost/functional/hash.hpp>
#include <boost/date_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/noncopyable.hpp>
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>

Expand Down

0 comments on commit c8b9631

Please sign in to comment.