From 77ceeb0fdccf4b3be12def47908b8bc9af1dc9e9 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 6 Apr 2021 10:21:31 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 367032687 --- cpp/core/internal/base_endpoint_channel.cc | 5 +++++ cpp/core/internal/mediums/webrtc.cc | 3 +++ cpp/core/internal/mediums/webrtc/connection_flow.cc | 2 ++ cpp/core/internal/mediums/webrtc/webrtc_socket.cc | 1 + 4 files changed, 11 insertions(+) diff --git a/cpp/core/internal/base_endpoint_channel.cc b/cpp/core/internal/base_endpoint_channel.cc index 7e64d35c..b09edd3e 100644 --- a/cpp/core/internal/base_endpoint_channel.cc +++ b/cpp/core/internal/base_endpoint_channel.cc @@ -139,6 +139,9 @@ ExceptionOr BaseEndpointChannel::Read() { auto parsed = parser::FromBytes(ByteArray(input)); if (parsed.ok() && parser::GetFrameType(parsed.result()) == V1Frame::KEEP_ALIVE) { + NEARBY_LOGS(INFO) + << __func__ + << ": Read unencrypted KEEP_ALIVE on encrypted channel."; result = ByteArray(input); } } @@ -247,6 +250,8 @@ void BaseEndpointChannel::CloseIo() { void BaseEndpointChannel::Close( proto::connections::DisconnectionReason reason) { + NEARBY_LOGS(INFO) << __func__ + << ": Closing endpoint channel, reason: " << reason; Close(); } diff --git a/cpp/core/internal/mediums/webrtc.cc b/cpp/core/internal/mediums/webrtc.cc index 1c839415..78416c62 100644 --- a/cpp/core/internal/mediums/webrtc.cc +++ b/cpp/core/internal/mediums/webrtc.cc @@ -721,6 +721,9 @@ void WebRtc::ProcessDataChannelBufferAmountChanged( void WebRtc::ProcessDataChannelClosed(const PeerId& remote_peer_id) { MutexLock lock(&mutex_); + NEARBY_LOG(INFO, + "Data channel has closed, removing connection flow for peer %s.", + remote_peer_id.GetId().c_str()); const auto& entry = sockets_.find(remote_peer_id.GetId()); if (entry == sockets_.end()) { return; diff --git a/cpp/core/internal/mediums/webrtc/connection_flow.cc b/cpp/core/internal/mediums/webrtc/connection_flow.cc index 9230994b..6a7cdfec 100644 --- a/cpp/core/internal/mediums/webrtc/connection_flow.cc +++ b/cpp/core/internal/mediums/webrtc/connection_flow.cc @@ -366,6 +366,8 @@ void ConnectionFlow::OnConnectionChange( // is closing right now - PeerConnection::Close() triggered // PeerConnectionObserver::OnConnectionChange(kClosed). // We must not call PeerConnection::Close() again on that code path + NEARBY_LOG(INFO, "Closing due to peer connection state change: %d", + new_state); Close(new_state != PeerConnectionState::kClosed); } } diff --git a/cpp/core/internal/mediums/webrtc/webrtc_socket.cc b/cpp/core/internal/mediums/webrtc/webrtc_socket.cc index 1d030929..e2d5ab7f 100644 --- a/cpp/core/internal/mediums/webrtc/webrtc_socket.cc +++ b/cpp/core/internal/mediums/webrtc/webrtc_socket.cc @@ -37,6 +37,7 @@ Exception WebRtcSocket::OutputStreamImpl::Write(const ByteArray& data) { } if (!socket_->SendMessage(data)) { + NEARBY_LOG(INFO, "Unable to write data to socket."); return {Exception::kIo}; } return {Exception::kSuccess};