tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1c19821d409dc7a17c5879d2578342798eb02341
parent a33e35e6ac7e2e548975f97b052f6165adada28b
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 21:19:28 -0700

Bug 2000941 - Vendor libwebrtc from 03a4c626c8

Upstream commit: https://webrtc.googlesource.com/src/+/03a4c626c821afa38c68757f9238e6619576d79f
    Provide Environment for AsyncUDPSocket for StunServer

    Bug: webrtc:42223992
    Change-Id: I3abaffa9ea0d94ab37bab10ca4c44b2fc06801de
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/409220
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45666}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/examples/BUILD.gn | 1+
Mthird_party/libwebrtc/examples/stunserver/stunserver_main.cc | 11+++++++----
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 2+-
Mthird_party/libwebrtc/p2p/BUILD.gn | 2++
Mthird_party/libwebrtc/p2p/base/local_network_access_port_unittest.cc | 9++++-----
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc | 2+-
Mthird_party/libwebrtc/p2p/base/port_unittest.cc | 2+-
Mthird_party/libwebrtc/p2p/base/stun_port_unittest.cc | 2+-
Mthird_party/libwebrtc/p2p/client/basic_port_allocator_unittest.cc | 2+-
Mthird_party/libwebrtc/p2p/test/stun_server.cc | 3++-
Mthird_party/libwebrtc/p2p/test/stun_server.h | 3++-
Mthird_party/libwebrtc/p2p/test/stun_server_unittest.cc | 28++++++++++------------------
Mthird_party/libwebrtc/p2p/test/test_stun_server.cc | 29++++++++++++++---------------
Mthird_party/libwebrtc/p2p/test/test_stun_server.h | 13+++++++++----
Mthird_party/libwebrtc/pc/peer_connection_integrationtest.cc | 4++--
Mthird_party/libwebrtc/pc/slow_peer_connection_integration_test.cc | 4++--
17 files changed, 62 insertions(+), 59 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:16:53.235119+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:19:13.093496+00:00. # base of lastest vendoring -916045f926 +03a4c626c8 diff --git a/third_party/libwebrtc/examples/BUILD.gn b/third_party/libwebrtc/examples/BUILD.gn @@ -831,6 +831,7 @@ if (is_linux || is_chromeos || is_win) { testonly = true sources = [ "stunserver/stunserver_main.cc" ] deps = [ + "../api/environment:environment_factory", "../p2p:p2p_server_utils", "../pc:rtc_pc", "../rtc_base:async_udp_socket", diff --git a/third_party/libwebrtc/examples/stunserver/stunserver_main.cc b/third_party/libwebrtc/examples/stunserver/stunserver_main.cc @@ -8,7 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ #include <iostream> +#include <memory> +#include <utility> +#include "api/environment/environment_factory.h" #include "p2p/test/stun_server.h" #include "rtc_base/async_udp_socket.h" #include "rtc_base/checks.h" @@ -34,19 +37,19 @@ int main(int argc, char* argv[]) { webrtc::ThreadManager::Instance()->WrapCurrentThread(); RTC_DCHECK(pthMain); - webrtc::AsyncUDPSocket* server_socket = - webrtc::AsyncUDPSocket::Create(pthMain->socketserver(), server_addr); + std::unique_ptr<webrtc::AsyncUDPSocket> server_socket = + webrtc::AsyncUDPSocket::Create(webrtc::CreateEnvironment(), server_addr, + *pthMain->socketserver()); if (!server_socket) { std::cerr << "Failed to create a UDP socket" << std::endl; return 1; } - StunServer* server = new StunServer(server_socket); + StunServer server(std::move(server_socket)); std::cout << "Listening at " << server_addr.ToString() << std::endl; pthMain->Run(); - delete server; return 0; } diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -326,7 +326,7 @@ index 589142b014..2ee80ded55 100644 } } diff --git a/examples/BUILD.gn b/examples/BUILD.gn -index 7cb844d37d..2712124deb 100644 +index 2fa1b295ed..dc476c9c68 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -9,15 +9,15 @@ diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -1169,6 +1169,7 @@ if (rtc_include_tests) { "../rtc_base/synchronization:mutex", "../rtc_base/third_party/sigslot", "../test:test_support", + "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -1364,6 +1365,7 @@ rtc_library("p2p_server_utils") { "../rtc_base/network:received_packet", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/third_party/libwebrtc/p2p/base/local_network_access_port_unittest.cc b/third_party/libwebrtc/p2p/base/local_network_access_port_unittest.cc @@ -71,9 +71,8 @@ enum ServerType { kStun, kTurn }; // Class to test LocalNetworkAccess integration with STUN and TURN ports. class LocalNetworkAccessPortTest - : public ::testing::Test, - public sigslot::has_slots<>, - public ::testing::WithParamInterface< + : public sigslot::has_slots<>, + public ::testing::TestWithParam< std::tuple<ServerType, absl::string_view, LnaFakeResult>> { public: LocalNetworkAccessPortTest() { @@ -81,8 +80,8 @@ class LocalNetworkAccessPortTest switch (server_type()) { case kStun: - stun_server_ = - TestStunServer::Create(&ss_, {server_address(), 5000}, thread_); + stun_server_ = TestStunServer::Create(env_, {server_address(), 5000}, + ss_, thread_); break; case kTurn: turn_server_.AddInternalSocket({server_address(), 5000}, PROTO_UDP); diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc @@ -310,7 +310,6 @@ class P2PTransportChannelTestBase : public ::testing::Test, ss_(new FirewallSocketServer(nss_.get())), socket_factory_(new BasicPacketSocketFactory(ss_.get())), main_(ss_.get()), - stun_server_(TestStunServer::Create(ss_.get(), kStunAddr, main_)), force_relay_(false) { ep1_.role_ = ICEROLE_CONTROLLING; ep2_.role_ = ICEROLE_CONTROLLED; @@ -319,6 +318,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, } void CreatePortAllocators(const Environment& env) { + stun_server_ = TestStunServer::Create(env, kStunAddr, *ss_, main_); turn_server_.emplace(env, &main_, ss_.get(), kTurnUdpIntAddr, kTurnUdpExtAddr); ServerAddresses stun_servers = {kStunAddr}; diff --git a/third_party/libwebrtc/p2p/base/port_unittest.cc b/third_party/libwebrtc/p2p/base/port_unittest.cc @@ -426,7 +426,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { nat_factory2_(ss_.get(), kNatAddr2, SocketAddress()), nat_socket_factory1_(&nat_factory1_), nat_socket_factory2_(&nat_factory2_), - stun_server_(TestStunServer::Create(ss_.get(), kStunAddr, main_)), + stun_server_(TestStunServer::Create(env_, kStunAddr, *ss_, main_)), turn_server_(env_, &main_, ss_.get(), kTurnUdpIntAddr, kTurnUdpExtAddr), username_(CreateRandomString(ICE_UFRAG_LENGTH)), password_(CreateRandomString(ICE_PWD_LENGTH)), diff --git a/third_party/libwebrtc/p2p/base/stun_port_unittest.cc b/third_party/libwebrtc/p2p/base/stun_port_unittest.cc @@ -164,7 +164,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { for (const auto& addr : stun_server_addresses) { RTC_CHECK(addr.family() == address.family()); stun_servers_.push_back( - webrtc::TestStunServer::Create(ss_.get(), addr, thread_)); + webrtc::TestStunServer::Create(env_, addr, *ss_, thread_)); } } diff --git a/third_party/libwebrtc/p2p/client/basic_port_allocator_unittest.cc b/third_party/libwebrtc/p2p/client/basic_port_allocator_unittest.cc @@ -166,7 +166,7 @@ class BasicPortAllocatorTestBase : public ::testing::Test, // must be called. nat_factory_(vss_.get(), kNatUdpAddr, kNatTcpAddr), nat_socket_factory_(new BasicPacketSocketFactory(&nat_factory_)), - stun_server_(TestStunServer::Create(fss_.get(), kStunAddr, thread_)), + stun_server_(TestStunServer::Create(env_, kStunAddr, *fss_, thread_)), turn_server_(env_, Thread::Current(), fss_.get(), diff --git a/third_party/libwebrtc/p2p/test/stun_server.cc b/third_party/libwebrtc/p2p/test/stun_server.cc @@ -27,7 +27,8 @@ namespace webrtc { -StunServer::StunServer(AsyncUDPSocket* socket) : socket_(socket) { +StunServer::StunServer(std::unique_ptr<AsyncUDPSocket> socket) + : socket_(std::move(socket)) { socket_->RegisterReceivedPacketCallback( [&](AsyncPacketSocket* socket, const ReceivedIpPacket& packet) { OnPacket(socket, packet); diff --git a/third_party/libwebrtc/p2p/test/stun_server.h b/third_party/libwebrtc/p2p/test/stun_server.h @@ -13,6 +13,7 @@ #include <memory> +#include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/sequence_checker.h" #include "api/transport/stun.h" @@ -28,7 +29,7 @@ const int STUN_SERVER_PORT = 3478; class StunServer { public: // Creates a STUN server, which will listen on the given socket. - explicit StunServer(AsyncUDPSocket* socket); + explicit StunServer(absl_nonnull std::unique_ptr<AsyncUDPSocket> socket); // Removes the STUN server from the socket and deletes the socket. virtual ~StunServer(); diff --git a/third_party/libwebrtc/p2p/test/stun_server_unittest.cc b/third_party/libwebrtc/p2p/test/stun_server_unittest.cc @@ -14,7 +14,7 @@ #include <memory> #include <string> -#include "absl/memory/memory.h" +#include "api/environment/environment.h" #include "api/transport/stun.h" #include "rtc_base/async_udp_socket.h" #include "rtc_base/byte_buffer.h" @@ -22,6 +22,7 @@ #include "rtc_base/test_client.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" +#include "test/create_test_environment.h" #include "test/gtest.h" namespace webrtc { @@ -33,28 +34,18 @@ const SocketAddress client_addr("1.2.3.4", 1234); class StunServerTest : public ::testing::Test { public: - StunServerTest() : ss_(new VirtualSocketServer()) { - ss_->SetMessageQueue(&main_thread); - server_.reset( - new StunServer(AsyncUDPSocket::Create(ss_.get(), server_addr))); - client_.reset(new TestClient( - absl::WrapUnique(AsyncUDPSocket::Create(ss_.get(), client_addr)))); - } - void Send(const StunMessage& msg) { ByteBufferWriter buf; msg.Write(&buf); Send(reinterpret_cast<const char*>(buf.Data()), static_cast<int>(buf.Length())); } - void Send(const char* buf, int len) { - client_->SendTo(buf, len, server_addr); - } - bool ReceiveFails() { return (client_->CheckNoPacket()); } + void Send(const char* buf, int len) { client_.SendTo(buf, len, server_addr); } + bool ReceiveFails() { return client_.CheckNoPacket(); } StunMessage* Receive() { StunMessage* msg = nullptr; std::unique_ptr<TestClient::Packet> packet = - client_->NextPacket(TestClient::kTimeoutMs); + client_.NextPacket(TestClient::kTimeoutMs); if (packet) { ByteBufferReader buf(packet->buf); msg = new StunMessage(); @@ -64,10 +55,11 @@ class StunServerTest : public ::testing::Test { } private: - AutoThread main_thread; - std::unique_ptr<VirtualSocketServer> ss_; - std::unique_ptr<StunServer> server_; - std::unique_ptr<TestClient> client_; + const Environment env_ = CreateTestEnvironment(); + VirtualSocketServer ss_; + AutoSocketServerThread main_thread_{&ss_}; + StunServer server_{AsyncUDPSocket::Create(env_, server_addr, ss_)}; + TestClient client_{AsyncUDPSocket::Create(env_, client_addr, ss_)}; }; TEST_F(StunServerTest, TestGood) { diff --git a/third_party/libwebrtc/p2p/test/test_stun_server.cc b/third_party/libwebrtc/p2p/test/test_stun_server.cc @@ -12,34 +12,33 @@ #include <functional> #include <memory> +#include <utility> +#include "api/environment/environment.h" #include "api/sequence_checker.h" #include "api/transport/stun.h" #include "p2p/test/stun_server.h" #include "rtc_base/async_udp_socket.h" #include "rtc_base/checks.h" -#include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/socket_server.h" namespace webrtc { -std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>> -TestStunServer::Create(SocketServer* ss, - const SocketAddress& addr, - Thread& network_thread) { - Socket* socket = ss->CreateSocket(addr.family(), SOCK_DGRAM); - RTC_CHECK(socket != nullptr) << "Failed to create socket"; - AsyncUDPSocket* udp_socket = AsyncUDPSocket::Create(socket, addr); +TestStunServer::StunServerPtr TestStunServer::Create(const Environment& env, + const SocketAddress& addr, + SocketServer& ss, + Thread& network_thread) { + std::unique_ptr<AsyncUDPSocket> udp_socket = + AsyncUDPSocket::Create(env, addr, ss); RTC_CHECK(udp_socket != nullptr) << "Failed to create AsyncUDPSocket"; TestStunServer* server = nullptr; - network_thread.BlockingCall( - [&]() { server = new TestStunServer(udp_socket, network_thread); }); - std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>> result( - server, [&](TestStunServer* server) { - network_thread.BlockingCall([server]() { delete server; }); - }); - return result; + network_thread.BlockingCall([&]() { + server = new TestStunServer(std::move(udp_socket), network_thread); + }); + return StunServerPtr(server, [&network_thread](TestStunServer* server) { + network_thread.BlockingCall([server]() { delete server; }); + }); } void TestStunServer::OnBindingRequest(StunMessage* msg, diff --git a/third_party/libwebrtc/p2p/test/test_stun_server.h b/third_party/libwebrtc/p2p/test/test_stun_server.h @@ -13,7 +13,10 @@ #include <functional> #include <memory> +#include <utility> +#include "absl/base/attributes.h" +#include "api/environment/environment.h" #include "api/transport/stun.h" #include "p2p/test/stun_server.h" #include "rtc_base/async_udp_socket.h" @@ -28,9 +31,11 @@ class TestStunServer : StunServer { public: using StunServerPtr = std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>>; - static StunServerPtr Create(SocketServer* ss, + static StunServerPtr Create(const Environment& env, const SocketAddress& addr, - Thread& network_thread); + SocketServer& ss, + Thread& network_thread + ABSL_ATTRIBUTE_LIFETIME_BOUND); // Set a fake STUN address to return to the client. void set_fake_stun_addr(const SocketAddress& addr) { fake_stun_addr_ = addr; } @@ -38,8 +43,8 @@ class TestStunServer : StunServer { private: static void DeleteOnNetworkThread(TestStunServer* server); - TestStunServer(AsyncUDPSocket* socket, Thread& network_thread) - : StunServer(socket), network_thread_(network_thread) {} + TestStunServer(std::unique_ptr<AsyncUDPSocket> socket, Thread& network_thread) + : StunServer(std::move(socket)), network_thread_(network_thread) {} void OnBindingRequest(StunMessage* msg, const SocketAddress& remote_addr) override; diff --git a/third_party/libwebrtc/pc/peer_connection_integrationtest.cc b/third_party/libwebrtc/pc/peer_connection_integrationtest.cc @@ -2005,8 +2005,8 @@ class PeerConnectionIntegrationIceStatesTest } void StartStunServer(const SocketAddress& server_address) { - stun_server_ = - TestStunServer::Create(firewall(), server_address, *network_thread()); + stun_server_ = TestStunServer::Create(env_, server_address, *firewall(), + *network_thread()); } bool TestIPv6() { diff --git a/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc b/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc @@ -277,8 +277,8 @@ class PeerConnectionIntegrationIceStatesTest } void StartStunServer(const SocketAddress& server_address) { - stun_server_ = - TestStunServer::Create(firewall(), server_address, *network_thread()); + stun_server_ = TestStunServer::Create(env_, server_address, *firewall(), + *network_thread()); } bool TestIPv6() {