From cdc428d1f65f18d445d1eb02ba3d4ca03e334417 Mon Sep 17 00:00:00 2001 From: QxQ <59914293+U-v-U@users.noreply.github.com> Date: Sun, 11 Oct 2020 22:00:55 +0800 Subject: [PATCH] update: updated port detection error message --- makespec/BUILDVERSION | 2 +- src/core/handler/KernelInstanceHandler.cpp | 22 +++++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index 4a915824..55b68d76 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -5985 +5986 diff --git a/src/core/handler/KernelInstanceHandler.cpp b/src/core/handler/KernelInstanceHandler.cpp index a91d6d3e..d5d07b11 100644 --- a/src/core/handler/KernelInstanceHandler.cpp +++ b/src/core/handler/KernelInstanceHandler.cpp @@ -41,30 +41,22 @@ namespace Qv2ray::core::handler std::optional KernelInstanceHandler::CheckPort(const QMap &info, int plugins) { - // - // Check inbound port allocation issue. QStringList portDetectionErrorMessage; - auto portDetectionMsg = tr("Another process is using the port required to start the connection:") + NEWLINE + NEWLINE; + auto portDetectionMsg = tr("There are other processes occupying the ports necessary to start the connection:") + NEWLINE + NEWLINE; for (const auto &key : info.keys()) { - auto result = components::port::CheckTCPPortStatus(info[key].address, info[key].port); + const auto result = components::port::CheckTCPPortStatus(info[key].address, info[key].port); if (!result) - { - portDetectionErrorMessage << tr("Port: %1 for listening IP: %2 for inbound tag: \"%3\"") // - .arg(info[key].port) - .arg(info[key].address) - .arg(key); - } + portDetectionErrorMessage << tr("Endpoint: %1:%2 for inbound: \"%3\"").arg(info[key].address).arg(info[key].port).arg(key); } if (GlobalConfig.pluginConfig.v2rayIntegration) { - for (int i = 0; i < plugins; i++) + for (auto i = 0; i < plugins; i++) { - auto result = components::port::CheckTCPPortStatus("127.0.0.1", GlobalConfig.pluginConfig.portAllocationStart + i); + const auto thisPort = GlobalConfig.pluginConfig.portAllocationStart + i; + const auto result = components::port::CheckTCPPortStatus("127.0.0.1", thisPort); if (!result) - { - portDetectionErrorMessage << tr("Port: %1 for plugin integration.").arg(GlobalConfig.pluginConfig.portAllocationStart + i); - } + portDetectionErrorMessage << tr("Local port: %1 for plugin integration.").arg(thisPort); } } if (!portDetectionErrorMessage.isEmpty())