From d56e7f140860a3088b65a42ead0ffca6f8dba7cb Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 12 Feb 2016 15:51:54 +0100 Subject: [PATCH] Added a proxy in Output for getting the host (by Erik Zandvliet) --- lib/socket.cpp | 2 +- lib/socket.h | 2 +- src/output/output.cpp | 10 +++++++++- src/output/output.h | 5 +++++ src/output/output_http.cpp | 2 +- src/output/output_http_internal.cpp | 3 ++- src/output/output_rtmp.cpp | 4 ++-- 7 files changed, 21 insertions(+), 7 deletions(-) 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;///= 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();