Skip to content

Commit

Permalink
Fix #2508, Support features query by API. 5.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 7, 2021
1 parent 69faf06 commit adf0043
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The changelog for SRS.

## SRS 4.0 Changelog

* v4.0, 2021-08-07, Fix [#2508](https://github.com/ossrs/srs/pull/2508), Support features query by API. 4.0.149
* v4.0, 2021-07-25, Fix build failed. 4.0.146
* v4.0, 2021-07-24, Merge [#2373](https://github.com/ossrs/srs/pull/2373), RTC: Fix NACK negotiation bug for Firefox. 4.0.145
* v4.0, 2021-07-24, Merge [#2483](https://github.com/ossrs/srs/pull/2483), RTC: Support statistic for HTTP-API, HTTP-Callback and Security. 4.0.144
Expand Down
129 changes: 111 additions & 18 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3617,6 +3617,7 @@ srs_error_t SrsConfig::check_normal_config()
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
&& n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker"
&& n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate"
&& n != "query_latest_version"
&& n != "circuit_breaker" && n != "is_full"
) {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
Expand Down Expand Up @@ -5672,20 +5673,26 @@ int SrsConfig::get_global_chunk_size()
return ::atoi(conf->arg0().c_str());
}

bool SrsConfig::get_forward_enabled(string vhost)
{
bool SrsConfig::get_forward_enabled(string vhost) {
static bool DEFAULT = false;

SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

conf = conf->get("forward");

return get_forward_enabled(conf);
}

bool SrsConfig::get_forward_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("forward");
if (!conf) {
return DEFAULT;
}

conf = conf->get("enabled");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
Expand Down Expand Up @@ -5723,7 +5730,19 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_vhost_http_hooks(vhost);
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_vhost_http_hooks_enabled(conf);
}

bool SrsConfig::get_vhost_http_hooks_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("http_hooks");
if (!conf) {
return DEFAULT;
}
Expand Down Expand Up @@ -6097,13 +6116,20 @@ bool SrsConfig::get_security_enabled(string vhost)
if (!conf) {
return DEFAULT;
}

return get_security_enabled(conf);
}

bool SrsConfig::get_security_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* security = conf->get("security");
if (!security) {
SrsConfDirective* conf = vhost->get("security");
if (!conf) {
return DEFAULT;
}

conf = security->get("enabled");
conf = conf->get("enabled");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
Expand Down Expand Up @@ -6578,7 +6604,19 @@ bool SrsConfig::get_exec_enabled(string vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_exec(vhost);
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_exec_enabled(conf);
}

bool SrsConfig::get_exec_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("exec");
if (!conf) {
return DEFAULT;
}
Expand Down Expand Up @@ -6787,10 +6825,22 @@ SrsConfDirective* SrsConfig::get_dash(string vhost)
}

bool SrsConfig::get_dash_enabled(string vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_dash_enabled(conf);
}

bool SrsConfig::get_dash_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_dash(vhost);
SrsConfDirective* conf = vhost->get("dash");
if (!conf) {
return DEFAULT;
}
Expand Down Expand Up @@ -6897,8 +6947,20 @@ SrsConfDirective* SrsConfig::get_hls(string vhost)
bool SrsConfig::get_hls_enabled(string vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_hls(vhost);

SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_hls_enabled(conf);
}

bool SrsConfig::get_hls_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("hls");

if (!conf) {
return DEFAULT;
Expand Down Expand Up @@ -7304,7 +7366,19 @@ bool SrsConfig::get_hds_enabled(const string &vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_hds(vhost);
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_hds_enabled(conf);
}

bool SrsConfig::get_hds_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("hds");
if (!conf) {
return DEFAULT;
}
Expand Down Expand Up @@ -7381,8 +7455,20 @@ SrsConfDirective* SrsConfig::get_dvr(string vhost)
bool SrsConfig::get_dvr_enabled(string vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = get_dvr(vhost);

SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}

return get_dvr_enabled(conf);
}

bool SrsConfig::get_dvr_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("dvr");
if (!conf) {
return DEFAULT;
}
Expand Down Expand Up @@ -8160,7 +8246,14 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost)
return DEFAULT;
}

