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 <steveanton@webrtc.org>
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24168}
This commit is contained in:
Qingsi Wang
2018-08-01 11:38:49 -07:00
committed by Commit Bot
parent d3b7ec2e91
commit f5cf02ac2c
3 changed files with 9 additions and 9 deletions

View File

@ -2349,8 +2349,7 @@ void P2PTransportChannel::LogCandidatePairConfig(
if (conn == nullptr) { if (conn == nullptr) {
return; return;
} }
auto candidate_pair_id = conn->hash(); ice_event_log_.LogCandidatePairConfig(type, conn->id(),
ice_event_log_.LogCandidatePairConfig(type, candidate_pair_id,
conn->ToLogDescription()); conn->ToLogDescription());
} }

View File

@ -1043,7 +1043,8 @@ class ConnectionRequest : public StunRequest {
Connection::Connection(Port* port, Connection::Connection(Port* port,
size_t index, size_t index,
const Candidate& remote_candidate) const Candidate& remote_candidate)
: port_(port), : id_(rtc::CreateRandomId()),
port_(port),
local_candidate_index_(index), local_candidate_index_(index),
remote_candidate_(remote_candidate), remote_candidate_(remote_candidate),
recv_rate_tracker_(100, 10u), recv_rate_tracker_(100, 10u),
@ -1068,7 +1069,6 @@ Connection::Connection(Port* port,
// TODO(mallinath) - Start connections from STATE_FROZEN. // TODO(mallinath) - Start connections from STATE_FROZEN.
// Wire up to send stun packets // Wire up to send stun packets
requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket);
hash_ = static_cast<uint32_t>(std::hash<std::string>{}(ToString()));
RTC_LOG(LS_INFO) << ToString() << ": Connection created"; RTC_LOG(LS_INFO) << ToString() << ": Connection created";
} }
@ -1619,14 +1619,14 @@ void Connection::LogCandidatePairConfig(
if (ice_event_log_ == nullptr) { if (ice_event_log_ == nullptr) {
return; return;
} }
ice_event_log_->LogCandidatePairConfig(type, hash(), ToLogDescription()); ice_event_log_->LogCandidatePairConfig(type, id(), ToLogDescription());
} }
void Connection::LogCandidatePairEvent(webrtc::IceCandidatePairEventType type) { void Connection::LogCandidatePairEvent(webrtc::IceCandidatePairEventType type) {
if (ice_event_log_ == nullptr) { if (ice_event_log_ == nullptr) {
return; return;
} }
ice_event_log_->LogCandidatePairEvent(type, hash()); ice_event_log_->LogCandidatePairEvent(type, id());
} }
void Connection::OnConnectionRequestResponse(ConnectionRequest* request, void Connection::OnConnectionRequestResponse(ConnectionRequest* request,

View File

@ -508,6 +508,9 @@ class Connection : public CandidatePairInterface,
~Connection() override; ~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. // The local port where this connection sends and receives packets.
Port* port() { return port_; } Port* port() { return port_; }
const Port* port() const { return port_; } const Port* port() const { return port_; }
@ -660,8 +663,6 @@ class Connection : public CandidatePairInterface,
std::string ToSensitiveString() const; std::string ToSensitiveString() const;
// Structured description of this candidate pair. // Structured description of this candidate pair.
const webrtc::IceCandidatePairDescription& ToLogDescription(); 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) { void set_ice_event_log(webrtc::IceEventLog* ice_event_log) {
ice_event_log_ = ice_event_log; ice_event_log_ = ice_event_log;
} }
@ -745,6 +746,7 @@ class Connection : public CandidatePairInterface,
void OnMessage(rtc::Message* pmsg) override; void OnMessage(rtc::Message* pmsg) override;
uint32_t id_;
Port* port_; Port* port_;
size_t local_candidate_index_; size_t local_candidate_index_;
Candidate remote_candidate_; Candidate remote_candidate_;
@ -814,7 +816,6 @@ class Connection : public CandidatePairInterface,
int num_pings_sent_ = 0; int num_pings_sent_ = 0;
absl::optional<webrtc::IceCandidatePairDescription> log_description_; absl::optional<webrtc::IceCandidatePairDescription> log_description_;
uint32_t hash_;
webrtc::IceEventLog* ice_event_log_ = nullptr; webrtc::IceEventLog* ice_event_log_ = nullptr;
friend class Port; friend class Port;