Pro side of JSON library updates.
This commit is contained in:
parent
74c8932106
commit
8fb8a98c5f
5 changed files with 34 additions and 36 deletions
|
@ -247,13 +247,13 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
Controller::deleteStream(Request["deletestream"].asStringRef(), Controller::Storage["streams"]);
|
||||
}
|
||||
if (Request["deletestream"].isArray()){
|
||||
for (JSON::ArrIter it = Request["deletestream"].ArrBegin(); it != Request["deletestream"].ArrEnd(); ++it){
|
||||
jsonForEach(Request["deletestream"], it){
|
||||
Controller::deleteStream(it->asStringRef(), Controller::Storage["streams"]);
|
||||
}
|
||||
}
|
||||
if (Request["deletestream"].isObject()){
|
||||
for (JSON::ObjIter it = Request["deletestream"].ObjBegin(); it != Request["deletestream"].ObjEnd(); ++it){
|
||||
Controller::deleteStream(it->first, Controller::Storage["streams"]);
|
||||
jsonForEach(Request["deletestream"], it){
|
||||
Controller::deleteStream(it.key(), Controller::Storage["streams"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
///
|
||||
if (Request.isMember("addprotocol")){
|
||||
if (Request["addprotocol"].isArray()){
|
||||
for (JSON::ArrIter it = Request["addprotocol"].ArrBegin(); it != Request["addprotocol"].ArrEnd(); ++it){
|
||||
jsonForEach(Request["addprotocol"], it){
|
||||
Controller::Storage["config"]["protocols"].append(*it);
|
||||
}
|
||||
}
|
||||
|
@ -314,9 +314,9 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
if (Request.isMember("deleteprotocol")){
|
||||
if (Request["deleteprotocol"].isArray() && Request["deleteprotocol"].size()){
|
||||
JSON::Value newProtocols;
|
||||
for (JSON::ArrIter it = Controller::Storage["config"]["protocols"].ArrBegin(); it != Controller::Storage["config"]["protocols"].ArrEnd(); ++it){
|
||||
jsonForEach(Controller::Storage["config"]["protocols"], it){
|
||||
bool add = true;
|
||||
for (JSON::ArrIter pit = Request["deleteprotocol"].ArrBegin(); pit != Request["deleteprotocol"].ArrEnd(); ++pit){
|
||||
jsonForEach(Request["deleteprotocol"], pit){
|
||||
if (*it == *pit){
|
||||
add = false;
|
||||
break;
|
||||
|
@ -330,7 +330,7 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
}
|
||||
if (Request["deleteprotocol"].isObject()){
|
||||
JSON::Value newProtocols;
|
||||
for (JSON::ArrIter it = Controller::Storage["config"]["protocols"].ArrBegin(); it != Controller::Storage["config"]["protocols"].ArrEnd(); ++it){
|
||||
jsonForEach(Controller::Storage["config"]["protocols"], it){
|
||||
if (*it != Request["deleteprotocol"]){
|
||||
newProtocols.append(*it);
|
||||
}
|
||||
|
@ -490,9 +490,9 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
if (!Request.isMember("streams") && (Request.isMember("addstream") || Request.isMember("deletestream"))){
|
||||
Response["streams"]["incomplete list"] = 1ll;
|
||||
if (Request.isMember("addstream")){
|
||||
for (JSON::ObjIter jit = Request["addstream"].ObjBegin(); jit != Request["addstream"].ObjEnd(); jit++){
|
||||
if (Controller::Storage["streams"].isMember(jit->first)){
|
||||
Response["streams"][jit->first] = Controller::Storage["streams"][jit->first];
|
||||
jsonForEach(Request["addstream"], jit){
|
||||
if (Controller::Storage["streams"].isMember(jit.key())){
|
||||
Response["streams"][jit.key()] = Controller::Storage["streams"][jit.key()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Controller{
|
|||
|
||||
Storage["streams"][streamName].removeMember("hardlimit_active");
|
||||
if (Storage["streams"][streamName]["online"].asInt() != 1){
|
||||
for (JSON::ArrIter limitIt = Storage["streams"][streamName]["limits"].ArrBegin(); limitIt != Storage["streams"][streamName]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["streams"][streamName]["limits"], limitIt){
|
||||
if ((*limitIt).isMember("triggered")){
|
||||
if ((*limitIt)["type"].asString() == "soft"){
|
||||
Log("SLIM", "Softlimit " + (*limitIt)["name"].asString() + " <= " + (*limitIt)["value"].asString() + " for stream " + streamName + " reset - stream unavailable.");
|
||||
|
@ -35,7 +35,7 @@ namespace Controller{
|
|||
}
|
||||
|
||||
//run over all limits.
|
||||
for (JSON::ArrIter limitIt = Storage["streams"][streamName]["limits"].ArrBegin(); limitIt != Storage["streams"][streamName]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["streams"][streamName]["limits"], limitIt){
|
||||
bool triggerLimit = false;
|
||||
if ((*limitIt)["name"].asString() == "users" && connectedUsers >= (*limitIt)["value"].asInt()){
|
||||
triggerLimit = true;
|
||||
|
@ -94,8 +94,8 @@ namespace Controller{
|
|||
|
||||
//check stream limits
|
||||
if (Storage["streams"].size()){
|
||||
for (JSON::ObjIter strmIt = Storage["streams"].ObjBegin(); strmIt != Storage["streams"].ObjEnd(); strmIt++){
|
||||
checkStreamLimits(strmIt->first, strmBandw[strmIt->first], strmUsers[strmIt->first]);
|
||||
jsonForEach(Storage["streams"], strmIt){
|
||||
checkStreamLimits(strmIt.key(), strmBandw[strmIt.key()], strmUsers[strmIt.key()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace Controller{
|
|||
return;
|
||||
}
|
||||
|
||||
for (JSON::ArrIter limitIt = Storage["config"]["limits"].ArrBegin(); limitIt != Storage["config"]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["config"]["limits"], limitIt){
|
||||
bool triggerLimit = false;
|
||||
if ((*limitIt)["name"].asString() == "users" && connectedUsers >= (*limitIt)["value"].asInt()){
|
||||
triggerLimit = true;
|
||||
|
@ -211,12 +211,11 @@ namespace Controller{
|
|||
return false;
|
||||
}
|
||||
std::string myCountryName = getCountry(host);
|
||||
JSON::ArrIter limitIt;
|
||||
bool hasWhitelist = false;
|
||||
bool hostOnWhitelist = false;
|
||||
if (Storage["streams"].isMember(streamName)){
|
||||
if (Storage["streams"][streamName].isMember("limits") && Storage["streams"][streamName]["limits"].size()){
|
||||
for (limitIt = Storage["streams"][streamName]["limits"].ArrBegin(); limitIt != Storage["streams"][streamName]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["streams"][streamName]["limits"], limitIt){
|
||||
if ((*limitIt)["name"].asString() == "host"){
|
||||
if ((*limitIt)["value"].asString()[0] == '+'){
|
||||
if (!onList(host, (*limitIt)["value"].asString().substr(1))){
|
||||
|
@ -291,7 +290,7 @@ namespace Controller{
|
|||
}
|
||||
}
|
||||
if (Storage["config"]["limits"].size()){
|
||||
for (limitIt = Storage["config"]["limits"].ArrBegin(); limitIt != Storage["config"]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["config"]["limits"], limitIt){
|
||||
if ((*limitIt)["name"].asString() == "host"){
|
||||
if ((*limitIt)["value"].asString()[0] == '+'){
|
||||
if (!onList(host, (*limitIt)["value"].asString().substr(1))){
|
||||
|
|
|
@ -134,17 +134,17 @@ namespace Controller {
|
|||
ret["needs_update"].null();
|
||||
|
||||
// check if everything is up to date or not
|
||||
for (JSON::ObjIter it = updrInfo.ObjBegin(); it != updrInfo.ObjEnd(); it++){
|
||||
if (it->first.substr(0, 4) != "Mist"){
|
||||
jsonForEach(updrInfo, it){
|
||||
if (it.key().substr(0, 4) != "Mist"){
|
||||
continue;
|
||||
}
|
||||
ret[it->first] = it->second;
|
||||
if (it->second.asString() != Secure::md5(readFile(Util::getMyPath() + it->first))){
|
||||
ret[it.key()] = *it;
|
||||
if (it->asString() != Secure::md5(readFile(Util::getMyPath() + it.key()))){
|
||||
ret["uptodate"] = 0;
|
||||
if (it->first.substr(0, 14) == "MistController"){
|
||||
ret["needs_update"].append(it->first);
|
||||
if (it.key().substr(0, 14) == "MistController"){
|
||||
ret["needs_update"].append(it.key());
|
||||
}else{
|
||||
ret["needs_update"].prepend(it->first);
|
||||
ret["needs_update"].prepend(it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ namespace Controller {
|
|||
}
|
||||
|
||||
//loop through the available components, update them
|
||||
for (JSON::ArrIter it = updrInfo["needs_update"].ArrBegin(); it != updrInfo["needs_update"].ArrEnd(); it++){
|
||||
jsonForEach(updrInfo["needs_update"], it){
|
||||
updateComponent(it->asStringRef(), updrInfo[it->asStringRef()].asStringRef(), updrConn);
|
||||
}
|
||||
updrConn.close();
|
||||
|
|
|
@ -88,13 +88,13 @@ void Controller::uplinkConnection(void * np) {
|
|||
Controller::Storage["streams"].removeMember(curVal.asStringRef());
|
||||
}
|
||||
if (curVal.isArray()) {
|
||||
for (JSON::ArrIter it = curVal.ArrBegin(); it != curVal.ArrEnd(); ++it) {
|
||||
jsonForEach(curVal, it) {
|
||||
Controller::Storage["streams"].removeMember(it->asString());
|
||||
}
|
||||
}
|
||||
if (curVal.isObject()) {
|
||||
for (JSON::ObjIter it = curVal.ObjBegin(); it != curVal.ObjEnd(); ++it) {
|
||||
Controller::Storage["streams"].removeMember(it->first);
|
||||
jsonForEach(curVal, it) {
|
||||
Controller::Storage["streams"].removeMember(it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,10 +113,10 @@ void Controller::uplinkConnection(void * np) {
|
|||
totalsRequest["start"] = (long long)lastSend;
|
||||
Controller::fillTotals(totalsRequest, data["totals"]);
|
||||
data["streams"] = Controller::Storage["streams"];
|
||||
for (JSON::ObjIter it = data["streams"].ObjBegin(); it != data["streams"].ObjEnd(); it++){
|
||||
it->second.removeMember("meta");
|
||||
it->second.removeMember("l_meta");
|
||||
it->second.removeMember("name");
|
||||
jsonForEach(data["streams"], it){
|
||||
it->removeMember("meta");
|
||||
it->removeMember("l_meta");
|
||||
it->removeMember("name");
|
||||
}
|
||||
data["config"] = Controller::Storage["config"];
|
||||
data["config"]["uniq"] = uniqId;
|
||||
|
|
|
@ -497,12 +497,11 @@ namespace Mist {
|
|||
return false;
|
||||
}
|
||||
std::string myCountryName = getCountry(host);
|
||||
JSON::ArrIter limitIt;
|
||||
bool hasWhitelist = false;
|
||||
bool hostOnWhitelist = false;
|
||||
if (Storage["streams"].isMember(streamName)){
|
||||
if (Storage["streams"][streamName].isMember("limits") && Storage["streams"][streamName]["limits"].size()){
|
||||
for (limitIt = Storage["streams"][streamName]["limits"].ArrBegin(); limitIt != Storage["streams"][streamName]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["streams"][streamName]["limits"], limitIt){
|
||||
if ((*limitIt)["name"].asString() == "host"){
|
||||
if ((*limitIt)["value"].asString()[0] == '+'){
|
||||
if (!onList(host, (*limitIt)["value"].asString().substr(1))){
|
||||
|
@ -577,7 +576,7 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
if (Storage["config"]["limits"].size()){
|
||||
for (limitIt = Storage["config"]["limits"].ArrBegin(); limitIt != Storage["config"]["limits"].ArrEnd(); limitIt++){
|
||||
jsonForEach(Storage["config"]["limits"], limitIt){
|
||||
if ((*limitIt)["name"].asString() == "host"){
|
||||
if ((*limitIt)["value"].asString()[0] == '+'){
|
||||
if (!onList(host, (*limitIt)["value"].asString().substr(1))){
|
||||
|
|
Loading…
Add table
Reference in a new issue