]> git.ipfire.org Git - pakfire.git/commitdiff
Always require WebSocket support in cURL
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 7 Feb 2025 12:06:05 +0000 (12:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 7 Feb 2025 12:06:05 +0000 (12:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
configure.ac
src/cli/lib/daemon.c
src/cli/lib/daemon.h
src/pakfire/daemon.c
src/pakfire/daemon.h
src/pakfire/job.c
src/pakfire/job.h
src/pakfire/xfer.c
src/pakfire/xfer.h

index f099809ccea8439695dd0af698b6887a0977cd60..cddc264cb6c981182ffd764108f351823db80ae3 100644 (file)
@@ -435,10 +435,8 @@ pakfire_client_LDADD = \
 
 # ------------------------------------------------------------------------------
 
-if CURL_HAS_WEBSOCKETS
 bin_PROGRAMS += \
        pakfire-daemon
-endif
 
 dist_pakfire_daemon_SOURCES = \
        src/cli/pakfire-daemon.c
index 7de23242e907a110b32c6318db2bd2baddd69e90..69b83f396e9d18adebda44e65c91ec9c21e54588 100644 (file)
@@ -325,28 +325,6 @@ save_LIBS="$LIBS"
 
 LIBS="$save_LIBS"
 
-# Check if cURL has support for WebSockets
-AC_CHECK_PROG(CURL_CONFIG, curl-config, curl-config)
-if test "$CURL_CONFIG" != ""; then
-       # Check for WebSocket support
-       AC_MSG_CHECKING([for curl WebSocket support])
-       CURL_PROTOCOLS=$($CURL_CONFIG --protocols)
-
-       if echo "$CURL_PROTOCOLS" | grep -qw "WSS"; then
-               AC_DEFINE(CURL_HAS_WEBSOCKETS, [1], [cURL has WebSocket Support])
-
-               AC_MSG_RESULT([yes])
-               CURL_HAS_WEBSOCKETS=yes
-       else
-               AC_MSG_RESULT([no])
-               CURL_HAS_WEBSOCKETS=no
-       fi
-else
-       AC_MSG_ERROR([curl-config not found])
-fi
-
-AM_CONDITIONAL(CURL_HAS_WEBSOCKETS, [test "x$CURL_HAS_WEBSOCKETS" = "xyes"])
-
 AC_DEFINE_UNQUOTED([PAKFIRE_CONFIG_DIR], ["${sysconfdir}/${PACKAGE_NAME}"],
        [The path where Pakfire stores configuration files])
 AC_DEFINE_UNQUOTED([PAKFIRE_CACHE_DIR], ["/var/cache/${PACKAGE_NAME}"],
index 4dff6b8bb26594c04998c6ad7d5e4db95288d33b..a727486089133ccecd76db710c741c9c64c593c8 100644 (file)
@@ -18,8 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 #include <pakfire/ctx.h>
 #include <pakfire/daemon.h>
 
@@ -46,5 +44,3 @@ ERROR:
 
        return r;
 }
-
-#endif /* CURL_HAS_WEBSOCKETS */
index a27ec39b2d851b4c07ec3633084fb281546ab4ae..736c7625a00479b3033370d53a67924051666f13 100644 (file)
 #ifndef PAKFIRE_CLI_DAEMON_H
 #define PAKFIRE_CLI_DAEMON_H
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 #include <pakfire/ctx.h>
 
 int cli_daemon_main(struct pakfire_ctx* ctx);
 
-#endif /* CURL_HAS_WEBSOCKETS */
 #endif /* PAKFIRE_CLI_DAEMON_H */
index ee877290145105d2a382c1e5d7f5eef5c10ea358..0ed933f30408d786458253bf15f7c33010768c6d 100644 (file)
@@ -18,8 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 #include <errno.h>
 #include <stdlib.h>
 
@@ -1399,5 +1397,3 @@ int pakfire_daemon_send_message(struct pakfire_daemon* self, struct json_object*
 
        return 0;
 }
-
-#endif /* CURL_HAS_WEBSOCKETS */
index f345d3c77e573a5de893e0f3caa7aac4203c5469..a1caaad83897a799cd4e94dea9886d1a10c009a7 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef PAKFIRE_DAEMON_H
 #define PAKFIRE_DAEMON_H
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 struct pakfire_daemon;
 
 #include <pakfire/buildservice.h>
@@ -49,5 +47,4 @@ int pakfire_daemon_job_finished(struct pakfire_daemon* daemon, struct pakfire_jo
 // Send message
 int pakfire_daemon_send_message(struct pakfire_daemon* self, struct json_object* message);
 
-#endif /* CURL_HAS_WEBSOCKETS */
 #endif /* PAKFIRE_DAEMON_H */
index dbf5ef490dd638afedca0ff80c1e5f99f9111383..5ec9531f533050bd8c5d46258402f03d66367989 100644 (file)
@@ -18,8 +18,6 @@
 #                                                                             #
 #############################################################################*/
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
@@ -1009,5 +1007,3 @@ int pakfire_job_handle_message(struct pakfire_job* self, struct json_object* mes
 
        return 0;
 }
-
-#endif /* CURL_HAS_WEBSOCKETS */
index 5f216f6ac1ded6dff751236411f11fb17f2e147f..db6ce25ae855e7024ebde7ae47dfefddb6660193 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef PAKFIRE_JOB_H
 #define PAKFIRE_JOB_H
 
-#ifdef CURL_HAS_WEBSOCKETS
-
 #include <pakfire/ctx.h>
 #include <pakfire/daemon.h>
 
@@ -50,5 +48,4 @@ int pakfire_job_terminate_log_stream(struct pakfire_job* job);
 // Message Received
 int pakfire_job_handle_message(struct pakfire_job* self, struct json_object* message);
 
-#endif /* CURL_HAS_WEBSOCKETS */
 #endif /* PAKFIRE_JOB_H */
index 4a31a729105723035a0ed6d97d10c71409a59e62..fad3422ae5f5f30615616ae5354492e9bd1a2172 100644 (file)
@@ -72,9 +72,7 @@ struct pakfire_xfer {
        enum {
                PAKFIRE_XFER_DOWNLOAD = 0,
                PAKFIRE_XFER_UPLOAD   = 1,
-#ifdef CURL_HAS_WEBSOCKETS
                PAKFIRE_XFER_SOCKET   = 2,
-#endif /* CURL_HAS_WEBSOCKETS */
        } direction;
 
        // Size
@@ -108,7 +106,6 @@ struct pakfire_xfer {
        // Event Loop
        sd_event_source* event;
 
-#ifdef CURL_HAS_WEBSOCKETS
        // Callbacks
        struct pakfire_xfer_callbacks {
                pakfire_xfer_open_callback open;
@@ -123,7 +120,6 @@ struct pakfire_xfer {
                char* data;
                size_t size;
        } buffer;
-#endif /* CURL_HAS_WEBSOCKETS */
 };
 
 static void pakfire_xfer_free(struct pakfire_xfer* xfer) {
@@ -139,11 +135,9 @@ static void pakfire_xfer_free(struct pakfire_xfer* xfer) {
        if (xfer->event)
                sd_event_source_unref(xfer->event);
 
-#ifdef CURL_HAS_WEBSOCKETS
        // Buffer
        if (xfer->buffer.data)
                free(xfer->buffer.data);
-#endif /* CURL_HAS_WEBSOCKETS */
 
        // Query Arguments
        if (xfer->queries)
@@ -937,7 +931,6 @@ static int pakfire_xfer_fail(struct pakfire_xfer* xfer, int code) {
                return -EAGAIN;
        }
 
-#ifdef CURL_HAS_WEBSOCKETS
        // Call the close callback for WebSockets
        if (xfer->direction == PAKFIRE_XFER_SOCKET) {
                if (xfer->callbacks.close) {
@@ -946,7 +939,6 @@ static int pakfire_xfer_fail(struct pakfire_xfer* xfer, int code) {
                                return r;
                }
        }
-#endif /* CURL_HAS_WEBSOCKETS */
 
        return code;
 }
@@ -971,7 +963,6 @@ static const char* curl_http_version(long v) {
        return "unknown";
 }
 
-#ifdef CURL_HAS_WEBSOCKETS
 static int pakfire_xfer_allocate(struct pakfire_xfer* xfer, size_t size) {
 
        // Otherwise, we resize the buffer
@@ -1136,7 +1127,6 @@ ERROR:
 
        return r;
 }
-#endif /* CURL_HAS_WEBSOCKETS */
 
 /*
        This function checks if the hashes match (if set up)
@@ -1327,12 +1317,10 @@ pakfire_xfer_error_code_t pakfire_xfer_done(
                                        return r;
                                break;
 
-#ifdef CURL_HAS_WEBSOCKETS
                        case PAKFIRE_XFER_SOCKET:
                                r = pakfire_xfer_done_socket(xfer, loop, code);
                                if (r < 0)
                                        return r;
-#endif /* CURL_HAS_WEBSOCKETS */
 
                        default:
                                break;
@@ -1375,10 +1363,8 @@ static int pakfire_xfer_update(void* data,
                        xfer->xferred = ulnow;
                        break;
 
-#ifdef CURL_HAS_WEBSOCKETS
                case PAKFIRE_XFER_SOCKET:
                        break;
-#endif /* CURL_HAS_WEBSOCKETS */
        }
 
        // Do nothing if no progress indicator has been set up
@@ -1501,7 +1487,6 @@ static int pakfire_xfer_prepare_url(struct pakfire_xfer* xfer) {
                goto ERROR;
        }
 
-#ifdef CURL_HAS_WEBSOCKETS
        // Replace the schema if we are using SOCKET
        if (xfer->direction == PAKFIRE_XFER_SOCKET) {
                r = curl_url_set(xfer->fullurl, CURLUPART_SCHEME, "wss", 0);
@@ -1510,7 +1495,6 @@ static int pakfire_xfer_prepare_url(struct pakfire_xfer* xfer) {
                        goto ERROR;
                }
        }
-#endif /* CURL_HAS_WEBSOCKETS */
 
        // Append any query arguments
        if (xfer->queries) {
@@ -1573,7 +1557,6 @@ int pakfire_xfer_prepare(struct pakfire_xfer* xfer, struct pakfire_progress* pro
                        }
                        break;
 
-#ifdef CURL_HAS_WEBSOCKETS
                case PAKFIRE_XFER_SOCKET:
                        // Ask cURL to connect and let us handle the rest
                        r = curl_easy_setopt(xfer->handle, CURLOPT_CONNECT_ONLY, 2L);
@@ -1583,7 +1566,6 @@ int pakfire_xfer_prepare(struct pakfire_xfer* xfer, struct pakfire_progress* pro
                        }
 
                        break;
-#endif /* CURL_HAS_WEBSOCKETS */
        }
 
        // Compose the URL
@@ -1636,7 +1618,6 @@ int pakfire_xfer_prepare(struct pakfire_xfer* xfer, struct pakfire_progress* pro
        return 0;
 }
 
-#ifdef CURL_HAS_WEBSOCKETS
 int pakfire_xfer_socket(struct pakfire_xfer* xfer, pakfire_xfer_open_callback open,
                pakfire_xfer_recv_callback recv, pakfire_xfer_send_callback send,
                pakfire_xfer_close_callback close, void* data) {
@@ -1674,7 +1655,6 @@ int pakfire_xfer_send_message(struct pakfire_xfer* xfer,
 
        return 0;
 }
-#endif /* CURL_HAS_WEBSOCKETS */
 
 pakfire_xfer_error_code_t pakfire_xfer_run(struct pakfire_xfer* xfer, int flags) {
        int r;
index 37d6c2d3cf7bcd8db4d91b19d1288fef7098db9e..8207a78da98af77a271b42121970f0c646257263 100644 (file)
@@ -135,7 +135,6 @@ pakfire_xfer_error_code_t pakfire_xfer_run_api_request(
        struct pakfire_xfer* xfer, struct json_object** response);
 
 // WebSocket
-#ifdef CURL_HAS_WEBSOCKETS
 typedef int (*pakfire_xfer_open_callback)(struct pakfire_xfer* xfer, void* data);
 typedef int (*pakfire_xfer_recv_callback)(struct pakfire_xfer* xfer, const char* message, const size_t size, void* data);
 typedef int (*pakfire_xfer_send_callback)(struct pakfire_xfer* xfer, void* data);
@@ -145,6 +144,5 @@ int pakfire_xfer_socket(struct pakfire_xfer* xfer, pakfire_xfer_open_callback op
        pakfire_xfer_recv_callback recv, pakfire_xfer_send_callback send, pakfire_xfer_close_callback close, void* data);
 
 int pakfire_xfer_send_message(struct pakfire_xfer* xfer, const char* message, const size_t length);
-#endif /* CURL_HAS_WEBSOCKETS */
 
 #endif /* PAKFIRE_XFER_H */