Merge branch 'development' into LTS_development

# Conflicts:
#	src/controller/controller_api.cpp
This commit is contained in:
Thulinma 2020-07-15 19:30:40 +02:00
commit a15b3c20f1
5 changed files with 52 additions and 28 deletions

View file

@ -2,6 +2,7 @@
#include <sys/stat.h> //for browse API call
#include <fstream>
#include <mist/http_parser.h>
#include <mist/url.h>
#include <mist/auth.h>
#include <mist/stream.h>
#include <mist/config.h>
@ -444,6 +445,7 @@ void Controller::handleUDPAPI(void * np){
return;
}
Util::Procs::socketList.insert(uSock.getSock());
uSock.SetDestination(UDP_API_HOST, UDP_API_PORT);
while (Controller::conf.is_active){
if (uSock.Receive()){
MEDIUM_MSG("UDP API: %s", uSock.data);
@ -453,6 +455,7 @@ void Controller::handleUDPAPI(void * np){
if (Request.isObject()){
tthread::lock_guard<tthread::mutex> guard(configMutex);
handleAPICommands(Request, Response);
uSock.SendNow(Response.toString());
}else{
WARN_MSG("Invalid API command received over UDP: %s", uSock.data);
}
@ -941,6 +944,15 @@ void Controller::handleAPICommands(JSON::Value & Request, JSON::Value & Response
Controller::fillActive(Request["stats_streams"], Response["stats_streams"]);
}
if (Request.isMember("api_endpoint")){
HTTP::URL url("http://localhost:4242");
url.host = Util::listenInterface;
if (url.host == "::"){url.host = "::1";}
if (url.host == "0.0.0.0"){url.host = "127.0.0.1";}
url.port = JSON::Value(Util::listenPort).asString();
Response["api_endpoint"] = url.getUrl();
}
if (Request.isMember("invalidate_sessions")){
if (Request["invalidate_sessions"].isArray()){
for (unsigned int i = 0; i < Request["invalidate_sessions"].size(); ++i){