diff --git a/.github/scripts/compile.sh b/.github/scripts/compile.sh index ae1ff3e33..cb7e041df 100755 --- a/.github/scripts/compile.sh +++ b/.github/scripts/compile.sh @@ -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}" \ diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 178ed19a0..a758c1b5f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 - name: Install qpid-proton run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index afea9cc81..9062ceb2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,12 @@ 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 ## @@ -122,15 +128,6 @@ message(STATUS "Found Proton: ${Proton_LIBRARIES} (found version \"${Proton_VERS # 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") @@ -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") diff --git a/README.adoc b/README.adoc index 28e3e9d54..c385a880b 100644 --- a/README.adoc +++ b/README.adoc @@ -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 diff --git a/packaging/skupper-router.spec.rpkg b/packaging/skupper-router.spec.rpkg index 0b11682ae..6613fbdaf 100644 --- a/packaging/skupper-router.spec.rpkg +++ b/packaging/skupper-router.spec.rpkg @@ -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 \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 838996ea9..a55525aef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 @@ -68,6 +69,7 @@ set(qpid_dispatch_SOURCES entity_cache.c failoverlist.c hash.c + http-libwebsockets.c iterator.c log.c message.c @@ -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() diff --git a/src/adaptors/http2/http2_adaptor_none.c b/src/adaptors/http2/http2_adaptor_none.c deleted file mode 100644 index 49c152e30..000000000 --- a/src/adaptors/http2/http2_adaptor_none.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "adaptors/http_common.h" - -// -// Empty implementation of management related http2 functions. -// The nghttp2 library was not found, so no http2 functionality provided. -// - -/** - * Configure listener. - */ -qd_http_listener_t *qd_http2_configure_listener(qd_dispatch_t *qd, const qd_http_bridge_config_t *config, qd_entity_t *entity) -{ - qd_log_source_t *log_source = qd_log_source(QD_HTTP_LOG_SOURCE); - char *port = qd_entity_get_string(entity, "port"); - qd_log(log_source, QD_LOG_ERROR, "HTTP2 adaptor not activated due to missing nghttp2 library. Cannot open listener on port %s", port); - free(port); - return 0; -} - -/** - * Delete listener via Management request - * Empty implementation. - */ -void qd_http2_delete_listener(qd_dispatch_t *qd, qd_http_listener_t *li) -{ - qd_log_source_t *log_source = qd_log_source(QD_HTTP_LOG_SOURCE); - qd_log(log_source, QD_LOG_ERROR, "HTTP2 adaptor not activated due to missing nghttp2 library. Cannot delete listeners"); -} - - -/** - * Configure connector - */ -qd_http_connector_t *qd_http2_configure_connector(qd_dispatch_t *qd, const qd_http_bridge_config_t *config, qd_entity_t *entity) -{ - qd_log_source_t *log_source = qd_log_source(QD_HTTP_LOG_SOURCE); - char *port = qd_entity_get_string(entity, "port"); - qd_log(log_source, QD_LOG_ERROR, "HTTP2 adaptor not activated due to missing nghttp2 library. Cannot open connector to port %s", port); - free(port); - return 0; -} - - -/** - * Delete connector via Management request - * Empty implementation. - */ -void qd_http2_delete_connector(qd_dispatch_t *qd, qd_http_connector_t *connector) -{ - qd_log_source_t *log_source = qd_log_source(QD_HTTP_LOG_SOURCE); - qd_log(log_source, QD_LOG_ERROR, "HTTP2 adaptor not activated due to missing nghttp2 library. Cannot delete connectors"); - -} diff --git a/src/http-libwebsockets.c b/src/http-libwebsockets.c index bcbc1f283..6bc24a873 100644 --- a/src/http-libwebsockets.c +++ b/src/http-libwebsockets.c @@ -33,10 +33,6 @@ #include #include -#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"; @@ -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); @@ -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); } diff --git a/src/http-none.c b/src/http-none.c deleted file mode 100644 index 15af50e0f..000000000 --- a/src/http-none.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "http.h" - -#include "qpid/dispatch/log.h" - -struct qd_dispatch_t; - -/* No HTTP implementation available. */ - -qd_http_server_t *qd_http_server(struct qd_server_t *s, qd_log_source_t *log) -{ - qd_log(log, QD_LOG_WARNING, "HTTP support is not available"); - return 0; -} - -void qd_http_server_free(qd_http_server_t *h) {} - -void* qd_http_server_run(void* qd_http_server) { return 0; } - -void qd_http_server_stop(qd_http_server_t *h) {} - -qd_lws_listener_t *qd_http_server_listen(qd_http_server_t *s, struct qd_listener_t *li) { return 0; } - -void qd_lws_listener_close(qd_lws_listener_t *hl) {} - - - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 52d54df7a..bd97acf9e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) -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 diff --git a/tests/system_tests_http.py b/tests/system_tests_http.py index 7c259ca42..685b2f55c 100644 --- a/tests/system_tests_http.py +++ b/tests/system_tests_http.py @@ -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]) self.assert_get("https://localhost:%s" % r.ports[1]) # requireSsl=True does not allow simple-ssl HTTP