Unified all push-in-enabled outputs into a single style/function of accepting incoming pushes
This commit is contained in:
parent
88749d2259
commit
9a783a782d
4 changed files with 39 additions and 29 deletions
|
@ -297,7 +297,7 @@ namespace Mist {
|
||||||
pullLock.unlink();
|
pullLock.unlink();
|
||||||
return;
|
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.post();
|
||||||
pullLock.close();
|
pullLock.close();
|
||||||
pullLock.unlink();
|
pullLock.unlink();
|
||||||
|
|
|
@ -1088,5 +1088,36 @@ namespace Mist{
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ namespace Mist {
|
||||||
bool sentHeader;///< If false, triggers sendHeader if parseData is true.
|
bool sentHeader;///< If false, triggers sendHeader if parseData is true.
|
||||||
|
|
||||||
std::map<int,DTSCPageData> bookKeeping;
|
std::map<int,DTSCPageData> bookKeeping;
|
||||||
|
bool allowPush(const std::string & passwd);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -586,35 +586,13 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::sanitizeName(streamName);
|
Util::sanitizeName(streamName);
|
||||||
//pull the server configuration
|
|
||||||
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(streamName);
|
|
||||||
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('@'));
|
|
||||||
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;
|
isPushing = true;
|
||||||
initialize();
|
if (!allowPush("")){
|
||||||
|
isPushing = false;
|
||||||
|
onFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//send a _result reply
|
//send a _result reply
|
||||||
AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER);
|
AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER);
|
||||||
|
|
Loading…
Add table
Reference in a new issue