From 067444306671531d3df3d39ad27d5df7cf14f3cc Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 10 Oct 2022 14:16:48 +0200 Subject: [PATCH] Fix push outputs to use the correct remote addresses --- lib/socket.cpp | 2 +- lib/socket_srt.cpp | 1 + src/output/output.cpp | 7 +++---- src/output/output_cmaf.cpp | 1 + src/output/output_rtmp.cpp | 1 + src/output/output_ts.cpp | 1 + src/output/output_tsrist.cpp | 1 + 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/socket.cpp b/lib/socket.cpp index 47b2b6bd..aaefa2f2 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -1207,7 +1207,7 @@ std::string Socket::Connection::getBinHost(){ } /// Sets hostname for connection manually. -/// Overwrites the detected host, thus possibily making it incorrect. +/// Overwrites the detected host, thus possibly making it incorrect. void Socket::Connection::setHost(std::string host){ remotehost = host; struct addrinfo *result, hints; diff --git a/lib/socket_srt.cpp b/lib/socket_srt.cpp index 6d1d5695..ac08dd8c 100644 --- a/lib/socket_srt.cpp +++ b/lib/socket_srt.cpp @@ -208,6 +208,7 @@ namespace Socket{ if (outgoing_port){setupAdapter("", outgoing_port);} sockaddr_in sa = createInetAddr(_host, _port); + memcpy(&remoteaddr, &sa, sizeof(sockaddr_in)); sockaddr *psa = (sockaddr *)&sa; HIGH_MSG("Going to connect sock %d", sock); diff --git a/src/output/output.cpp b/src/output/output.cpp index d525b8ea..307c6b8c 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -218,10 +218,9 @@ namespace Mist{ std::string Output::getConnectedBinHost(){ if (!prevHost.size()){ - if (myConn && myConn.getPureSocket() != -1){ - prevHost = myConn.getBinHost(); - } - if (!prevHost.size()){prevHost.assign("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001", 16);} + MEDIUM_MSG("Setting prevHost to %s", getConnectedHost().c_str()); + prevHost = myConn.getBinHost(); + if (!prevHost.size()){prevHost.assign("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16);} } return prevHost; } diff --git a/src/output/output_cmaf.cpp b/src/output/output_cmaf.cpp index eb7c87da..fa046db5 100644 --- a/src/output/output_cmaf.cpp +++ b/src/output/output_cmaf.cpp @@ -93,6 +93,7 @@ namespace Mist{ INFO_MSG("About to push stream %s out. Host: %s, port: %" PRIu32 ", location: %s", streamName.c_str(), pushUrl.host.c_str(), pushUrl.getPort(), pushUrl.path.c_str()); + myConn.setHost(pushUrl.host); initialize(); initialSeek(); startPushOut(); diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index 23194f4a..41cf2191 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -54,6 +54,7 @@ namespace Mist{ } INFO_MSG("About to push stream %s out. Host: %s, port: %d, app: %s, stream: %s", streamName.c_str(), pushUrl.host.c_str(), pushUrl.getPort(), app.c_str(), streamOut.c_str()); + myConn.setHost(pushUrl.host); initialize(); initialSeek(); startPushOut(""); diff --git a/src/output/output_ts.cpp b/src/output/output_ts.cpp index bf46663b..cec6eee4 100644 --- a/src/output/output_ts.cpp +++ b/src/output/output_ts.cpp @@ -85,6 +85,7 @@ namespace Mist{ } } pushSock.SetDestination(target.host, target.getPort()); + myConn.setHost(target.host); pushing = false; }else{ //No push target? Check if this is a push input or pull output by waiting for data for 5s diff --git a/src/output/output_tsrist.cpp b/src/output/output_tsrist.cpp index 10b29673..a2861184 100644 --- a/src/output/output_tsrist.cpp +++ b/src/output/output_tsrist.cpp @@ -130,6 +130,7 @@ namespace Mist{ onFail("Failed to start RIST connection"); return; } + myConn.setHost(target.host); wantRequest = false; parseData = true; initialize();