Fix: keep the local FRP address and align the MCP read-only preset
A subordinate that already runs its own FRP proxy must keep advertising its own master address: the upstream auto FRP is only a fallback entry and should not overwrite the address baked into generated clients and kernel payloads. GetEffectiveMasterAddress now returns the local address when [frp] UseFrp is on and a master address is configured; otherwise the upstream address is used exactly as before. The startup banner, the hot switch tips and the settings dialog follow the same rule, and the dialog now explains under the field when the address is supplied by the upstream FRP. The MCP settings dialog's read-only preset now unchecks every other tool switch (file transfer, host management, chat, keylog), matching the smart preset and the first-open state; previously Smart followed by Read-only left those four checked. The FRP auto-proxy messages now go through _TRF and the three language files carry the new local-FRP variants and the upstream-address hint. Verified: build.cmd server passes; the default (no local FRP) path is unchanged. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
a6c417a061
commit
b0e172bf91
7 files changed
+58
-8
No files matched your search
@@ -3086,6 +3086,18 @@ static bool IsFrpSupported(const char* logPrefix = nullptr)
|
||||
return true;
|
||||
}
|
||||
|
||||
// 本地是否已启用自有 FRP(主菜单设置:UseFrp + 主控地址)。
|
||||
// 本地 FRP 只在 64 位主控上启动;32 位恒为未启用。
|
||||
bool CMy2015RemoteDlg::IsLocalFrpEnabled()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
if (THIS_CFG.GetInt("frp", "UseFrp", 0) == 0) return false;
|
||||
return !THIS_CFG.GetStr("settings", "master", "").empty();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::InitFrpClients()
|
||||
{
|
||||
// 显示初始化消息
|
||||
@@ -3103,7 +3115,7 @@ void CMy2015RemoteDlg::InitFrpClients()
|
||||
std::string ip = THIS_CFG.GetStr("settings", "master", "");
|
||||
|
||||
CString tip;
|
||||
if (hasUpperFrp) {
|
||||
if (hasUpperFrp && !IsLocalFrpEnabled()) {
|
||||
// 使用上级配置的 FRP,无需关心公网 IP
|
||||
tip = _L("使用上级配置的FRP代理");
|
||||
} else {
|
||||
@@ -3432,6 +3444,11 @@ bool CMy2015RemoteDlg::GetEffectiveMasterAddress(std::string& outIP, int& outPor
|
||||
if (!frpConfigStr.empty()) {
|
||||
FrpAutoConfig frpCfg = ParseFrpAutoConfig(frpConfigStr, heartbeat);
|
||||
if (frpCfg.enabled && frpCfg.remotePort > 0) {
|
||||
// 本地已启用自有 FRP 时保持本地地址:上级自动 FRP 只是备用入口,
|
||||
// 不再覆盖生成客户端/内核载荷里的主控地址。
|
||||
if (IsLocalFrpEnabled()) {
|
||||
return false;
|
||||
}
|
||||
outIP = frpCfg.serverAddr;
|
||||
outPort = frpCfg.remotePort;
|
||||
return true; // 使用了 FRP 地址
|
||||
@@ -3729,7 +3746,11 @@ void CMy2015RemoteDlg::CheckUpperFrpConfigChange()
|
||||
// 首次:从无到有 → 启动
|
||||
if (newCfg.enabled) {
|
||||
StartFrpcAuto(newCfg);
|
||||
tip.FormatL("[FRP] 已启用上级 FRP 反向代理(远程端口 %d),已生效", newPort);
|
||||
if (IsLocalFrpEnabled()) {
|
||||
tip.Format(_TRF("[FRP] 已启用上级 FRP 反向代理(远程端口 %d);本地 FRP 已启用,主控地址保持不变"), newPort);
|
||||
} else {
|
||||
tip.Format(_TRF("[FRP] 已启用上级 FRP 反向代理(远程端口 %d),已生效"), newPort);
|
||||
}
|
||||
} else {
|
||||
// 新配置无效,但 cur 非空 —— 提示但不启动;同时确保 [frp_auto] 不残留旧值
|
||||
ClearFrpAutoSection();
|
||||
@@ -3745,8 +3766,13 @@ void CMy2015RemoteDlg::CheckUpperFrpConfigChange()
|
||||
StopFrpcAuto();
|
||||
if (newCfg.enabled) {
|
||||
StartFrpcAuto(newCfg); // 内部会用新值覆盖 [frp_auto]
|
||||
tip.FormatL("[FRP] 上级 FRP 反向代理配置已切换(远程端口 %d → %d),已生效",
|
||||
oldPort, newPort);
|
||||
if (IsLocalFrpEnabled()) {
|
||||
tip.Format(_TRF("[FRP] 上级 FRP 反向代理配置已切换(远程端口 %d → %d);本地 FRP 已启用,主控地址保持不变"),
|
||||
oldPort, newPort);
|
||||
} else {
|
||||
tip.Format(_TRF("[FRP] 上级 FRP 反向代理配置已切换(远程端口 %d → %d),已生效"),
|
||||
oldPort, newPort);
|
||||
}
|
||||
} else {
|
||||
// 新配置无效(解析失败等),旧的 FRPC 已停,[frp_auto] 必须一并清空
|
||||
ClearFrpAutoSection();
|
||||
|
||||
Reference in new issue
Block a user