From 31679c46d4145eb4bef10847e8b312c40fea7b65 Mon Sep 17 00:00:00 2001 From: Xiaoniu Date: Mon, 28 Jun 2021 07:51:57 +0800 Subject: [PATCH 1/2] check 'vhost' validity in 'http raw dvr api' (#2435) --- trunk/src/app/srs_app_config.cpp | 8 ++++++++ trunk/src/app/srs_app_http_api.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 29e2339ae..262418621 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -3171,6 +3171,8 @@ srs_error_t SrsConfig::raw_disable_vhost(string vhost, bool& applied) applied = false; SrsConfDirective* conf = root->get("vhost", vhost); + srs_assert(conf); + conf->get_or_create("enabled")->set_arg0("off"); if ((err = do_reload_vhost_removed(vhost)) != srs_success) { @@ -3189,6 +3191,8 @@ srs_error_t SrsConfig::raw_enable_vhost(string vhost, bool& applied) applied = false; SrsConfDirective* conf = root->get("vhost", vhost); + srs_assert(conf); + conf->get_or_create("enabled")->set_arg0("on"); if ((err = do_reload_vhost_added(vhost)) != srs_success) { @@ -3207,6 +3211,8 @@ srs_error_t SrsConfig::raw_enable_dvr(string vhost, string stream, bool& applied applied = false; SrsConfDirective* conf = root->get("vhost", vhost); + srs_assert(conf); + conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); if (conf->args.size() == 1 && (conf->arg0() == "all" || conf->arg0() == "none")) { @@ -3233,6 +3239,8 @@ srs_error_t SrsConfig::raw_disable_dvr(string vhost, string stream, bool& applie applied = false; SrsConfDirective* conf = root->get("vhost", vhost); + srs_assert(conf); + conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); std::vector::iterator it; diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 5087a825e..81c7add7e 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1206,7 +1206,12 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* if (action != "enable" && action != "disable") { return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); } - + + // the vhost must exists. + if (!_srs_config->get_vhost(value, false)) { + return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_PARAMS); + } + if (!_srs_config->get_dvr_enabled(value)) { return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); } From 6ea270adf3bcd783c27c3f42046fc2d495dac219 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 28 Jun 2021 07:54:50 +0800 Subject: [PATCH 2/2] Merge #2435, fix #2015, fix bug for HTTP-RAW-API to check vhost. 4.0.136 --- CHANGELOG.md | 1 + trunk/src/core/srs_core_version4.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4829cca5..d63e07548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-06-28, Merge [#2435](https://github.com/ossrs/srs/pull/2435), fix bug for HTTP-RAW-API to check vhost. 4.0.136 * v4.0, 2021-06-28, Fix [#2431](https://github.com/ossrs/srs/issues/2431), configure FFmpeg bug. 4.0.135 * v4.0, 2021-06-28, Merge [#2444](https://github.com/ossrs/srs/pull/2444), add libavcodec/crystalhd.c for FFmpeg. 4.0.134 * v4.0, 2021-06-28, Merge [#2438](https://github.com/ossrs/srs/pull/2438), fix losing of last HLS ts file 4.0.133 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 7890accec..f9ba8dad6 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 135 +#define VERSION_REVISION 136 #endif