mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] receive id and password when login to server in the first time
This commit is contained in:
@@ -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<int> 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;
|
||||
|
||||
@@ -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_,
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user