conf = conf->get("http_remux");
return get_vhost_http_remux_enabled(conf);
}

bool SrsConfig::get_vhost_http_remux_enabled(SrsConfDirective* vhost)
{
static bool DEFAULT = false;

SrsConfDirective* conf = vhost->get("http_remux");
if (!conf) {
return DEFAULT;
}
Expand Down
9 changes: 9 additions & 0 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ class SrsConfig
public:
// Whether the forwarder enabled.
virtual bool get_forward_enabled(std::string vhost);
virtual bool get_forward_enabled(SrsConfDirective* vhost);
// Get the forward directive of vhost.
virtual SrsConfDirective* get_forwards(std::string vhost);

Expand Down Expand Up @@ -686,6 +687,7 @@ class SrsConfig
// Whether vhost http-hooks enabled.
// @remark, if not enabled, donot callback all http hooks.
virtual bool get_vhost_http_hooks_enabled(std::string vhost);
virtual bool get_vhost_http_hooks_enabled(SrsConfDirective* vhost);
// Get the on_connect callbacks of vhost.
// @return the on_connect callback directive, the args is the url to callback.
virtual SrsConfDirective* get_vhost_on_connect(std::string vhost);
Expand Down Expand Up @@ -765,6 +767,7 @@ class SrsConfig
public:
// Whether the secrity of vhost enabled.
virtual bool get_security_enabled(std::string vhost);
virtual bool get_security_enabled(SrsConfDirective* vhost);
// Get the security rules.
virtual SrsConfDirective* get_security_rules(std::string vhost);
// vhost transcode section
Expand Down Expand Up @@ -847,6 +850,7 @@ class SrsConfig
public:
// Whether the exec is enabled of vhost.
virtual bool get_exec_enabled(std::string vhost);
virtual bool get_exec_enabled(SrsConfDirective* vhost);
// Get all exec publish directives of vhost.
virtual std::vector<SrsConfDirective*> get_exec_publishs(std::string vhost);
// vhost ingest section
Expand Down Expand Up @@ -884,6 +888,7 @@ class SrsConfig
public:
// Whether DASH is enabled.
virtual bool get_dash_enabled(std::string vhost);
virtual bool get_dash_enabled(SrsConfDirective* vhost);
// Get the duration of segment in srs_utime_t.
virtual srs_utime_t get_dash_fragment(std::string vhost);
// Get the period to update MPD in srs_utime_t.
Expand All @@ -901,6 +906,7 @@ class SrsConfig
public:
// Whether HLS is enabled.
virtual bool get_hls_enabled(std::string vhost);
virtual bool get_hls_enabled(SrsConfDirective* vhost);
// Get the HLS m3u8 list ts segment entry prefix info.
virtual std::string get_hls_entry_prefix(std::string vhost);
// Get the HLS ts/m3u8 file store path.
Expand Down Expand Up @@ -958,6 +964,7 @@ class SrsConfig
public:
// Whether HDS is enabled.
virtual bool get_hds_enabled(const std::string &vhost);
virtual bool get_hds_enabled(SrsConfDirective* vhost);
// Get the HDS file store path.
virtual std::string get_hds_path(const std::string &vhost);
// Get the hds fragment time, in srs_utime_t.
Expand All @@ -972,6 +979,7 @@ class SrsConfig
public:
// Whether dvr is enabled.
virtual bool get_dvr_enabled(std::string vhost);
virtual bool get_dvr_enabled(SrsConfDirective* vhost);
// Get the filter of dvr to apply to.
// @remark user can use srs_config_apply_filter(conf, req):bool to check it.
virtual SrsConfDirective* get_dvr_apply(std::string vhost);
Expand Down Expand Up @@ -1047,6 +1055,7 @@ class SrsConfig
public:
// Get whether vhost enabled http flv live stream
virtual bool get_vhost_http_remux_enabled(std::string vhost);
virtual bool get_vhost_http_remux_enabled(SrsConfDirective* vhost);
// Get the fast cache duration for http audio live stream.
virtual srs_utime_t get_vhost_http_remux_fast_cache(std::string vhost);
// Get the http flv live stream mount point for vhost.
Expand Down
Loading

0 comments on commit adf0043

Please sign in to comment.