From c0487310499cc1333f7c61f39c1d42ede327c6fb Mon Sep 17 00:00:00 2001 From: Haibo Chen Date: Sat, 7 Aug 2021 23:37:18 +0800 Subject: [PATCH] Get original ip instead of proxy ip, for rtc api (#2514) v4.0.150 --- trunk/src/app/srs_app_rtc_api.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_rtc_api.cpp b/trunk/src/app/srs_app_rtc_api.cpp index 1dac31a31..db2289284 100644 --- a/trunk/src/app/srs_app_rtc_api.cpp +++ b/trunk/src/app/srs_app_rtc_api.cpp @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include using namespace std; @@ -96,6 +96,11 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe } if (clientip.empty()) { clientip = dynamic_cast(r)->connection()->remote_ip(); + // Overwrite by ip from proxy. + string oip = srs_get_original_ip(r); + if (!oip.empty()) { + clientip = oip; + } } string api; @@ -314,6 +319,11 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt } if (clientip.empty()){ clientip = dynamic_cast(r)->connection()->remote_ip(); + // Overwrite by ip from proxy. + string oip = srs_get_original_ip(r); + if (!oip.empty()) { + clientip = oip; + } } string api;