[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_); std::lock_guard lock(props->privacy_status_mutex_);
props->privacy_command_pending_ = false; props->privacy_command_pending_ = false;
if (!relock) props->privacy_status_received_ = 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); }); 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(), const int result = SendControllerData(recipient.remote_id, message.c_str(),
message.size(), mouse_label_.c_str()); message.size(), mouse_label_.c_str());
if (result != 0) { if (result != 0) {
LOG_WARN("Send cursor state to [{}] failed, ret={}", LOG_WARN("Send cursor state failed, ret={}", result);
recipient.remote_id, result);
continue; continue;
} }
if (!delivery.has_sent || if (!delivery.has_sent ||
delivery.last_sent.render_mode != outgoing.render_mode || delivery.last_sent.render_mode != outgoing.render_mode ||
delivery.last_sent.hidden_reason != outgoing.hidden_reason) { delivery.last_sent.hidden_reason != outgoing.hidden_reason) {
LOG_INFO("Send cursor presentation to [{}]: mode={}, reason={}", LOG_INFO("Send cursor presentation: mode={}, reason={}",
recipient.remote_id, static_cast<int>(outgoing.render_mode), static_cast<int>(outgoing.render_mode),
static_cast<int>(outgoing.hidden_reason)); static_cast<int>(outgoing.hidden_reason));
} }
delivery.last_sent = outgoing; delivery.last_sent = outgoing;
@@ -3143,10 +3142,9 @@ void GuiApplication::HandlePasswordChangeResult() {
uncertain ? "console_password_uncertain" : "console_password_rejected"); uncertain ? "console_password_uncertain" : "console_password_rejected");
#endif #endif
if (uncertain) { if (uncertain) {
LOG_WARN("Password change outcome is unknown: {}; re-authenticating", LOG_WARN("Password change outcome is unknown; re-authenticating");
error);
} else { } else {
LOG_WARN("Password change failed: {}", error); LOG_WARN("Password change failed");
if (!settings_.ClearPendingPasswordChange()) { if (!settings_.ClearPendingPasswordChange()) {
LOG_WARN("Could not clear rejected pending password change"); 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_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__) #if defined(__linux__) && !defined(__OHOS__)
HeadlessConsole::Instance().NotifyKey("console_password_confirmed"); HeadlessConsole::Instance().NotifyKey("console_password_confirmed");
#endif #endif
@@ -362,8 +362,7 @@ void ClipboardController::SendDeferredLocalText() {
session->peer_, last_text_.data(), last_text_.size(), session->peer_, last_text_.data(), last_text_.size(),
session->clipboard_label_.c_str()); session->clipboard_label_.c_str());
if (ret != 0) { if (ret != 0) {
LOG_WARN("Failed to send deferred clipboard data to peer [{}], ret={}", LOG_WARN("Failed to send deferred clipboard data, ret={}", ret);
session->remote_id_, ret);
return; return;
} }
deferred_local_session_.reset(); deferred_local_session_.reset();
@@ -390,8 +389,7 @@ int ClipboardController::SendToPeers(const std::string &text) {
MiniRtcSendReliableDataFrame(props->peer_, text.data(), text.size(), MiniRtcSendReliableDataFrame(props->peer_, text.data(), text.size(),
props->clipboard_label_.c_str()); props->clipboard_label_.c_str());
if (ret != 0) { if (ret != 0) {
LOG_WARN("Failed to send clipboard data to peer [{}], ret={}", LOG_WARN("Failed to send clipboard data, ret={}", ret);
remote_id.c_str(), ret);
return ret; return ret;
} }
} }
@@ -379,8 +379,8 @@ bool KeyboardController::ReleaseRemotePressedKeysLocked(
if (state_it != remote_states_.end()) { if (state_it != remote_states_.end()) {
const auto& keys = state_it->second.pressed_keys; const auto& keys = state_it->second.pressed_keys;
if (!keys.empty()) { if (!keys.empty()) {
LOG_WARN("Releasing {} remote keyboard keys for remote_id={}, reason={}", LOG_WARN("Releasing {} remote keyboard keys, reason={}", keys.size(),
keys.size(), remote_id, reason ? reason : "unknown"); reason ? reason : "unknown");
} }
// Stage before erasing: subsequent dispatcher retries must still see the // Stage before erasing: subsequent dispatcher retries must still see the
// keys if injection fails, even though active/heartbeat state is gone. // keys if injection fails, even though active/heartbeat state is gone.
@@ -60,8 +60,7 @@ bool RestrictCachePermissions(const std::filesystem::path &path,
close(fd); close(fd);
} }
if (error) { if (error) {
LOG_WARN("Cannot restrict credential cache permissions for {}: {}", LOG_WARN("Cannot restrict credential cache permissions: {}",
path.string(),
std::error_code(error, std::generic_category()).message()); std::error_code(error, std::generic_category()).message());
} }
return error == 0; return error == 0;
@@ -184,7 +184,7 @@ void GuiRuntime::HandlePresenceProbeTimeout() {
offline_warning_text_ = offline_warning_text_ =
localization::device_offline[localization_language_index_]; localization::device_offline[localization_language_index_];
show_offline_warning_window_ = true; 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 { thumbnail = thumbnail_, queued_at]() mutable {
if (props->peer_events_) props->peer_events_->Deactivate(); if (props->peer_events_) props->peer_events_->Deactivate();
if (peer && !props->lan_session_) { if (peer && !props->lan_session_) {
LOG_INFO("[{}] Background leave connection [{}]", props->local_id_, LOG_INFO("Background leave connection");
props->remote_id_);
MiniRtcLeaveConnection(peer, props->remote_id_.c_str()); MiniRtcLeaveConnection(peer, props->remote_id_.c_str());
MiniRtcDestroyPeer(&peer); MiniRtcDestroyPeer(&peer);
} }
@@ -405,13 +404,12 @@ void GuiRuntime::CloseRemoteSession(std::shared_ptr<RemoteSession> props) {
props->remote_host_name_, props->remote_host_name_,
props->remember_password_ ? props->remote_password_ : "", props->remember_password_ ? props->remote_password_ : "",
platform, direct ? &target : nullptr) != 0) { 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>( const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - queued_at).count(); std::chrono::steady_clock::now() - queued_at).count();
LOG_INFO("[{}] Session cleanup completed in {} ms", props->remote_id_, LOG_INFO("Session cleanup completed in {} ms", elapsed);
elapsed);
}); });
} }
@@ -433,8 +431,7 @@ void GuiRuntime::CloseServerController(const std::string& remote_id) {
[peer = peer_, transmission_id = std::string(client_id_), remote_id] { [peer = peer_, transmission_id = std::string(client_id_), remote_id] {
if (PeerDisconnectPeerConnection(peer, transmission_id.c_str(), if (PeerDisconnectPeerConnection(peer, transmission_id.c_str(),
remote_id.c_str()) != 0) { remote_id.c_str()) != 0) {
LOG_WARN("[{}] Could not queue controller disconnect notification", LOG_WARN("Could not queue controller disconnect notification");
remote_id);
} }
}); });
} }
@@ -482,7 +479,7 @@ void GuiRuntime::CloseConnectionPeer() {
connection_peer_cleanup_ = session_cleanup_queue_.PostTask( connection_peer_cleanup_ = session_cleanup_queue_.PostTask(
[peer, handler = peer_events_, id = std::string(client_id_)]() mutable { [peer, handler = peer_events_, id = std::string(client_id_)]() mutable {
handler->Deactivate(); handler->Deactivate();
LOG_INFO("[{}] Background connection peer cleanup", id); LOG_INFO("Background connection peer cleanup");
if (!IsLocalPeer(peer)) MiniRtcLeaveConnection(peer, id.c_str()); if (!IsLocalPeer(peer)) MiniRtcLeaveConnection(peer, id.c_str());
UnbindLocalPeer(peer); UnbindLocalPeer(peer);
MiniRtcDestroyPeer(&peer); MiniRtcDestroyPeer(&peer);
@@ -534,7 +531,8 @@ void GuiRuntime::HandleSessionCleanup() {
try { try {
it->second.get(); it->second.get();
} catch (const std::exception& error) { } 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); if (auto pending = pending_reconnects_.find(it->first);
pending != pending_reconnects_.end()) { pending != pending_reconnects_.end()) {
@@ -568,7 +566,8 @@ void GuiRuntime::WaitForSessionCleanup() {
try { try {
task.get(); task.get();
} catch (const std::exception& error) { } 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(); 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)) { if (session_cleanup_tasks_.count(remote_id)) {
pending_reconnects_[remote_id] = {password ? password : "", pending_reconnects_[remote_id] = {password ? password : "",
remember_password, background}; 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; return 0;
} }
// Wall requests, including deferred reconnects, must not replace the single // 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_ = offline_warning_text_ =
localization::device_offline[localization_language_index_]; localization::device_offline[localization_language_index_];
show_offline_warning_window_ = true; show_offline_warning_window_ = true;
LOG_WARN("Presence probe failed for [{}], ret={}", remote_id, ret); LOG_WARN("Presence probe failed, ret={}", ret);
} else { } else {
LOG_INFO("Presence probe requested for [{}] before connect", remote_id); LOG_INFO("Presence probe requested before connect");
} }
return -1; 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; if (!background) focused_remote_id_ = remote_id;
auto stale = FindRemoteSession(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) { if (it != remote_sessions_.end() && it->second == stale) {
remote_sessions_.erase(it); remote_sessions_.erase(it);
exists = false; exists = false;
LOG_INFO("[{}] Recreating stale remote session before connect", LOG_INFO("Recreating stale remote session before connect");
remote_id);
} }
} }
if (exists && !stale->closing_.load() && if (exists && !stale->closing_.load() &&
@@ -694,7 +693,7 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
: std::string(password), : std::string(password),
remember_password, background}; remember_password, background};
CloseRemoteSession(stale); CloseRemoteSession(stale);
LOG_INFO("[{}] Reconnecting after terminal peer status {}", remote_id, LOG_INFO("Reconnecting after terminal peer status {}",
static_cast<int>(status)); static_cast<int>(status));
return 0; 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 (!background) show_connection_status_window_ = true;
if (!props->peer_) { if (!props->peer_) {
LOG_INFO("Create peer [{}] instance failed", props->local_id_); LOG_INFO("Create peer instance failed");
return -1; return -1;
} }
@@ -753,9 +752,10 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
} }
if (peer_to_init) { 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); 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(); auto callback = events->EnterCallback();
if (!callback) continue; if (!callback) continue;
if (action.kind < 0) { 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); transfers_.Cancel(events.get(), action.id);
remote_input_.Disconnect(action.id); remote_input_.Disconnect(action.id);
CloseServerController(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, [](const std::string& id, int64_t queued_ms, int64_t execution_ms,
InputOutcome outcome) { InputOutcome outcome) {
LOG_WARN("Remote input result: peer={} queue_ms={} execution_ms={} " LOG_DEBUG("Remote input result for peer={}", id);
"result={}", LOG_WARN(
id, queued_ms, execution_ms, InputOutcomeName(outcome)); "Remote input result: queue_ms={} execution_ms={} result={}",
queued_ms, execution_ms, InputOutcomeName(outcome));
}, },
[this] { return devices_.ResetToInitialDisplay(); }, [this] { return devices_.ResetToInitialDisplay(); },
[this](const std::string& id, unsigned mask) { [this](const std::string& id, unsigned mask) {
@@ -128,8 +129,7 @@ void GuiRuntime::SendRemoteInput(const RemoteAction& action) {
: MiniRtcSendReliableDataFrame( : MiniRtcSendReliableDataFrame(
props->peer_, message.data(), message.size(), props->peer_, message.data(), message.size(),
mouse ? props->mouse_label_.c_str() : props->keyboard_label_.c_str()); mouse ? props->mouse_label_.c_str() : props->keyboard_label_.c_str());
if (result != 0) if (result != 0) LOG_WARN("Send remote input failed, ret={}", result);
LOG_WARN("Send remote input failed, remote_id={}, ret={}", id, result);
} }
} }
@@ -258,8 +258,7 @@ int GuiRuntime::CreateConnectionPeer() {
} else if (!credential_recovery_in_progress_) { } else if (!credential_recovery_in_progress_) {
credential_recovery_in_progress_ = true; credential_recovery_in_progress_ = true;
credential_recovery_attempt_pending_ = true; credential_recovery_attempt_pending_ = true;
LOG_INFO("Recovering an interrupted password change for [{}]", LOG_INFO("Recovering an interrupted password change");
client_id_);
} }
try_pending_identity = credential_recovery_in_progress_ && try_pending_identity = credential_recovery_in_progress_ &&
credential_recovery_attempt_pending_ && credential_recovery_attempt_pending_ &&
@@ -352,7 +351,8 @@ int GuiRuntime::CreateConnectionPeer() {
peer_ = MiniRtcCreatePeer(&params_); peer_ = MiniRtcCreatePeer(&params_);
} }
if (peer_) { 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 #ifdef _WIN32
if (managed_host_frontend_) { if (managed_host_frontend_) {
if (!local_host_) local_host_ = std::make_shared<LocalHostChannel>(false); if (!local_host_) local_host_ = std::make_shared<LocalHostChannel>(false);
@@ -378,9 +378,9 @@ int GuiRuntime::CreateConnectionPeer() {
} }
#endif #endif
MiniRtcInit(peer_); MiniRtcInit(peer_);
LOG_INFO("Peer [{}] init finish", client_id_); LOG_INFO("Peer initialization finished");
} else { } else {
LOG_INFO("Create peer [{}] instance failed", client_id_); LOG_INFO("Create peer instance failed");
} }
if (0 == devices_.EnsureCaptureReady()) { if (0 == devices_.EnsureCaptureReady()) {
@@ -440,7 +440,7 @@ void GuiRuntime::HandleRecentConnections() {
platform, direct ? &target : nullptr) == 0) platform, direct ? &target : nullptr) == 0)
reload_recent_connections_ = true; reload_recent_connections_ = true;
else 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_) { if (session_cleanup_tasks_.empty() && reload_recent_connections_ && thumbnail_) {
@@ -327,10 +327,11 @@ void PeerEventHandler::OnReceiveDataBuffer(
bound_peer, wire_id.data(), wire_id.size(), bound_peer, wire_id.data(), wire_id.size(),
static_cast<MiniRtcVideoQuality>(settings.quality), settings.frame_rate, static_cast<MiniRtcVideoQuality>(settings.quality), settings.frame_rate,
static_cast<MiniRtcVideoDegradationPreference>(settings.preference)) == 0; static_cast<MiniRtcVideoDegradationPreference>(settings.preference)) == 0;
LOG_INFO("Video settings: peer={} source={} request={} quality={} fps={} " LOG_INFO(
"preference={} accepted={}", "Video settings: source={} request={} quality={} fps={} preference={} "
remote_id, source_id, settings.request_id, settings.quality, "accepted={}",
settings.frame_rate, settings.preference, remote_action.vs.accepted); source_id, settings.request_id, settings.quality, settings.frame_rate,
settings.preference, remote_action.vs.accepted);
remote_action.type = ControlType::video_settings_status; remote_action.type = ControlType::video_settings_status;
const auto message = remote_action.to_json(); const auto message = remote_action.to_json();
PeerSendReliableDataFrameToPeer(bound_peer, message.data(), message.size(), PeerSendReliableDataFrameToPeer(bound_peer, message.data(), message.size(),
@@ -373,9 +374,9 @@ void PeerEventHandler::OnReceiveDataBuffer(
source_id != runtime->keyboard_label_) return; source_id != runtime->keyboard_label_) return;
if (runtime->remote_input_.Push(remote_id, remote_action) == if (runtime->remote_input_.Push(remote_id, remote_action) ==
RemoteInputDispatcher::Result::overflow) RemoteInputDispatcher::Result::overflow)
LOG_WARN("Remote input queue overflow: peer={}, clearing stale input and " LOG_WARN(
"releasing keys/buttons", "Remote input queue overflow: clearing stale input and releasing "
remote_id); "keys/buttons");
return; return;
} }
if (remote_action.type == ControlType::audio_capture) { if (remote_action.type == ControlType::audio_capture) {
@@ -500,7 +501,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
if (props->remote_host_name_.empty()) { if (props->remote_host_name_.empty()) {
props->remote_host_name_ = std::string(remote_action.i.host_name, props->remote_host_name_ = std::string(remote_action.i.host_name,
remote_action.i.host_name_size); 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++) { for (int i = 0; i < remote_action.i.display_num; i++) {
props->display_info_list_.push_back( props->display_info_list_.push_back(
@@ -526,7 +527,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
runtime->codec_status_controllers_.erase(remote_id); 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_) { if (source_id == runtime->control_data_label_) {
runtime->SetControllerPrivacySupport( runtime->SetControllerPrivacySupport(
remote_id, remote_action.i.supports_privacy_screen); 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(); const auto now = std::chrono::steady_clock::now();
auto [position, first] = last_remote_pointer_input_time_.try_emplace(remote_id, now); auto [position, first] = last_remote_pointer_input_time_.try_emplace(remote_id, now);
position->second = 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) { if (remote_action.type == ControlType::mouse) {
@@ -76,7 +76,7 @@ void PeerEventHandler::SendClientInfo(MiniRtcPeerPtr* peer,
{"platform", HostPlatformName(kClientPlatform)}}; {"platform", HostPlatformName(kClientPlatform)}};
const std::string payload = message.dump(); const std::string payload = message.dump();
if (PeerSendSignalMessage(peer, payload.data(), payload.size()) != 0) { 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>(); const std::string response_user_id = j["user_id"].get<std::string>();
if (!response_user_id.empty() && if (!response_user_id.empty() &&
response_user_id != runtime->client_id_) { response_user_id != runtime->client_id_) {
LOG_WARN("Ignore password change response for unexpected id [{}]", LOG_WARN("Ignore password change response for unexpected device");
response_user_id);
return; return;
} }
} }
@@ -235,7 +234,7 @@ void PeerEventHandler::OnSignalStatus(MiniRtcSignalStatus status, const char* us
} else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) { } else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) {
runtime->signal_connected_ = true; runtime->signal_connected_ = true;
runtime->need_to_send_recent_connections_ = 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); SendClientInfo(runtime->peer_, client_id);
std::lock_guard<std::mutex> lock(runtime->password_change_mutex_); std::lock_guard<std::mutex> lock(runtime->password_change_mutex_);
if (runtime->credential_recovery_in_progress_) { if (runtime->credential_recovery_in_progress_) {
@@ -276,7 +275,7 @@ void PeerEventHandler::OnSignalStatus(MiniRtcSignalStatus status, const char* us
props->signal_connected_ = false; props->signal_connected_ = false;
} else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) { } else if (MiniRtcSignalStatus::MiniRtcSignalConnected == status) {
props->signal_connected_ = true; props->signal_connected_ = true;
LOG_INFO("[{}] connected to signal server", remote_id); LOG_INFO("Connected to signal server");
SendClientInfo(props->peer_, client_id); SendClientInfo(props->peer_, client_id);
} else if (MiniRtcSignalStatus::MiniRtcSignalFailed == status) { } else if (MiniRtcSignalStatus::MiniRtcSignalFailed == status) {
props->signal_connected_ = false; props->signal_connected_ = false;
@@ -372,8 +371,7 @@ void PeerEventHandler::DispatchConnectionStatus(MiniRtcConnectionStatus status,
MiniRtcSendReliableDataFrame(props->peer_, msg.data(), msg.size(), MiniRtcSendReliableDataFrame(props->peer_, msg.data(), msg.size(),
runtime->control_data_label_.c_str()); runtime->control_data_label_.c_str());
if (ret != 0) { if (ret != 0) {
LOG_WARN("[{}] host information send failed, ret={}", remote_id, LOG_WARN("Host information send failed, ret={}", ret);
ret);
} }
} }
@@ -579,7 +577,7 @@ void PeerEventHandler::OnNetStatusReport(
sizeof(runtime->self_hosted_id_) - 1); sizeof(runtime->self_hosted_id_) - 1);
runtime->self_hosted_id_[sizeof(runtime->self_hosted_id_) - 1] = '\0'; 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); runtime->settings_.PersistSelfHostedIdentity(client_id);
} else { } else {
@@ -600,7 +598,7 @@ void PeerEventHandler::OnNetStatusReport(
->client_id_with_password_[sizeof(runtime->client_id_with_password_) - ->client_id_with_password_[sizeof(runtime->client_id_with_password_) -
1] = '\0'; 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(); runtime->settings_.Save();
} }
#if defined(__linux__) && !defined(__OHOS__) #if defined(__linux__) && !defined(__OHOS__)
@@ -673,7 +671,7 @@ std::string GuiRuntime::BuildHostInformation(bool advertise_trust) {
void GuiRuntime::AnnounceHostCapabilities(const std::string& id) { void GuiRuntime::AnnounceHostCapabilities(const std::string& id) {
const auto message = BuildHostInformation(); const auto message = BuildHostInformation();
const int ret = SendControllerData(id, message.data(), message.size(), control_data_label_.c_str()); 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 } // namespace crossdesk
@@ -38,8 +38,8 @@ void GuiRuntime::SetControllerPrivacySupport(const std::string& remote_id,
if (found->second == MiniRtcConnectionStatus::MiniRtcConnectionConnecting || if (found->second == MiniRtcConnectionStatus::MiniRtcConnectionConnecting ||
found->second == MiniRtcConnectionStatus::MiniRtcConnectionGathering) { found->second == MiniRtcConnectionStatus::MiniRtcConnectionGathering) {
privacy_sessions_.RememberSupport(remote_id, supported); privacy_sessions_.RememberSupport(remote_id, supported);
LOG_INFO("Privacy: retained early controller capability, peer={}, supported={}", LOG_INFO("Privacy: retained early controller capability, supported={}",
remote_id, supported); supported);
} }
return; return;
} }
@@ -68,7 +68,7 @@ void GuiRuntime::QueuePrivacyCommand(const std::string& remote_id,
!privacy_sessions_.Supports(remote_id)) return; !privacy_sessions_.Supports(remote_id)) return;
std::lock_guard lock(privacy_commands_mutex_); std::lock_guard lock(privacy_commands_mutex_);
if (privacy_commands_.size() >= 32) return; 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)); static_cast<int>(command.flag));
privacy_commands_.emplace_back(remote_id, command); privacy_commands_.emplace_back(remote_id, command);
} }
@@ -149,7 +149,7 @@ void GuiRuntime::HandlePrivacy() {
control_data_label_.c_str()); control_data_label_.c_str());
if (result != 0) { if (result != 0) {
sent = false; sent = false;
LOG_WARN("Privacy status send failed, peer={}, ret={}", id, result); LOG_WARN("Privacy status send failed, ret={}", result);
} }
} }
if (sent) { if (sent) {
+6 -3
View File
@@ -50,8 +50,10 @@ void InitLogger(const std::string& log_dir, const std::string& logger_name) {
if (g_logger) { if (g_logger) {
if (directory != g_log_dir || logger_name != g_logger_name) { if (directory != g_log_dir || logger_name != g_logger_name) {
g_logger->warn( g_logger->warn(
"InitLogger called after logger initialized. Keeping logger {} in {}", "InitLogger called after logger initialized. Keeping existing "
g_logger_name, g_log_dir); "logger");
SPDLOG_LOGGER_DEBUG(g_logger, "Keeping logger {} in {}", g_logger_name,
g_log_dir);
} }
return; return;
} }
@@ -88,7 +90,8 @@ std::shared_ptr<spdlog::logger> get_logger() {
: spdlog::level::info); : spdlog::level::info);
logger->flush_on(spdlog::level::info); logger->flush_on(spdlog::level::info);
spdlog::register_logger(logger); spdlog::register_logger(logger);
logger->info("Logger initialized: path={}", file_sink->filename()); logger->info("Logger initialized");
SPDLOG_LOGGER_DEBUG(logger, "Log file: {}", file_sink->filename());
g_logger = std::move(logger); g_logger = std::move(logger);
}); });
@@ -1193,7 +1193,7 @@ struct LinuxTrayImpl {
icon_rgba.assign(pixels, pixels + static_cast<size_t>(width) * icon_rgba.assign(pixels, pixels + static_cast<size_t>(width) *
static_cast<size_t>(height) * 4); static_cast<size_t>(height) * 4);
stbi_image_free(pixels); stbi_image_free(pixels);
LOG_INFO("Loaded Linux tray icon: {}", candidate.string()); LOG_DEBUG("Loaded Linux tray icon: {}", candidate.string());
return true; return true;
} }
@@ -56,7 +56,9 @@ bool GuiRuntime::ForwardUserSessionData(const std::string& id,
(user_stream || user_control || host_info || preview || audio)) { (user_stream || user_control || host_info || preview || audio)) {
if (!local_host_->Send({{"op", "data"}, {"id", id}, {"epoch", epoch}, {"stream", stream}, if (!local_host_->Send({{"op", "data"}, {"id", id}, {"epoch", epoch}, {"stream", stream},
{"bytes", Json::binary(std::vector<uint8_t>(data, data + size))}})) { {"bytes", Json::binary(std::vector<uint8_t>(data, data + size))}})) {
LOG_WARN("Cannot forward user-session data for [{}] on {}; reconnecting local frontend", id, stream); LOG_WARN(
"Cannot forward user-session data on {}; reconnecting local frontend",
stream);
local_gui_ready_ = false; local_gui_ready_ = false;
// Reset the mirrored sessions so an incomplete reliable stream fails // Reset the mirrored sessions so an incomplete reliable stream fails
// explicitly. Never fall through to file/clipboard handling as SYSTEM. // explicitly. Never fall through to file/clipboard handling as SYSTEM.
@@ -46,9 +46,7 @@ bool InstallServiceWithElevation() {
std::error_code error; std::error_code error;
if (!std::filesystem::is_regular_file(service_path, error) || if (!std::filesystem::is_regular_file(service_path, error) ||
!std::filesystem::is_regular_file(helper_path, error)) { !std::filesystem::is_regular_file(helper_path, error)) {
LOG_ERROR("Portable service install failed: service binaries missing, " LOG_ERROR("Portable service install failed: service binaries missing");
"service={}, helper={}",
service_path.string(), helper_path.string());
return false; return false;
} }
@@ -298,8 +298,7 @@ void GuiRuntime::HandleWindowsServiceIntegration() {
if (managed_host_frontend_ && id.rfind("lan/", 0) != 0) continue; if (managed_host_frontend_ && id.rfind("lan/", 0) != 0) continue;
const int ret = SendControllerData(id, msg.data(), msg.size(), const int ret = SendControllerData(id, msg.data(), msg.size(),
control_data_label_.c_str()); control_data_label_.c_str());
if (ret != 0) if (ret != 0) LOG_WARN("Windows service status send failed, ret={}", ret);
LOG_WARN("Windows service status send failed, peer={}, ret={}", id, ret);
} }
#endif #endif
} }
+1 -1
View File
@@ -434,7 +434,7 @@ std::vector<std::filesystem::path> Thumbnail::FindThumbnailPath(
std::vector<std::filesystem::path> thumbnails_path; std::vector<std::filesystem::path> thumbnails_path;
if (!std::filesystem::is_directory(directory)) { if (!std::filesystem::is_directory(directory)) {
LOG_ERROR("No such directory [{}]", directory.string()); LOG_ERROR("Thumbnail directory does not exist");
return thumbnails_path; return thumbnails_path;
} }
+2 -2
View File
@@ -44,8 +44,8 @@ std::filesystem::path FileReceiver::GetDefaultDesktopPath() {
std::error_code ec; std::error_code ec;
std::filesystem::create_directories(desktop_path, ec); std::filesystem::create_directories(desktop_path, ec);
if (ec) { if (ec) {
LOG_ERROR("FileReceiver: failed to create desktop directory [{}]: {}", LOG_ERROR("FileReceiver: failed to create desktop directory: {}",
desktop_path.string().c_str(), ec.message().c_str()); ec.message().c_str());
} }
return desktop_path; return desktop_path;
@@ -98,9 +98,9 @@ void ConfigureLinuxCaCerts(httplib::Client* cli) {
} }
cli->set_ca_cert_path(ca_file, ca_dir); cli->set_ca_cert_path(ca_file, ca_dir);
LOG_INFO("Configured version.json TLS CA bundle: file={}, dir={}", LOG_DEBUG("Configured version.json TLS CA bundle: file={}, dir={}",
ca_file.empty() ? "<none>" : ca_file, ca_file.empty() ? "<none>" : ca_file,
ca_dir.empty() ? "<none>" : ca_dir); ca_dir.empty() ? "<none>" : ca_dir);
} }
#endif #endif