1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Support set the ice-ufrag and ice-pwd for connectivity check. v5.0.191 (#3837)

Checking the HTTPS API or UDP connectivity for WHIP tests can be
difficult. For example, if the UDP port isn't available but the API is
fine, OBS only says it can't connect to the server. It's hard to see the
HTTPS API response or check if the UDP port is available.

This feature lets you set the ice username and password in SRS. You can
then send a STUN request using nc and see the response, making it easier
to check UDP port connectivity.

1. Use curl to test the WHIP API, including ice-frag and ice-pwd
queries.
2. Use nc to send a STUN binding request to test UDP connectivity.
3. If both the API and UDP are working, you should get a STUN response.

---------

Co-authored-by: john <hondaxiao@tencent.com>
This commit is contained in:
john 2023-10-17 22:36:10 +08:00
parent 3da81e4b75
commit ba33bb8f8b
6 changed files with 37 additions and 8 deletions

View file

@ -543,17 +543,18 @@ srs_error_t SrsRtcServer::do_create_session(SrsRtcUserConfig* ruc, SrsSdp& local
// All tracks default as inactive, so we must enable them.
session->set_all_tracks_status(req->get_stream_url(), ruc->publish_, true);
std::string local_pwd = srs_random_str(32);
std::string local_ufrag = "";
std::string local_pwd = ruc->req_->ice_pwd_.empty() ? srs_random_str(32) : ruc->req_->ice_pwd_;
std::string local_ufrag = ruc->req_->ice_ufrag_.empty() ? srs_random_str(8) : ruc->req_->ice_ufrag_;
// TODO: FIXME: Rename for a better name, it's not an username.
std::string username = "";
while (true) {
local_ufrag = srs_random_str(8);
username = local_ufrag + ":" + ruc->remote_sdp_.get_ice_ufrag();
if (!_srs_rtc_manager->find_by_name(username)) {
break;
}
// Username conflict, regenerate a new one.
local_ufrag = srs_random_str(8);
}
local_sdp.set_ice_ufrag(local_ufrag);