Fix password inputting issue and improve authorization
This commit is contained in:
Binary file not shown.
@@ -410,6 +410,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_NOTIFY(NM_DBLCLK, IDC_ONLINE, &CMy2015RemoteDlg::OnListClick)
|
ON_NOTIFY(NM_DBLCLK, IDC_ONLINE, &CMy2015RemoteDlg::OnListClick)
|
||||||
ON_COMMAND(ID_ONLINE_UNAUTHORIZE, &CMy2015RemoteDlg::OnOnlineUnauthorize)
|
ON_COMMAND(ID_ONLINE_UNAUTHORIZE, &CMy2015RemoteDlg::OnOnlineUnauthorize)
|
||||||
ON_COMMAND(ID_TOOL_REQUEST_AUTH, &CMy2015RemoteDlg::OnToolRequestAuth)
|
ON_COMMAND(ID_TOOL_REQUEST_AUTH, &CMy2015RemoteDlg::OnToolRequestAuth)
|
||||||
|
ON_COMMAND(ID_TOOL_INPUT_PASSWORD, &CMy2015RemoteDlg::OnToolInputPassword)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
@@ -927,7 +928,7 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
|||||||
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||||
m_nMaxConnection = nMaxConnection <= 0 ? 10000 : nMaxConnection;
|
m_nMaxConnection = nMaxConnection <= 0 ? 10000 : nMaxConnection;
|
||||||
}
|
}
|
||||||
const std::string method = THIS_CFG.GetStr("settings", "UDPOption");
|
const std::string method = THIS_CFG.GetStr("settings", "UDPOption", "0");
|
||||||
if (!Activate(nPort, m_nMaxConnection, method)){
|
if (!Activate(nPort, m_nMaxConnection, method)){
|
||||||
OnCancel();
|
OnCancel();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -948,10 +949,12 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
|||||||
ExitProcess(-1);
|
ExitProcess(-1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
int tm = THIS_CFG.GetInt("settings", "Notify", 10);
|
||||||
|
tm = min(tm, 10);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
SetTimer(TIMER_CHECK, 10 * 1000, NULL);
|
SetTimer(TIMER_CHECK, max(1, tm) * 1000, NULL);
|
||||||
#else
|
#else
|
||||||
SetTimer(TIMER_CHECK, 600 * 1000, NULL);
|
SetTimer(TIMER_CHECK, max(1, tm) * 60 * 1000, NULL);
|
||||||
#endif
|
#endif
|
||||||
IPConverter cvt;
|
IPConverter cvt;
|
||||||
CString tip = !ip.empty() && ip != cvt.getPublicIP() ?
|
CString tip = !ip.empty() && ip != cvt.getPublicIP() ?
|
||||||
@@ -1085,18 +1088,20 @@ LRESULT CMy2015RemoteDlg::OnPasswordCheck(WPARAM wParam, LPARAM lParam) {
|
|||||||
isChecking = true;
|
isChecking = true;
|
||||||
if (!CheckValid(-1))
|
if (!CheckValid(-1))
|
||||||
{
|
{
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
CInputDialog dlg(this);
|
CInputDialog dlg(this);
|
||||||
dlg.m_str = m_superPass.c_str();
|
dlg.m_str = m_superPass.c_str();
|
||||||
dlg.Init("输入密码", "输入主控程序的密码:");
|
dlg.Init("输入密码", "输入主控程序的密码:");
|
||||||
dlg.DoModal();
|
dlg.DoModal();
|
||||||
if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) {
|
if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) {
|
||||||
THIS_APP->UpdateMaxConnection(1);
|
KillTimer(TIMER_CHECK);
|
||||||
|
m_nMaxConnection = 1;
|
||||||
|
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
|
||||||
|
int tm = THIS_CFG.GetInt("settings", "Notify", 10);
|
||||||
|
THIS_CFG.SetInt("settings", "Notify", tm - 1);
|
||||||
MessageBox("请向管理员申请口令。", "提示", MB_ICONWARNING);
|
MessageBox("请向管理员申请口令。", "提示", MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_superPass = dlg.m_str.GetString();
|
m_superPass = dlg.m_str.GetString();
|
||||||
MessageBox("请及时对当前主控程序授权: 在工具菜单中生成口令!", "提示", MB_ICONWARNING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isChecking = false;
|
isChecking = false;
|
||||||
@@ -1471,7 +1476,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
|||||||
const Validation *verify = GetValidation();
|
const Validation *verify = GetValidation();
|
||||||
std::string masterHash = GetMasterHash();
|
std::string masterHash = GetMasterHash();
|
||||||
if (masterHash != GetPwdHash() && !verify->IsValid()) {
|
if (masterHash != GetPwdHash() && !verify->IsValid()) {
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
MessageBox("此程序已经失效,请联系管理员处理!", "提示", MB_ICONWARNING);
|
MessageBox("此程序已经失效,请联系管理员处理!", "提示", MB_ICONWARNING);
|
||||||
OnMainExit();
|
OnMainExit();
|
||||||
ExitProcess(-1);
|
ExitProcess(-1);
|
||||||
@@ -1488,7 +1492,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
|||||||
dlg.m_sDeviceID = deviceID.c_str();
|
dlg.m_sDeviceID = deviceID.c_str();
|
||||||
dlg.m_sPassword = pwd;
|
dlg.m_sPassword = pwd;
|
||||||
if (pwd.IsEmpty() && IDOK != dlg.DoModal() || dlg.m_sPassword.IsEmpty()) {
|
if (pwd.IsEmpty() && IDOK != dlg.DoModal() || dlg.m_sPassword.IsEmpty()) {
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1498,7 +1501,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
|||||||
{
|
{
|
||||||
THIS_CFG.SetStr(settings, pwdKey, "");
|
THIS_CFG.SetStr(settings, pwdKey, "");
|
||||||
MessageBox("格式错误,请重新申请口令!", "提示", MB_ICONINFORMATION);
|
MessageBox("格式错误,请重新申请口令!", "提示", MB_ICONINFORMATION);
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<std::string> subvector(v.end() - 4, v.end());
|
std::vector<std::string> subvector(v.end() - 4, v.end());
|
||||||
@@ -1508,10 +1510,9 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
|||||||
std::string fixedKey = getFixedLengthID(finalKey);
|
std::string fixedKey = getFixedLengthID(finalKey);
|
||||||
if (hash256 != fixedKey) {
|
if (hash256 != fixedKey) {
|
||||||
THIS_CFG.SetStr(settings, pwdKey, "");
|
THIS_CFG.SetStr(settings, pwdKey, "");
|
||||||
if (pwd.IsEmpty() || (IDOK != dlg.DoModal() || hash256 != fixedKey)) {
|
if (pwd.IsEmpty() || hash256 != fixedKey || IDOK != dlg.DoModal()) {
|
||||||
if (!dlg.m_sPassword.IsEmpty())
|
if (!dlg.m_sPassword.IsEmpty())
|
||||||
MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING);
|
MessageBox("口令错误, 无法继续操作!", "提示", MB_ICONWARNING);
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1522,11 +1523,16 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
|||||||
if (curDate < v[0] || curDate > v[1]) {
|
if (curDate < v[0] || curDate > v[1]) {
|
||||||
THIS_CFG.SetStr(settings, pwdKey, "");
|
THIS_CFG.SetStr(settings, pwdKey, "");
|
||||||
MessageBox("口令过期,请重新申请口令!", "提示", MB_ICONINFORMATION);
|
MessageBox("口令过期,请重新申请口令!", "提示", MB_ICONINFORMATION);
|
||||||
KillTimer(TIMER_CHECK);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dlg.m_sPassword != pwd)
|
if (dlg.m_sPassword != pwd)
|
||||||
THIS_CFG.SetStr(settings, pwdKey, dlg.m_sPassword.GetString());
|
THIS_CFG.SetStr(settings, pwdKey, dlg.m_sPassword.GetString());
|
||||||
|
|
||||||
|
int maxConn = v.size() == 7 ? atoi(v[2].c_str()) : 1;
|
||||||
|
if (maxConn != m_nMaxConnection) {
|
||||||
|
m_nMaxConnection = maxConn;
|
||||||
|
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2322,6 +2328,10 @@ void CMy2015RemoteDlg::OnToolAuth()
|
|||||||
dlg.DoModal();
|
dlg.DoModal();
|
||||||
if (!dlg.m_sUserPwd.IsEmpty()){
|
if (!dlg.m_sUserPwd.IsEmpty()){
|
||||||
m_superPass = dlg.m_sUserPwd;
|
m_superPass = dlg.m_sUserPwd;
|
||||||
|
if (deviceID.c_str() == dlg.m_sDeviceID) {
|
||||||
|
m_nMaxConnection = dlg.m_nHostNum;
|
||||||
|
THIS_APP->UpdateMaxConnection(m_nMaxConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2856,3 +2866,27 @@ void CMy2015RemoteDlg::OnToolRequestAuth()
|
|||||||
CString url = _T("https://github.com/yuanyuanxiang/SimpleRemoter/wiki#请求授权");
|
CString url = _T("https://github.com/yuanyuanxiang/SimpleRemoter/wiki#请求授权");
|
||||||
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL);
|
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMy2015RemoteDlg::OnToolInputPassword()
|
||||||
|
{
|
||||||
|
if (CheckValid(-1)) {
|
||||||
|
CString pwd = THIS_CFG.GetStr("settings", "Password", "").c_str();
|
||||||
|
auto v = splitString(pwd.GetBuffer(), '-');
|
||||||
|
CString info;
|
||||||
|
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)) {
|
||||||
|
CInputDialog dlg(this);
|
||||||
|
dlg.m_str = pwd;
|
||||||
|
dlg.Init("更改口令", "请输入新的口令:");
|
||||||
|
if (dlg.DoModal() == IDOK) {
|
||||||
|
THIS_CFG.SetStr("settings", "Password", dlg.m_str.GetString());
|
||||||
|
#ifdef _DEBUG
|
||||||
|
SetTimer(TIMER_CHECK, 10 * 1000, NULL);
|
||||||
|
#else
|
||||||
|
SetTimer(TIMER_CHECK, 600 * 1000, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -264,4 +264,5 @@ public:
|
|||||||
afx_msg void OnOnlineUnauthorize();
|
afx_msg void OnOnlineUnauthorize();
|
||||||
afx_msg void OnToolRequestAuth();
|
afx_msg void OnToolRequestAuth();
|
||||||
afx_msg LRESULT OnPasswordCheck(WPARAM wParam, LPARAM lParam);
|
afx_msg LRESULT OnPasswordCheck(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg void OnToolInputPassword();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ BOOL CBuildDlg::OnInitDialog()
|
|||||||
m_ComboExe.InsertString(IndexGhost, "ghost.exe");
|
m_ComboExe.InsertString(IndexGhost, "ghost.exe");
|
||||||
m_ComboExe.InsertString(IndexServerDll, "ServerDll.dll");
|
m_ComboExe.InsertString(IndexServerDll, "ServerDll.dll");
|
||||||
m_ComboExe.InsertString(OTHER_ITEM, CString("ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>"));
|
m_ComboExe.InsertString(OTHER_ITEM, CString("ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>"));
|
||||||
m_ComboExe.SetCurSel(0);
|
m_ComboExe.SetCurSel(IndexTestRun_MemDLL);
|
||||||
|
|
||||||
m_ComboBits.InsertString(0, "64λ");
|
m_ComboBits.InsertString(0, "64λ");
|
||||||
m_ComboBits.InsertString(1, "32λ");
|
m_ComboBits.InsertString(1, "32λ");
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
|
|||||||
DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID);
|
DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID);
|
||||||
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
||||||
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
||||||
DDV_MaxChars(pDX, m_sPassword, 37);
|
DDV_MaxChars(pDX, m_sPassword, 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX)
|
|||||||
DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID);
|
DDX_Text(pDX, IDC_EDIT_DEVICEID, m_sDeviceID);
|
||||||
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
DDV_MaxChars(pDX, m_sDeviceID, 19);
|
||||||
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
DDX_Text(pDX, IDC_EDIT_DEVICEPWD, m_sPassword);
|
||||||
DDV_MaxChars(pDX, m_sPassword, 37);
|
DDV_MaxChars(pDX, m_sPassword, 42);
|
||||||
DDX_Text(pDX, IDC_EDIT_USERPWD, m_sUserPwd);
|
DDX_Text(pDX, IDC_EDIT_USERPWD, m_sUserPwd);
|
||||||
DDV_MaxChars(pDX, m_sUserPwd, 24);
|
DDV_MaxChars(pDX, m_sUserPwd, 24);
|
||||||
DDX_Control(pDX, IDC_EXPIRE_DATE, m_PwdExpireDate);
|
DDX_Control(pDX, IDC_EXPIRE_DATE, m_PwdExpireDate);
|
||||||
@@ -153,7 +153,7 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX)
|
|||||||
DDX_DateTimeCtrl(pDX, IDC_START_DATE, m_StartTm);
|
DDX_DateTimeCtrl(pDX, IDC_START_DATE, m_StartTm);
|
||||||
DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum);
|
DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum);
|
||||||
DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum);
|
DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum);
|
||||||
DDV_MinMaxInt(pDX, m_nHostNum, 1, 9999);
|
DDV_MinMaxInt(pDX, m_nHostNum, 1, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ BOOL CInputDialog::OnInitDialog()
|
|||||||
|
|
||||||
SetWindowText(m_sCaption);
|
SetWindowText(m_sCaption);
|
||||||
GetDlgItem(IDC_STATIC)->SetWindowText(m_sPrompt);
|
GetDlgItem(IDC_STATIC)->SetWindowText(m_sPrompt);
|
||||||
|
GetDlgItem(IDC_EDIT_FOLDERNAME)->SetWindowText(m_str);
|
||||||
|
|
||||||
m_Static2thInput.SetWindowTextA(m_sItemName);
|
m_Static2thInput.SetWindowTextA(m_sItemName);
|
||||||
m_Static2thInput.ShowWindow(m_sItemName.IsEmpty() ? SW_HIDE : SW_SHOW);
|
m_Static2thInput.ShowWindow(m_sItemName.IsEmpty() ? SW_HIDE : SW_SHOW);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ BOOL CSettingDlg::OnInitDialog()
|
|||||||
m_sPublicIP = THIS_CFG.GetStr("settings", "master", "").c_str();
|
m_sPublicIP = THIS_CFG.GetStr("settings", "master", "").c_str();
|
||||||
m_sPublicIP = m_sPublicIP.IsEmpty() ? cvt.getPublicIP().c_str() : m_sPublicIP;
|
m_sPublicIP = m_sPublicIP.IsEmpty() ? cvt.getPublicIP().c_str() : m_sPublicIP;
|
||||||
std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543");
|
std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543");
|
||||||
m_sUdpOption = THIS_CFG.GetStr("settings", "UDPOption", "").c_str();
|
m_sUdpOption = THIS_CFG.GetStr("settings", "UDPOption", "0").c_str();
|
||||||
|
|
||||||
int DXGI = THIS_CFG.GetInt("settings", "DXGI");
|
int DXGI = THIS_CFG.GetInt("settings", "DXGI");
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user