Added a proxy in Output for getting the host (by Erik Zandvliet)
This commit is contained in:
parent
2d78e1e5f1
commit
d56e7f1408
7 changed files with 21 additions and 7 deletions
|
@ -606,7 +606,7 @@ bool Socket::Connection::iwrite(std::string & buffer) {
|
|||
} //iwrite
|
||||
|
||||
/// Gets hostname for connection, if available.
|
||||
std::string Socket::Connection::getHost() {
|
||||
std::string Socket::Connection::getHost() const {
|
||||
return remotehost;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Socket {
|
|||
void drop(); ///< Close connection without shutdown.
|
||||
void setBlocking(bool blocking); ///< Set this socket to be blocking (true) or nonblocking (false).
|
||||
bool isBlocking(); ///< Check if this socket is blocking (true) or nonblocking (false).
|
||||
std::string getHost(); ///< Gets hostname for connection, if available.
|
||||
std::string getHost() const; ///< Gets hostname for connection, if available.
|
||||
std::string getBinHost();
|
||||
void setHost(std::string host); ///< Sets hostname for connection manually.
|
||||
int getSocket(); ///< Returns internal socket number.
|
||||
|
|
|
@ -111,6 +111,14 @@ namespace Mist {
|
|||
selectDefaultTracks();
|
||||
sought = false;
|
||||
}
|
||||
|
||||
std::string Output::getConnectedHost(){
|
||||
return myConn.getHost();
|
||||
}
|
||||
|
||||
std::string Output::getConnectedBinHost(){
|
||||
return myConn.getBinHost();
|
||||
}
|
||||
|
||||
/// Connects or reconnects to the stream.
|
||||
/// Assumes streamName class member has been set already.
|
||||
|
@ -665,7 +673,7 @@ namespace Mist {
|
|||
IPC::statExchange tmpEx(statsPage.getData());
|
||||
tmpEx.now(now);
|
||||
if (setHost){
|
||||
tmpEx.host(myConn.getBinHost());
|
||||
tmpEx.host(getConnectedBinHost());
|
||||
setHost = false;
|
||||
}
|
||||
tmpEx.crc(crc);
|
||||
|
|
|
@ -75,6 +75,11 @@ namespace Mist {
|
|||
bool sought;///<If a seek has been done, this is set to true. Used for seeking on prepareNext().
|
||||
bool completeKeyReadyTimeOut;//a bool to see if there has been a keyframe TimeOut for complete keys in Live
|
||||
protected://these are to be messed with by child classes
|
||||
|
||||
virtual std::string getConnectedHost();
|
||||
virtual std::string getConnectedBinHost();
|
||||
|
||||
|
||||
IPC::sharedClient statsPage;///< Shared memory used for statistics reporting.
|
||||
bool isBlocking;///< If true, indicates that myConn is blocking.
|
||||
unsigned int crc;///< Checksum, if any, for usage in the stats.
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace Mist {
|
|||
DEBUG_MSG(DLVL_HIGH, "Connector found: %s", connector.c_str());
|
||||
//build arguments for starting output process
|
||||
|
||||
std::string temphost=myConn.getHost();
|
||||
std::string temphost=getConnectedHost();
|
||||
std::string debuglevel = JSON::Value((long long)Util::Config::printDebugLevel).asString();
|
||||
std::string tmparg = Util::getMyPath() + std::string("MistOut") + connector;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace Mist {
|
||||
OutHTTP::OutHTTP(Socket::Connection & conn) : HTTPOutput(conn){
|
||||
if (myConn.getPureSocket() >= 0){
|
||||
std::string host = myConn.getHost();
|
||||
std::string host = getConnectedHost();
|
||||
dup2(myConn.getSocket(), STDIN_FILENO);
|
||||
dup2(myConn.getSocket(), STDOUT_FILENO);
|
||||
myConn.drop();
|
||||
|
@ -15,6 +15,7 @@ namespace Mist {
|
|||
myConn.setHost(host);
|
||||
}
|
||||
}
|
||||
|
||||
OutHTTP::~OutHTTP() {}
|
||||
|
||||
bool OutHTTP::listenMode(){
|
||||
|
|
|
@ -499,13 +499,13 @@ namespace Mist {
|
|||
std::string IP = source.substr(0, source.find('@'));
|
||||
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());
|
||||
DEBUG_MSG(DLVL_FAIL, "Push from %s to %s rejected - source host not whitelisted", getConnectedHost().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());
|
||||
DEBUG_MSG(DLVL_FAIL, "Push from %s rejected - stream '%s' not configured.", getConnectedHost().c_str(), streamName.c_str());
|
||||
myConn.close();
|
||||
}
|
||||
configLock.post();
|
||||
|
|
Loading…
Add table
Reference in a new issue