Add http_dir option (not yet used).
This commit is contained in:
parent
d75473ec63
commit
c4e7233159
@ -600,6 +600,18 @@
|
||||
<para>Not reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>http_dir</option> <replaceable>directory</replaceable></term>
|
||||
<listitem>
|
||||
<para>When a listener is using the websockets protocol,
|
||||
it is possible to serve http data as well. Set
|
||||
<option>http_dir</option> to a directory which
|
||||
contains the files you wish to serve. If this
|
||||
option is not specified, then no normal http
|
||||
connections will be possible.</para>
|
||||
<para>Not reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>listener</option> <replaceable>port</replaceable></term>
|
||||
<listitem>
|
||||
|
@ -150,6 +150,12 @@
|
||||
# only the cafile, certfile, keyfile and ciphers options are supported.
|
||||
#protocol mqtt
|
||||
|
||||
# When a listener is using the websockets protocol, it is possible to serve
|
||||
# http data as well. Set http_dir to a directory which contains the files you
|
||||
# wish to serve. If this option is not specified, then no normal http
|
||||
# connections will be possible.
|
||||
#http_dir
|
||||
|
||||
# Set use_username_as_clientid to true to replace the clientid that a client
|
||||
# connected with with its username. This allows authentication to be tied to
|
||||
# the clientid, which means that it is possible to prevent one client
|
||||
@ -284,8 +290,16 @@
|
||||
|
||||
# Choose the protocol to use when listening.
|
||||
# This can be either mqtt or websockets.
|
||||
# Certificate based TLS may be used with websockets, except that only the
|
||||
# cafile, certfile, keyfile and ciphers options are supported.
|
||||
#protocol mqtt
|
||||
|
||||
# When a listener is using the websockets protocol, it is possible to serve
|
||||
# http data as well. Set http_dir to a directory which contains the files you
|
||||
# wish to serve. If this option is not specified, then no normal http
|
||||
# connections will be possible.
|
||||
#http_dir
|
||||
|
||||
# Set use_username_as_clientid to true to replace the clientid that a client
|
||||
# connected with with its username. This allows authentication to be tied to
|
||||
# the clientid, which means that it is possible to prevent one client
|
||||
|
@ -1015,6 +1015,13 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
|
||||
if(_conf_parse_string(&token, "crlfile", &cur_listener->crlfile, saveptr)) return MOSQ_ERR_INVAL;
|
||||
#else
|
||||
_mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
|
||||
#endif
|
||||
}else if(!strcmp(token, "http_dir")){
|
||||
#ifdef WITH_WEBSOCKETS
|
||||
if(reload) continue; // Listeners not valid for reloading.
|
||||
if(_conf_parse_string(&token, "http_dir", &cur_listener->http_dir, saveptr)) return MOSQ_ERR_INVAL;
|
||||
#else
|
||||
_mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Websockets support not available.");
|
||||
#endif
|
||||
}else if(!strcmp(token, "idle_timeout")){
|
||||
#ifdef WITH_BRIDGE
|
||||
|
@ -75,6 +75,7 @@ struct _mqtt3_listener {
|
||||
#endif
|
||||
#ifdef WITH_WEBSOCKETS
|
||||
struct libwebsocket_context *ws_context;
|
||||
char *http_dir;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -297,6 +298,7 @@ struct _mqtt3_bridge{
|
||||
|
||||
#ifdef WITH_WEBSOCKETS
|
||||
struct libws_mqtt_hack {
|
||||
char *http_dir;
|
||||
struct mosquitto *old_mosq;
|
||||
struct mosquitto *new_mosq;
|
||||
struct libws_mqtt_hack *next;
|
||||
|
@ -331,6 +331,7 @@ struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listen
|
||||
struct libwebsocket_protocols *p;
|
||||
int protocol_count;
|
||||
int i;
|
||||
struct libws_mqtt_hack *user;
|
||||
|
||||
/* Count valid protocols */
|
||||
for(protocol_count=0; protocols[protocol_count].name; protocol_count++);
|
||||
@ -362,10 +363,12 @@ struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listen
|
||||
info.options |= LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT;
|
||||
}
|
||||
#endif
|
||||
info.user = _mosquitto_calloc(1, sizeof(struct libws_mqtt_hack));
|
||||
if(!info.user){
|
||||
user = _mosquitto_calloc(1, sizeof(struct libws_mqtt_hack));
|
||||
if(!user){
|
||||
return NULL;
|
||||
}
|
||||
user->http_dir = listener->http_dir;
|
||||
info.user = user;
|
||||
|
||||
lws_set_log_level(0, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user