mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #319, support enable or disable vhost.
This commit is contained in:
parent
631e76cd32
commit
e8a00de4a3
3 changed files with 93 additions and 10 deletions
|
@ -1155,7 +1155,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
} else if (scope == "vhost") {
|
||||
std::string param = r->query_get("param");
|
||||
std::string data = r->query_get("data");
|
||||
if (param != "create" && param != "update" && param != "delete") {
|
||||
if (param != "create" && param != "update" && param != "delete" && param != "disable" && param != "enable") {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED;
|
||||
srs_error("raw api query invalid scope=%s, param=%s. ret=%d", scope.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
|
@ -1202,7 +1202,32 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
srs_error("raw api update vhost=%s, param=%s failed. ret=%d", value.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
} else if (param == "disable") {
|
||||
// when disable, the vhost must exists and enabled.
|
||||
SrsConfDirective* vhost = _srs_config->get_vhost(value, false);
|
||||
if (param.empty() || !vhost || !_srs_config->get_vhost_enabled(vhost)) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||
srs_error("raw api update check vhost=%s, param=%s failed. ret=%d", value.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
|
||||
if ((ret = _srs_config->raw_disable_vhost(value, applied)) != ERROR_SUCCESS) {
|
||||
srs_error("raw api update vhost=%s, param=%s failed. ret=%d", value.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
} else if (param == "enable") {
|
||||
// when enable, the vhost must exists and disabled.
|
||||
SrsConfDirective* vhost = _srs_config->get_vhost(value, false);
|
||||
if (param.empty() || !vhost || _srs_config->get_vhost_enabled(vhost)) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||
srs_error("raw api update check vhost=%s, param=%s failed. ret=%d", value.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
|
||||
if ((ret = _srs_config->raw_enable_vhost(value, applied)) != ERROR_SUCCESS) {
|
||||
srs_error("raw api update vhost=%s, param=%s failed. ret=%d", value.c_str(), param.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue