Diff
Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 04:29:08 UTC (rev 282910)
@@ -1,5 +1,74 @@
2021-09-22 Alan Coon <alanc...@apple.com>
+ Cherry-pick r281982. rdar://problem/83430119
+
+ Enable WebRTC relay for SafariViewController
+ https://bugs.webkit.org/show_bug.cgi?id=229768
+
+ Reviewed by Eric Carlson.
+
+ Use source application bundle identifier instead of attributed bundle identifier for nw_parameters_set_source_application_by_bundle_id.
+ Use attributed bundle identifier for nw_parameters_set_attributed_bundle_identifier.
+ Make sure to not set token data in case application bundle identifier is available.
+ This allows the OS to decide whether to relay the nw_connections or not.
+
+ Introduce a helper routine to share more code between UDP and TCP sockets.
+
+ Manually tested as testing relay would require non-localhost connections
+ and an application bundle identifier that would be known by the OS.
+
+ * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
+ (WebKit::NetworkRTCProvider::NetworkRTCProvider):
+ * NetworkProcess/webrtc/NetworkRTCProvider.h:
+ (WebKit::NetworkRTCProvider::applicationBundleIdentifier const):
+ * NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
+ (WebKit::NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa):
+ * NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:
+ (WebKit::NetworkRTCUDPSocketCocoaConnections::NetworkRTCUDPSocketCocoaConnections):
+ (WebKit::NetworkRTCUDPSocketCocoaConnections::configureParameters):
+ * NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.h: Added.
+ * NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.mm: Added.
+ (WebKit::setNWParametersApplicationIdentifiers):
+ * Platform/spi/Cocoa/NWParametersSPI.h:
+ * WebKit.xcodeproj/project.pbxproj:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-03 Youenn Fablet <you...@apple.com>
+
+ Enable WebRTC relay for SafariViewController
+ https://bugs.webkit.org/show_bug.cgi?id=229768
+
+ Reviewed by Eric Carlson.
+
+ Use source application bundle identifier instead of attributed bundle identifier for nw_parameters_set_source_application_by_bundle_id.
+ Use attributed bundle identifier for nw_parameters_set_attributed_bundle_identifier.
+ Make sure to not set token data in case application bundle identifier is available.
+ This allows the OS to decide whether to relay the nw_connections or not.
+
+ Introduce a helper routine to share more code between UDP and TCP sockets.
+
+ Manually tested as testing relay would require non-localhost connections
+ and an application bundle identifier that would be known by the OS.
+
+ * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
+ (WebKit::NetworkRTCProvider::NetworkRTCProvider):
+ * NetworkProcess/webrtc/NetworkRTCProvider.h:
+ (WebKit::NetworkRTCProvider::applicationBundleIdentifier const):
+ * NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
+ (WebKit::NetworkRTCTCPSocketCocoa::NetworkRTCTCPSocketCocoa):
+ * NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:
+ (WebKit::NetworkRTCUDPSocketCocoaConnections::NetworkRTCUDPSocketCocoaConnections):
+ (WebKit::NetworkRTCUDPSocketCocoaConnections::configureParameters):
+ * NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.h: Added.
+ * NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.mm: Added.
+ (WebKit::setNWParametersApplicationIdentifiers):
+ * Platform/spi/Cocoa/NWParametersSPI.h:
+ * WebKit.xcodeproj/project.pbxproj:
+
+2021-09-22 Alan Coon <alanc...@apple.com>
+
Cherry-pick r281960. rdar://problem/83429573
[iOS] Gather logs for IOKit class
Modified: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp 2021-09-23 04:29:08 UTC (rev 282910)
@@ -49,6 +49,7 @@
#include "NetworkRTCResolverCocoa.h"
#include "NetworkRTCTCPSocketCocoa.h"
#include "NetworkRTCUDPSocketCocoa.h"
+#include "NetworkSessionCocoa.h"
#endif
namespace WebKit {
@@ -91,6 +92,10 @@
, m_sourceApplicationAuditToken(connection.networkProcess().sourceApplicationAuditToken())
#endif
{
+#if PLATFORM(COCOA)
+ if (auto* session = static_cast<NetworkSessionCocoa*>(connection.networkSession()))
+ m_applicationBundleIdentifier = session->sourceApplicationBundleIdentifier().utf8();
+#endif
#if !RELEASE_LOG_DISABLED
rtc::LogMessage::SetLogOutput(WebKit2LogWebRTC.state == WTFLogChannelState::On ? rtc::LS_INFO : rtc::LS_WARNING, doReleaseLogging);
#endif
Modified: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h 2021-09-23 04:29:08 UTC (rev 282910)
@@ -108,6 +108,7 @@
#if PLATFORM(COCOA)
const std::optional<audit_token_t>& sourceApplicationAuditToken() const { return m_sourceApplicationAuditToken; }
+ const char* applicationBundleIdentifier() const { return m_applicationBundleIdentifier.data(); }
#endif
private:
@@ -160,6 +161,7 @@
#if PLATFORM(COCOA)
HashMap<WebPageProxyIdentifier, String> m_attributedBundleIdentifiers;
std::optional<audit_token_t> m_sourceApplicationAuditToken;
+ CString m_applicationBundleIdentifier;
#endif
};
Modified: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm 2021-09-23 04:29:08 UTC (rev 282910)
@@ -32,6 +32,7 @@
#include "LibWebRTCNetworkMessages.h"
#include "Logging.h"
#include "NWParametersSPI.h"
+#include "NetworkRTCUtilitiesCocoa.h"
#include <WebCore/STUNMessageParsing.h>
#include <dispatch/dispatch.h>
#include <wtf/BlockPtr.h>
@@ -96,10 +97,8 @@
nw_tcp_options_set_no_delay(tcp_options, true);
}));
- if (auto token = rtcProvider.sourceApplicationAuditToken())
- nw_parameters_set_source_application(tcpTLS.get(), *token);
- if (!attributedBundleIdentifier.isEmpty())
- nw_parameters_set_source_application_by_bundle_id(tcpTLS.get(), attributedBundleIdentifier.utf8().data());
+ setNWParametersApplicationIdentifiers(tcpTLS.get(), rtcProvider.applicationBundleIdentifier(), rtcProvider.sourceApplicationAuditToken(), attributedBundleIdentifier);
+
if (isRelayDisabled)
nw_parameters_set_account_id(tcpTLS.get(), "com.apple.safari.peertopeer");
Modified: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm 2021-09-23 04:29:08 UTC (rev 282910)
@@ -78,6 +78,7 @@
#endif
bool m_shouldBypassRelay { false };
+ CString m_sourceApplicationBundleIdentifier;
std::optional<audit_token_t> m_sourceApplicationAuditToken;
String m_attributedBundleIdentifier;
@@ -166,6 +167,7 @@
, m_isKnownTracker(isKnownTracker(domain))
#endif
, m_shouldBypassRelay(isRelayDisabled)
+ , m_sourceApplicationBundleIdentifier(rtcProvider.applicationBundleIdentifier())
, m_sourceApplicationAuditToken(rtcProvider.sourceApplicationAuditToken())
, m_attributedBundleIdentifier(WTFMove(attributedBundleIdentifier))
{
@@ -242,10 +244,7 @@
nw_parameters_set_is_known_tracker(parameters, m_isKnownTracker);
#endif
- if (m_sourceApplicationAuditToken)
- nw_parameters_set_source_application(parameters, *m_sourceApplicationAuditToken);
- if (!m_attributedBundleIdentifier.isEmpty())
- nw_parameters_set_source_application_by_bundle_id(parameters, m_attributedBundleIdentifier.utf8().data());
+ setNWParametersApplicationIdentifiers(parameters, m_sourceApplicationBundleIdentifier.data(), m_sourceApplicationAuditToken, m_attributedBundleIdentifier);
nw_parameters_set_reuse_local_address(parameters, true);
}
Copied: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.h (from rev 282909, branches/safari-612-branch/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h) (0 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.h (rev 0)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.h 2021-09-23 04:29:08 UTC (rev 282910)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(LIBWEBRTC)
+
+#include "NWParametersSPI.h"
+#include <optional>
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+void setNWParametersApplicationIdentifiers(nw_parameters_t, const char* sourceApplicationBundleIdentifier, std::optional<audit_token_t>, const String& attributedBundleIdentifier);
+
+} // namespace WebKit
+
+#endif // USE(LIBWEBRTC)
Copied: branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.mm (from rev 282909, branches/safari-612-branch/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h) (0 => 282910)
--- branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.mm (rev 0)
+++ branches/safari-612-branch/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUtilitiesCocoa.mm 2021-09-23 04:29:08 UTC (rev 282910)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetworkRTCUtilitiesCocoa.h"
+
+#if USE(LIBWEBRTC)
+
+#import <wtf/SoftLinking.h>
+#import <wtf/text/WTFString.h>
+
+#if HAVE(NWPARAMETERS_TRACKER_API)
+SOFT_LINK_LIBRARY_OPTIONAL(libnetwork)
+SOFT_LINK_OPTIONAL(libnetwork, nw_parameters_set_attributed_bundle_identifier, void, __cdecl, (nw_parameters_t, const char*))
+#endif
+
+namespace WebKit {
+
+void setNWParametersApplicationIdentifiers(nw_parameters_t parameters, const char* sourceApplicationBundleIdentifier, std::optional<audit_token_t> sourceApplicationAuditToken, const String& attributedBundleIdentifier)
+{
+ if (sourceApplicationBundleIdentifier && *sourceApplicationBundleIdentifier)
+ nw_parameters_set_source_application_by_bundle_id(parameters, sourceApplicationBundleIdentifier);
+ else if (sourceApplicationAuditToken)
+ nw_parameters_set_source_application(parameters, *sourceApplicationAuditToken);
+
+#if HAVE(NWPARAMETERS_TRACKER_API)
+ if (!attributedBundleIdentifier.isEmpty() && nw_parameters_set_attributed_bundle_identifierPtr())
+ nw_parameters_set_attributed_bundle_identifierPtr()(parameters, attributedBundleIdentifier.utf8().data());
+#endif
+}
+
+} // namespace WebKit
+
+#endif // USE(LIBWEBRTC)
Modified: branches/safari-612-branch/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h 2021-09-23 04:29:08 UTC (rev 282910)
@@ -36,6 +36,7 @@
void nw_parameters_set_account_id(nw_parameters_t, const char * account_id);
void nw_parameters_set_source_application(nw_parameters_t, audit_token_t);
void nw_parameters_set_source_application_by_bundle_id(nw_parameters_t, const char*);
+void nw_parameters_set_attributed_bundle_identifier(nw_parameters_t, const char*);
nw_endpoint_t nw_endpoint_create_host_with_numeric_port(const char* hostname, uint16_t port_host_order);
#if HAVE(NWPARAMETERS_TRACKER_API)
Modified: branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (282909 => 282910)
--- branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-09-23 04:29:04 UTC (rev 282909)
+++ branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-09-23 04:29:08 UTC (rev 282910)
@@ -951,6 +951,7 @@
41DD72AB2682167300A90C71 /* NWParametersSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DD72AA2682167300A90C71 /* NWParametersSPI.h */; };
41DE7C6C22278F1E00532B65 /* ServiceWorkerFetchTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41518536222704F6005430C6 /* ServiceWorkerFetchTask.cpp */; };
41E0A7CB23B645CD00561060 /* WebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417915AC2256BB7400D6F97E /* WebSocketChannel.cpp */; };
+ 41E242E026E0C908009A8C64 /* NetworkRTCUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41E242DF26E0C904009A8C64 /* NetworkRTCUtilitiesCocoa.mm */; };
41F060E11654318500F3281C /* WebSocketChannelMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */; };
41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; };
41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
@@ -3873,6 +3874,8 @@
41E0A7C623B6397800561060 /* LibWebRTCCodecsProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LibWebRTCCodecsProxy.h; sourceTree = "<group>"; };
41E0A7C723B6397900561060 /* LibWebRTCCodecsProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = LibWebRTCCodecsProxy.messages.in; sourceTree = "<group>"; };
41E0A7C823B6397900561060 /* LibWebRTCCodecsProxy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LibWebRTCCodecsProxy.mm; sourceTree = "<group>"; };
+ 41E242DE26E0C8D6009A8C64 /* NetworkRTCUtilitiesCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkRTCUtilitiesCocoa.h; sourceTree = "<group>"; };
+ 41E242DF26E0C904009A8C64 /* NetworkRTCUtilitiesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkRTCUtilitiesCocoa.mm; sourceTree = "<group>"; };
41E67A8C25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRealtimeAudioSource.h; sourceTree = "<group>"; };
41E67A8D25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRealtimeAudioSource.cpp; sourceTree = "<group>"; };
41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketChannelMessageReceiver.cpp; path = DerivedSources/WebKit2/WebSocketChannelMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -8493,6 +8496,8 @@
410BA139257135F2002E2F8A /* NetworkRTCTCPSocketCocoa.mm */,
41DD72A7267B8C3100A90C71 /* NetworkRTCUDPSocketCocoa.h */,
41DD72A6267B8C3000A90C71 /* NetworkRTCUDPSocketCocoa.mm */,
+ 41E242DE26E0C8D6009A8C64 /* NetworkRTCUtilitiesCocoa.h */,
+ 41E242DF26E0C904009A8C64 /* NetworkRTCUtilitiesCocoa.mm */,
411223BC26024E8100B0A0B6 /* RTCDataChannelRemoteManagerProxy.cpp */,
411223BB26024E8000B0A0B6 /* RTCDataChannelRemoteManagerProxy.h */,
411223BD26024E8100B0A0B6 /* RTCDataChannelRemoteManagerProxy.messages.in */,
@@ -14253,6 +14258,7 @@
51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */,
4176901422FDD41B00B1576D /* NetworkRTCProvider.mm in Sources */,
51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */,
+ 41E242E026E0C908009A8C64 /* NetworkRTCUtilitiesCocoa.mm in Sources */,
31F060E11654318500F3281C /* NetworkSocketChannelMessageReceiver.cpp in Sources */,
5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */,
2D92A790212B6AD400F493FD /* NPIdentifierData.cpp in Sources */,