From 6f22eb55b30e4ae7d6cf0527c196e74a761efe28 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Thu, 14 Jul 2022 11:38:44 +0200 Subject: [PATCH] peerconnection: measure invalid ice-chars in remote description in order to deprecate the non-spec usage BUG=chromium:1053756 Change-Id: I2588aba64a6e7ff05b39c5505504579a5f58a75f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268380 Reviewed-by: Florent Castelli Commit-Queue: Florent Castelli Cr-Commit-Position: refs/heads/main@{#37522} --- pc/peer_connection.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index fe6e863efd..367341bbb3 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -1996,6 +1996,26 @@ void PeerConnection::ReportFirstConnectUsageMetrics() { // Record the number of configured ICE servers for connected connections. RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.PeerConnection.IceServers.Connected", configuration_.servers.size(), 0, 31, 32); + + // Record the number of valid / invalid ice-ufrag. We do allow certain + // non-spec ice-char for backward-compat reasons. At this point we know + // that the ufrag/pwd consists of a valid ice-char or one of the four + // not allowed characters since we have passed the IsIceChar check done + // by the p2p transport description on setRemoteDescription calls. + auto transport_infos = remote_description()->description()->transport_infos(); + if (transport_infos.size() > 0) { + auto ice_parameters = transport_infos[0].description.GetIceParameters(); + auto is_invalid_char = [](char c) { + return c == '-' || c == '=' || c == '#' || c == '_'; + }; + bool isUsingInvalidIceCharInUfrag = + absl::c_any_of(ice_parameters.ufrag, is_invalid_char); + bool isUsingInvalidIceCharInPwd = + absl::c_any_of(ice_parameters.pwd, is_invalid_char); + RTC_HISTOGRAM_BOOLEAN( + "WebRTC.PeerConnection.ValidIceChars", + !(isUsingInvalidIceCharInUfrag || isUsingInvalidIceCharInPwd)); + } } void PeerConnection::OnIceGatheringChange(