Add config to to enable/disable permissions checks in EmulatedTURNServer

Bug: chromium:1024965
Change-Id: I91b8d29932f08b3011635e62a0879c645b89f106
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/372260
Auto-Submit: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43611}
This commit is contained in:
Jonas Oreland 2024-12-19 12:23:23 +01:00 committed by WebRTC LUCI CQ
parent 35f73ddca4
commit 99dfa391ca
4 changed files with 9 additions and 4 deletions

View File

@ -92,6 +92,7 @@ struct EmulatedEndpointConfig {
struct EmulatedTURNServerConfig {
EmulatedEndpointConfig client_config;
EmulatedEndpointConfig peer_config;
bool enable_permission_checks = true;
};
// EmulatedTURNServer is an abstraction for a TURN server.

View File

@ -119,18 +119,21 @@ class EmulatedTURNServer::AsyncPacketSocketWrapper
const rtc::SocketAddress local_address_;
};
EmulatedTURNServer::EmulatedTURNServer(std::unique_ptr<rtc::Thread> thread,
EmulatedTURNServer::EmulatedTURNServer(const EmulatedTURNServerConfig& config,
std::unique_ptr<rtc::Thread> thread,
EmulatedEndpoint* client,
EmulatedEndpoint* peer)
: thread_(std::move(thread)), client_(client), peer_(peer) {
ice_config_.username = "keso";
ice_config_.password = "keso";
SendTask(thread_.get(), [this]() {
SendTask(thread_.get(), [this, enable_permission_checks =
config.enable_permission_checks]() {
RTC_DCHECK_RUN_ON(thread_.get());
turn_server_ = std::make_unique<cricket::TurnServer>(thread_.get());
turn_server_->set_realm(kTestRealm);
turn_server_->set_realm(kTestSoftware);
turn_server_->set_auth_hook(this);
turn_server_->set_enable_permission_checks(enable_permission_checks);
auto client_socket = Wrap(client_);
turn_server_->AddInternalSocket(client_socket, cricket::PROTO_UDP);

View File

@ -42,7 +42,8 @@ class EmulatedTURNServer : public EmulatedTURNServerInterface,
// Create an EmulatedTURNServer.
// `thread` is a thread that will be used to run cricket::TurnServer
// that expects all calls to be made from a single thread.
EmulatedTURNServer(std::unique_ptr<rtc::Thread> thread,
EmulatedTURNServer(const EmulatedTURNServerConfig& config,
std::unique_ptr<rtc::Thread> thread,
EmulatedEndpoint* client,
EmulatedEndpoint* peer);
~EmulatedTURNServer() override;

View File

@ -371,7 +371,7 @@ EmulatedTURNServerInterface* NetworkEmulationManagerImpl::CreateTURNServer(
str.AppendFormat("turn_server_%u",
static_cast<unsigned>(turn_servers_.size()));
auto turn = std::make_unique<EmulatedTURNServer>(
time_controller_->CreateThread(str.str()), client, peer);
config, time_controller_->CreateThread(str.str()), client, peer);
auto out = turn.get();
turn_servers_.push_back(std::move(turn));
return out;