From ea2107d33af86819e961a17c30a6e3a10908b84a Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:27:21 -0500 Subject: [PATCH 1/3] Prevent websocketpp from polluting installs When clients of fc (such as graphene) do an install (via `make install` or similar), websocketpp was installing as well. This commit prevents this from happening. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeadd2b..53ac49f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/git_revision.cpp.in" "${CMAKE_CU list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") list(APPEND sources ${fc_headers}) -add_subdirectory( vendor/websocketpp ) +add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/udt4 ) setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) From 397c10ce1982f1c007a1efc38454ff63f85c1eed Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:41:22 -0500 Subject: [PATCH 2/3] Fix installation FC now installs properly with a `make install` --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53ac49f..f1bcdce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,8 @@ list(APPEND sources ${fc_headers}) add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/udt4 ) -setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) +setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC ) +install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include ) # begin readline stuff find_package(Curses) From 2bd8e92a756c4e9e3d43c6e5c2aebddaf6b7db27 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 18 Mar 2016 09:32:55 -0400 Subject: [PATCH 3/3] Windows build fixes (disable compiling permessage-deflate, which isn't very useful right now. The build error will probably be resolved in websocketpp by the time we need it) --- CMakeLists.txt | 1 + src/network/http/websocket.cpp | 42 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeadd2b..69c4dff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,6 +316,7 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/udt4/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp + ${ZLIB_INCLUDE_DIR} ) #target_link_libraries( fc PUBLIC udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 81a7cad..b8a3d3c 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -1,9 +1,19 @@ #include + +#ifndef WIN32 +// websocket++ currently does not build correctly with permessage deflate enabled +// since chrome does not work with websocketpp's implementation of permessage-deflate +// yet, I'm just disabling it on windows instead of trying to fix the build error. +# define ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE +#endif + #include #include #include #include -#include +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE +# include +#endif #include #include @@ -56,7 +66,8 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; - + +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_with_stub_log_and_deflate : public websocketpp::config::asio { typedef asio_with_stub_log_and_deflate type; typedef asio base; @@ -98,6 +109,7 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; +#endif ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log : public websocketpp::config::asio_tls { typedef asio_tls_stub_log type; @@ -132,6 +144,7 @@ namespace fc { namespace http { transport_type; }; +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log_and_deflate : public websocketpp::config::asio_tls { typedef asio_tls_stub_log_and_deflate type; typedef asio_tls base; @@ -169,6 +182,7 @@ namespace fc { namespace http { typedef websocketpp::extensions::permessage_deflate::enabled permessage_deflate_type; }; +#endif using websocketpp::connection_hdl; @@ -513,10 +527,18 @@ namespace fc { namespace http { } // namespace detail websocket_server::websocket_server(bool enable_permessage_deflate /* = true */) : - my( enable_permessage_deflate ? + my( +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_server_impl : +#endif (detail::abstract_websocket_server*)new detail::websocket_server_impl ) - {} + { +#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + if (enable_permessage_deflate) + elog("Websocket permessage-deflate requested but not enabled during compile"); +#endif + } websocket_server::~websocket_server(){} void websocket_server::on_connection( const on_connection_handler& handler ) @@ -543,10 +565,18 @@ namespace fc { namespace http { websocket_tls_server::websocket_tls_server(const string& server_pem, const string& ssl_password, bool enable_permessage_deflate /* = true */) : - my( enable_permessage_deflate ? + my( +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) : +#endif (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) ) - {} + { +#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + if (enable_permessage_deflate) + elog("Websocket permessage-deflate requested but not enabled during compile"); +#endif + } websocket_tls_server::~websocket_tls_server(){} void websocket_tls_server::on_connection( const on_connection_handler& handler )