mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #319, http raw api support query. 3.0.3
This commit is contained in:
parent
8a2709dd2c
commit
11c409688b
5 changed files with 78 additions and 17 deletions
|
@ -342,6 +342,7 @@ Remark:
|
|||
|
||||
## History
|
||||
|
||||
* v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. 3.0.3
|
||||
* v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2
|
||||
* v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1
|
||||
* <strong>v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.</strong>
|
||||
|
@ -1184,6 +1185,7 @@ Winlin
|
|||
[bug #50]: https://github.com/simple-rtmp-server/srs/issues/50
|
||||
[bug #34]: https://github.com/simple-rtmp-server/srs/issues/34
|
||||
[bug #367]: https://github.com/simple-rtmp-server/srs/issues/367
|
||||
[bug #319]: https://github.com/simple-rtmp-server/srs/issues/319
|
||||
|
||||
[r2.0a0]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a0
|
||||
[r1.0r4]: https://github.com/simple-rtmp-server/srs/releases/tag/1.0r4
|
||||
|
|
|
@ -944,15 +944,10 @@ int SrsConfig::reload_conf(SrsConfig* conf)
|
|||
|
||||
// merge config: pid
|
||||
if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) {
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) {
|
||||
srs_error("notify subscribes reload pid failed. ret=%d", ret);
|
||||
if ((ret = do_reload_pid()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
srs_trace("reload pid success.");
|
||||
}
|
||||
|
||||
// merge config: srs_log_tank
|
||||
if (!srs_directive_equals(root->get("srs_log_tank"), old_root->get("srs_log_tank"))) {
|
||||
|
@ -2213,21 +2208,47 @@ int SrsConfig::raw_set_listen(const vector<string>& eps, bool& applied)
|
|||
|
||||
applied = false;
|
||||
|
||||
SrsConfDirective* listen = root->get("listen");
|
||||
SrsConfDirective* conf = root->get("listen");
|
||||
|
||||
// not changed, ignore.
|
||||
if (srs_vector_actual_equals(listen->args, eps)) {
|
||||
if (srs_vector_actual_equals(conf->args, eps)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// changed, apply and reload.
|
||||
listen->args = eps;
|
||||
conf->args = eps;
|
||||
|
||||
if ((ret = do_reload_listen()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
applied = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::raw_set_pid(string pid, bool& applied)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
applied = false;
|
||||
|
||||
|
||||
SrsConfDirective* conf = root->get_or_create("pid");
|
||||
|
||||
if (conf->arg0() == pid) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
conf->args.clear();
|
||||
conf->args.push_back(pid);
|
||||
|
||||
if ((ret = do_reload_pid()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
applied = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2235,7 +2256,6 @@ int SrsConfig::do_reload_listen()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// force to reload the memory server.
|
||||
vector<ISrsReloadHandler*>::iterator it;
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
|
@ -2249,6 +2269,23 @@ int SrsConfig::do_reload_listen()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::do_reload_pid()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
vector<ISrsReloadHandler*>::iterator it;
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) {
|
||||
srs_error("notify subscribes reload pid failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
srs_trace("reload pid success.");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
string SrsConfig::config()
|
||||
{
|
||||
return config_file;
|
||||
|
|
|
@ -331,14 +331,15 @@ public:
|
|||
virtual int raw_to_json(SrsAmf0Object* obj);
|
||||
/**
|
||||
* raw set the global listen.
|
||||
* @param applied whether the config is applied.
|
||||
*/
|
||||
virtual int raw_set_listen(const std::vector<std::string>& eps, bool& applied);
|
||||
private:
|
||||
/**
|
||||
* do reload listen, for reload from signal or raw api.
|
||||
* raw set the global pid.
|
||||
*/
|
||||
virtual int raw_set_pid(std::string pid, bool& applied);
|
||||
private:
|
||||
virtual int do_reload_listen();
|
||||
virtual int do_reload_pid();
|
||||
public:
|
||||
/**
|
||||
* get the config file path.
|
||||
|
|
|
@ -977,6 +977,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
// possible updates:
|
||||
// @param scope @param value value-description
|
||||
// global.listen 1935,1936 the port list.
|
||||
// global.pid ./objs/srs.pid the pid file of srs.
|
||||
if (rpc == "update") {
|
||||
if (!allow_update) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED;
|
||||
|
@ -986,7 +987,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
|
||||
std::string scope = r->query_get("scope");
|
||||
std::string value = r->query_get("value");
|
||||
if (scope.empty() || (scope != "global.listen")) {
|
||||
if (scope.empty() || (scope != "global.listen" && scope != "global.pid")) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||
srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
|
@ -1007,7 +1008,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
}
|
||||
if (invalid) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||
srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
|
||||
srs_error("raw api update check global.listen=%s failed. ret=%d", value.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
|
||||
|
@ -1015,6 +1016,26 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
} else if (scope == "global.pid") {
|
||||
bool invalid = value.empty();
|
||||
if (!invalid) {
|
||||
invalid = !srs_string_starts_with(value, "./")
|
||||
&& !srs_string_starts_with(value, "/tmp")
|
||||
&& !srs_string_starts_with(value, "/var");
|
||||
}
|
||||
if (!invalid) {
|
||||
invalid = !srs_string_ends_with(value, ".pid");
|
||||
}
|
||||
if (invalid) {
|
||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||
srs_error("raw api update check global.pid=%s failed. ret=%d", value.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
|
||||
if ((ret = _srs_config->raw_set_pid(value, applied)) != ERROR_SUCCESS) {
|
||||
srs_error("raw api update global.pid=%s failed. ret=%d", value.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
}
|
||||
|
||||
// whether the config applied.
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 2
|
||||
#define VERSION_REVISION 3
|
||||
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "SRS"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue