[fix] restrict sensitive information in release logs

This commit is contained in:
dijunkun
2026-11-11 02:13:59 +08:00
parent 67afb25c75
commit 6a8e79d4a9
19 changed files with 87 additions and 91 deletions
@@ -2335,7 +2335,7 @@ void GuiApplication::BindStreamCallbacks() {
std::lock_guard lock(props->privacy_status_mutex_);
props->privacy_command_pending_ = false;
if (!relock) props->privacy_status_received_ = false;
LOG_WARN("Privacy command send failed, remote_id={}", props->remote_id_);
LOG_WARN("Privacy command send failed");
}
};
stream->on_toggle_privacy([send_privacy] { send_privacy(false); });
@@ -2981,16 +2981,15 @@ void GuiApplication::ShareLocalCursorState() {
const int result = SendControllerData(recipient.remote_id, message.c_str(),
message.size(), mouse_label_.c_str());
if (result != 0) {
LOG_WARN("Send cursor state to [{}] failed, ret={}",
recipient.remote_id, result);
LOG_WARN("Send cursor state failed, ret={}", result);
continue;
}
if (!delivery.has_sent ||
delivery.last_sent.render_mode != outgoing.render_mode ||
delivery.last_sent.hidden_reason != outgoing.hidden_reason) {
LOG_INFO("Send cursor presentation to [{}]: mode={}, reason={}",
recipient.remote_id, static_cast<int>(outgoing.render_mode),
LOG_INFO("Send cursor presentation: mode={}, reason={}",
static_cast<int>(outgoing.render_mode),
static_cast<int>(outgoing.hidden_reason));
}
delivery.last_sent = outgoing;
@@ -3143,10 +3142,9 @@ void GuiApplication::HandlePasswordChangeResult() {
uncertain ? "console_password_uncertain" : "console_password_rejected");
#endif
if (uncertain) {
LOG_WARN("Password change outcome is unknown: {}; re-authenticating",
error);
LOG_WARN("Password change outcome is unknown; re-authenticating");
} else {
LOG_WARN("Password change failed: {}", error);
LOG_WARN("Password change failed");
if (!settings_.ClearPendingPasswordChange()) {
LOG_WARN("Could not clear rejected pending password change");
}
@@ -3168,7 +3166,7 @@ void GuiApplication::HandlePasswordChangeResult() {
LOG_WARN("Password changed on server; pending recovery record retained");
}
LOG_INFO("Password changed successfully for [{}]", client_id_);
LOG_INFO("Password changed successfully");
#if defined(__linux__) && !defined(__OHOS__)
HeadlessConsole::Instance().NotifyKey("console_password_confirmed");
#endif
@@ -362,8 +362,7 @@ void ClipboardController::SendDeferredLocalText() {
session->peer_, last_text_.data(), last_text_.size(),
session->clipboard_label_.c_str());
if (ret != 0) {
LOG_WARN("Failed to send deferred clipboard data to peer [{}], ret={}",
session->remote_id_, ret);
LOG_WARN("Failed to send deferred clipboard data, ret={}", ret);
return;
}
deferred_local_session_.reset();
@@ -390,8 +389,7 @@ int ClipboardController::SendToPeers(const std::string &text) {
MiniRtcSendReliableDataFrame(props->peer_, text.data(), text.size(),
props->clipboard_label_.c_str());
if (ret != 0) {
LOG_WARN("Failed to send clipboard data to peer [{}], ret={}",
remote_id.c_str(), ret);
LOG_WARN("Failed to send clipboard data, ret={}", ret);
return ret;
}
}
@@ -379,8 +379,8 @@ bool KeyboardController::ReleaseRemotePressedKeysLocked(
if (state_it != remote_states_.end()) {
const auto& keys = state_it->second.pressed_keys;
if (!keys.empty()) {
LOG_WARN("Releasing {} remote keyboard keys for remote_id={}, reason={}",
keys.size(), remote_id, reason ? reason : "unknown");
LOG_WARN("Releasing {} remote keyboard keys, reason={}", keys.size(),
reason ? reason : "unknown");
}
// Stage before erasing: subsequent dispatcher retries must still see the
// keys if injection fails, even though active/heartbeat state is gone.
@@ -60,8 +60,7 @@ bool RestrictCachePermissions(const std::filesystem::path &path,
close(fd);
}
if (error) {
LOG_WARN("Cannot restrict credential cache permissions for {}: {}",
path.string(),
LOG_WARN("Cannot restrict credential cache permissions: {}",
std::error_code(error, std::generic_category()).message());
}
return error == 0;
@@ -184,7 +184,7 @@ void GuiRuntime::HandlePresenceProbeTimeout() {
offline_warning_text_ =
localization::device_offline[localization_language_index_];
show_offline_warning_window_ = true;
LOG_WARN("Presence probe timed out for [{}]", presence_remote_id);
LOG_WARN("Presence probe timed out");
}
}
@@ -383,8 +383,7 @@ void GuiRuntime::CloseRemoteSession(std::shared_ptr<RemoteSession> props) {
thumbnail = thumbnail_, queued_at]() mutable {
if (props->peer_events_) props->peer_events_->Deactivate();
if (peer && !props->lan_session_) {
LOG_INFO("[{}] Background leave connection [{}]", props->local_id_,
props->remote_id_);
LOG_INFO("Background leave connection");
MiniRtcLeaveConnection(peer, props->remote_id_.c_str());
MiniRtcDestroyPeer(&peer);
}
@@ -405,13 +404,12 @@ void GuiRuntime::CloseRemoteSession(std::shared_ptr<RemoteSession> props) {
props->remote_host_name_,
props->remember_password_ ? props->remote_password_ : "",
platform, direct ? &target : nullptr) != 0) {
LOG_ERROR("[{}] Failed to save recent connection", props->remote_id_);
LOG_ERROR("Failed to save recent connection");
}
}
const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - queued_at).count();
LOG_INFO("[{}] Session cleanup completed in {} ms", props->remote_id_,
elapsed);
LOG_INFO("Session cleanup completed in {} ms", elapsed);
});
}
@@ -433,8 +431,7 @@ void GuiRuntime::CloseServerController(const std::string& remote_id) {
[peer = peer_, transmission_id = std::string(client_id_), remote_id] {
if (PeerDisconnectPeerConnection(peer, transmission_id.c_str(),
remote_id.c_str()) != 0) {
LOG_WARN("[{}] Could not queue controller disconnect notification",
remote_id);
LOG_WARN("Could not queue controller disconnect notification");
}
});
}
@@ -482,7 +479,7 @@ void GuiRuntime::CloseConnectionPeer() {
connection_peer_cleanup_ = session_cleanup_queue_.PostTask(
[peer, handler = peer_events_, id = std::string(client_id_)]() mutable {
handler->Deactivate();
LOG_INFO("[{}] Background connection peer cleanup", id);
LOG_INFO("Background connection peer cleanup");
if (!IsLocalPeer(peer)) MiniRtcLeaveConnection(peer, id.c_str());
UnbindLocalPeer(peer);
MiniRtcDestroyPeer(&peer);
@@ -534,7 +531,8 @@ void GuiRuntime::HandleSessionCleanup() {
try {
it->second.get();
} catch (const std::exception& error) {
LOG_ERROR("[{}] Session cleanup failed: {}", it->first, error.what());
LOG_ERROR("Session cleanup failed");
LOG_DEBUG("Session cleanup failed for [{}]: {}", it->first, error.what());
}
if (auto pending = pending_reconnects_.find(it->first);
pending != pending_reconnects_.end()) {
@@ -568,7 +566,8 @@ void GuiRuntime::WaitForSessionCleanup() {
try {
task.get();
} catch (const std::exception& error) {
LOG_ERROR("[{}] Session cleanup failed: {}", id, error.what());
LOG_ERROR("Session cleanup failed");
LOG_DEBUG("Session cleanup failed for [{}]: {}", id, error.what());
}
}
session_cleanup_tasks_.clear();
@@ -641,7 +640,7 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
if (session_cleanup_tasks_.count(remote_id)) {
pending_reconnects_[remote_id] = {password ? password : "",
remember_password, background};
LOG_INFO("[{}] Reconnect queued until previous peer is destroyed", remote_id);
LOG_INFO("Reconnect queued until previous peer is destroyed");
return 0;
}
// Wall requests, including deferred reconnects, must not replace the single
@@ -654,14 +653,15 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
offline_warning_text_ =
localization::device_offline[localization_language_index_];
show_offline_warning_window_ = true;
LOG_WARN("Presence probe failed for [{}], ret={}", remote_id, ret);
LOG_WARN("Presence probe failed, ret={}", ret);
} else {
LOG_INFO("Presence probe requested for [{}] before connect", remote_id);
LOG_INFO("Presence probe requested before connect");
}
return -1;
}
LOG_INFO("Connect to [{}]", remote_id);
LOG_INFO("Connecting to remote device");
LOG_DEBUG("Connect to [{}]", remote_id);
if (!background) focused_remote_id_ = remote_id;
auto stale = FindRemoteSession(remote_id);
@@ -676,8 +676,7 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
if (it != remote_sessions_.end() && it->second == stale) {
remote_sessions_.erase(it);
exists = false;
LOG_INFO("[{}] Recreating stale remote session before connect",
remote_id);
LOG_INFO("Recreating stale remote session before connect");
}
}
if (exists && !stale->closing_.load() &&
@@ -694,7 +693,7 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
: std::string(password),
remember_password, background};
CloseRemoteSession(stale);
LOG_INFO("[{}] Reconnecting after terminal peer status {}", remote_id,
LOG_INFO("Reconnecting after terminal peer status {}",
static_cast<int>(status));
return 0;
}
@@ -727,7 +726,7 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
if (!background) show_connection_status_window_ = true;
if (!props->peer_) {
LOG_INFO("Create peer [{}] instance failed", props->local_id_);
LOG_INFO("Create peer instance failed");
return -1;
}
@@ -753,9 +752,10 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
}
if (peer_to_init) {
LOG_INFO("[{}] Create peer instance successful", local_id);
LOG_INFO("Create peer instance successful");
LOG_DEBUG("Local peer id: [{}]", local_id);
MiniRtcInit(peer_to_init);
LOG_INFO("[{}] Peer init finish", local_id);
LOG_INFO("Peer initialization finished");
}
}
@@ -159,7 +159,7 @@ void GuiRuntime::TickControllerTrust() {
auto callback = events->EnterCallback();
if (!callback) continue;
if (action.kind < 0) {
LOG_WARN("Reject controller [{}]: trusted device verification required", action.id);
LOG_WARN("Reject controller: trusted device verification required");
transfers_.Cancel(events.get(), action.id);
remote_input_.Disconnect(action.id);
CloseServerController(action.id);
+11 -11
View File
@@ -53,9 +53,10 @@ GuiRuntime::GuiRuntime()
},
[](const std::string& id, int64_t queued_ms, int64_t execution_ms,
InputOutcome outcome) {
LOG_WARN("Remote input result: peer={} queue_ms={} execution_ms={} "
"result={}",
id, queued_ms, execution_ms, InputOutcomeName(outcome));
LOG_DEBUG("Remote input result for peer={}", id);
LOG_WARN(
"Remote input result: queue_ms={} execution_ms={} result={}",
queued_ms, execution_ms, InputOutcomeName(outcome));
},
[this] { return devices_.ResetToInitialDisplay(); },
[this](const std::string& id, unsigned mask) {
@@ -128,8 +129,7 @@ void GuiRuntime::SendRemoteInput(const RemoteAction& action) {
: MiniRtcSendReliableDataFrame(
props->peer_, message.data(), message.size(),
mouse ? props->mouse_label_.c_str() : props->keyboard_label_.c_str());
if (result != 0)
LOG_WARN("Send remote input failed, remote_id={}, ret={}", id, result);
if (result != 0) LOG_WARN("Send remote input failed, ret={}", result);
}
}
@@ -258,8 +258,7 @@ int GuiRuntime::CreateConnectionPeer() {
} else if (!credential_recovery_in_progress_) {
credential_recovery_in_progress_ = true;
credential_recovery_attempt_pending_ = true;
LOG_INFO("Recovering an interrupted password change for [{}]",
client_id_);
LOG_INFO("Recovering an interrupted password change");
}
try_pending_identity = credential_recovery_in_progress_ &&
credential_recovery_attempt_pending_ &&
@@ -352,7 +351,8 @@ int GuiRuntime::CreateConnectionPeer() {
peer_ = MiniRtcCreatePeer(&params_);
}
if (peer_) {
LOG_INFO("Create peer instance [{}] successful", client_id_);
LOG_INFO("Create peer instance successful");
LOG_DEBUG("Local client id: [{}]", client_id_);
#ifdef _WIN32
if (managed_host_frontend_) {
if (!local_host_) local_host_ = std::make_shared<LocalHostChannel>(false);
@@ -378,9 +378,9 @@ int GuiRuntime::CreateConnectionPeer() {
}
#endif
MiniRtcInit(peer_);
LOG_INFO("Peer [{}] init finish", client_id_);
LOG_INFO("Peer initialization finished");
} else {
LOG_INFO("Create peer [{}] instance failed", client_id_);
LOG_INFO("Create peer instance failed");
}
if (0 == devices_.EnsureCaptureReady()) {
@@ -440,7 +440,7 @@ void GuiRuntime::HandleRecentConnections() {
platform, direct ? &target : nullptr) == 0)
reload_recent_connections_ = true;
else
LOG_ERROR("[{}] Failed to save recent connection", props->remote_id_);
LOG_ERROR("Failed to save recent connection");
}
}
if (session_cleanup_tasks_.empty() && reload_recent_connections_ && thumbnail_) {
@@ -327,10 +327,11 @@ void PeerEventHandler::OnReceiveDataBuffer(
bound_peer, wire_id.data(), wire_id.size(),
static_cast<MiniRtcVideoQuality>(settings.quality), settings.frame_rate,
static_cast<MiniRtcVideoDegradationPreference>(settings.preference)) == 0;
LOG_INFO("Video settings: peer={} source={} request={} quality={} fps={} "
"preference={} accepted={}",
remote_id, source_id, settings.request_id, settings.quality,
settings.frame_rate, settings.preference, remote_action.vs.accepted);
LOG_INFO(
"Video settings: source={} request={} quality={} fps={} preference={} "
"accepted={}",
source_id, settings.request_id, settings.quality, settings.frame_rate,
settings.preference, remote_action.vs.accepted);
remote_action.type = ControlType::video_settings_status;
const auto message = remote_action.to_json();
PeerSendReliableDataFrameToPeer(bound_peer, message.data(), message.size(),
@@ -373,9 +374,9 @@ void PeerEventHandler::OnReceiveDataBuffer(
source_id != runtime->keyboard_label_) return;
if (runtime->remote_input_.Push(remote_id, remote_action) ==
RemoteInputDispatcher::Result::overflow)
LOG_WARN("Remote input queue overflow: peer={}, clearing stale input and "
"releasing keys/buttons",
remote_id);
LOG_WARN(
"Remote input queue overflow: clearing stale input and releasing "
"keys/buttons");
return;
}
if (remote_action.type == ControlType::audio_capture) {
@@ -500,7 +501,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
if (props->remote_host_name_.empty()) {
props->remote_host_name_ = std::string(remote_action.i.host_name,
remote_action.i.host_name_size);
LOG_INFO("Remote hostname: [{}]", props->remote_host_name_);
LOG_DEBUG("Remote hostname: [{}]", props->remote_host_name_);
for (int i = 0; i < remote_action.i.display_num; i++) {
props->display_info_list_.push_back(
@@ -526,7 +527,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
runtime->codec_status_controllers_.erase(remote_id);
}
}
LOG_INFO("Remote hostname: [{}]", host_name);
LOG_DEBUG("Remote hostname: [{}]", host_name);
if (source_id == runtime->control_data_label_) {
runtime->SetControllerPrivacySupport(
remote_id, remote_action.i.supports_privacy_screen);
@@ -602,7 +603,7 @@ InputOutcome GuiRuntime::ApplyRemoteInput(const std::string& remote_id,
const auto now = std::chrono::steady_clock::now();
auto [position, first] = last_remote_pointer_input_time_.try_emplace(remote_id, now);
position->second = now;
if (first) LOG_INFO("Remote pointer input received: peer={}", remote_id);
if (first) LOG_INFO("Remote pointer input received");
}
if (remote_action.type == ControlType::mouse) {
@@ -76,7 +76,7 @@ void PeerEventHandler::SendClientInfo(MiniRtcPeerPtr* peer,
{"platform", HostPlatformName(kClientPlatform)}};
const std::string payload = message.dump();
if (PeerSendSignalMessage(peer, payload.data(), payload.size()) != 0) {
LOG_WARN("[{}] failed to report client information", client_id);
LOG_WARN("Failed to report client information");
}
}
@@ -195,8 +195,7 @@ void PeerEventHandler::OnSignalMessage(const char* message, size_t size,
const std::string response_user_id = j["user_id"].get<std::string>();
if (!response_user_id.empty() &&
response_user_id != runtime->client_id_) {
LOG_WARN("Ignore password change response for unexpected id [{}]",
response_user_id);
LOG_WARN("Ignore password change response for unexpected device");
return;
}
}
@@ -235,7 +234,7 @@ void PeerEventHandler::OnSignalStatus(MiniRtcSignalStatus status, const char* us
} else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) {
runtime->signal_connected_ = true;
runtime->need_to_send_recent_connections_ = true;
LOG_INFO("[{}] connected to signal server", client_id);
LOG_INFO("Connected to signal server");
SendClientInfo(runtime->peer_, client_id);
std::lock_guard<std::mutex> lock(runtime->password_change_mutex_);
if (runtime->credential_recovery_in_progress_) {
@@ -276,7 +275,7 @@ void PeerEventHandler::OnSignalStatus(MiniRtcSignalStatus status, const char* us
props->signal_connected_ = false;
} else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) {
props->signal_connected_ = true;
LOG_INFO("[{}] connected to signal server", remote_id);
LOG_INFO("Connected to signal server");
SendClientInfo(props->peer_, client_id);
} else if (MiniRtcSignalStatus::MiniRtcSignalFailed == status) {
props->signal_connected_ = false;
@@ -372,8 +371,7 @@ void PeerEventHandler::DispatchConnectionStatus(MiniRtcConnectionStatus status,
MiniRtcSendReliableDataFrame(props->peer_, msg.data(), msg.size(),
runtime->control_data_label_.c_str());
if (ret != 0) {
LOG_WARN("[{}] host information send failed, ret={}", remote_id,
ret);
LOG_WARN("Host information send failed, ret={}", ret);
}
}
@@ -579,7 +577,7 @@ void PeerEventHandler::OnNetStatusReport(
sizeof(runtime->self_hosted_id_) - 1);
runtime->self_hosted_id_[sizeof(runtime->self_hosted_id_) - 1] = '\0';
LOG_INFO("Use self-hosted client id [{}] and save to cache file", id);
LOG_DEBUG("Use self-hosted client id [{}] and save to cache file", id);
runtime->settings_.PersistSelfHostedIdentity(client_id);
} else {
@@ -600,7 +598,7 @@ void PeerEventHandler::OnNetStatusReport(
->client_id_with_password_[sizeof(runtime->client_id_with_password_) -
1] = '\0';
LOG_INFO("Use client id [{}] and save id into cache file", id);
LOG_DEBUG("Use client id [{}] and save id into cache file", id);
runtime->settings_.Save();
}
#if defined(__linux__) && !defined(__OHOS__)
@@ -673,7 +671,7 @@ std::string GuiRuntime::BuildHostInformation(bool advertise_trust) {
void GuiRuntime::AnnounceHostCapabilities(const std::string& id) {
const auto message = BuildHostInformation();
const int ret = SendControllerData(id, message.data(), message.size(), control_data_label_.c_str());
if (ret != 0) LOG_WARN("[{}] host information send failed, ret={}", id, ret);
if (ret != 0) LOG_WARN("Host information send failed, ret={}", ret);
}
} // namespace crossdesk
@@ -38,8 +38,8 @@ void GuiRuntime::SetControllerPrivacySupport(const std::string& remote_id,
if (found->second == MiniRtcConnectionStatus::MiniRtcConnectionConnecting ||
found->second == MiniRtcConnectionStatus::MiniRtcConnectionGathering) {
privacy_sessions_.RememberSupport(remote_id, supported);
LOG_INFO("Privacy: retained early controller capability, peer={}, supported={}",
remote_id, supported);
LOG_INFO("Privacy: retained early controller capability, supported={}",
supported);
}
return;
}
@@ -68,7 +68,7 @@ void GuiRuntime::QueuePrivacyCommand(const std::string& remote_id,
!privacy_sessions_.Supports(remote_id)) return;
std::lock_guard lock(privacy_commands_mutex_);
if (privacy_commands_.size() >= 32) return;
LOG_INFO("Privacy: queued controller command, peer={}, flag={}", remote_id,
LOG_INFO("Privacy: queued controller command, flag={}",
static_cast<int>(command.flag));
privacy_commands_.emplace_back(remote_id, command);
}
@@ -149,7 +149,7 @@ void GuiRuntime::HandlePrivacy() {
control_data_label_.c_str());
if (result != 0) {
sent = false;
LOG_WARN("Privacy status send failed, peer={}, ret={}", id, result);
LOG_WARN("Privacy status send failed, ret={}", result);
}
}
if (sent) {