Added Buffer->Controller logging capabilities.
This commit is contained in:
parent
ce5b99774d
commit
d625e68c5f
4 changed files with 23 additions and 5 deletions
|
@ -180,7 +180,6 @@ namespace Buffer {
|
|||
if ( !usr->S.Received().get().empty()){
|
||||
switch (usr->S.Received().get()[0]){
|
||||
case 'P': { //Push
|
||||
std::cout << "Push attempt from IP " << usr->S.Received().get().substr(2) << std::endl;
|
||||
if (thisStream->checkWaitingIP(usr->S.Received().get().substr(2))){
|
||||
usr->S.Received().get().clear();
|
||||
Socket::Connection tmp = usr->S;
|
||||
|
@ -326,7 +325,6 @@ namespace Buffer {
|
|||
|
||||
// disconnect listener
|
||||
buffer_running = false;
|
||||
std::cout << "Buffer shutting down" << std::endl;
|
||||
SS.close();
|
||||
delete thisStream;
|
||||
return 0;
|
||||
|
|
|
@ -6,6 +6,16 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
namespace Buffer {
|
||||
|
||||
static JSON::Value ctrl_log;
|
||||
|
||||
void Stream::Log(std::string type, std::string message){
|
||||
JSON::Value l;
|
||||
l.append(type);
|
||||
l.append(message);
|
||||
ctrl_log.append(l);
|
||||
}
|
||||
|
||||
/// Stores the singleton reference.
|
||||
Stream * Stream::ref = 0;
|
||||
|
||||
|
@ -71,6 +81,9 @@ namespace Buffer {
|
|||
oIt->second.removeMember("commentheader");
|
||||
}
|
||||
}
|
||||
|
||||
Storage["ctrl_log"] = ctrl_log;
|
||||
ctrl_log.null();
|
||||
|
||||
ret = Storage.toString();
|
||||
Storage["log"].null();
|
||||
|
@ -93,14 +106,14 @@ namespace Buffer {
|
|||
if (pass == waiting_ip.substr(1)){
|
||||
return true;
|
||||
}else{
|
||||
std::cout << "Password '" << pass << "' incorrect" << std::endl;
|
||||
Log("BUFF", "Push to stream " + name + " denied, incorrect password: "+pass);
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
if (ip == waiting_ip || ip == "::ffff:" + waiting_ip){
|
||||
return true;
|
||||
}else{
|
||||
std::cout << ip << " != (::ffff:)" << waiting_ip << std::endl;
|
||||
Log("BUFF", "Push to stream " + name + " denied, wrong IP: "+ip+" != (::ffff:)"+waiting_ip);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +212,7 @@ namespace Buffer {
|
|||
for (it = metadata.tracks.begin(); it != metadata.tracks.end(); ++it){
|
||||
if ((it->first & (sockNo << 16)) == (sockNo << 16)){
|
||||
toDelete.insert(it->first);
|
||||
std::cout << "Input lost, removing track: " << it->second.getIdentifier() << std::endl;
|
||||
Log("BUFF", "Stream "+name+" lost input for track: "+ it->second.getIdentifier());
|
||||
}
|
||||
}
|
||||
while (toDelete.size()){
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace Buffer {
|
|||
bool parsePacket(std::string & buffer);
|
||||
/// Thread-safe parsePacket override.
|
||||
bool parsePacket(Socket::Connection & c);
|
||||
/// Logs a message to the controller.
|
||||
void Log(std::string type, std::string message);
|
||||
DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks);
|
||||
private:
|
||||
void deletionCallback(DTSC::livePos deleting);
|
||||
|
|
|
@ -488,6 +488,11 @@ int main(int argc, char ** argv){
|
|||
}
|
||||
}
|
||||
}
|
||||
if (Request.isMember("ctrl_log") && Request["ctrl_log"].size() > 0){
|
||||
for (JSON::ArrIter it = Request["ctrl_log"].ArrBegin(); it != Request["ctrl_log"].ArrEnd(); it++){
|
||||
Controller::Log((*it)[0u], (*it)[1u]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue