diff --git a/src/single_window/local_peer_window.cpp b/src/single_window/local_peer_window.cpp index 9d2dab6..6d3c200 100644 --- a/src/single_window/local_peer_window.cpp +++ b/src/single_window/local_peer_window.cpp @@ -135,28 +135,6 @@ int Render::LocalWindow() { ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH); ImGui::Spacing(); - if (!password_inited_) { - char a[] = { - "123456789QWERTYUPASDFGHJKLZXCVBNMqwertyupasdfghijkzxcvbnm"}; - std::mt19937 generator((unsigned int)std::chrono::system_clock::now() - .time_since_epoch() - .count()); - std::uniform_int_distribution distribution(0, - (int)(strlen(a) - 1)); - - random_password_.clear(); - for (int i = 0; i < 6; i++) { - random_password_ += a[distribution(generator)]; - } - password_inited_ = true; - if (0 != strcmp(random_password_.c_str(), password_saved_)) { - memcpy(password_saved_, random_password_.c_str(), - sizeof(password_saved_)); - LOG_INFO("Generate new password and save into cache file"); - SaveSettingsIntoCacheFile(); - } - } - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::InputTextWithHint( "##server_pwd", @@ -281,10 +259,6 @@ int Render::LocalWindow() { focus_on_input_widget_ = true; } else { show_reset_password_window_ = false; - LOG_INFO("Generate new password and save into cache file"); - memcpy(password_saved_, new_password_, sizeof(password_saved_)); - memset(new_password_, 0, sizeof(new_password_)); - SaveSettingsIntoCacheFile(); LeaveConnection(peer_, client_id_); is_create_connection_ = false; focus_on_input_widget_ = true; diff --git a/src/single_window/render.cpp b/src/single_window/render.cpp index 272dc70..cf0aca3 100644 --- a/src/single_window/render.cpp +++ b/src/single_window/render.cpp @@ -569,8 +569,9 @@ int Render::CreateMainWindow() { ImGui::SetCurrentContext(main_ctx_); - SDL_WindowFlags window_flags = (SDL_WindowFlags)( - SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN); + SDL_WindowFlags window_flags = + (SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS | + SDL_WINDOW_HIDDEN); main_window_ = SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (int)main_window_width_default_, diff --git a/src/single_window/render_callback_func.cpp b/src/single_window/render_callback_func.cpp index 5b8e476..868672d 100644 --- a/src/single_window/render_callback_func.cpp +++ b/src/single_window/render_callback_func.cpp @@ -474,13 +474,33 @@ void Render::NetStatusReport(const char *client_id, size_t client_id_size, return; } - if (0 == strcmp(render->client_id_, "")) { + if (strchr(client_id, '@') != nullptr) { + std::string id, password; + const char *at_pos = strchr(client_id, '@'); + if (at_pos == nullptr) { + id = client_id; + password.clear(); + } else { + id.assign(client_id, at_pos - client_id); + password = at_pos + 1; + } + + LOG_ERROR("{}:{}", id, password); + memset(&render->client_id_, 0, sizeof(render->client_id_)); - memcpy(render->client_id_, client_id, client_id_size); + strncpy(render->client_id_, id.c_str(), sizeof(render->client_id_) - 1); + render->client_id_[sizeof(render->client_id_) - 1] = '\0'; + + memset(&render->password_saved_, 0, sizeof(render->password_saved_)); + strncpy(render->password_saved_, password.c_str(), + sizeof(render->password_saved_) - 1); + render->password_saved_[sizeof(render->password_saved_) - 1] = '\0'; LOG_INFO("Use client id [{}] and save id into cache file", client_id); render->SaveSettingsIntoCacheFile(); } + LOG_ERROR("{}", user_id); + std::string remote_id(user_id, user_id_size); if (render->client_properties_.find(remote_id) == render->client_properties_.end()) { diff --git a/thirdparty/minirtc b/thirdparty/minirtc index 3317657..4305587 160000 --- a/thirdparty/minirtc +++ b/thirdparty/minirtc @@ -1 +1 @@ -Subproject commit 331765760243f5ab817dc085fa3ab3ef4ba9da8b +Subproject commit 43055872fa5c1b55096d607673693492df63c56f