<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[280523] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/280523">280523</a></dd>
<dt>Author</dt> <dd>youenn@apple.com</dd>
<dt>Date</dt> <dd>2021-08-01 09:02:21 -0700 (Sun, 01 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce an experimental feature to toggle WebRTC socket proxying
https://bugs.webkit.org/show_bug.cgi?id=228681

Reviewed by Eric Carlson.

Source/WebKit:

Decide whether to disable proxying based on experimental feature in WebProcess.
Send the disable relay value from WebProcess to NetworkProcess for TCP sockets.
Manually tested.

* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
(WebKit::NetworkRTCProvider::createClientTCPSocket):
* NetworkProcess/webrtc/NetworkRTCProvider.h:
* NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
* NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h:
* NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
(WebKit::NetworkRTCTCPSocketCocoa::createClientTCPSocket):
(WebKit::NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa):
* WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
(WebKit::RTCSocketFactory::CreateClientTcpSocket):
(WebKit::LibWebRTCProvider::createSocketFactory):
* WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
(WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
* WebProcess/Network/webrtc/LibWebRTCSocketFactory.h:

Source/WTF:

* Scripts/Preferences/WebPreferencesExperimental.yaml:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFScriptsPreferencesWebPreferencesExperimentalyaml">trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProvidercpp">trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProviderh">trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProvidermessagesin">trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesswebrtcNetworkRTCTCPSocketCocoah">trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesswebrtcNetworkRTCTCPSocketCocoamm">trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCProvidercpp">trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCProviderh">trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCSocketFactorycpp">trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCSocketFactoryh">trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WTF/ChangeLog  2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2021-08-01  Youenn Fablet  <youenn@apple.com>
+
+        Introduce an experimental feature to toggle WebRTC socket proxying
+        https://bugs.webkit.org/show_bug.cgi?id=228681
+
+        Reviewed by Eric Carlson.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
</ins><span class="cx"> 2021-07-31  Yusuke Suzuki  <ysuzuki@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [JSC] Move JIT_UNICODE_EXPRESSIONS to ENABLE(YARR_JIT_UNICODE_EXPRESSIONS) in PlatformEnable.h
</span></span></pre></div>
<a id="trunkSourceWTFScriptsPreferencesWebPreferencesExperimentalyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml     2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml        2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -1357,6 +1357,19 @@
</span><span class="cx">     WebKit:
</span><span class="cx">       default: false
</span><span class="cx"> 
</span><ins>+WebRTCSocketsProxyingEnabled:
+  type: bool
+  humanReadableName: "WebRTC Sockets Proxying"
+  humanReadableDescription: "Enable WebRTC Sockets Proxying"
+  condition: ENABLE(WEB_RTC)
+  defaultValue:
+    WebKitLegacy:
+      default: false
+    WebKit:
+      default: false
+    WebCore:
+      default: false
+
</ins><span class="cx"> WebRTCVP9Profile0CodecEnabled:
</span><span class="cx">   type: bool
</span><span class="cx">   humanReadableName: "WebRTC VP9 profile 0 codec"
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/ChangeLog       2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2021-08-01  Youenn Fablet  <youenn@apple.com>
+
+        Introduce an experimental feature to toggle WebRTC socket proxying
+        https://bugs.webkit.org/show_bug.cgi?id=228681
+
+        Reviewed by Eric Carlson.
+
+        Decide whether to disable proxying based on experimental feature in WebProcess.
+        Send the disable relay value from WebProcess to NetworkProcess for TCP sockets.
+        Manually tested.
+
+        * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
+        (WebKit::NetworkRTCProvider::createClientTCPSocket):
+        * NetworkProcess/webrtc/NetworkRTCProvider.h:
+        * NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
+        * NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h:
+        * NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
+        (WebKit::NetworkRTCTCPSocketCocoa::createClientTCPSocket):
+        (WebKit::NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa):
+        * WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
+        (WebKit::RTCSocketFactory::CreateClientTcpSocket):
+        (WebKit::LibWebRTCProvider::createSocketFactory):
+        * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
+        (WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
+        * WebProcess/Network/webrtc/LibWebRTCSocketFactory.h:
+
</ins><span class="cx"> 2021-07-31  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Improve LocalSampleBufferDisplayLayer logging
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp 2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp    2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -177,9 +177,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, String&& userAgent, int options)
</del><ins>+void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, String&& userAgent, int options, bool isRelayDisabled)
</ins><span class="cx"> {
</span><del>-    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, localAddress, remoteAddress, userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
</del><ins>+    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, localAddress, remoteAddress, userAgent = WTFMove(userAgent).isolatedCopy(), options, isRelayDisabled]() mutable {
</ins><span class="cx">         if (!m_connection)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -188,10 +188,10 @@
</span><span class="cx">             m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><del>-        callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
</del><ins>+        callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options, isRelayDisabled]() mutable {
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">             if (m_platformTCPSocketsEnabled) {
</span><del>-                if (auto socket = NetworkRTCTCPSocketCocoa::createClientTCPSocket(identifier, *this, remoteAddress, options, m_ipcConnection.copyRef())) {
</del><ins>+                if (auto socket = NetworkRTCTCPSocketCocoa::createClientTCPSocket(identifier, *this, remoteAddress, options, isRelayDisabled, m_ipcConnection.copyRef())) {
</ins><span class="cx">                     addSocket(identifier, WTFMove(socket));
</span><span class="cx">                     return;
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h   2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h      2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">     void startListeningForIPC();
</span><span class="cx"> 
</span><span class="cx">     void createUDPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, uint16_t, uint16_t, bool isFirstParty, bool isRelayDisabled, WebCore::RegistrableDomain&&);
</span><del>-    void createClientTCPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, const RTCNetwork::SocketAddress&, String&& userAgent, int);
</del><ins>+    void createClientTCPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, const RTCNetwork::SocketAddress&, String&& userAgent, int, bool isRelayDisabled);
</ins><span class="cx">     void createServerTCPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, uint16_t minPort, uint16_t maxPort, int);
</span><span class="cx">     void wrapNewTCPConnection(WebCore::LibWebRTCSocketIdentifier identifier, WebCore::LibWebRTCSocketIdentifier newConnectionSocketIdentifier);
</span><span class="cx">     void sendToSocket(WebCore::LibWebRTCSocketIdentifier, const IPC::DataReference&, RTCNetwork::SocketAddress&&, RTCPacketOptions&&);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesswebrtcNetworkRTCProvidermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in 2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in    2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> messages -> NetworkRTCProvider {
</span><span class="cx">     CreateUDPSocket(WebCore::LibWebRTCSocketIdentifier identifier, WebKit::RTCNetwork::SocketAddress localAddress, uint16_t minPort, uint16_t maxPort, bool isFirstParty, bool isRelayDisabled, WebCore::RegistrableDomain domain)
</span><span class="cx">     CreateServerTCPSocket(WebCore::LibWebRTCSocketIdentifier identifier, WebKit::RTCNetwork::SocketAddress localAddress, uint16_t minPort, uint16_t maxPort, int options)
</span><del>-    CreateClientTCPSocket(WebCore::LibWebRTCSocketIdentifier identifier, WebKit::RTCNetwork::SocketAddress localAddress, WebKit::RTCNetwork::SocketAddress remoteAddress, String userAgent, int options)
</del><ins>+    CreateClientTCPSocket(WebCore::LibWebRTCSocketIdentifier identifier, WebKit::RTCNetwork::SocketAddress localAddress, WebKit::RTCNetwork::SocketAddress remoteAddress, String userAgent, int options, bool isRelayDisabled)
</ins><span class="cx">     WrapNewTCPConnection(WebCore::LibWebRTCSocketIdentifier identifier, WebCore::LibWebRTCSocketIdentifier newConnectionSocketIdentifier)
</span><span class="cx"> 
</span><span class="cx">     void SetPlatformTCPSocketsEnabled(bool enabled)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesswebrtcNetworkRTCTCPSocketCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h     2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.h        2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -39,9 +39,9 @@
</span><span class="cx"> class NetworkRTCTCPSocketCocoa final : public NetworkRTCProvider::Socket {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    static std::unique_ptr<NetworkRTCProvider::Socket> createClientTCPSocket(WebCore::LibWebRTCSocketIdentifier, NetworkRTCProvider&, const rtc::SocketAddress&, int options, Ref<IPC::Connection>&&);
</del><ins>+    static std::unique_ptr<NetworkRTCProvider::Socket> createClientTCPSocket(WebCore::LibWebRTCSocketIdentifier, NetworkRTCProvider&, const rtc::SocketAddress&, int options, bool isRelayDisabled, Ref<IPC::Connection>&&);
</ins><span class="cx"> 
</span><del>-    NetworkRTCTCPSocketCocoa(WebCore::LibWebRTCSocketIdentifier, NetworkRTCProvider&, const rtc::SocketAddress&, int options, Ref<IPC::Connection>&&);
</del><ins>+    NetworkRTCTCPSocketCocoa(WebCore::LibWebRTCSocketIdentifier, NetworkRTCProvider&, const rtc::SocketAddress&, int options, bool isRelayDisabled, Ref<IPC::Connection>&&);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // NetworkRTCProvider::Socket.
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesswebrtcNetworkRTCTCPSocketCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm    2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm       2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -50,12 +50,12 @@
</span><span class="cx">     return queue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCTCPSocketCocoa::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& remoteAddress, int tcpOptions, Ref<IPC::Connection>&& connection)
</del><ins>+std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCTCPSocketCocoa::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& remoteAddress, int tcpOptions, bool isRelayDisabled, Ref<IPC::Connection>&& connection)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: We should migrate ssltcp candidates, maybe support OPT_TLS_INSECURE as well.
</span><span class="cx">     if ((tcpOptions & rtc::PacketSocketFactory::OPT_TLS_FAKE) || (tcpOptions & rtc::PacketSocketFactory::OPT_TLS_INSECURE))
</span><span class="cx">         return nullptr;
</span><del>-    return makeUnique<NetworkRTCTCPSocketCocoa>(identifier, rtcProvider, remoteAddress, tcpOptions, WTFMove(connection));
</del><ins>+    return makeUnique<NetworkRTCTCPSocketCocoa>(identifier, rtcProvider, remoteAddress, tcpOptions, isRelayDisabled, WTFMove(connection));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline void processIncomingData(RetainPtr<nw_connection_t>&& nwConnection, Function<Vector<uint8_t>(Vector<uint8_t>&&)>&& processData, Vector<uint8_t>&& buffer = { })
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">     }).get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa(LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& remoteAddress, int options, Ref<IPC::Connection>&& connection)
</del><ins>+NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa(LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& remoteAddress, int options, bool isRelayDisabled, Ref<IPC::Connection>&& connection)
</ins><span class="cx">     : m_identifier(identifier)
</span><span class="cx">     , m_rtcProvider(rtcProvider)
</span><span class="cx">     , m_connection(WTFMove(connection))
</span><span class="lines">@@ -98,6 +98,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (auto token = rtcProvider.sourceApplicationAuditToken())
</span><span class="cx">         nw_parameters_set_source_application(tcpTLS.get(), *token);
</span><ins>+    if (isRelayDisabled)
+        nw_parameters_set_account_id(tcpTLS.get(), "com.apple.safari.peertopeer");
</ins><span class="cx"> 
</span><span class="cx">     m_nwConnection = adoptNS(nw_connection_create(host.get(), tcpTLS.get()));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp      2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp 2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -90,6 +90,8 @@
</span><span class="cx"> public:
</span><span class="cx">     RTCSocketFactory(String&& userAgent, bool isFirstParty, RegistrableDomain&&);
</span><span class="cx"> 
</span><ins>+    void disableRelay() final { m_isRelayDisabled = true; }
+
</ins><span class="cx"> private:
</span><span class="cx">     // SuspendableSocketFactory
</span><span class="cx">     rtc::AsyncPacketSocket* CreateUdpSocket(const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort) final;
</span><span class="lines">@@ -98,7 +100,6 @@
</span><span class="cx">     rtc::AsyncResolverInterface* CreateAsyncResolver() final;
</span><span class="cx">     void suspend() final;
</span><span class="cx">     void resume() final;
</span><del>-    void disableRelay() final { m_isRelayDisabled = true; }
</del><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     String m_userAgent;
</span><span class="lines">@@ -126,7 +127,7 @@
</span><span class="cx"> 
</span><span class="cx"> rtc::AsyncPacketSocket* RTCSocketFactory::CreateClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, const rtc::ProxyInfo&, const std::string&, const rtc::PacketSocketTcpOptions& options)
</span><span class="cx"> {
</span><del>-    return WebProcess::singleton().libWebRTCNetwork().socketFactory().createClientTcpSocket(this, localAddress, remoteAddress, String { m_userAgent }, options);
</del><ins>+    return WebProcess::singleton().libWebRTCNetwork().socketFactory().createClientTcpSocket(this, localAddress, remoteAddress, String { m_userAgent }, options, m_isRelayDisabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> rtc::AsyncResolverInterface* RTCSocketFactory::CreateAsyncResolver()
</span><span class="lines">@@ -159,7 +160,13 @@
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr<LibWebRTCProvider::SuspendableSocketFactory> LibWebRTCProvider::createSocketFactory(String&& userAgent, bool isFirstParty, RegistrableDomain&& domain)
</span><span class="cx"> {
</span><del>-    return makeUnique<RTCSocketFactory>(WTFMove(userAgent), isFirstParty, WTFMove(domain));
</del><ins>+    auto factory = makeUnique<RTCSocketFactory>(WTFMove(userAgent), isFirstParty, WTFMove(domain));
+
+    auto* page = m_webPage.corePage();
+    if (!page || !page->settings().webRTCSocketsProxyingEnabled())
+        factory->disableRelay();
+
+    return factory;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr<RTCDataChannelRemoteHandlerConnection> LibWebRTCProvider::createRTCDataChannelRemoteHandlerConnection()
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.h (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.h        2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.h   2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -63,16 +63,14 @@
</span><span class="cx">     RefPtr<WebCore::RTCDataChannelRemoteHandlerConnection> createRTCDataChannelRemoteHandlerConnection() final;
</span><span class="cx">     void setLoggingLevel(WTFLogLevel) final;
</span><span class="cx"> 
</span><ins>+    WebPage& m_webPage;
</ins><span class="cx"> #if ENABLE(GPU_PROCESS) && PLATFORM(COCOA) && !PLATFORM(MACCATALYST)
</span><del>-    WebPage& m_webPage;
</del><span class="cx">     bool m_didInitializeCallback { false };
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline LibWebRTCProvider::LibWebRTCProvider(WebPage& webPage)
</span><del>-#if ENABLE(GPU_PROCESS) && PLATFORM(COCOA) && !PLATFORM(MACCATALYST)
</del><span class="cx">     : m_webPage(webPage)
</span><del>-#endif
</del><span class="cx"> {
</span><span class="cx">     m_useNetworkThreadWithSocketServer = false;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCSocketFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp 2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp    2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx">     return socket.release();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-rtc::AsyncPacketSocket* LibWebRTCSocketFactory::createClientTcpSocket(const void* socketGroup, const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, const rtc::PacketSocketTcpOptions& options)
</del><ins>+rtc::AsyncPacketSocket* LibWebRTCSocketFactory::createClientTcpSocket(const void* socketGroup, const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, const rtc::PacketSocketTcpOptions& options, bool isRelayDisabled)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!WTF::isMainRunLoop());
</span><span class="cx"> 
</span><span class="lines">@@ -113,13 +113,13 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: We only transfer options.opts but should also handle other members.
</span><span class="cx">     if (m_connection)
</span><del>-        m_connection->send(Messages::NetworkRTCProvider::CreateClientTCPSocket(socket->identifier(), RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, options.opts), 0);
</del><ins>+        m_connection->send(Messages::NetworkRTCProvider::CreateClientTCPSocket(socket->identifier(), RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, options.opts,  isRelayDisabled), 0);
</ins><span class="cx">     else {
</span><span class="cx">         callOnMainRunLoop([] {
</span><span class="cx">             WebProcess::singleton().ensureNetworkProcessConnection();
</span><span class="cx">         });
</span><del>-        m_pendingMessageTasks.append([identifier = socket->identifier(), localAddress = RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), remoteAddress = RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, opts = options.opts](auto& connection) {
-            connection.send(Messages::NetworkRTCProvider::CreateClientTCPSocket(identifier, localAddress, remoteAddress, userAgent, opts), 0);
</del><ins>+        m_pendingMessageTasks.append([identifier = socket->identifier(), localAddress = RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), remoteAddress = RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, opts = options.opts, isRelayDisabled](auto& connection) {
+            connection.send(Messages::NetworkRTCProvider::CreateClientTCPSocket(identifier, localAddress, remoteAddress, userAgent, opts, isRelayDisabled), 0);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkwebrtcLibWebRTCSocketFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h (280522 => 280523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h   2021-08-01 14:10:39 UTC (rev 280522)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h      2021-08-01 16:02:21 UTC (rev 280523)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx">     void forSocketInGroup(const void* socketGroup, const Function<void(LibWebRTCSocket&)>&);
</span><span class="cx">     rtc::AsyncPacketSocket* createUdpSocket(const void* socketGroup, const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort, bool isFirstParty, bool isRelayDisabled, const WebCore::RegistrableDomain&);
</span><span class="cx">     rtc::AsyncPacketSocket* createServerTcpSocket(const void* socketGroup, const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort, int options);
</span><del>-    rtc::AsyncPacketSocket* createClientTcpSocket(const void* socketGroup, const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, const rtc::PacketSocketTcpOptions&);
</del><ins>+    rtc::AsyncPacketSocket* createClientTcpSocket(const void* socketGroup, const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, const rtc::PacketSocketTcpOptions&, bool isRelayDisabled);
</ins><span class="cx">     rtc::AsyncPacketSocket* createNewConnectionSocket(LibWebRTCSocket&, WebCore::LibWebRTCSocketIdentifier newConnectionSocketIdentifier, const rtc::SocketAddress&);
</span><span class="cx"> 
</span><span class="cx">     LibWebRTCResolver* resolver(LibWebRTCResolverIdentifier identifier) { return m_resolvers.get(identifier); }
</span></span></pre>
</div>
</div>

</body>
</html>