Minimum supported libwebsockets version is now 1.3.

This commit is contained in:
Roger A. Light 2015-07-08 09:07:48 +01:00
parent 300034f868
commit 4c147309a4
3 changed files with 3 additions and 27 deletions

View File

@ -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.

View File

@ -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.

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2014 Roger Light <roger@atchoo.org>
Copyright (c) 2014-2015 Roger Light <roger@atchoo.org>
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){