WebRTC data channel only applications require capture permissions for direct connections
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2018 02:05:01 +0000 (02:05 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2018 02:05:01 +0000 (02:05 +0000)
commitd28ba75243e861ed3d252c0b133f58b2fff05fba
tree6ed15fa01318e8b4c0747a15aca141a103ab6f41
parent097adc8ada68a16b3c51c7af4109b03a7d9c770b
WebRTC data channel only applications require capture permissions for direct connections
https://bugs.webkit.org/show_bug.cgi?id=174500
<rdar://problem/34134281>

Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/datachannel/mdns-ice-candidates.html

Add support at PeerConnectionBackend to obfuscate any gathered host candidate
by replacing the IP address with an opaque name that can be resolved by MDNS.
An opaque name is generated for each IP address and is scoped by the document owning the peer connection object.

Add support to resolve any such MDNS ICE candidate.
A limit of 250 ms is fixed for the resolution to happen.
After 250 ms, the candidate is discarded.

Add an experimental flag around this feature, off by default.

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::extractIPAddres):
(WebCore::PeerConnectionBackend::addIceCandidate):
(WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
(WebCore::PeerConnectionBackend::addIceCandidateFailed):
(WebCore::PeerConnectionBackend::newICECandidate):
(WebCore::PeerConnectionBackend::doneGatheringCandidates):
(WebCore::PeerConnectionBackend::registerMDNSName):
(WebCore::PeerConnectionBackend::finishedRegisteringMDNSName):
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCIceCandidate.h:
(WebCore::RTCIceCandidate::setCandidate):
* Modules/mediastream/RTCPeerConnection.h:
* dom/Document.cpp:
(WebCore::Document::prepareForDestruction):
(WebCore::Document::suspend):
* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::mdnsICECandidatesEnabled const):
(WebCore::RuntimeEnabledFeatures::setMDNSICECandidatesEnabled):
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:

Source/WebKit:

Add support for MDNS registration and resolution by NetworkProcess.
WebProcess gives instruction to do the actual registrations/resolutions.

* CMakeLists.txt:
* DerivedSources.make:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess):
(WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
* NetworkProcess/NetworkConnectionToWebProcess.h:
(WebKit::NetworkConnectionToWebProcess::mdnsRegister):
* NetworkProcess/webrtc/NetworkMDNSRegister.cpp: Added.
(WebKit::NetworkMDNSRegister::NetworkMDNSRegister):
(WebKit::NetworkMDNSRegister::~NetworkMDNSRegister):
(WebKit::NetworkMDNSRegister::unregisterMDNSNames):
(WebKit::PendingRegistrationRequest::PendingRegistrationRequest):
(WebKit::registerMDNSNameCallback):
(WebKit::NetworkMDNSRegister::registerMDNSName):
(WebKit::PendingResolutionRequest::PendingResolutionRequest):
(WebKit::PendingResolutionRequest::~PendingResolutionRequest):
(WebKit::PendingResolutionRequest::timeout):
(WebKit::resolveMDNSNameCallback):
(WebKit::NetworkMDNSRegister::resolveMDNSName):
* NetworkProcess/webrtc/NetworkMDNSRegister.h: Added.
* NetworkProcess/webrtc/NetworkMDNSRegister.messages.in: Added.
* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetWebRTCMDNSICECandidatesEnabled):
(WKPreferencesGetWebRTCMDNSICECandidatesEnabled):
* UIProcess/API/C/WKPreferencesRef.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didReceiveMessage):
* WebProcess/Network/webrtc/LibWebRTCNetwork.h:
(WebKit::LibWebRTCNetwork::mdnsRegister):
* WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
(WebKit::LibWebRTCProvider::unregisterMDNSNames):
(WebKit::LibWebRTCProvider::registerMDNSName):
(WebKit::LibWebRTCProvider::resolveMDNSName):
* WebProcess/Network/webrtc/LibWebRTCProvider.h:
* WebProcess/Network/webrtc/WebMDNSRegister.cpp: Added.
(WebKit::WebMDNSRegister::finishedRegisteringMDNSName):
(WebKit::WebMDNSRegister::finishedResolvingMDNSName):
(WebKit::WebMDNSRegister::unregisterMDNSNames):
(WebKit::WebMDNSRegister::registerMDNSName):
(WebKit::WebMDNSRegister::resolveMDNSName):
* WebProcess/Network/webrtc/WebMDNSRegister.h: Added.
* WebProcess/Network/webrtc/WebMDNSRegister.messages.in: Added.

Tools:

Adding options to enable MDNS ICE candidates.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMediaDevicesEnabled):
(WTR::TestRunner::setMDNSICECandidatesEnabled):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

* webrtc/datachannel/mdns-ice-candidates-expected.txt: Added.
* webrtc/datachannel/mdns-ice-candidates.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/webrtc/datachannel/mdns-ice-candidates-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/datachannel/mdns-ice-candidates.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCIceCandidate.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/dom/Document.cpp
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp [new file with mode: 0644]
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.messages.in [new file with mode: 0644]
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRef.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.h
Source/WebKit/WebProcess/Network/webrtc/WebMDNSRegister.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/Network/webrtc/WebMDNSRegister.h [new file with mode: 0644]
Source/WebKit/WebProcess/Network/webrtc/WebMDNSRegister.messages.in [new file with mode: 0644]
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp