TT#157801 skip libwebsockets IPv6 bindings if not available

Add an explicit test to see if libwebsockets has been compiled with
support for IPv6. If it hasn't then we don't try to create v6 bindings.

Closes #1432

Change-Id: I6902f5b4203aa09cb28a8edb46f97b339677ed75
pull/1439/head
Richard Fuchs 4 years ago
parent 6d0eba931a
commit db0dbd3666

@ -920,6 +920,10 @@ int websocket_init(void) {
(!rtpe_config.https_ifs || !*rtpe_config.https_ifs))
return 0;
struct sockaddr_storage sa;
int ret = lws_interface_to_sa(1, "::1", (void *) &sa, sizeof(sa));
bool have_lws_ipv6 = (ret == 0);
const char *err = NULL;
lws_set_log_level(LLL_ERR | LLL_WARN, websocket_log);
@ -945,10 +949,15 @@ int websocket_init(void) {
goto err;
bool success = false;
bool ipv6_fail = false;
for (int i = 0; i < G_N_ELEMENTS(eps); i++) {
endpoint_t *ep = &eps[i];
if (!ep->port)
continue;
if (ep->address.family->af == AF_INET6 && !have_lws_ipv6) {
ipv6_fail = true;
continue;
}
struct lws_context_creation_info *vhost = g_slice_alloc(sizeof(*vhost));
g_queue_push_tail(&websocket_vhost_configs, vhost);
@ -966,6 +975,9 @@ int websocket_init(void) {
success = true;
}
err = "Failed to create any LWS vhost from given config";
if (ipv6_fail)
err = "Failed to create any LWS vhost from given config. Hint: LWS IPv6 support is not "
"available and config lists at least one IPv6 vhost";
if (!success)
goto err;
}
@ -983,10 +995,15 @@ int websocket_init(void) {
goto err;
bool success = false;
bool ipv6_fail = false;
for (int i = 0; i < G_N_ELEMENTS(eps); i++) {
endpoint_t *ep = &eps[i];
if (!ep->port)
continue;
if (ep->address.family->af == AF_INET6 && !have_lws_ipv6) {
ipv6_fail = true;
continue;
}
struct lws_context_creation_info *vhost = g_slice_alloc(sizeof(*vhost));
g_queue_push_tail(&websocket_vhost_configs, vhost);
@ -1008,6 +1025,9 @@ int websocket_init(void) {
success = true;
}
err = "Failed to create any LWS vhost from given config";
if (ipv6_fail)
err = "Failed to create any LWS vhost from given config. Hint: LWS IPv6 support is not "
"available and config lists at least one IPv6 vhost";
if (!success)
goto err;
}

Loading…
Cancel
Save