Add socket_domain option.

pull/1077/head
Roger A. Light 7 years ago
parent 8509dde342
commit d29dac087d

@ -1,6 +1,12 @@
1.5.5 - 201812xx
================
Broker:
- Add `socket_domain` option to allow listeners to disable IPv6 support.
This is required to work around a problem in libwebsockets that means
sockets only listen on IPv6 by default if IPv6 support is compiled in.
Closes #1004.
Client:
- Always print leading zeros in mosquitto_sub when output format is hex.
Closes #1066.

@ -813,6 +813,27 @@
<para>Not reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>socket_domain</option> [ ipv4 | ipv6 ]</term>
<listitem>
<para>By default, a listener will attempt to listen on
all supported IP protocol versions. If you do not
have an IPv4 or IPv6 interface you may wish to
disable support for either of those protocol
versions. In particular, note that due to the
limitations of the websockets library, it will only
ever attempt to open IPv6 sockets if IPv6 support
is compiled in, and so will fail if IPv6 is not
available.</para>
<para>Set to <option>ipv4</option> to force the
listener to only use IPv4, or set to
<option>ipv6</option> to force the listener to only
use IPv6. If you want support for both IPv4 and
IPv6, then do not use the
<option>socket_domain</option> option.</para>
<para>Not reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>use_username_as_clientid</option> [ true | false ]</term>
<listitem>

@ -446,6 +446,7 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
|| config->default_listener.max_connections != -1
|| config->default_listener.mount_point
|| config->default_listener.protocol != mp_mqtt
|| config->default_listener.socket_domain
|| config->default_listener.security_options.password_file
|| config->default_listener.security_options.psk_file
|| config->default_listener.security_options.auth_plugin_config_count
@ -476,6 +477,7 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
}
config->listeners[config->listener_count-1].max_connections = config->default_listener.max_connections;
config->listeners[config->listener_count-1].protocol = config->default_listener.protocol;
config->listeners[config->listener_count-1].socket_domain = config->default_listener.socket_domain;
config->listeners[config->listener_count-1].client_count = 0;
config->listeners[config->listener_count-1].socks = NULL;
config->listeners[config->listener_count-1].sock_count = 0;
@ -1773,6 +1775,22 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
#endif
}else if(!strcmp(token, "socket_domain")){
if(reload) continue; // Listeners not valid for reloading.
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(!strcmp(token, "ipv4")){
cur_listener->socket_domain = AF_INET;
}else if(!strcmp(token, "ipv6")){
cur_listener->socket_domain = AF_INET6;
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid socket_domain value \"%s\" in configuration.", token);
return MOSQ_ERR_INVAL;
}
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty socket_domain value in configuration.");
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "store_clean_interval")){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: store_clean_interval is no longer needed.");
}else if(!strcmp(token, "sys_interval")){

@ -218,6 +218,7 @@ struct mosquitto__listener {
int sock_count;
int client_count;
enum mosquitto_protocol protocol;
int socket_domain;
bool use_username_as_clientid;
#ifdef WITH_TLS
char *cafile;

@ -391,7 +391,11 @@ int net__socket_listen(struct mosquitto__listener *listener)
snprintf(service, 10, "%d", listener->port);
memset(&hints, 0, sizeof(struct addrinfo));
if(listener->socket_domain){
hints.ai_family = listener->socket_domain;
}else{
hints.ai_family = AF_UNSPEC;
}
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM;

@ -729,6 +729,9 @@ struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *li
#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;
}
user = mosquitto__calloc(1, sizeof(struct libws_mqtt_hack));
if(!user){

Loading…
Cancel
Save