Skip to content

Commit

Permalink
Get original ip instead of proxy ip, for rtc api (ossrs#2514) v4.0.150
Browse files Browse the repository at this point in the history
  • Loading branch information
Haibo Chen authored and winlinvip committed Aug 7, 2021
1 parent 92cbb1f commit c048731
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion trunk/src/app/srs_app_rtc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <srs_protocol_utility.hpp>
#include <srs_app_config.hpp>
#include <srs_app_statistic.hpp>

#include <srs_app_utility.hpp>
#include <unistd.h>
#include <deque>
using namespace std;
Expand Down Expand Up @@ -96,6 +96,11 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
}
if (clientip.empty()) {
clientip = dynamic_cast<SrsHttpMessage*>(r)->connection()->remote_ip();
// Overwrite by ip from proxy.
string oip = srs_get_original_ip(r);
if (!oip.empty()) {
clientip = oip;
}
}

string api;
Expand Down Expand Up @@ -314,6 +319,11 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
}
if (clientip.empty()){
clientip = dynamic_cast<SrsHttpMessage*>(r)->connection()->remote_ip();
// Overwrite by ip from proxy.
string oip = srs_get_original_ip(r);
if (!oip.empty()) {
clientip = oip;
}
}

string api;
Expand Down

0 comments on commit c048731

Please sign in to comment.