Robustified stream/protocol related API calls
This commit is contained in:
parent
04e0dfeab0
commit
0e0da824f7
4 changed files with 30 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue