diff --git a/CHANGELOG.md b/CHANGELOG.md index b136864924..56519ef068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-07-04, For [#2424](https://github.com/ossrs/srs/issues/2424), use srandom/random to generate. 4.0.139 * v4.0, 2021-07-01, Merge [#2452](https://github.com/ossrs/srs/pull/2452), fix FFmpeg bug by updating channel_layout. 4.0.138 * v4.0, 2021-06-30, Merge [#2440](https://github.com/ossrs/srs/pull/2440), fix [#2390](https://github.com/ossrs/srs/issues/2390), SRT bug for zerolatency. 4.0.137 * v4.0, 2021-06-28, Merge [#2435](https://github.com/ossrs/srs/pull/2435), fix bug for HTTP-RAW-API to check vhost. 4.0.136 diff --git a/README.md b/README.md index 800821b01a..0f3b69dce6 100755 --- a/README.md +++ b/README.md @@ -220,12 +220,7 @@ Please read [CHANGELOG](CHANGELOG.md#changelog). ## Releases -* 2021-06-26, [Release v3.0-r6](https://github.com/ossrs/srs/releases/tag/v3.0-r6), 3.0 release6, 3.0.163, 123011 lines. -* 2021-04-28, [Release v3.0-r5][r3.0r5], 3.0 release5, 3.0.161, 122750 lines. -* 2021-04-24, [Release v3.0-r4][r3.0r4], 3.0 release4, 3.0.160, 122750 lines. -* 2021-01-02, [Release v3.0-r3][r3.0r3], 3.0 release3, 3.0.156, 122736 lines. -* 2020-10-31, [Release v3.0-r2][r3.0r2], 3.0 release2, 3.0.153, 122663 lines. -* 2020-10-10, [Release v3.0-r1][r3.0r1], 3.0 release1, 3.0.144, 122674 lines. +* 2020-07-04, Release [v4.0.139](https://github.com/ossrs/srs/releases/tag/v4.0.139), 4.0 dev0, v4.0.139, 143245 lines. * 2020-06-27, [Release v3.0-r0][r3.0r0], 3.0 release0, 3.0.141, 122674 lines. * 2020-03-29, [Release v3.0-b3][r3.0b4], 3.0 beta4, 3.0.139, 122674 lines. * 2020-03-18, [Release v3.0-b3][r3.0b3], 3.0 beta3, 3.0.134, 122509 lines. diff --git a/trunk/.gitignore b/trunk/.gitignore index 44e1d851d7..ae78e3ae07 100644 --- a/trunk/.gitignore +++ b/trunk/.gitignore @@ -13,6 +13,7 @@ /ide/srs_xcode/srs_xcode.xcodeproj/xcuserdata/ /research/aac/ /research/api-server/static-dir/mse +/research/api-server/static-dir/crossdomain.xml /research/bat/ /research/big/ /research/bitch/ diff --git a/trunk/research/api-server/static-dir/crossdomain.xml b/trunk/research/api-server/static-dir/crossdomain.xml deleted file mode 100644 index ae91084820..0000000000 --- a/trunk/research/api-server/static-dir/crossdomain.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index 2befc1384d..a311e9f193 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -468,7 +468,7 @@ void SrsIngester::show_ingest_log_message() } // random choose one ingester to report. - int index = rand() % (int)ingesters.size(); + int index = srs_random() % (int)ingesters.size(); SrsIngesterFFMPEG* ingester = ingesters.at(index); // reportable diff --git a/trunk/src/app/srs_app_latest_version.cpp b/trunk/src/app/srs_app_latest_version.cpp index a3168c1d35..5eee702aef 100644 --- a/trunk/src/app/srs_app_latest_version.cpp +++ b/trunk/src/app/srs_app_latest_version.cpp @@ -54,7 +54,7 @@ srs_error_t SrsLatestVersion::start() return srs_success; } - server_id_ = srs_random_str(10); + server_id_ = srs_random_str(16); return trd_->start(); } diff --git a/trunk/src/app/srs_app_rtc_dtls.cpp b/trunk/src/app/srs_app_rtc_dtls.cpp index ca0d1aa450..555ff06046 100644 --- a/trunk/src/app/srs_app_rtc_dtls.cpp +++ b/trunk/src/app/srs_app_rtc_dtls.cpp @@ -19,6 +19,7 @@ using namespace std; #include #include #include +#include #include #include @@ -297,7 +298,7 @@ srs_error_t SrsDtlsCertificate::initialize() X509_NAME* subject = X509_NAME_new(); srs_assert(subject); - int serial = rand(); + int serial = (int)srs_random(); ASN1_INTEGER_set(X509_get_serialNumber(dtls_cert), serial); const std::string& aor = RTMP_SIG_SRS_DOMAIN; diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 0307644360..5215b1538b 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -7,6 +7,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 163 +#define SRS_VERSION3_REVISION 164 #endif diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index c30d735f1f..54605d270a 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 138 +#define VERSION_REVISION 139 #endif diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 7e2a635b85..041aad1452 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -102,7 +102,7 @@ srs_utime_t srs_get_system_startup_time() if (_srs_system_time_startup_time <= 0) { srs_update_system_time(); } - + return _srs_system_time_startup_time; } diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index cfe2f1db8d..14fd9081a7 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -81,9 +81,6 @@ srs_error_t do_main(int argc, char** argv) // TODO: support both little and big endian. srs_assert(srs_is_little_endian()); - - // For RTC to generating random ICE username. - ::srandom((unsigned long)(srs_update_system_time() | (::getpid()<<13))); // for gperf gmp or gcp, // should never enable it when not enabled for performance issue. diff --git a/trunk/src/protocol/srs_protocol_utility.cpp b/trunk/src/protocol/srs_protocol_utility.cpp index eab2196d38..e0b999a735 100644 --- a/trunk/src/protocol/srs_protocol_utility.cpp +++ b/trunk/src/protocol/srs_protocol_utility.cpp @@ -131,39 +131,38 @@ void srs_parse_query_string(string q, map& query) } } -static bool _random_initialized = false; - void srs_random_generate(char* bytes, int size) { - if (!_random_initialized) { - _random_initialized = true; - ::srandom((unsigned long)(srs_update_system_time() | (::getpid()<<13))); - } - for (int i = 0; i < size; i++) { // the common value in [0x0f, 0xf0] - bytes[i] = 0x0f + (random() % (256 - 0x0f - 0x0f)); + bytes[i] = 0x0f + (srs_random() % (256 - 0x0f - 0x0f)); } } std::string srs_random_str(int len) { - if (!_random_initialized) { - _random_initialized = true; - ::srandom((unsigned long)(srs_update_system_time() | (::getpid()<<13))); - } - static string random_table = "01234567890123456789012345678901234567890123456789abcdefghijklmnopqrstuvwxyz"; string ret; ret.reserve(len); for (int i = 0; i < len; ++i) { - ret.append(1, random_table[random() % random_table.size()]); + ret.append(1, random_table[srs_random() % random_table.size()]); } return ret; } +long srs_random() +{ + static bool _random_initialized = false; + if (!_random_initialized) { + _random_initialized = true; + ::srandom((unsigned long)(srs_update_system_time() | (::getpid()<<13))); + } + + return random(); +} + string srs_generate_tc_url(string host, string vhost, string app, int port) { string tcUrl = "rtmp://"; diff --git a/trunk/src/protocol/srs_protocol_utility.hpp b/trunk/src/protocol/srs_protocol_utility.hpp index fce5e924c0..d3a4f9df9d 100644 --- a/trunk/src/protocol/srs_protocol_utility.hpp +++ b/trunk/src/protocol/srs_protocol_utility.hpp @@ -55,6 +55,9 @@ extern void srs_random_generate(char* bytes, int size); // Generate random string [0-9a-z] in size of len bytes. extern std::string srs_random_str(int len); +// Generate random value, use srandom(now_us) to init seed if not initialized. +extern long srs_random(); + /** * generate the tcUrl without param. * @remark Use host as tcUrl.vhost if vhost is default vhost. diff --git a/trunk/src/protocol/srs_rtmp_handshake.cpp b/trunk/src/protocol/srs_rtmp_handshake.cpp index 85e38371ff..bbbce8eae5 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.cpp +++ b/trunk/src/protocol/srs_rtmp_handshake.cpp @@ -341,7 +341,7 @@ namespace srs_internal key_block::key_block() { - offset = (int32_t)rand(); + offset = (int32_t)srs_random(); random0 = NULL; random1 = NULL; @@ -423,7 +423,7 @@ namespace srs_internal digest_block::digest_block() { - offset = (int32_t)rand(); + offset = (int32_t)srs_random(); random0 = NULL; random1 = NULL;