From f5cf02ac2c4a189894abc66840728da7f2684691 Mon Sep 17 00:00:00 2001 From: Qingsi Wang Date: Wed, 1 Aug 2018 11:38:49 -0700 Subject: [PATCH] Use randomly generated IDs for candidate pairs in ICE event logs. We used to use an integer-valued hash as the candidate pair ID in ICE event logs, and the preimage of this hash contains address information. Bug: None Change-Id: Ib24aa89164600c62e0b0a7d771af379ace80a0e3 Reviewed-on: https://webrtc-review.googlesource.com/91920 Reviewed-by: Steve Anton Reviewed-by: Qingsi Wang Commit-Queue: Qingsi Wang Cr-Commit-Position: refs/heads/master@{#24168} --- p2p/base/p2ptransportchannel.cc | 3 +-- p2p/base/port.cc | 8 ++++---- p2p/base/port.h | 7 ++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc index 3ebe2e5c1f..11cf412b2b 100644 --- a/p2p/base/p2ptransportchannel.cc +++ b/p2p/base/p2ptransportchannel.cc @@ -2349,8 +2349,7 @@ void P2PTransportChannel::LogCandidatePairConfig( if (conn == nullptr) { return; } - auto candidate_pair_id = conn->hash(); - ice_event_log_.LogCandidatePairConfig(type, candidate_pair_id, + ice_event_log_.LogCandidatePairConfig(type, conn->id(), conn->ToLogDescription()); } diff --git a/p2p/base/port.cc b/p2p/base/port.cc index 9ec9dee390..81d59ba7f2 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -1043,7 +1043,8 @@ class ConnectionRequest : public StunRequest { Connection::Connection(Port* port, size_t index, const Candidate& remote_candidate) - : port_(port), + : id_(rtc::CreateRandomId()), + port_(port), local_candidate_index_(index), remote_candidate_(remote_candidate), recv_rate_tracker_(100, 10u), @@ -1068,7 +1069,6 @@ Connection::Connection(Port* port, // TODO(mallinath) - Start connections from STATE_FROZEN. // Wire up to send stun packets requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); - hash_ = static_cast(std::hash{}(ToString())); RTC_LOG(LS_INFO) << ToString() << ": Connection created"; } @@ -1619,14 +1619,14 @@ void Connection::LogCandidatePairConfig( if (ice_event_log_ == nullptr) { return; } - ice_event_log_->LogCandidatePairConfig(type, hash(), ToLogDescription()); + ice_event_log_->LogCandidatePairConfig(type, id(), ToLogDescription()); } void Connection::LogCandidatePairEvent(webrtc::IceCandidatePairEventType type) { if (ice_event_log_ == nullptr) { return; } - ice_event_log_->LogCandidatePairEvent(type, hash()); + ice_event_log_->LogCandidatePairEvent(type, id()); } void Connection::OnConnectionRequestResponse(ConnectionRequest* request, diff --git a/p2p/base/port.h b/p2p/base/port.h index 28c494c609..d881fb8eaf 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -508,6 +508,9 @@ class Connection : public CandidatePairInterface, ~Connection() override; + // A unique ID assigned when the connection is created. + uint32_t id() { return id_; } + // The local port where this connection sends and receives packets. Port* port() { return port_; } const Port* port() const { return port_; } @@ -660,8 +663,6 @@ class Connection : public CandidatePairInterface, std::string ToSensitiveString() const; // Structured description of this candidate pair. const webrtc::IceCandidatePairDescription& ToLogDescription(); - // Integer typed hash value of this candidate pair. - uint32_t hash() { return hash_; } void set_ice_event_log(webrtc::IceEventLog* ice_event_log) { ice_event_log_ = ice_event_log; } @@ -745,6 +746,7 @@ class Connection : public CandidatePairInterface, void OnMessage(rtc::Message* pmsg) override; + uint32_t id_; Port* port_; size_t local_candidate_index_; Candidate remote_candidate_; @@ -814,7 +816,6 @@ class Connection : public CandidatePairInterface, int num_pings_sent_ = 0; absl::optional log_description_; - uint32_t hash_; webrtc::IceEventLog* ice_event_log_ = nullptr; friend class Port;