Unified all push-in-enabled outputs into a single style/function of accepting incoming pushes
This commit is contained in:
parent
daa0833970
commit
ef3f4aaf1a
5 changed files with 40 additions and 114 deletions
|
@ -295,7 +295,7 @@ namespace Mist {
|
|||
}
|
||||
|
||||
void inputTS::stream() {
|
||||
if (!Util::startInput(streamName, "push://")) {//manually override stream url to start the buffer
|
||||
if (!Util::startInput(streamName, "push://INTERNAL_ONLY:"+config->getString("input"))) {//manually override stream url to start the buffer
|
||||
FAIL_MSG("Could not start buffer for %s", streamName.c_str());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1294,6 +1294,34 @@ namespace Mist{
|
|||
|
||||
std::string source = strmSource.substr(7);
|
||||
std::string IP = source.substr(0, source.find('@'));
|
||||
|
||||
/*LTS-START*/
|
||||
std::string password;
|
||||
if (source.find('@') != std::string::npos){
|
||||
password = source.substr(source.find('@')+1);
|
||||
if (password != ""){
|
||||
if (password == passwd){
|
||||
INFO_MSG("Password accepted - ignoring IP settings.");
|
||||
IP = "";
|
||||
}else{
|
||||
INFO_MSG("Password rejected - checking IP.");
|
||||
if (IP == ""){
|
||||
IP = "deny-all.invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string smp = streamName.substr(0, streamName.find_first_of("+ "));
|
||||
if(Triggers::shouldTrigger("STREAM_PUSH", smp)){
|
||||
std::string payload = streamName+"\n" + getConnectedHost() +"\n"+capa["name"].asStringRef()+"\n"+reqUrl;
|
||||
if (!Triggers::doTrigger("STREAM_PUSH", payload, smp)){
|
||||
FAIL_MSG("Push from %s to %s rejected - STREAM_PUSH trigger denied the push", getConnectedHost().c_str(), streamName.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
|
||||
if (IP != ""){
|
||||
if (!myConn.isAddress(IP)){
|
||||
FAIL_MSG("Push from %s to %s rejected - source host not whitelisted", getConnectedHost().c_str(), streamName.c_str());
|
||||
|
|
|
@ -173,65 +173,13 @@ namespace Mist {
|
|||
void OutDTSC::handlePush(DTSC::Scan & dScan){
|
||||
streamName = dScan.getMember("stream").asString();
|
||||
std::string passString = dScan.getMember("password").asString();
|
||||
|
||||
Util::sanitizeName(streamName);
|
||||
//pull the server configuration
|
||||
std::string smp = streamName.substr(0,(streamName.find_first_of("+ ")));
|
||||
IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); ///< Contains server configuration and capabilities
|
||||
IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
configLock.wait();
|
||||
|
||||
DTSC::Scan streamCfg = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(smp);
|
||||
if (streamCfg){
|
||||
if (streamCfg.getMember("source").asString().substr(0, 7) != "push://"){
|
||||
DEBUG_MSG(DLVL_FAIL, "Push rejected - stream %s not a push-able stream. (%s != push://*)", streamName.c_str(), streamCfg.getMember("source").asString().c_str());
|
||||
myConn.close();
|
||||
}else{
|
||||
std::string source = streamCfg.getMember("source").asString().substr(7);
|
||||
std::string IP = source.substr(0, source.find('@'));
|
||||
/*LTS-START*/
|
||||
std::string password;
|
||||
if (source.find('@') != std::string::npos){
|
||||
password = source.substr(source.find('@')+1);
|
||||
if (password != ""){
|
||||
if (passString == Secure::md5(salt + password)){
|
||||
DEBUG_MSG(DLVL_DEVEL, "Password accepted - ignoring IP settings.");
|
||||
IP = "";
|
||||
}else{
|
||||
DEBUG_MSG(DLVL_DEVEL, "Password rejected - checking IP.");
|
||||
if (IP == ""){
|
||||
IP = "deny-all.invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Triggers::shouldTrigger("STREAM_PUSH", smp)){
|
||||
std::string payload = streamName+"\n" + myConn.getHost() +"\n"+capa["name"].asStringRef()+"\n"+reqUrl;
|
||||
if (!Triggers::doTrigger("STREAM_PUSH", payload, smp)){
|
||||
DEBUG_MSG(DLVL_FAIL, "Push from %s to %s rejected - STREAM_PUSH trigger denied the push", myConn.getHost().c_str(), streamName.c_str());
|
||||
myConn.close();
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
if (IP != ""){
|
||||
if (!myConn.isAddress(IP)){
|
||||
DEBUG_MSG(DLVL_FAIL, "Push from %s to %s rejected - source host not whitelisted", myConn.getHost().c_str(), streamName.c_str());
|
||||
myConn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
DEBUG_MSG(DLVL_FAIL, "Push from %s rejected - stream '%s' not configured.", myConn.getHost().c_str(), streamName.c_str());
|
||||
myConn.close();
|
||||
}
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
if (!myConn){return;}//do not initialize if rejected
|
||||
initialize();
|
||||
pushing = true;
|
||||
if (!allowPush(passString)){
|
||||
pushing = false;
|
||||
myConn.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -779,7 +779,7 @@ namespace Mist {
|
|||
Util::sanitizeName(streamName);
|
||||
|
||||
isPushing = true;
|
||||
if (!allowPush("")){
|
||||
if (!allowPush(app_name)){
|
||||
isPushing = false;
|
||||
onFinish();
|
||||
return;
|
||||
|
|
|
@ -359,62 +359,12 @@ namespace Mist {
|
|||
continue;
|
||||
}
|
||||
if (HTTP_R.method == "ANNOUNCE"){
|
||||
std::string smp = streamName.substr(0,(streamName.find_first_of("+ ")));
|
||||
IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE); ///< Contains server configuration and capabilities
|
||||
IPC::semaphore configLock(SEM_CONF, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
configLock.wait();
|
||||
|
||||
DTSC::Scan streamCfg = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(smp);
|
||||
if (streamCfg){
|
||||
if (streamCfg.getMember("source").asString().substr(0, 7) != "push://"){
|
||||
FAIL_MSG("Push rejected - stream %s not a push-able stream. (%s != push://*)", streamName.c_str(), streamCfg.getMember("source").asString().c_str());
|
||||
onFinish();
|
||||
}else{
|
||||
std::string source = streamCfg.getMember("source").asString().substr(7);
|
||||
std::string IP = source.substr(0, source.find('@'));
|
||||
/*LTS-START*/
|
||||
std::string password;
|
||||
if (source.find('@') != std::string::npos){
|
||||
password = source.substr(source.find('@')+1);
|
||||
if (password != ""){
|
||||
if (password == HTTP_R.GetVar("pass")){
|
||||
INFO_MSG("Password accepted - ignoring IP settings.");
|
||||
IP = "";
|
||||
}else{
|
||||
INFO_MSG("Password rejected - checking IP.");
|
||||
if (IP == ""){
|
||||
IP = "deny-all.invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Triggers::shouldTrigger("STREAM_PUSH", smp)){
|
||||
std::string payload = streamName+"\n" + getConnectedHost() +"\n"+capa["name"].asStringRef()+"\n"+reqUrl;
|
||||
if (!Triggers::doTrigger("STREAM_PUSH", payload, smp)){
|
||||
FAIL_MSG("Push from %s to %s rejected - STREAM_PUSH trigger denied the push", getConnectedHost().c_str(), streamName.c_str());
|
||||
onFinish();
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
if (IP != ""){
|
||||
if (!myConn.isAddress(IP)){
|
||||
FAIL_MSG("Push from %s to %s rejected - source host not whitelisted", getConnectedHost().c_str(), streamName.c_str());
|
||||
onFinish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
FAIL_MSG("Push from %s rejected - stream '%s' not configured.", getConnectedHost().c_str(), streamName.c_str());
|
||||
onFinish();
|
||||
}
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
if (!myConn){return;}//do not initialize if rejected
|
||||
isPushing = true;
|
||||
initialize();
|
||||
if (!allowPush(HTTP_R.GetVar("pass"))){
|
||||
isPushing = false;
|
||||
onFinish();
|
||||
return;
|
||||
}
|
||||
INFO_MSG("Pushing to stream %s", streamName.c_str());
|
||||
parseSDP(HTTP_R.body);
|
||||
HTTP_S.SendResponse("200", "OK", myConn);
|
||||
|
|
Loading…
Add table
Reference in a new issue