mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] password modification supported
This commit is contained in:
@@ -174,10 +174,8 @@ int Render::LocalWindow() {
|
|||||||
regenerate_password_ ? ICON_FA_SPINNER : ICON_FA_ARROWS_ROTATE,
|
regenerate_password_ ? ICON_FA_SPINNER : ICON_FA_ARROWS_ROTATE,
|
||||||
ImVec2(22, 38))) {
|
ImVec2(22, 38))) {
|
||||||
regenerate_password_ = true;
|
regenerate_password_ = true;
|
||||||
password_inited_ = false;
|
|
||||||
regenerate_password_start_time_ = ImGui::GetTime();
|
regenerate_password_start_time_ = ImGui::GetTime();
|
||||||
LeaveConnection(peer_, client_id_);
|
LeaveConnection(peer_, client_id_);
|
||||||
is_create_connection_ = false;
|
|
||||||
}
|
}
|
||||||
if (ImGui::GetTime() - regenerate_password_start_time_ > 0.3f) {
|
if (ImGui::GetTime() - regenerate_password_start_time_ > 0.3f) {
|
||||||
regenerate_password_ = false;
|
regenerate_password_ = false;
|
||||||
@@ -259,8 +257,22 @@ int Render::LocalWindow() {
|
|||||||
focus_on_input_widget_ = true;
|
focus_on_input_widget_ = true;
|
||||||
} else {
|
} else {
|
||||||
show_reset_password_window_ = false;
|
show_reset_password_window_ = false;
|
||||||
|
memset(&password_saved_, 0, sizeof(password_saved_));
|
||||||
|
strncpy(password_saved_, new_password_,
|
||||||
|
sizeof(password_saved_) - 1);
|
||||||
|
password_saved_[sizeof(password_saved_) - 1] = '\0';
|
||||||
|
|
||||||
|
std::string client_id_with_password =
|
||||||
|
std::string(client_id_) + "@" + password_saved_;
|
||||||
|
strncpy(client_id_with_password_, client_id_with_password.c_str(),
|
||||||
|
sizeof(client_id_with_password_) - 1);
|
||||||
|
client_id_with_password_[sizeof(client_id_with_password_) - 1] =
|
||||||
|
'\0';
|
||||||
|
|
||||||
|
SaveSettingsIntoCacheFile();
|
||||||
|
|
||||||
LeaveConnection(peer_, client_id_);
|
LeaveConnection(peer_, client_id_);
|
||||||
is_create_connection_ = false;
|
DestroyPeer(&peer_);
|
||||||
focus_on_input_widget_ = true;
|
focus_on_input_widget_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,9 @@ int Render::ConnectTo(const std::string &remote_id, const char *password,
|
|||||||
sizeof(props->remote_password_) - 1);
|
sizeof(props->remote_password_) - 1);
|
||||||
props->remote_password_[sizeof(props->remote_password_) - 1] = '\0';
|
props->remote_password_[sizeof(props->remote_password_) - 1] = '\0';
|
||||||
}
|
}
|
||||||
ret = JoinConnection(props->peer_, remote_id.c_str(), password);
|
|
||||||
|
std::string remote_id_with_pwd = remote_id + "@" + password;
|
||||||
|
ret = JoinConnection(props->peer_, remote_id_with_pwd.c_str());
|
||||||
if (0 == ret) {
|
if (0 == ret) {
|
||||||
props->rejoin_ = false;
|
props->rejoin_ = false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -177,10 +177,10 @@ int Render::SaveSettingsIntoCacheFile() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cd_cache_.client_id, 0, sizeof(cd_cache_.client_id));
|
memset(&cd_cache_.client_id_with_password, 0,
|
||||||
memcpy(cd_cache_.client_id, client_id_, sizeof(client_id_));
|
sizeof(cd_cache_.client_id_with_password));
|
||||||
memset(&cd_cache_.password, 0, sizeof(cd_cache_.password));
|
memcpy(cd_cache_.client_id_with_password, client_id_with_password_,
|
||||||
memcpy(cd_cache_.password, password_saved_, sizeof(password_saved_));
|
sizeof(client_id_with_password_));
|
||||||
memcpy(&cd_cache_.language, &language_button_value_,
|
memcpy(&cd_cache_.language, &language_button_value_,
|
||||||
sizeof(language_button_value_));
|
sizeof(language_button_value_));
|
||||||
memcpy(&cd_cache_.video_quality, &video_quality_button_value_,
|
memcpy(&cd_cache_.video_quality, &video_quality_button_value_,
|
||||||
@@ -246,11 +246,28 @@ int Render::LoadSettingsFromCacheFile() {
|
|||||||
cd_cache_file.close();
|
cd_cache_file.close();
|
||||||
cd_cache_mutex_.unlock();
|
cd_cache_mutex_.unlock();
|
||||||
|
|
||||||
memset(&client_id_, 0, sizeof(client_id_));
|
memset(&client_id_with_password_, 0, sizeof(client_id_with_password_));
|
||||||
memcpy(client_id_, cd_cache_.client_id, sizeof(client_id_));
|
memcpy(client_id_with_password_, cd_cache_.client_id_with_password,
|
||||||
memcpy(password_saved_, cd_cache_.password, sizeof(password_saved_));
|
sizeof(client_id_with_password_));
|
||||||
if (0 != strcmp(password_saved_, "") && 7 == sizeof(password_saved_)) {
|
|
||||||
password_inited_ = true;
|
if (strchr(client_id_with_password_, '@') != nullptr) {
|
||||||
|
std::string id, password;
|
||||||
|
const char* at_pos = strchr(client_id_with_password_, '@');
|
||||||
|
if (at_pos == nullptr) {
|
||||||
|
id = client_id_with_password_;
|
||||||
|
password.clear();
|
||||||
|
} else {
|
||||||
|
id.assign(client_id_with_password_, at_pos - client_id_with_password_);
|
||||||
|
password = at_pos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&client_id_, 0, sizeof(client_id_));
|
||||||
|
strncpy(client_id_, id.c_str(), sizeof(client_id_) - 1);
|
||||||
|
client_id_[sizeof(client_id_) - 1] = '\0';
|
||||||
|
|
||||||
|
memset(&password_saved_, 0, sizeof(password_saved_));
|
||||||
|
strncpy(password_saved_, password.c_str(), sizeof(password_saved_) - 1);
|
||||||
|
password_saved_[sizeof(password_saved_) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(aes128_key_, cd_cache_.key, sizeof(cd_cache_.key));
|
memcpy(aes128_key_, cd_cache_.key, sizeof(cd_cache_.key));
|
||||||
@@ -461,7 +478,7 @@ int Render::CreateConnectionPeer() {
|
|||||||
params_.on_connection_status = OnConnectionStatusCb;
|
params_.on_connection_status = OnConnectionStatusCb;
|
||||||
params_.net_status_report = NetStatusReport;
|
params_.net_status_report = NetStatusReport;
|
||||||
|
|
||||||
params_.user_id = client_id_;
|
params_.user_id = client_id_with_password_;
|
||||||
params_.user_data = this;
|
params_.user_data = this;
|
||||||
|
|
||||||
peer_ = CreatePeer(¶ms_);
|
peer_ = CreatePeer(¶ms_);
|
||||||
@@ -937,6 +954,10 @@ void Render::InitializeMainWindow() {
|
|||||||
|
|
||||||
void Render::MainLoop() {
|
void Render::MainLoop() {
|
||||||
while (!exit_) {
|
while (!exit_) {
|
||||||
|
if (!peer_) {
|
||||||
|
CreateConnectionPeer();
|
||||||
|
}
|
||||||
|
|
||||||
UpdateLabels();
|
UpdateLabels();
|
||||||
ProcessSdlEvent();
|
ProcessSdlEvent();
|
||||||
HandleRecentConnections();
|
HandleRecentConnections();
|
||||||
@@ -949,13 +970,6 @@ void Render::MainLoop() {
|
|||||||
|
|
||||||
UpdateInteractions();
|
UpdateInteractions();
|
||||||
|
|
||||||
if (SignalStatus::SignalConnected == signal_status_ &&
|
|
||||||
!is_create_connection_ && password_inited_) {
|
|
||||||
LOG_INFO("Connected with signal server, create p2p connection");
|
|
||||||
is_create_connection_ =
|
|
||||||
CreateConnection(peer_, client_id_, password_saved_) ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (need_to_send_host_info_) {
|
if (need_to_send_host_info_) {
|
||||||
RemoteAction remote_action;
|
RemoteAction remote_action;
|
||||||
remote_action.i.display_num = display_info_list_.size();
|
remote_action.i.display_num = display_info_list_.size();
|
||||||
|
|||||||
@@ -236,8 +236,7 @@ class Render {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct CDCache {
|
struct CDCache {
|
||||||
char client_id[10];
|
char client_id_with_password[17];
|
||||||
char password[7];
|
|
||||||
int language;
|
int language;
|
||||||
int video_quality;
|
int video_quality;
|
||||||
int video_encode_format;
|
int video_encode_format;
|
||||||
@@ -364,11 +363,9 @@ class Render {
|
|||||||
bool password_validating_ = false;
|
bool password_validating_ = false;
|
||||||
uint32_t password_validating_time_ = 0;
|
uint32_t password_validating_time_ = 0;
|
||||||
bool show_settings_window_ = false;
|
bool show_settings_window_ = false;
|
||||||
bool is_create_connection_ = false;
|
|
||||||
bool rejoin_ = false;
|
bool rejoin_ = false;
|
||||||
bool local_id_copied_ = false;
|
bool local_id_copied_ = false;
|
||||||
bool show_password_ = true;
|
bool show_password_ = true;
|
||||||
bool password_inited_ = false;
|
|
||||||
bool regenerate_password_ = false;
|
bool regenerate_password_ = false;
|
||||||
bool show_about_window_ = false;
|
bool show_about_window_ = false;
|
||||||
bool show_connection_status_window_ = false;
|
bool show_connection_status_window_ = false;
|
||||||
@@ -407,6 +404,7 @@ class Render {
|
|||||||
uint64_t last_frame_time_;
|
uint64_t last_frame_time_;
|
||||||
char client_id_[10] = "";
|
char client_id_[10] = "";
|
||||||
char client_id_display_[12] = "";
|
char client_id_display_[12] = "";
|
||||||
|
char client_id_with_password_[17] = "";
|
||||||
char password_saved_[7] = "";
|
char password_saved_[7] = "";
|
||||||
int language_button_value_ = 0;
|
int language_button_value_ = 0;
|
||||||
int video_quality_button_value_ = 0;
|
int video_quality_button_value_ = 0;
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ void Render::NetStatusReport(const char *client_id, size_t client_id_size,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(client_id, '@') != nullptr) {
|
if (strchr(client_id, '@') != nullptr && strchr(user_id, '-') == nullptr) {
|
||||||
std::string id, password;
|
std::string id, password;
|
||||||
const char *at_pos = strchr(client_id, '@');
|
const char *at_pos = strchr(client_id, '@');
|
||||||
if (at_pos == nullptr) {
|
if (at_pos == nullptr) {
|
||||||
@@ -485,8 +485,6 @@ void Render::NetStatusReport(const char *client_id, size_t client_id_size,
|
|||||||
password = at_pos + 1;
|
password = at_pos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERROR("{}:{}", id, password);
|
|
||||||
|
|
||||||
memset(&render->client_id_, 0, sizeof(render->client_id_));
|
memset(&render->client_id_, 0, sizeof(render->client_id_));
|
||||||
strncpy(render->client_id_, id.c_str(), sizeof(render->client_id_) - 1);
|
strncpy(render->client_id_, id.c_str(), sizeof(render->client_id_) - 1);
|
||||||
render->client_id_[sizeof(render->client_id_) - 1] = '\0';
|
render->client_id_[sizeof(render->client_id_) - 1] = '\0';
|
||||||
@@ -495,12 +493,18 @@ void Render::NetStatusReport(const char *client_id, size_t client_id_size,
|
|||||||
strncpy(render->password_saved_, password.c_str(),
|
strncpy(render->password_saved_, password.c_str(),
|
||||||
sizeof(render->password_saved_) - 1);
|
sizeof(render->password_saved_) - 1);
|
||||||
render->password_saved_[sizeof(render->password_saved_) - 1] = '\0';
|
render->password_saved_[sizeof(render->password_saved_) - 1] = '\0';
|
||||||
LOG_INFO("Use client id [{}] and save id into cache file", client_id);
|
|
||||||
|
memset(&render->client_id_with_password_, 0,
|
||||||
|
sizeof(render->client_id_with_password_));
|
||||||
|
strncpy(render->client_id_with_password_, id.c_str(),
|
||||||
|
sizeof(render->client_id_with_password_) - 1);
|
||||||
|
render->client_id_with_password_[sizeof(render->client_id_with_password_) -
|
||||||
|
1] = '\0';
|
||||||
|
|
||||||
|
LOG_INFO("Use client id [{}] and save id into cache file", id);
|
||||||
render->SaveSettingsIntoCacheFile();
|
render->SaveSettingsIntoCacheFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERROR("{}", user_id);
|
|
||||||
|
|
||||||
std::string remote_id(user_id, user_id_size);
|
std::string remote_id(user_id, user_id_size);
|
||||||
if (render->client_properties_.find(remote_id) ==
|
if (render->client_properties_.find(remote_id) ==
|
||||||
render->client_properties_.end()) {
|
render->client_properties_.end()) {
|
||||||
|
|||||||
@@ -237,7 +237,6 @@ int Render::SettingWindow() {
|
|||||||
if (!stream_window_inited_) {
|
if (!stream_window_inited_) {
|
||||||
LOG_INFO("Recreate peer instance");
|
LOG_INFO("Recreate peer instance");
|
||||||
DestroyPeer(&peer_);
|
DestroyPeer(&peer_);
|
||||||
is_create_connection_ = false;
|
|
||||||
CreateConnectionPeer();
|
CreateConnectionPeer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
thirdparty/minirtc
vendored
2
thirdparty/minirtc
vendored
Submodule thirdparty/minirtc updated: 43055872fa...3686dd0019
Reference in New Issue
Block a user