Skip to content

Commit 95664cf

Browse files
committed
[WebRTC] Allow stuns server URIs
https://bugs.webkit.org/show_bug.cgi?id=279976 Reviewed by Youenn Fablet. According to RFC 7064: > The "stuns" URI scheme is intended to be used by applications with > a need to identify a STUN server to be used for NAT traversal over > a secure connection. LibWebRTC accepts this kind of URL but doesn't seem to make a difference when connecting, as compared to stun URIs. Based on patch from Mikolaj Staworzynski <mikolaj.staworzynski@redembedded.com> * LayoutTests/webrtc/stun-server-filtering.html: * Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::iceServersFromConfiguration): Canonical link: https://commits.webkit.org/284082@main
1 parent 8b1be3f commit 95664cf

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

LayoutTests/webrtc/stun-server-filtering.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
<script src='../resources/testharnessreport.js'></script>
44
<script>
55
promise_test(async (test) => {
6-
let pc = new RTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'stun:blabla.local']}]});
6+
let pc = new RTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'stun:blabla.local', 'stuns:bar.com']}]});
77
let promise = new Promise(resolve => pc.onicecandidateerror = resolve);
88
let configuration = pc.getConfiguration();
99

10-
assert_equals(configuration.iceServers[0].urls.length, 1);
10+
assert_equals(configuration.iceServers[0].urls.length, 2);
1111
assert_equals(configuration.iceServers[0].urls[0], 'stun:foo.com');
12+
assert_equals(configuration.iceServers[0].urls[1], 'stuns:bar.com');
1213

1314
const event = await promise;
1415
assert_equals(event.url, 'stun:blabla.local');

Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> RTCPeerConnection
495495
if (server.credential.utf8().length() > MaxTurnUsernameLength || server.username.utf8().length() > MaxTurnUsernameLength)
496496
return Exception { TypeError, "TURN/TURNS username and/or credential are too long"_s };
497497
}
498-
} else if (!serverURL.protocolIs("stun"_s))
498+
} else if (!serverURL.protocolIs("stun"_s) && !serverURL.protocolIs("stuns"_s))
499499
return Exception { NotSupportedError, "ICE server protocol not supported"_s };
500500
}
501501
if (serverURLs.size())

0 commit comments

Comments
 (0)