http-api: Allow anon access on local only connections

This commit is contained in:
Roger Light 2026-01-12 17:33:57 +00:00
parent c6d3e9b225
commit 5b93c81269

View file

@ -407,12 +407,24 @@ static enum MHD_Result http_api_handler(void *cls, struct MHD_Connection
int http_api__start_local(struct mosquitto__listener *listener)
{
listener->security_options = mosquitto_calloc(1, sizeof(struct mosquitto__security_options));
if(listener->security_options == NULL){
return MOSQ_ERR_NOMEM;
}
listener->host = mosquitto_strdup("127.0.0.1");
if(!listener->host){
mosquitto_FREE(listener->security_options);
return MOSQ_ERR_NOMEM;
}
listener->port = 9883;
if(db.config->security_options.allow_anonymous == -1){
listener->security_options->allow_anonymous = true;
}else{
listener->security_options->allow_anonymous = db.config->security_options.allow_anonymous;
}
if(listener->http_dir == NULL && strlen(HTTP_API_DIR) > 1){
#ifdef WIN32
char *http_dir_canonical = _fullpath(NULL, HTTP_API_DIR, 0);