Final remove support for legacy libwebsockets

This means libwebsockets < 2.4.0.
This commit is contained in:
Roger A. Light 2020-12-01 13:39:33 +00:00
parent 730fc34539
commit b34dcd2a67
11 changed files with 53 additions and 164 deletions

View File

@ -45,6 +45,7 @@ Breaking changes:
- The mosquitto_sub, mosquitto_pub, and mosquitto_rr clients will now load
OS provided CA certificates by default if `-L mqtts://...` is used, or if
the port is set to 8883 and no other CA certificates are loaded.
- Minimum support libwebsockets version is now 2.4.0
Broker:

View File

@ -291,12 +291,7 @@ struct mosquitto {
int shared_sub_count;
int pollfd_index;
# ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws *wsi;
# else
struct libwebsocket_context *ws_context;
struct libwebsocket *wsi;
# endif
# endif
bool ws_want_write;
bool assigned_id;

View File

@ -229,7 +229,7 @@ int net__socket_close(struct mosquitto *mosq)
if(mosq->state != mosq_cs_disconnecting){
mosquitto__set_state(mosq, mosq_cs_disconnect_ws);
}
libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
lws_callback_on_writable(mosq->wsi);
}else
#endif
{

View File

@ -69,7 +69,7 @@ int packet__alloc(struct mosquitto__packet *packet)
if(packet->remaining_count == 5) return MOSQ_ERR_PAYLOAD_SIZE;
packet->packet_length = packet->remaining_length + 1 + (uint8_t)packet->remaining_count;
#ifdef WITH_WEBSOCKETS
packet->payload = mosquitto__malloc(sizeof(uint8_t)*packet->packet_length + LWS_SEND_BUFFER_PRE_PADDING + LWS_SEND_BUFFER_POST_PADDING);
packet->payload = mosquitto__malloc(sizeof(uint8_t)*packet->packet_length + LWS_PRE);
#else
packet->payload = mosquitto__malloc(sizeof(uint8_t)*packet->packet_length);
#endif
@ -159,7 +159,7 @@ int packet__queue(struct mosquitto *mosq, struct mosquitto__packet *packet)
#ifdef WITH_BROKER
# ifdef WITH_WEBSOCKETS
if(mosq->wsi){
libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
lws_callback_on_writable(mosq->wsi);
return MOSQ_ERR_SUCCESS;
}else{
return packet__write(mosq);

View File

@ -2145,16 +2145,12 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "websockets_headers_size")){
#ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER) && LWS_LIBRARY_VERSION_NUMBER>=1007000
if(conf__parse_int(&token, "websockets_headers_size", &tmp_int, saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int < 0 || tmp_int > UINT16_MAX){
log__printf(NULL, MOSQ_LOG_WARNING, "Error: Websockets headers size must be between 0 and 65535 inclusive.");
return MOSQ_ERR_INVAL;
}
config->websockets_headers_size = (uint16_t)tmp_int;
# else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Websockets headers size require libwebsocket 1.7+");
# endif
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Websockets support not available.");
#endif

View File

@ -225,12 +225,12 @@ int mosquitto_main_loop(struct mosquitto__listener_sock *listensock, int listens
* citizens. */
if(db.config->listeners[i].ws_context){
#if LWS_LIBRARY_VERSION_NUMBER > 3002000
libwebsocket_service(db.config->listeners[i].ws_context, -1);
lws_service(db.config->listeners[i].ws_context, -1);
#elif LWS_LIBRARY_VERSION_NUMBER == 3002000
lws_sul_schedule(db.config->listeners[i].ws_context, 0, &sul, lws__sul_callback, 10);
libwebsocket_service(db.config->listeners[i].ws_context, 0);
lws_service(db.config->listeners[i].ws_context, 0);
#else
libwebsocket_service(db.config->listeners[i].ws_context, 0);
lws_service(db.config->listeners[i].ws_context, 0);
#endif
}
@ -264,7 +264,7 @@ void do_disconnect(struct mosquitto *context, int reason)
mosquitto__set_state(context, mosq_cs_disconnect_ws);
}
if(context->wsi){
libwebsocket_callback_on_writable(context->ws_context, context->wsi);
lws_callback_on_writable(context->wsi);
}
if(context->sock != INVALID_SOCKET){
HASH_DELETE(hh_sock, db.contexts_by_sock, context);

View File

@ -344,7 +344,7 @@ void listeners__stop(struct mosquitto__listener_sock *listensock, int listensock
for(i=0; i<db.config->listener_count; i++){
#ifdef WITH_WEBSOCKETS
if(db.config->listeners[i].ws_context){
libwebsocket_context_destroy(db.config->listeners[i].ws_context);
lws_context_destroy(db.config->listeners[i].ws_context);
}
mosquitto__free(db.config->listeners[i].ws_protocol);
#endif

View File

@ -23,25 +23,6 @@ Contributors:
#ifdef WITH_WEBSOCKETS
# include <libwebsockets.h>
# if defined(LWS_LIBRARY_VERSION_NUMBER)
# define libwebsocket_callback_on_writable(A, B) lws_callback_on_writable((B))
# define libwebsocket_service(A, B) lws_service((A), (B))
# define libwebsocket_create_context(A) lws_create_context((A))
# define libwebsocket_context_destroy(A) lws_context_destroy((A))
# define libwebsocket_write(A, B, C, D) lws_write((A), (B), (C), (D))
# define libwebsocket_get_socket_fd(A) lws_get_socket_fd((A))
# define libwebsockets_return_http_status(A, B, C, D) lws_return_http_status((B), (C), (D))
# define libwebsockets_get_protocol(A) lws_get_protocol((A))
# define libwebsocket_context lws_context
# define libwebsocket_protocols lws_protocols
# define libwebsocket_callback_reasons lws_callback_reasons
# define libwebsocket lws
# else
# define lws_pollfd pollfd
# define lws_service_fd(A, B) libwebsocket_service_fd((A), (B))
# define lws_pollargs libwebsocket_pollargs
# endif
#endif
#include "mosquitto_internal.h"
@ -240,9 +221,9 @@ struct mosquitto__listener {
enum mosquitto__keyform tls_keyform;
#endif
#ifdef WITH_WEBSOCKETS
struct libwebsocket_context *ws_context;
struct lws_context *ws_context;
char *http_dir;
struct libwebsocket_protocols *ws_protocol;
struct lws_protocols *ws_protocol;
#endif
struct mosquitto__security_options security_options;
#ifdef WITH_UNIX_SOCKETS
@ -841,11 +822,7 @@ DWORD WINAPI SigThreadProc(void* data);
* Websockets related functions
* ============================================================ */
#ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws_context *mosq_websockets_init(struct mosquitto__listener *listener, const struct mosquitto__config *conf);
# else
struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *listener, const struct mosquitto__config *conf);
# endif
#endif
void do_disconnect(struct mosquitto *context, int reason);

View File

@ -246,11 +246,7 @@ static void loop_handle_reads_writes(struct mosquitto *context, uint32_t events)
wspoll.fd = context->sock;
wspoll.events = (int16_t)context->events;
wspoll.revents = (int16_t)events;
#ifdef LWS_LIBRARY_VERSION_NUMBER
lws_service_fd(lws_get_context(context->wsi), &wspoll);
#else
lws_service_fd(context->ws_context, &wspoll);
#endif
return;
}
#endif

View File

@ -251,11 +251,7 @@ static void loop_handle_reads_writes(struct pollfd *pollfds)
wspoll.fd = pollfds[context->pollfd_index].fd;
wspoll.events = pollfds[context->pollfd_index].events;
wspoll.revents = pollfds[context->pollfd_index].revents;
#ifdef LWS_LIBRARY_VERSION_NUMBER
lws_service_fd(lws_get_context(context->wsi), &wspoll);
#else
lws_service_fd(context->ws_context, &wspoll);
#endif
continue;
}
#endif

View File

@ -54,24 +54,16 @@ POSSIBILITY OF SUCH DAMAGE.
#define WS_SERV_BUF_SIZE 4096
#define WS_TX_BUF_SIZE (WS_SERV_BUF_SIZE*2)
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user,
void *in,
size_t len);
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user,
void *in,
size_t len);
@ -86,79 +78,43 @@ struct libws_http_data {
FILE *fptr;
};
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
/* first protocol must always be HTTP handler */
{
"http-only", /* name */
callback_http, /* lws_callback_function */
sizeof (struct libws_http_data), /* per_session_data_size */
0, /* rx_buffer_size */
#ifndef LWS_LIBRARY_VERSION_NUMBER
0, /* no_buffer_all_partial_tx v1.3 only */
#endif
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
0, /* id */
#endif
#ifdef LWS_LIBRARY_VERSION_NUMBER
NULL, /* user v1.4 on */
# if LWS_LIBRARY_VERSION_NUMBER >= 2003000
WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */
# endif
#endif
},
{
"mqtt",
callback_mqtt,
sizeof(struct libws_mqtt_data),
0, /* rx_buffer_size */
#ifndef LWS_LIBRARY_VERSION_NUMBER
0, /* no_buffer_all_partial_tx v1.3 only */
#endif
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
1, /* id */
#endif
#ifdef LWS_LIBRARY_VERSION_NUMBER
NULL, /* user v1.4 on */
# if LWS_LIBRARY_VERSION_NUMBER >= 2003000
WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */
# endif
#endif
},
{
"mqttv3.1",
callback_mqtt,
sizeof(struct libws_mqtt_data),
0, /* rx_buffer_size */
#ifndef LWS_LIBRARY_VERSION_NUMBER
0, /* no_buffer_all_partial_tx v1.3 only */
#endif
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
2, /* id */
#endif
#ifdef LWS_LIBRARY_VERSION_NUMBER
NULL, /* user v1.4 on */
# if LWS_LIBRARY_VERSION_NUMBER >= 2003000
WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */
# endif
#endif
},
{
NULL,
NULL,
0,
0, /* rx_buffer_size */
#ifndef LWS_LIBRARY_VERSION_NUMBER
0, /* no_buffer_all_partial_tx v1.3 only */
#endif
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
0, /* id */
#endif
#ifdef LWS_LIBRARY_VERSION_NUMBER
NULL, /* user v1.4 on */
# if LWS_LIBRARY_VERSION_NUMBER >= 2003000
0 /* tx_packet_size v2.3.0 */
# endif
#endif
}
};
@ -171,13 +127,9 @@ static void easy_address(int sock, struct mosquitto *mosq)
}
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user,
void *in,
size_t len)
@ -187,7 +139,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
size_t txlen;
int count;
unsigned int ucount;
const struct libwebsocket_protocols *p;
const struct lws_protocols *p;
struct libws_mqtt_data *u = (struct libws_mqtt_data *)user;
size_t pos;
uint8_t *buf;
@ -198,15 +150,12 @@ static int callback_mqtt(struct libwebsocket_context *context,
case LWS_CALLBACK_ESTABLISHED:
mosq = context__init(WEBSOCKET_CLIENT);
if(mosq){
p = libwebsockets_get_protocol(wsi);
p = lws_get_protocol(wsi);
mosq->listener = p->user;
if(!mosq->listener){
mosquitto__free(mosq);
return -1;
}
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
mosq->ws_context = context;
#endif
mosq->wsi = wsi;
#ifdef WITH_TLS
if(in){
@ -220,7 +169,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
}else{
return -1;
}
easy_address(libwebsocket_get_socket_fd(wsi), mosq);
easy_address(lws_get_socket_fd(wsi), mosq);
if(!mosq->address){
/* getpeername and inet_ntop failed and not a bridge */
mosquitto__free(mosq);
@ -236,7 +185,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
u->mosq = NULL;
return -1;
}
mosq->sock = libwebsocket_get_socket_fd(wsi);
mosq->sock = lws_get_socket_fd(wsi);
HASH_ADD(hh_sock, db.contexts_by_sock, sock, sizeof(mosq->sock), mosq);
mux__add_in(mosq);
break;
@ -289,19 +238,19 @@ static int callback_mqtt(struct libwebsocket_context *context,
if(packet->pos == 0 && packet->to_process == packet->packet_length){
/* First time this packet has been dealt with.
* libwebsockets requires that the payload has
* LWS_SEND_BUFFER_PRE_PADDING space available before the
* actual data and LWS_SEND_BUFFER_POST_PADDING afterwards.
* LWS_PRE space available before the
* actual data.
* We've already made the payload big enough to allow this,
* but need to move it into position here. */
memmove(&packet->payload[LWS_SEND_BUFFER_PRE_PADDING], packet->payload, packet->packet_length);
packet->pos += LWS_SEND_BUFFER_PRE_PADDING;
memmove(&packet->payload[LWS_PRE], packet->payload, packet->packet_length);
packet->pos += LWS_PRE;
}
if(packet->to_process > WS_TX_BUF_SIZE){
txlen = WS_TX_BUF_SIZE;
}else{
txlen = packet->to_process;
}
count = libwebsocket_write(wsi, &packet->payload[packet->pos], txlen, LWS_WRITE_BINARY);
count = lws_write(wsi, &packet->payload[packet->pos], txlen, LWS_WRITE_BINARY);
if(count < 0){
if (mosq->state == mosq_cs_disconnect_ws
|| mosq->state == mosq_cs_disconnecting
@ -355,7 +304,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
return -1;
}
if(mosq->current_out_packet){
libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
lws_callback_on_writable(mosq->wsi);
}
break;
@ -438,7 +387,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
if(mosq->state != mosq_cs_disconnecting){
mosquitto__set_state(mosq, mosq_cs_disconnect_ws);
}
libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
lws_callback_on_writable(mosq->wsi);
} else if (rc) {
do_disconnect(mosq, MOSQ_ERR_CONN_LOST);
return -1;
@ -455,10 +404,7 @@ static int callback_mqtt(struct libwebsocket_context *context,
static char *http__canonical_filename(
#ifndef LWS_LIBRARY_VERSION_NUMBER
struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
struct lws *wsi,
const char *in,
const char *http_dir)
{
@ -473,7 +419,7 @@ static char *http__canonical_filename(
}
filename = mosquitto__malloc(slen);
if(!filename){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
lws_return_http_status(wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
return NULL;
}
if(((char *)in)[inlen-1] == '/'){
@ -488,7 +434,7 @@ static char *http__canonical_filename(
filename_canonical = _fullpath(NULL, filename, 0);
mosquitto__free(filename);
if(!filename_canonical){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
lws_return_http_status(wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
return NULL;
}
#else
@ -496,13 +442,13 @@ static char *http__canonical_filename(
mosquitto__free(filename);
if(!filename_canonical){
if(errno == EACCES){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_FORBIDDEN, NULL);
lws_return_http_status(wsi, HTTP_STATUS_FORBIDDEN, NULL);
}else if(errno == EINVAL || errno == EIO || errno == ELOOP){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
lws_return_http_status(wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
}else if(errno == ENAMETOOLONG){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_REQ_URI_TOO_LONG, NULL);
lws_return_http_status(wsi, HTTP_STATUS_REQ_URI_TOO_LONG, NULL);
}else if(errno == ENOENT || errno == ENOTDIR){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_NOT_FOUND, NULL);
lws_return_http_status(wsi, HTTP_STATUS_NOT_FOUND, NULL);
}
return NULL;
}
@ -510,7 +456,7 @@ static char *http__canonical_filename(
if(strncmp(http_dir, filename_canonical, strlen(http_dir))){
/* Requested file isn't within http_dir, deny access. */
free(filename_canonical);
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_FORBIDDEN, NULL);
lws_return_http_status(wsi, HTTP_STATUS_FORBIDDEN, NULL);
return NULL;
}
@ -518,13 +464,9 @@ static char *http__canonical_filename(
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user,
void *in,
size_t len)
@ -549,11 +491,7 @@ static int callback_http(struct libwebsocket_context *context,
return -1;
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
hack = (struct libws_mqtt_hack *)lws_context_user(lws_get_context(wsi));
#else
hack = (struct libws_mqtt_hack *)libwebsocket_context_user(context);
#endif
if(!hack){
return -1;
}
@ -566,26 +504,22 @@ static int callback_http(struct libwebsocket_context *context,
/* Forbid POST */
if(lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI)){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_METHOD_NOT_ALLOWED, NULL);
lws_return_http_status(wsi, HTTP_STATUS_METHOD_NOT_ALLOWED, NULL);
return -1;
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
filename_canonical = http__canonical_filename(wsi, (char *)in, http_dir);
#else
filename_canonical = http__canonical_filename(context, wsi, (char *)in, http_dir);
#endif
if(!filename_canonical) return -1;
u->fptr = fopen(filename_canonical, "rb");
if(!u->fptr){
free(filename_canonical);
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_NOT_FOUND, NULL);
lws_return_http_status(wsi, HTTP_STATUS_NOT_FOUND, NULL);
return -1;
}
if(fstat(fileno(u->fptr), &filestat) < 0){
free(filename_canonical);
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
lws_return_http_status(wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
fclose(u->fptr);
u->fptr = NULL;
return -1;
@ -601,11 +535,11 @@ static int callback_http(struct libwebsocket_context *context,
buflen = (size_t)snprintf((char *)buf, 4096, "HTTP/1.0 302 OK\r\n"
"Location: %s/\r\n\r\n",
(char *)in);
return libwebsocket_write(wsi, buf, buflen, LWS_WRITE_HTTP);
return lws_write(wsi, buf, buflen, LWS_WRITE_HTTP);
}
if((filestat.st_mode & S_IFREG) != S_IFREG){
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_FORBIDDEN, NULL);
lws_return_http_status(wsi, HTTP_STATUS_FORBIDDEN, NULL);
fclose(u->fptr);
u->fptr = NULL;
free(filename_canonical);
@ -619,12 +553,12 @@ static int callback_http(struct libwebsocket_context *context,
"Server: mosquitto\r\n"
"Content-Length: %u\r\n\r\n",
(unsigned int)filestat.st_size);
if(libwebsocket_write(wsi, buf, buflen, LWS_WRITE_HTTP) < 0){
if(lws_write(wsi, buf, buflen, LWS_WRITE_HTTP) < 0){
fclose(u->fptr);
u->fptr = NULL;
return -1;
}
libwebsocket_callback_on_writable(context, wsi);
lws_callback_on_writable(wsi);
break;
case LWS_CALLBACK_HTTP_BODY:
@ -649,7 +583,7 @@ static int callback_http(struct libwebsocket_context *context,
u->fptr = NULL;
return -1;
}
rc = libwebsocket_write(wsi, buf, buflen, LWS_WRITE_HTTP);
rc = lws_write(wsi, buf, buflen, LWS_WRITE_HTTP);
if(rc < 0){
return -1;
}
@ -667,7 +601,7 @@ static int callback_http(struct libwebsocket_context *context,
}
}
}while(u->fptr && !lws_send_pipe_choked(wsi));
libwebsocket_callback_on_writable(context, wsi);
lws_callback_on_writable(wsi);
}else{
return -1;
}
@ -718,10 +652,10 @@ static void log_wrap(int level, const char *line)
log__printf(NULL, MOSQ_LOG_WEBSOCKETS, "%s", l);
}
struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *listener, const struct mosquitto__config *conf)
struct lws_context *mosq_websockets_init(struct mosquitto__listener *listener, const struct mosquitto__config *conf)
{
struct lws_context_creation_info info;
struct libwebsocket_protocols *p;
struct lws_protocols *p;
size_t protocol_count;
int i;
struct libws_mqtt_hack *user;
@ -729,7 +663,7 @@ struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *li
/* Count valid protocols */
for(protocol_count=0; protocols[protocol_count].name; protocol_count++);
p = mosquitto__calloc(protocol_count+1, sizeof(struct libwebsocket_protocols));
p = mosquitto__calloc(protocol_count+1, sizeof(struct lws_protocols));
if(!p){
log__printf(NULL, MOSQ_LOG_ERR, "Out of memory.");
return NULL;
@ -754,22 +688,18 @@ struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *li
info.ssl_private_key_filepath = listener->keyfile;
info.ssl_cipher_list = listener->ciphers;
#if defined(WITH_WEBSOCKETS) && LWS_LIBRARY_VERSION_NUMBER>=3001000
info->tls_1_3_plus_cipher_list = listener->ciphers_tls13;
info.tls1_3_plus_cipher_list = listener->ciphers_tls13;
#endif
if(listener->require_certificate){
info.options |= LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT;
}
#endif
#if LWS_LIBRARY_VERSION_MAJOR>1
info.options |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
#endif
if(listener->socket_domain == AF_INET){
info.options |= LWS_SERVER_OPTION_DISABLE_IPV6;
}
#if defined(LWS_LIBRARY_VERSION_NUMBER) && LWS_LIBRARY_VERSION_NUMBER>=1007000
info.max_http_header_data = conf->websockets_headers_size;
#endif
user = mosquitto__calloc(1, sizeof(struct libws_mqtt_hack));
if(!user){
@ -793,15 +723,13 @@ struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *li
}
info.user = user;
#if defined(LWS_LIBRARY_VERSION_NUMBER) && LWS_LIBRARY_VERSION_NUMBER>=2004000
info.pt_serv_buf_size = WS_SERV_BUF_SIZE;
#endif
listener->ws_protocol = p;
lws_set_log_level(conf->websockets_log_level, log_wrap);
log__printf(NULL, MOSQ_LOG_INFO, "Opening websockets listen socket on port %d.", listener->port);
return libwebsocket_create_context(&info);
return lws_create_context(&info);
}