From 4c147309a48b2dfc2b33effdac283f32e9561681 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 8 Jul 2015 09:07:48 +0100 Subject: [PATCH] Minimum supported libwebsockets version is now 1.3. --- ChangeLog.txt | 1 + compiling.txt | 1 + src/websockets.c | 28 +--------------------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b4231dfa..d588b5ee 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -22,6 +22,7 @@ Broker: it. Closes #470258. - Change sys tree printing output. This format shouldn't be relied upon and may change at any time. Closes #470246. +- Minimum supported libwebsockets version is now 1.3. Client library: - Outgoing messages with QoS>1 are no longer retried after a timeout period. diff --git a/compiling.txt b/compiling.txt index dcf7a12d..04ecb283 100644 --- a/compiling.txt +++ b/compiling.txt @@ -7,6 +7,7 @@ The following packages are required for mosquitto: * libsystemd (optional, disabled by default) * On Windows, the Redhat pthreads library is required if threading support is to be included. +* libwebsockets (optional, disabled by default, version 1.3 and above) To compile, run "make", but also see the file config.mk for more details on the various options that can be compiled in. diff --git a/src/websockets.c b/src/websockets.c index be6b1df5..812c6dc4 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Roger Light +Copyright (c) 2014-2015 Roger Light All rights reserved. Redistribution and use in source and binary forms, with or without @@ -66,18 +66,6 @@ struct libws_http_data { FILE *fptr; }; -#ifndef LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG - /* This is libwebsockets 1.2.x or earlier, we have to degrade our capabilities. - * Once lws 1.3 is widely available this should be removed. */ -# define LWS_IS_OLD -# define HTTP_STATUS_FORBIDDEN 403 -# define HTTP_STATUS_NOT_FOUND 404 -# define HTTP_STATUS_METHOD_NOT_ALLOWED 405 -# define HTTP_STATUS_REQ_URI_TOO_LONG 414 -# define HTTP_STATUS_INTERNAL_SERVER_ERROR 500 -# define libwebsockets_return_http_status(A, B, C, D) -#endif - static struct libwebsocket_protocols protocols[] = { /* first protocol must always be HTTP handler */ { @@ -209,10 +197,6 @@ static int callback_mqtt(struct libwebsocket_context *context, packet->pos += LWS_SEND_BUFFER_PRE_PADDING; } count = libwebsocket_write(wsi, &packet->payload[packet->pos], packet->to_process, LWS_WRITE_BINARY); -#ifdef LWS_IS_OLD - /* lws < 1.3 doesn't return a valid count, assume everything sent. */ - count = packet->to_process; -#endif if(count < 0){ return 0; } @@ -347,9 +331,7 @@ static int callback_http(struct libwebsocket_context *context, struct libws_mqtt_hack *hack; char *http_dir; size_t buflen, slen; -#ifndef LWS_IS_OLD size_t wlen; -#endif char *filename, *filename_canonical; unsigned char buf[4096]; struct stat filestat; @@ -369,13 +351,11 @@ static int callback_http(struct libwebsocket_context *context, return -1; } -#ifndef LWS_IS_OLD /* Forbid POST */ if(lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI)){ libwebsockets_return_http_status(context, wsi, HTTP_STATUS_METHOD_NOT_ALLOWED, NULL); return -1; } -#endif if(!strcmp((char *)in, "/")){ slen = strlen(http_dir) + strlen("/index.html") + 2; @@ -459,7 +439,6 @@ static int callback_http(struct libwebsocket_context *context, libwebsocket_callback_on_writable(context, wsi); break; -#ifndef LWS_IS_OLD case LWS_CALLBACK_HTTP_BODY: /* For extra POST data? */ return -1; @@ -499,7 +478,6 @@ static int callback_http(struct libwebsocket_context *context, }else{ return -1; } -#endif default: return 0; @@ -547,16 +525,12 @@ struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *li info.ssl_ca_filepath = listener->cafile; info.ssl_cert_filepath = listener->certfile; info.ssl_private_key_filepath = listener->keyfile; -#ifndef LWS_IS_OLD info.ssl_cipher_list = listener->ciphers; -#endif if(listener->require_certificate){ info.options |= LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT; } #endif -#ifndef LWS_IS_OLD info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; -#endif user = mosquitto__calloc(1, sizeof(struct libws_mqtt_hack)); if(!user){