Skip to content

Commit

Permalink
Merge branch 'develop' into pr-feature/connectivity-check
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhihong committed Oct 17, 2023
2 parents 36d8a62 + a458c9c commit b696331
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ RUN ldd /usr/local/srs/objs/ffmpeg/bin/ffmpeg && \

# Default workdir and command.
WORKDIR /usr/local/srs
ENV SRS_DAEMON=off
ENV SRS_DAEMON=off SRS_IN_DOCKER=on
CMD ["./objs/srs", "-c", "conf/docker.conf"]

6 changes: 6 additions & 0 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ srt_server {
# Overwrite by env SRS_SRT_SERVER_MAXBW
# default: -1
maxbw 1000000000;
# Maximum Segment Size. Used for buffer allocation and rate calculation using packet counter assuming fully
# filled packets. Each party can set its own MSS value independently. During a handshake the parties exchange
# MSS values, and the lowest is used.
# Overwrite by env SRS_SRT_SERVER_MSS
# default: 1500
mss 1500;
# The timeout time of the SRT connection on the sender side in ms. When SRT connects to a peer costs time
# more than this config, it will be close.
# Overwrite by env SRS_SRT_SERVER_CONNECT_TIMEOUT
Expand Down
6 changes: 6 additions & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The changelog for SRS.
<a name="v6-changes"></a>

## SRS 6.0 Changelog
* v6.0, 2023-10-17, Merge [#3758](https://github.com/ossrs/srs/pull/3758): Refine docker detect mechenism. v6.0.90 (#3758)
* v6.0, 2023-10-11, Merge [#3827](https://github.com/ossrs/srs/pull/3827): Fix bug for upgrading to OpenSSL 3.0. v6.0.89 (#3827)
* v6.0, 2023-10-10, Merge [#3825](https://github.com/ossrs/srs/pull/3825): SRT: Fix the missing config mss. v6.0.88 (#3825)
* v6.0, 2023-10-08, Merge [#3824](https://github.com/ossrs/srs/pull/3824): Solve the problem of inaccurate HLS TS duration. v6.0.87 (#3824)
* v6.0, 2023-10-08, Merge [#3815](https://github.com/ossrs/srs/pull/3815): Use new cache image name. v6.0.86 (#3815)
* v6.0, 2023-09-26, Merge [#3811](https://github.com/ossrs/srs/pull/3811): Turn off the related utests H265 option. v6.0.85 (#3811)
Expand Down Expand Up @@ -99,6 +102,9 @@ The changelog for SRS.
<a name="v5-changes"></a>

## SRS 5.0 Changelog
* v5.0, 2023-10-17, Merge [#3758](https://github.com/ossrs/srs/pull/3758): Refine docker detect mechenism. v5.0.190 (#3758)
* v5.0, 2023-10-11, Merge [#3827](https://github.com/ossrs/srs/pull/3827): Fix bug for upgrading to OpenSSL 3.0. v5.0.189 (#3827)
* v5.0, 2023-10-10, Merge [#3825](https://github.com/ossrs/srs/pull/3825): SRT: Fix the missing config mss. v5.0.188 (#3825)
* v5.0, 2023-10-08, Merge [#3824](https://github.com/ossrs/srs/pull/3824): Solve the problem of inaccurate HLS TS duration. v5.0.187 (#3824)
* v5.0, 2023-10-08, Merge [#3815](https://github.com/ossrs/srs/pull/3815): Use new cache image name. v5.0.186 (#3815)
* v5.0, 2023-09-28, Merge [#3816](https://github.com/ossrs/srs/pull/3816): cherry-pick from develop, for srt utest. v5.0.185 (#3816)
Expand Down
4 changes: 2 additions & 2 deletions trunk/research/console/en_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<li class="{{'/configs'| sc_filter_nav_active}}"><a href="javascript:void(0)" ng-click="gogogo('/configs')">Config</a></li>
<li><a href="javascript:void(0)" ng-click="redirect('en_index.html', 'ng_index.html')">Chinese</a></li>
<li>
<a href="https://github.com/ossrs/srs-console">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs-console?style=social">
<a href="https://github.com/ossrs/srs">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
</a>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions trunk/research/console/ng_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<li class="{{'/configs'| sc_filter_nav_active}}"><a href="javascript:void(0)" ng-click="gogogo('/configs')">配置</a></li>
<li><a href="javascript:void(0)" ng-click="redirect('ng_index.html', 'en_index.html')">English</a></li>
<li>
<a href="https://github.com/ossrs/srs-console">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs-console?style=social">
<a href="https://github.com/ossrs/srs">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
</a>
</li>
</ul>
Expand Down
53 changes: 48 additions & 5 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,38 @@ bool is_common_space(char ch)
return (ch == ' ' || ch == '\t' || ch == SRS_CR || ch == SRS_LF);
}

extern bool _srs_in_docker;

// Detect docker by https://stackoverflow.com/a/41559867
srs_error_t srs_detect_docker()
{
srs_error_t err = srs_success;

_srs_in_docker = false;

SrsFileReader fr;
if ((err = fr.open("/proc/1/cgroup")) != srs_success) {
return err;
}

ssize_t nn;
char buf[1024];
if ((err = fr.read(buf, sizeof(buf), &nn)) != srs_success) {
return err;
}

if (nn <= 0) {
return err;
}

string s(buf, nn);
if (srs_string_contains(s, "/docker")) {
_srs_in_docker = true;
}

return err;
}

namespace srs_internal
{
SrsConfigBuffer::SrsConfigBuffer()
Expand Down Expand Up @@ -1934,6 +1966,19 @@ srs_error_t SrsConfig::parse_options(int argc, char** argv)
if (root->directives.empty()) root->get_or_create("vhost", "__defaultVhost__");
}

// Ignore any error while detecting docker.
if ((err = srs_detect_docker()) != srs_success) {
srs_error_reset(err);
}

// Try to load the config if docker detect failed.
if (!_srs_in_docker) {
_srs_in_docker = _srs_config->get_in_docker();
if (_srs_in_docker) {
srs_trace("enable in_docker by config");
}
}

////////////////////////////////////////////////////////////////////////
// check log name and level
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2856,7 +2901,7 @@ string SrsConfig::argv()

bool SrsConfig::get_daemon()
{
SRS_OVERWRITE_BY_ENV_BOOL2("srs.daemon");
SRS_OVERWRITE_BY_ENV_BOOL2("srs.daemon"); // SRS_DAEMON

SrsConfDirective* conf = root->get("daemon");
if (!conf || conf->arg0().empty()) {
Expand Down Expand Up @@ -6520,8 +6565,6 @@ string SrsConfig::get_ingest_input_url(SrsConfDirective* conf)
return conf->arg0();
}

extern bool _srs_in_docker;

bool SrsConfig::get_log_tank_file()
{
if (!srs_getenv("srs.srs_log_tank").empty()) { // SRS_SRS_LOG_TANK
Expand Down Expand Up @@ -7912,15 +7955,15 @@ int64_t SrsConfig::get_srto_maxbw()

int SrsConfig::get_srto_mss()
{
SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.mms"); // SRS_SRT_SERVER_MMS
SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.mss"); // SRS_SRT_SERVER_MSS

static int DEFAULT = 1500;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}

conf = conf->get("mms");
conf = conf->get("mss");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 5
#define VERSION_MINOR 0
#define VERSION_REVISION 187
#define VERSION_REVISION 190

#endif
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 87
#define VERSION_REVISION 90

#endif
48 changes: 3 additions & 45 deletions trunk/src/main/srs_main_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ using namespace std;
// pre-declare
srs_error_t run_directly_or_daemon();
srs_error_t run_in_thread_pool();
srs_error_t srs_detect_docker();
void show_macro_features();

// @global log and context.
Expand All @@ -79,6 +78,9 @@ bool _srs_config_by_env = false;
// The binary name of SRS.
const char* _srs_binary = NULL;

// @global Other variables.
bool _srs_in_docker = false;

// Free global data, for address sanitizer.
extern void srs_free_global_system_ips();

Expand Down Expand Up @@ -131,11 +133,6 @@ srs_error_t do_main(int argc, char** argv, char** envp)
#ifdef SRS_GPERF_MP
#warning "gmp is not used for memory leak, please use gmc instead."
#endif

// Ignore any error while detecting docker.
if ((err = srs_detect_docker()) != srs_success) {
srs_error_reset(err);
}

// never use srs log(srs_trace, srs_error, etc) before config parse the option,
// which will load the log config and apply it.
Expand Down Expand Up @@ -400,49 +397,10 @@ void show_macro_features()
#endif
}

// Detect docker by https://stackoverflow.com/a/41559867
bool _srs_in_docker = false;
srs_error_t srs_detect_docker()
{
srs_error_t err = srs_success;

_srs_in_docker = false;

SrsFileReader fr;
if ((err = fr.open("/proc/1/cgroup")) != srs_success) {
return err;
}

ssize_t nn;
char buf[1024];
if ((err = fr.read(buf, sizeof(buf), &nn)) != srs_success) {
return err;
}

if (nn <= 0) {
return err;
}

string s(buf, nn);
if (srs_string_contains(s, "/docker")) {
_srs_in_docker = true;
}

return err;
}

srs_error_t run_directly_or_daemon()
{
srs_error_t err = srs_success;

// Try to load the config if docker detect failed.
if (!_srs_in_docker) {
_srs_in_docker = _srs_config->get_in_docker();
if (_srs_in_docker) {
srs_trace("enable in_docker by config");
}
}

// Load daemon from config, disable it for docker.
// @see https://github.com/ossrs/srs/issues/1594
bool run_as_daemon = _srs_config->get_daemon();
Expand Down
5 changes: 1 addition & 4 deletions trunk/src/protocol/srs_protocol_rtmp_handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,7 @@ namespace srs_internal
return srs_error_new(ERROR_OpenSslSetG, "set word");
}

// 4. Set the key length
DH_set_length(pdh, bits_count);

// 5. Generate private and public key
// 4. Generate private and public key
// @see ./test/dhtest.c:152
if (!DH_generate_key(pdh)) {
return srs_error_new(ERROR_OpenSslGenerateDHKeys, "dh generate key");
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/utest/srs_utest_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,7 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesSrtServer)
SrsSetEnvConfig(srto_maxbw, "SRS_SRT_SERVER_MAXBW", "1000000000");
EXPECT_EQ(1000000000, conf.get_srto_maxbw());

SrsSetEnvConfig(srto_mss, "SRS_SRT_SERVER_MMS", "1000");
SrsSetEnvConfig(srto_mss, "SRS_SRT_SERVER_MSS", "1000");
EXPECT_EQ(1000, conf.get_srto_mss());

SrsSetEnvConfig(srto_conntimeout, "SRS_SRT_SERVER_CONNECT_TIMEOUT", "2000");
Expand Down

0 comments on commit b696331

Please sign in to comment.