Robustified stream/protocol related API calls

This commit is contained in:
Thulinma 2017-05-09 11:31:24 +02:00
parent 04e0dfeab0
commit 0e0da824f7
4 changed files with 30 additions and 0 deletions

View file

@ -167,6 +167,9 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
/// Local-only helper function that checks for duplicate protocols and removes them
static void removeDuplicateProtocols(){
JSON::Value & P = Controller::Storage["config"]["protocols"];
jsonForEach(P, it){
it->removeNullMembers();
}
std::set<std::string> ignores;
ignores.insert("online");
bool reloop = true;

View file

@ -132,11 +132,23 @@ namespace Controller {
if (out.isMember(jit.key())){
if ( !streamsEqual((*jit), out[jit.key()])){
out[jit.key()] = (*jit);
out[jit.key()].removeNullMembers();
out[jit.key()]["name"] = jit.key();
Log("STRM", std::string("Updated stream ") + jit.key());
}
}else{
std::string checked = jit.key();
Util::sanitizeName(checked);
if (checked != jit.key() || !checked.size()){
if (!checked.size()){
FAIL_MSG("Invalid stream name '%s'", jit.key().c_str());
}else{
FAIL_MSG("Invalid stream name '%s'. Suggested alternative: '%s'", jit.key().c_str(), checked.c_str());
}
continue;
}
out[jit.key()] = (*jit);
out[jit.key()].removeNullMembers();
out[jit.key()]["name"] = jit.key();
Log("STRM", std::string("New stream ") + jit.key());
}