Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check 'vhost' validity in 'http raw dvr api' #2435

Merged
merged 1 commit into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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")) {
Expand All @@ -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<string>::iterator it;
Expand Down
7 changes: 6 additions & 1 deletion trunk/src/app/srs_app_http_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down