Added location storage and handling in Controller and Load Balancer

This commit is contained in:
Thulinma 2020-06-19 13:12:31 +02:00
parent 0b6710e4eb
commit 45b5ea30ac
3 changed files with 17 additions and 25 deletions

View file

@ -551,6 +551,11 @@ void Controller::handleAPICommands(JSON::Value &Request, JSON::Value &Response){
Controller::prometheus = out["prometheus"].asStringRef();
}
if (in.isMember("defaultStream")){out["defaultStream"] = in["defaultStream"];}
if (in.isMember("location") && in["location"].isObject()){
out["location"]["lat"] = in["location"]["lat"].asDouble();
out["location"]["lon"] = in["location"]["lon"].asDouble();
out["location"]["name"] = in["location"]["name"].asStringRef();
}
}
if (Request.isMember("bandwidth")){
if (Request["bandwidth"].isObject()){

View file

@ -1729,6 +1729,13 @@ void Controller::handlePrometheus(HTTP::Parser &H, Socket::Connection &conn, int
resp["bw"].append(servUpBytes);
resp["bw"].append(servDownBytes);
resp["bwlimit"] = bwLimit;
if (Storage["config"].isMember("location") && Storage["config"]["location"].isMember("lat") && Storage["config"]["location"].isMember("lon")){
resp["loc"]["lat"] = Storage["config"]["location"]["lat"].asDouble();
resp["loc"]["lon"] = Storage["config"]["location"]["lon"].asDouble();
if (Storage["config"]["location"].isMember("name")){
resp["loc"]["name"] = Storage["config"]["location"]["name"].asStringRef();
}
}
resp["obw"].append(servUpOtherBytes);
resp["obw"].append(servDownOtherBytes);