[170] Fix WS listeners not being able to bind to an IP.

Closes #170. Thanks to minghuadev.

Bug: https://github.com/eclipse/mosquitto/issues/170
This commit is contained in:
Roger A. Light 2016-05-26 09:21:15 +01:00
parent afc2c9951c
commit 7761218d3c
4 changed files with 17 additions and 6 deletions

View File

@ -16,6 +16,8 @@ Broker:
- Fix reconnecting for bridges that use TLS on Windows. Closes #154. - Fix reconnecting for bridges that use TLS on Windows. Closes #154.
- Broker and bridges can now cope with unknown incoming PUBACK, PUBREC, - Broker and bridges can now cope with unknown incoming PUBACK, PUBREC,
PUBREL, PUBCOMP without disconnecting. Closes #57. PUBREL, PUBCOMP without disconnecting. Closes #57.
- Fix websockets listeners not being able to bind to an IP address. Closes
#170.
Client library: Client library:
- Fix the case where a message received just before the keepalive timer - Fix the case where a message received just before the keepalive timer

View File

@ -629,17 +629,23 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>listener</option> <replaceable>port</replaceable></term> <term><option>listener</option> <replaceable>port</replaceable> <replaceable><optional>bind address/host</optional></replaceable></term>
<listitem> <listitem>
<para>Listen for incoming network connection on the <para>Listen for incoming network connection on the
specified port. A second optional argument allows specified port. A second optional argument allows
the listener to be bound to a specific ip the listener to be bound to a specific ip
address/hostname. If this variable is used and address/hostname. If this variable is used and
neither <option>bind_address</option> nor neither the global <option>bind_address</option>
<option>port</option> are used then the default nor <option>port</option> options are used then the
listener will not be started. This option may be default listener will not be started.</para>
specified multiple times. See also the <para>The <option>bind address/host</option> option
<option>mount_point</option> option.</para> allows this listener to be bound to a specific IP
address by passing an IP address or hostname. For
websockets listeners, it is only possible to pass
an IP address here.</para>
<para>This option may be specified multiple times. See
also the <option>mount_point</option>
option.</para>
<para>Not reloaded on reload signal.</para> <para>Not reloaded on reload signal.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -271,6 +271,8 @@
# this case, mosquitto will attempt to bind the listener to that # this case, mosquitto will attempt to bind the listener to that
# address and so restrict access to the associated network and # address and so restrict access to the associated network and
# interface. By default, mosquitto will listen on all interfaces. # interface. By default, mosquitto will listen on all interfaces.
# Note that for a websockets listener it is not possible to bind to a host
# name.
# listener port-number [ip address/host name] # listener port-number [ip address/host name]
#listener #listener

View File

@ -584,6 +584,7 @@ struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listen
} }
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
info.iface = listener->host;
info.port = listener->port; info.port = listener->port;
info.protocols = p; info.protocols = p;
info.gid = -1; info.gid = -1;