Feat: TLS certificate menu and config dialog for the MFC server
Add a "TLS证书" item to the Extensions menu below "MCP设置" that opens a runtime-built dialog to enable one-way TLS and set the certificate and private-key paths. On OK it writes the [tls] Enabled/CertPath/KeyPath keys and calls ServerTlsIdentity::Load() so the change takes effect for new connections immediately (design doc §7.1), mirroring the existing CMcpSettingsDlg runtime-template pattern. All new strings are wired into the en_US / zh_TW / de_DE language files, and the menu item is gated by HIDE_MENU_TLS_CERTIFICATE / MF_TLS_CERTIFICATE like MCP settings. Co-Authored-By: deepseek-v4-pro
This commit is contained in:
1 parent
96b9eea70a
commit
c93f09e9ac
12 files changed
+351
-2
No files matched your search
@@ -50,6 +50,7 @@
|
||||
#include "CFileSpeedDlg.h"
|
||||
#include "McpServer.h"
|
||||
#include "McpSettingsDlg.h"
|
||||
#include "TlsCertificateDlg.h"
|
||||
#include "common/md5.h"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@@ -1059,6 +1060,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_COMMAND(ID_TOOL_RELOAD_PLUGINS, &CMy2015RemoteDlg::OnToolReloadPlugins)
|
||||
ON_COMMAND(ID_TOOL_PLUGIN_SETTINGS, &CMy2015RemoteDlg::OnToolPluginSettings)
|
||||
ON_COMMAND(ID_MCP_SETTINGS, &CMy2015RemoteDlg::OnMcpSettings)
|
||||
ON_COMMAND(ID_TLS_CERTIFICATE, &CMy2015RemoteDlg::OnTlsCertificate)
|
||||
ON_COMMAND(ID_CONNECTION_MANAGE, &CMy2015RemoteDlg::OnConnectionManage)
|
||||
ON_COMMAND(ID_TALK_MANAGE, &CMy2015RemoteDlg::OnChat)
|
||||
ON_COMMAND(ID_MACHINE_MANAGE, &CMy2015RemoteDlg::OnMachineManager)
|
||||
@@ -1323,6 +1325,17 @@ VOID CMy2015RemoteDlg::CreateSolidMenu()
|
||||
ID_MCP_SETTINGS, _TR("MCP设置(&M)..."));
|
||||
}
|
||||
|
||||
// 动态插入「TLS证书」菜单项,位于「MCP设置」之后、「插件设置」之前(对同一锚点
|
||||
// ID_TOOL_PLUGIN_SETTINGS 二次 InsertMenu,后插者更贴近锚点,故排在 MCP 下方)。
|
||||
if (!SHOULD_HIDE_MENU(HIDE_MENU_TLS_CERTIFICATE, MF_TLS_CERTIFICATE)) {
|
||||
UINT tlsFlags = MF_BYCOMMAND;
|
||||
if (THIS_CFG.GetInt("tls", "Enabled", 0)) {
|
||||
tlsFlags |= MF_CHECKED; // 已启用 TLS 则菜单打勾
|
||||
}
|
||||
pExtMenu->InsertMenu(ID_TOOL_PLUGIN_SETTINGS, tlsFlags,
|
||||
ID_TLS_CERTIFICATE, _TR("TLS证书(&T)..."));
|
||||
}
|
||||
|
||||
// 将 3 个插件相关菜单项收拢到「插件」二级菜单(位于「MCP设置」之下、原「插件设置」之前,
|
||||
// 顺序不变:插件设置 / 刷新插件 / 获取插件)。
|
||||
// 注意:先删除顶层项、再按位置插入子菜单,避免同一命令 ID 同时存在于子菜单与顶层时,
|
||||
@@ -11558,6 +11571,21 @@ void CMy2015RemoteDlg::OnMcpSettings()
|
||||
ApplyFrpSettings();
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::OnTlsCertificate()
|
||||
{
|
||||
CTlsCertificateDlg dlg(this);
|
||||
if (dlg.DoModal() != IDOK) return;
|
||||
|
||||
// 对话框内已写入 [tls] 三键并调 ServerTlsIdentity::Load(THIS_CFG) 热重载,
|
||||
// 对新建连接即时生效(设计文档 §7.1)。
|
||||
// 菜单在启动时只构建一次(CreateSolidMenu),勾选状态不会自动刷新,
|
||||
// 这里同步「扩展」菜单上「TLS证书」的勾选,使其与 [tls] Enabled 一致。
|
||||
if (CMenu* pExtMenu = m_MainMenu.GetSubMenu(3)) {
|
||||
pExtMenu->CheckMenuItem(ID_TLS_CERTIFICATE, MF_BYCOMMAND |
|
||||
(THIS_CFG.GetInt("tls", "Enabled", 0) ? MF_CHECKED : MF_UNCHECKED));
|
||||
}
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::OnConnectionManage()
|
||||
{
|
||||
BYTE cmd = COMMAND_CONNECTION;
|
||||
|
||||
Reference in new issue
Block a user