Merge branch 'development' into LTS_development

# Conflicts:
#	src/output/output.h
#	src/output/output_rtmp.cpp
This commit is contained in:
Thulinma 2017-02-28 14:07:18 +01:00
commit daa0833970
6 changed files with 60 additions and 61 deletions

View file

@ -173,10 +173,6 @@ namespace Mist {
return 0;
}
if (streamName != "") {
config->getOption("streamname") = streamName;
}
streamName = config->getString("streamname");
nProxy.streamName = streamName;
if (!setup()) {
@ -189,6 +185,7 @@ namespace Mist {
std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl;
return 0;
}
myMeta.sourceURI = config->getString("input");
parseHeader();
MEDIUM_MSG("Header parsed, %lu tracks", myMeta.tracks.size());
@ -357,7 +354,7 @@ namespace Mist {
pullLock.unlink();
return;
}
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
pullLock.post();
pullLock.close();
pullLock.unlink();

View file

@ -1272,5 +1272,36 @@ namespace Mist{
return true;
}
/// Checks if the set streamName allows pushes from this connector/IP/password combination.
/// Runs all appropriate triggers and checks.
/// Returns true if the push should continue, false otherwise.
bool Output::allowPush(const std::string & passwd){
std::string strmSource;
// Initialize the stream source if needed, connect to it
initialize();
//pull the source setting from metadata
strmSource = myMeta.sourceURI;
if (!strmSource.size()){
FAIL_MSG("Push rejected - stream %s not configured", streamName.c_str());
return false;
}
if (strmSource.substr(0, 7) != "push://"){
FAIL_MSG("Push rejected - stream %s not a push-able stream. (%s != push://*)", streamName.c_str(), strmSource.c_str());
return false;
}
std::string source = strmSource.substr(7);
std::string IP = source.substr(0, source.find('@'));
if (IP != ""){
if (!myConn.isAddress(IP)){
FAIL_MSG("Push from %s to %s rejected - source host not whitelisted", getConnectedHost().c_str(), streamName.c_str());
return false;
}
}
return true;
}
}

View file

@ -127,6 +127,7 @@ namespace Mist {
std::map<int,DTSCPageData> bookKeeping;
virtual bool isRecording(){return false;};
bool allowPush(const std::string & passwd);
};
}

View file

@ -777,63 +777,13 @@ namespace Mist {
}
Util::sanitizeName(streamName);
//pull the server configuration
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 == app_name){
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("")){
isPushing = false;
onFinish();
return;
}
}
//send a _result reply
AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER);