1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

rename the config_query to query

This commit is contained in:
winlin 2015-08-28 13:01:04 +08:00
parent 75ca759e5d
commit f167616379
5 changed files with 21 additions and 21 deletions

View file

@ -129,9 +129,9 @@ http_api {
# whether enable rpc reload. # whether enable rpc reload.
# default: off # default: off
allow_reload off; allow_reload off;
# whether enable rpc config_query. # whether enable rpc query.
# default: off # default: off
allow_config_query off; allow_query off;
} }
} }
# embeded http server in srs. # embeded http server in srs.

View file

@ -1831,7 +1831,7 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj)
ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean()); ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean());
} else if (ssdir->name == "allow_reload") { } else if (ssdir->name == "allow_reload") {
ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean()); ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean());
} else if (ssdir->name == "allow_config_query") { } else if (ssdir->name == "allow_query") {
ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean()); ssobj->set(ssdir->name, ssdir->dumps_arg0_to_boolean());
} }
} }
@ -2019,7 +2019,7 @@ int SrsConfig::check_config()
if (n == "raw_api") { if (n == "raw_api") {
for (int j = 0; j < (int)obj->directives.size(); j++) { for (int j = 0; j < (int)obj->directives.size(); j++) {
string m = obj->at(j)->name; string m = obj->at(j)->name;
if (m != "enabled" && m != "allow_reload" && m != "allow_config_query") { if (m != "enabled" && m != "allow_reload" && m != "allow_query") {
ret = ERROR_SYSTEM_CONFIG_INVALID; ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported http_api.raw_api directive %s, ret=%d", m.c_str(), ret); srs_error("unsupported http_api.raw_api directive %s, ret=%d", m.c_str(), ret);
return ret; return ret;
@ -4647,7 +4647,7 @@ bool SrsConfig::get_raw_api_allow_reload()
return SRS_CONF_PERFER_FALSE(conf->arg0()); return SRS_CONF_PERFER_FALSE(conf->arg0());
} }
bool SrsConfig::get_raw_api_allow_config_query() bool SrsConfig::get_raw_api_allow_query()
{ {
static bool DEFAULT = false; static bool DEFAULT = false;
@ -4661,7 +4661,7 @@ bool SrsConfig::get_raw_api_allow_config_query()
return DEFAULT; return DEFAULT;
} }
conf = conf->get("allow_config_query"); conf = conf->get("allow_query");
if (!conf || conf->arg0().empty()) { if (!conf || conf->arg0().empty()) {
return DEFAULT; return DEFAULT;
} }

View file

@ -1071,9 +1071,9 @@ public:
*/ */
virtual bool get_raw_api_allow_reload(); virtual bool get_raw_api_allow_reload();
/** /**
* whether allow rpc config_query. * whether allow rpc query.
*/ */
virtual bool get_raw_api_allow_config_query(); virtual bool get_raw_api_allow_query();
// http stream section // http stream section
private: private:
/** /**

View file

@ -845,7 +845,7 @@ SrsGoApiRaw::SrsGoApiRaw(SrsServer* svr)
raw_api = _srs_config->get_raw_api(); raw_api = _srs_config->get_raw_api();
allow_reload = _srs_config->get_raw_api_allow_reload(); allow_reload = _srs_config->get_raw_api_allow_reload();
allow_config_query = _srs_config->get_raw_api_allow_config_query(); allow_query = _srs_config->get_raw_api_allow_query();
_srs_config->subscribe(this); _srs_config->subscribe(this);
} }
@ -868,7 +868,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// the rpc is required. // the rpc is required.
std::string rpc = r->query_get("rpc"); std::string rpc = r->query_get("rpc");
if (rpc.empty() || (rpc != "reload" && rpc != "config_query" && rpc != "raw")) { if (rpc.empty() || (rpc != "reload" && rpc != "query" && rpc != "raw")) {
ret = ERROR_SYSTEM_CONFIG_RAW; ret = ERROR_SYSTEM_CONFIG_RAW;
srs_error("raw api invalid rpc=%s. ret=%d", rpc.c_str(), ret); srs_error("raw api invalid rpc=%s. ret=%d", rpc.c_str(), ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
@ -903,16 +903,16 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return srs_api_response(w, r, obj->to_json()); return srs_api_response(w, r, obj->to_json());
} }
// for rpc=config_query, to get the configs of server. // for rpc=query, to get the configs of server.
// @param scope the scope to query for config, it can be: // @param scope the scope to query for config, it can be:
// global, the configs belongs to the root, donot includes any sub directives. // global, the configs belongs to the root, donot includes any sub directives.
// vhost, the configs for specified vhost by @param vhost. // vhost, the configs for specified vhost by @param vhost.
// @param vhost the vhost name for @param scope is vhost to query config. // @param vhost the vhost name for @param scope is vhost to query config.
// for the default vhost, must be __defaultVhost__ // for the default vhost, must be __defaultVhost__
if (rpc == "config_query") { if (rpc == "query") {
if (!allow_config_query) { if (!allow_query) {
ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED; ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED;
srs_error("raw api allow_config_query disabled rpc=%s. ret=%d", rpc.c_str(), ret); srs_error("raw api allow_query disabled rpc=%s. ret=%d", rpc.c_str(), ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
} }
@ -920,7 +920,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
std::string vhost = r->query_get("vhost"); std::string vhost = r->query_get("vhost");
if (scope.empty() || (scope != "global" && scope != "vhost")) { if (scope.empty() || (scope != "global" && scope != "vhost")) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
srs_error("raw api config_query invalid scope=%s. ret=%d", scope.c_str(), ret); srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
} }
@ -928,7 +928,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// query vhost scope. // query vhost scope.
if (vhost.empty()) { if (vhost.empty()) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
srs_error("raw api config_query vhost invalid vhost=%s. ret=%d", vhost.c_str(), ret); srs_error("raw api query vhost invalid vhost=%s. ret=%d", vhost.c_str(), ret);
return ret; return ret;
} }
@ -936,14 +936,14 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
SrsConfDirective* conf = root->get("vhost", vhost); SrsConfDirective* conf = root->get("vhost", vhost);
if (!conf) { if (!conf) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
srs_error("raw api config_query vhost invalid vhost=%s. ret=%d", vhost.c_str(), ret); srs_error("raw api query vhost invalid vhost=%s. ret=%d", vhost.c_str(), ret);
return ret; return ret;
} }
SrsAmf0Object* data = SrsAmf0Any::object(); SrsAmf0Object* data = SrsAmf0Any::object();
obj->set("vhost", data); obj->set("vhost", data);
if ((ret = _srs_config->vhost_to_json(conf, data)) != ERROR_SUCCESS) { if ((ret = _srs_config->vhost_to_json(conf, data)) != ERROR_SUCCESS) {
srs_error("raw api config_query vhost failed. ret=%d", ret); srs_error("raw api query vhost failed. ret=%d", ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
} }
} else { } else {
@ -952,7 +952,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// query global scope. // query global scope.
if ((ret = _srs_config->global_to_json(data)) != ERROR_SUCCESS) { if ((ret = _srs_config->global_to_json(data)) != ERROR_SUCCESS) {
srs_error("raw api config_query global failed. ret=%d", ret); srs_error("raw api query global failed. ret=%d", ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
} }
} }
@ -967,7 +967,7 @@ int SrsGoApiRaw::on_reload_http_api_raw_api()
{ {
raw_api = _srs_config->get_raw_api(); raw_api = _srs_config->get_raw_api();
allow_reload = _srs_config->get_raw_api_allow_reload(); allow_reload = _srs_config->get_raw_api_allow_reload();
allow_config_query = _srs_config->get_raw_api_allow_config_query(); allow_query = _srs_config->get_raw_api_allow_query();
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }

View file

@ -186,7 +186,7 @@ private:
private: private:
bool raw_api; bool raw_api;
bool allow_reload; bool allow_reload;
bool allow_config_query; bool allow_query;
public: public:
SrsGoApiRaw(SrsServer* svr); SrsGoApiRaw(SrsServer* svr);
virtual ~SrsGoApiRaw(); virtual ~SrsGoApiRaw();