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
|
## 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-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
|
* 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>
|
* <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 #50]: https://github.com/simple-rtmp-server/srs/issues/50
|
||||||
[bug #34]: https://github.com/simple-rtmp-server/srs/issues/34
|
[bug #34]: https://github.com/simple-rtmp-server/srs/issues/34
|
||||||
[bug #367]: https://github.com/simple-rtmp-server/srs/issues/367
|
[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
|
[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
|
[r1.0r4]: https://github.com/simple-rtmp-server/srs/releases/tag/1.0r4
|
||||||
|
|
|
@ -944,14 +944,9 @@ int SrsConfig::reload_conf(SrsConfig* conf)
|
||||||
|
|
||||||
// merge config: pid
|
// merge config: pid
|
||||||
if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) {
|
if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) {
|
||||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
if ((ret = do_reload_pid()) != ERROR_SUCCESS) {
|
||||||
ISrsReloadHandler* subscribe = *it;
|
return ret;
|
||||||
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.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge config: srs_log_tank
|
// merge config: srs_log_tank
|
||||||
|
@ -2213,21 +2208,47 @@ int SrsConfig::raw_set_listen(const vector<string>& eps, bool& applied)
|
||||||
|
|
||||||
applied = false;
|
applied = false;
|
||||||
|
|
||||||
SrsConfDirective* listen = root->get("listen");
|
SrsConfDirective* conf = root->get("listen");
|
||||||
|
|
||||||
// not changed, ignore.
|
// not changed, ignore.
|
||||||
if (srs_vector_actual_equals(listen->args, eps)) {
|
if (srs_vector_actual_equals(conf->args, eps)) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// changed, apply and reload.
|
// changed, apply and reload.
|
||||||
listen->args = eps;
|
conf->args = eps;
|
||||||
|
|
||||||
if ((ret = do_reload_listen()) != ERROR_SUCCESS) {
|
if ((ret = do_reload_listen()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
applied = true;
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2235,7 +2256,6 @@ int SrsConfig::do_reload_listen()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// force to reload the memory server.
|
|
||||||
vector<ISrsReloadHandler*>::iterator it;
|
vector<ISrsReloadHandler*>::iterator it;
|
||||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
ISrsReloadHandler* subscribe = *it;
|
ISrsReloadHandler* subscribe = *it;
|
||||||
|
@ -2249,6 +2269,23 @@ int SrsConfig::do_reload_listen()
|
||||||
return ret;
|
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()
|
string SrsConfig::config()
|
||||||
{
|
{
|
||||||
return config_file;
|
return config_file;
|
||||||
|
|
|
@ -331,14 +331,15 @@ public:
|
||||||
virtual int raw_to_json(SrsAmf0Object* obj);
|
virtual int raw_to_json(SrsAmf0Object* obj);
|
||||||
/**
|
/**
|
||||||
* raw set the global listen.
|
* 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);
|
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_listen();
|
||||||
|
virtual int do_reload_pid();
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* get the config file path.
|
* get the config file path.
|
||||||
|
|
|
@ -977,6 +977,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||||
// possible updates:
|
// possible updates:
|
||||||
// @param scope @param value value-description
|
// @param scope @param value value-description
|
||||||
// global.listen 1935,1936 the port list.
|
// global.listen 1935,1936 the port list.
|
||||||
|
// global.pid ./objs/srs.pid the pid file of srs.
|
||||||
if (rpc == "update") {
|
if (rpc == "update") {
|
||||||
if (!allow_update) {
|
if (!allow_update) {
|
||||||
ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED;
|
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 scope = r->query_get("scope");
|
||||||
std::string value = r->query_get("value");
|
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;
|
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
||||||
srs_error("raw api 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);
|
||||||
|
@ -1007,7 +1008,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||||
}
|
}
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
|
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);
|
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);
|
srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
|
||||||
return srs_api_response_code(w, r, 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.
|
// whether the config applied.
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 2
|
#define VERSION_REVISION 3
|
||||||
|
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue