diff --git a/lib/socket.cpp b/lib/socket.cpp index a0138904..d66e948e 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -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; } diff --git a/lib/socket.h b/lib/socket.h index b6e733e1..aac1f399 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -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. diff --git a/src/output/output.cpp b/src/output/output.cpp index 19cc5c24..ed5ba792 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -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); diff --git a/src/output/output.h b/src/output/output.h index e8c08477..30934090 100644 --- a/src/output/output.h +++ b/src/output/output.h @@ -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. diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index 163f61b3..2989300e 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -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; diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index a19aba18..4806d67b 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -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(){ diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index f05419a3..9fa33d9e 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -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();