mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Log: Use 8 bytes random string as context id
This commit is contained in:
parent
5b199249d0
commit
742826a655
6 changed files with 33 additions and 35 deletions
|
@ -57,20 +57,6 @@ using namespace std;
|
|||
#include <srs_app_rtc_server.hpp>
|
||||
#include <srs_app_rtc_source.hpp>
|
||||
|
||||
// TODO: FIXME: Move to utility.
|
||||
string gen_random_str(int len)
|
||||
{
|
||||
static string random_table = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
string ret;
|
||||
ret.reserve(len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
ret.append(1, random_table[random() % random_table.size()]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64_t SrsNtp::kMagicNtpFractionalUnit = 1ULL << 32;
|
||||
|
||||
SrsNtp::SrsNtp()
|
||||
|
|
|
@ -75,9 +75,6 @@ const uint8_t kSLI = 2;
|
|||
const uint8_t kRPSI = 3;
|
||||
const uint8_t kAFB = 15;
|
||||
|
||||
// TODO: FIXME: Move to utility.
|
||||
extern std::string gen_random_str(int len);
|
||||
|
||||
class SrsNtp
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <srs_app_http_api.hpp>
|
||||
#include <srs_app_rtc_dtls.hpp>
|
||||
#include <srs_service_utility.hpp>
|
||||
#include <srs_protocol_utility.hpp>
|
||||
#include <srs_app_rtc_source.hpp>
|
||||
#include <srs_app_rtc_api.hpp>
|
||||
|
||||
|
@ -310,12 +311,12 @@ srs_error_t SrsRtcServer::create_session(
|
|||
return srs_error_new(ERROR_RTC_SOURCE_BUSY, "stream %s busy", req->get_stream_url().c_str());
|
||||
}
|
||||
|
||||
std::string local_pwd = gen_random_str(32);
|
||||
std::string local_pwd = srs_random_str(32);
|
||||
std::string local_ufrag = "";
|
||||
// TODO: FIXME: Rename for a better name, it's not an username.
|
||||
std::string username = "";
|
||||
while (true) {
|
||||
local_ufrag = gen_random_str(8);
|
||||
local_ufrag = srs_random_str(8);
|
||||
|
||||
username = local_ufrag + ":" + remote_sdp.get_ice_ufrag();
|
||||
if (!map_username_session.count(username)) {
|
||||
|
@ -361,9 +362,9 @@ srs_error_t SrsRtcServer::create_session2(SrsSdp& local_sdp, SrsRtcConnection**
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::string local_pwd = gen_random_str(32);
|
||||
std::string local_pwd = srs_random_str(32);
|
||||
// TODO: FIXME: Collision detect.
|
||||
std::string local_ufrag = gen_random_str(8);
|
||||
std::string local_ufrag = srs_random_str(8);
|
||||
|
||||
SrsRtcConnection* session = new SrsRtcConnection(this);
|
||||
*psession = session;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue