mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-23 15:53:10 +08:00
Fix: Master Authorization issue while password binding domain
This commit is contained in:
@@ -360,8 +360,10 @@ std::string CMy2015RemoteDlg::GetHardwareID(int v)
|
|||||||
{
|
{
|
||||||
int version = v == -1 ? THIS_CFG.GetInt("settings", "BindType", 0) : v;
|
int version = v == -1 ? THIS_CFG.GetInt("settings", "BindType", 0) : v;
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 0:
|
case 0: {
|
||||||
return getHardwareID();
|
static auto hardwareID = getHardwareID();
|
||||||
|
return hardwareID;
|
||||||
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
std::string master = THIS_CFG.GetStr("settings", "master");
|
std::string master = THIS_CFG.GetStr("settings", "master");
|
||||||
if (!master.empty()) return master;
|
if (!master.empty()) return master;
|
||||||
@@ -2024,9 +2026,9 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
auto settings = "settings", pwdKey = "Password";
|
auto settings = "settings", pwdKey = "Password";
|
||||||
// 验证口令
|
// 验证口令
|
||||||
CPasswordDlg dlg(this);
|
CPasswordDlg dlg(this);
|
||||||
static std::string hardwareID = GetHardwareID();
|
std::string hardwareID = GetHardwareID();
|
||||||
static std::string hashedID = hashSHA256(hardwareID);
|
std::string hashedID = hashSHA256(hardwareID);
|
||||||
static std::string deviceID = getFixedLengthID(hashedID);
|
std::string deviceID = getFixedLengthID(hashedID);
|
||||||
CString pwd = THIS_CFG.GetStr(settings, pwdKey, "").c_str();
|
CString pwd = THIS_CFG.GetStr(settings, pwdKey, "").c_str();
|
||||||
|
|
||||||
dlg.m_sDeviceID = deviceID.c_str();
|
dlg.m_sDeviceID = deviceID.c_str();
|
||||||
@@ -2034,6 +2036,7 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
if (pwd.IsEmpty() && IDOK != dlg.DoModal() || dlg.m_sPassword.IsEmpty()) {
|
if (pwd.IsEmpty() && IDOK != dlg.DoModal() || dlg.m_sPassword.IsEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
deviceID = dlg.m_sDeviceID.GetBuffer();
|
||||||
|
|
||||||
// 密码形式:20250209 - 20350209: SHA256: HostNum
|
// 密码形式:20250209 - 20350209: SHA256: HostNum
|
||||||
auto v = splitString(dlg.m_sPassword.GetBuffer(), '-');
|
auto v = splitString(dlg.m_sPassword.GetBuffer(), '-');
|
||||||
@@ -2052,7 +2055,7 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
THIS_CFG.SetStr(settings, "PwdHmac", "");
|
THIS_CFG.SetStr(settings, "PwdHmac", "");
|
||||||
if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) {
|
if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) {
|
||||||
if (!dlg.m_sPassword.IsEmpty())
|
if (!dlg.m_sPassword.IsEmpty())
|
||||||
THIS_APP->MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING);
|
THIS_APP->MessageBox("口令错误, 无法继续操作!\r\n请通过工具菜单重新输入口令。", "提示", MB_ICONWARNING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2077,6 +2080,11 @@ bool CMy2015RemoteDlg::CheckValid(int trail)
|
|||||||
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
|
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef _DEBUG
|
||||||
|
SetTimer(TIMER_CHECK, 10 * 1000, NULL);
|
||||||
|
#else
|
||||||
|
SetTimer(TIMER_CHECK, 600 * 1000, NULL);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3805,13 +3813,16 @@ void CMy2015RemoteDlg::OnToolInputPassword()
|
|||||||
CString info;
|
CString info;
|
||||||
info.Format("软件有效期限: %s — %s, 并发连接数量: %d.", v[0].c_str(), v[1].c_str(), atoi(v[2].c_str()));
|
info.Format("软件有效期限: %s — %s, 并发连接数量: %d.", v[0].c_str(), v[1].c_str(), atoi(v[2].c_str()));
|
||||||
if (IDYES == MessageBoxA(info + "\n如需修改授权信息,请联系管理员。是否现在修改授权?", "提示", MB_YESNO | MB_ICONINFORMATION)) {
|
if (IDYES == MessageBoxA(info + "\n如需修改授权信息,请联系管理员。是否现在修改授权?", "提示", MB_YESNO | MB_ICONINFORMATION)) {
|
||||||
CInputDialog dlg(this);
|
CPasswordDlg dlg(this);
|
||||||
dlg.m_str = pwd;
|
std::string hardwareID = GetHardwareID();
|
||||||
dlg.Init("更改口令", "请输入新的口令:");
|
std::string hashedID = hashSHA256(hardwareID);
|
||||||
dlg.Init2("校验码 (HMAC):", THIS_CFG.GetStr("settings", "PwdHmac", "").c_str());
|
std::string deviceID = getFixedLengthID(hashedID);
|
||||||
if (dlg.DoModal() == IDOK) {
|
dlg.m_sDeviceID = deviceID.c_str();
|
||||||
THIS_CFG.SetStr("settings", "Password", dlg.m_str.GetString());
|
dlg.m_sPassword = THIS_CFG.GetStr("settings", "Password", "").c_str();
|
||||||
THIS_CFG.SetStr("settings", "PwdHmac", dlg.m_sSecondInput.GetString());
|
dlg.m_sPasscodeHmac = THIS_CFG.GetStr("settings", "PwdHmac", "").c_str();
|
||||||
|
if (IDOK == dlg.DoModal() && !dlg.m_sPassword.IsEmpty()) {
|
||||||
|
THIS_CFG.SetStr("settings", "Password", dlg.m_sPassword.GetString());
|
||||||
|
THIS_CFG.SetStr("settings", "PwdHmac", dlg.m_sPasscodeHmac.GetString());
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
SetTimer(TIMER_CHECK, 10 * 1000, NULL);
|
SetTimer(TIMER_CHECK, 10 * 1000, NULL);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user