From 99dfa391caf083139d87d7d7e5cc7f2f7a541190 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Thu, 19 Dec 2024 12:23:23 +0100 Subject: [PATCH] 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 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#43611} --- api/test/network_emulation_manager.h | 1 + test/network/emulated_turn_server.cc | 7 +++++-- test/network/emulated_turn_server.h | 3 ++- test/network/network_emulation_manager.cc | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index 5e20be567f..338e16744d 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -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. diff --git a/test/network/emulated_turn_server.cc b/test/network/emulated_turn_server.cc index 47d2c9cbd6..049ea46cc6 100644 --- a/test/network/emulated_turn_server.cc +++ b/test/network/emulated_turn_server.cc @@ -119,18 +119,21 @@ class EmulatedTURNServer::AsyncPacketSocketWrapper const rtc::SocketAddress local_address_; }; -EmulatedTURNServer::EmulatedTURNServer(std::unique_ptr thread, +EmulatedTURNServer::EmulatedTURNServer(const EmulatedTURNServerConfig& config, + std::unique_ptr 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(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); diff --git a/test/network/emulated_turn_server.h b/test/network/emulated_turn_server.h index de5d266897..557d83df78 100644 --- a/test/network/emulated_turn_server.h +++ b/test/network/emulated_turn_server.h @@ -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 thread, + EmulatedTURNServer(const EmulatedTURNServerConfig& config, + std::unique_ptr thread, EmulatedEndpoint* client, EmulatedEndpoint* peer); ~EmulatedTURNServer() override; diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc index 47de18431e..becad9d903 100644 --- a/test/network/network_emulation_manager.cc +++ b/test/network/network_emulation_manager.cc @@ -371,7 +371,7 @@ EmulatedTURNServerInterface* NetworkEmulationManagerImpl::CreateTURNServer( str.AppendFormat("turn_server_%u", static_cast(turn_servers_.size())); auto turn = std::make_unique( - 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;