diff --git a/README.md b/README.md index c282c30d8..da8dfbc7a 100755 --- a/README.md +++ b/README.md @@ -338,6 +338,7 @@ Remark: ## History +* v2.0, 2019-12-26, For [#1488][bug #1488], pass client ip to http callback. 2.0.269 * v2.0, 2019-12-23, Fix [srs-librtmp #22](https://github.com/ossrs/srs-librtmp/issues/22), parse vhost splited by single seperator. 2.0.268 * v2.0, 2019-12-23, Fix [srs-librtmp #25](https://github.com/ossrs/srs-librtmp/issues/25), build srs-librtmp on windows. 2.0.267 * v2.0, 2019-12-13, Support openssl versions greater than 1.1.0. 2.0.266 diff --git a/trunk/src/app/srs_app_conn.cpp b/trunk/src/app/srs_app_conn.cpp index 06858e94b..2ee282681 100644 --- a/trunk/src/app/srs_app_conn.cpp +++ b/trunk/src/app/srs_app_conn.cpp @@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +using namespace std; + #include #include #include @@ -117,6 +119,10 @@ int SrsConnection::srs_id() return id; } +string SrsConnection::remote_ip() { + return ip; +} + void SrsConnection::expire() { expired = true; diff --git a/trunk/src/app/srs_app_conn.hpp b/trunk/src/app/srs_app_conn.hpp index 0c12a5e0c..29b956c8c 100644 --- a/trunk/src/app/srs_app_conn.hpp +++ b/trunk/src/app/srs_app_conn.hpp @@ -130,6 +130,8 @@ public: * get the srs id which identify the client. */ virtual int srs_id(); + // Get the remote ip of peer. + virtual std::string remote_ip(); /** * set connection to expired. */ diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 0a94def33..ccc4db4c7 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -870,6 +870,11 @@ SrsRequest* SrsHttpMessage::to_request(string vhost) srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param); req->as_http(); + + // Set ip by remote ip of connection. + if (conn) { + req->ip = conn->remote_ip(); + } return req; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 68600f5e5..bb1461400 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 268 +#define VERSION_REVISION 269 // generated by configure, only macros. #include