Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #48 - Make libwebsockets and libnghttp2 mandatory #397

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ do_build () {
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DRUNTIME_CHECK="${runtime_check}" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DProton_USE_STATIC_LIBS=ON -DUSE_LIBWEBSOCKETS=ON -DUSE_LIBNGHTTP2=ON \
-DProton_USE_STATIC_LIBS=ON \
-DProton_DIR="$WORKING/proton_install${suffix}/usr/lib64/cmake/Proton" \
-DBUILD_TESTING=OFF \
-DVERSION="${VERSION}" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ jobs:

- name: Install Linux build dependencies
run: |
sudo apt update; sudo apt install -y python3-qpid-proton libpython3-dev ninja-build
sudo apt update; sudo apt install -y python3-qpid-proton libpython3-dev ninja-build libwebsockets-dev libnghttp2-dev
jiridanek marked this conversation as resolved.
Show resolved Hide resolved

- name: Install qpid-proton
run: |
Expand Down
19 changes: 6 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,19 @@ find_package(Python 3.6.8 REQUIRED COMPONENTS Interpreter Development)
find_package(Threads REQUIRED)
find_package(Proton 0.37.0 REQUIRED COMPONENTS Core Proactor Tls)
message(STATUS "Found Proton: ${Proton_LIBRARIES} (found version \"${Proton_VERSION}\")" )

# http2 support
find_package(libnghttp2 1.33.0 REQUIRED)
# Web Sockets
find_package(LibWebSockets 4.0.1 REQUIRED)

##
## Optional dependencies
##

# google benchmark tests are disabled by default
OPTION(BUILD_BENCHMARKS "Enable building and running benchmarks with Google Benchmark" OFF)

# http2 support is optional
find_package(libnghttp2 1.33.0)
CMAKE_DEPENDENT_OPTION(USE_LIBNGHTTP2 "Use libnghttp2 for HTTP/2 support" ON
"libnghttp2_FOUND" OFF)

# Web Sockets
find_package(LibWebSockets 3.0.1)
CMAKE_DEPENDENT_OPTION(USE_LIBWEBSOCKETS "Use libwebsockets for WebSocket support" ON
"LIBWEBSOCKETS_FOUND" OFF)

if (NOT DEFINED DISPATCH_TEST_TIMEOUT)
set(DISPATCH_TEST_TIMEOUT "600")
Expand All @@ -141,10 +138,6 @@ include (CTest)
set(PYTHON_TEST_COMMAND "-m" "unittest" "-v" "\${py_test_module}"
CACHE STRING "Command used to run tests implemented in Python unittest; \${py_test_module} will be replaced with test module name.")

set (SO_VERSION_MAJOR 2)
set (SO_VERSION_MINOR 0)
set (SO_VERSION "${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}")

if (NOT DEFINED LIB_SUFFIX)
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if ("${LIB64}" STREQUAL "TRUE" AND ${CMAKE_SIZEOF_VOID_P} STREQUAL "8")
Expand Down
7 changes: 0 additions & 7 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,3 @@ The version of skupper-router being used can be obtained running `skrouterd --ve
The `libbenchmark` library is required by the benchmarks.

|===

==== Optional dependencies

The following CMake options can be used to force-enable (or force-disable) the use of optional dependencies:

- `-DUSE_LIBNGHTTP2`, for the libnghttp2 library, needed by the http2 protocol adaptor
- `-DUSE_LIBWEBSOCKETS`, for the libwebsockets library, needed to configure `http: yes` listeners
2 changes: 0 additions & 2 deletions packaging/skupper-router.spec.rpkg
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ cd %{_builddir}/qpid-proton-%{proton_vendored_version}
cd %{_builddir}/skupper-router
%cmake \
-DVERSION="%{version} (upstream rpm build)" \
-DUSE_LIBWEBSOCKETS=ON \
-DUSE_LIBNGHTTP2=ON \
-DPython_EXECUTABLE=%{python3} \
-DProton_USE_STATIC_LIBS=ON \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
Expand Down
33 changes: 11 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ set(qpid_dispatch_SOURCES
adaptors/http1/http1_client.c
adaptors/http1/http1_server.c
adaptors/http1/http1_request_info.c
adaptors/http2/http2_adaptor.c
adaptors/tcp_adaptor.c
adaptors/test_adaptor.c
alloc.c
Expand All @@ -68,6 +69,7 @@ set(qpid_dispatch_SOURCES
entity_cache.c
failoverlist.c
hash.c
http-libwebsockets.c
iterator.c
log.c
message.c
Expand Down Expand Up @@ -133,38 +135,25 @@ set(qpid_dispatch_SOURCES
)

set(qpid_dispatch_INCLUDES
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/router_core
${CMAKE_CURRENT_BINARY_DIR}
${LIBWEBSOCKETS_INCLUDE_DIRS}
${NGHTTP2_INCLUDE_DIRS}
)

set(qpid_dispatch_LIBRARIES
${Proton_Proactor_LIBRARIES}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${LIBWEBSOCKETS_LIBRARIES}
${NGHTTP2_LIBRARIES}
${Proton_Core_LIBRARIES}
${Proton_Proactor_LIBRARIES}
${Proton_Tls_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${rt_lib}
${CMAKE_DL_LIBS}
${Python_LIBRARIES}
${rt_lib}
)

# USE_LIBWEBSOCKETS is true only if LIBWEBSOCKETS_FOUND
if(USE_LIBWEBSOCKETS)
list(APPEND qpid_dispatch_SOURCES http-libwebsockets.c)
list(APPEND qpid_dispatch_INCLUDES ${LIBWEBSOCKETS_INCLUDE_DIRS})
list(APPEND qpid_dispatch_LIBRARIES ${LIBWEBSOCKETS_LIBRARIES})
else(USE_LIBWEBSOCKETS)
list(APPEND qpid_dispatch_SOURCES http-none.c)
endif(USE_LIBWEBSOCKETS)

if(USE_LIBNGHTTP2)
list(APPEND qpid_dispatch_SOURCES adaptors/http2/http2_adaptor.c)
list(APPEND qpid_dispatch_INCLUDES ${NGHTTP2_INCLUDE_DIRS})
list(APPEND qpid_dispatch_LIBRARIES ${NGHTTP2_LIBRARIES})
else(USE_LIBNGHTTP2)
list(APPEND qpid_dispatch_SOURCES adaptors/http2/http2_adaptor_none.c)
endif(USE_LIBNGHTTP2)

if ((DEFINED ASAN_LIBRARY) OR (DEFINED UBSAN_LIBRARY) OR (DEFINED TSAN_LIBRARY))
set(USING_SANITIZERS TRUE)
endif()
Expand Down
72 changes: 0 additions & 72 deletions src/adaptors/http2/http2_adaptor_none.c

This file was deleted.

23 changes: 0 additions & 23 deletions src/http-libwebsockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#include <inttypes.h>
#include <libwebsockets.h>

#if LWS_LIBRARY_VERSION_MAJOR > 3 || (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2)
#define QD_HAVE_MODERN_LIBWEBSOCKETS 1
#endif

static const char *CIPHER_LIST = "ALL:aNULL:!eNULL:@STRENGTH"; /* Default */
static const char *IGNORED = "ignore-this-log-message";

Expand Down Expand Up @@ -380,18 +376,12 @@ static void listener_start(qd_lws_listener_t *hl, qd_http_server_t *hs) {

info.options |=
LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT |
#ifdef QD_HAVE_MODERN_LIBWEBSOCKETS
(config->ssl_required ? 0 : LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT | LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER) |
#else
(config->ssl_required ? 0 : LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT) |
#endif
((config->requireAuthentication && info.ssl_ca_filepath) ? LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT : 0);
}
info.vhost_name = hl->listener->config.host_port;
#ifdef QD_HAVE_MODERN_LIBWEBSOCKETS
info.finalize = finalize_http;
info.finalize_arg = hl;
#endif
hl->vhost = lws_create_vhost(hs->context, &info);
if (!hl->vhost) {
qd_log(hs->log, QD_LOG_NOTICE, "Error listening for HTTP on %s", config->host_port);
Expand Down Expand Up @@ -437,19 +427,6 @@ static void listener_close(qd_lws_listener_t *hl, qd_http_server_t *hs) {
static int callback_http(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
/*
* Modern LibWebSockets uses the .finalize callback on lws_context for cleanup
*/
#ifndef QD_HAVE_MODERN_LIBWEBSOCKETS
switch (reason) {
case LWS_CALLBACK_PROTOCOL_DESTROY:
finalize_http(NULL, wsi_listener(wsi));
break;
default:
break;
}
#endif

/* Do default HTTP handling for all the cases we don't care about. */
return lws_callback_http_dummy(wsi, reason, user, in, len);
}
Expand Down
45 changes: 0 additions & 45 deletions src/http-none.c

This file was deleted.

8 changes: 2 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,9 @@ foreach(py_test_module
add_test(${py_test_module} ${TEST_WRAP} ${CONFIGURED_PYTHON_TEST_COMMAND})
endforeach()

if(USE_LIBWEBSOCKETS)
set(SYSTEM_TESTS_HTTP system_tests_http system_tests_websockets)
endif()
set(SYSTEM_TESTS_HTTP system_tests_http system_tests_websockets)
jiridanek marked this conversation as resolved.
Show resolved Hide resolved

if(USE_LIBNGHTTP2)
set(SYSTEM_TESTS_HTTP2 system_tests_http2 system_tests_grpc system_tests_http2_tls)
endif(USE_LIBNGHTTP2)
set(SYSTEM_TESTS_HTTP2 system_tests_http2 system_tests_grpc system_tests_http2_tls)

if(DEFINED ENV{SKUPPER_SYSTEM_TEST_SKIP_POLICY})
#nothing to do
Expand Down
7 changes: 2 additions & 5 deletions tests/system_tests_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,10 @@ def address():
self.assert_get("https://localhost:%s" % r.ports[0])
# requireSsl=false Allows simple-ssl HTTP

# DISPATCH-1513: libwebsockets versions 3.2.0 introduces a new flag called
# DISPATCH-1513: libwebsockets version 3.2.0 introduced a new flag called
# LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER
# The new flag allows (as the flag says) HTTP over HTTPS listeners.
# Since this flag is not available before lws 3.2.0 we need
# to selectively disable this check
if skupper_router_site.LIBWEBSOCKETS_VERSION >= (3, 2, 0):
self.assert_get("http://localhost:%s" % r.ports[0])
self.assert_get("http://localhost:%s" % r.ports[0])
jiridanek marked this conversation as resolved.
Show resolved Hide resolved

self.assert_get("https://localhost:%s" % r.ports[1])
# requireSsl=True does not allow simple-ssl HTTP
Expand Down