mirror of
https://github.com/netchx/netch.git
synced 2026-03-26 18:49:46 +08:00
尝试杀子进程后进行端口检查
This commit is contained in:
@@ -57,13 +57,32 @@ namespace Netch.Controllers
|
||||
|
||||
KillProcessByName(pEncryptedProxyController.MainFile);
|
||||
|
||||
// 检查端口是否被占用
|
||||
if (PortHelper.PortInUse(Global.Settings.Socks5LocalPort))
|
||||
{
|
||||
MessageBoxX.Show("Socks5" + i18N.Translate("port is in use."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PortHelper.PortInUse(Global.Settings.HTTPLocalPort))
|
||||
{
|
||||
MessageBoxX.Show("HTTP" + i18N.Translate("port is in use."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PortHelper.PortInUse(Global.Settings.RedirectorTCPPort, PortType.TCP))
|
||||
{
|
||||
MessageBoxX.Show("RedirectorTCP"+i18N.Translate("port is in use."));
|
||||
return false;
|
||||
}
|
||||
|
||||
Global.MainForm.StatusText(i18N.Translate("Starting ", pEncryptedProxyController.Name));
|
||||
result = pEncryptedProxyController.Start(server, mode);
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
// 加密代理已启动
|
||||
Logging.Info("加密代理已启动");
|
||||
switch (mode.Type)
|
||||
{
|
||||
case 0: // 进程代理模式
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Netch.Forms
|
||||
|
||||
if (State == State.Waiting || State == State.Stopped)
|
||||
{
|
||||
#region 服务器、模式 需选择
|
||||
// 服务器、模式 需选择
|
||||
if (ServerComboBox.SelectedIndex == -1)
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("Please select a server first"));
|
||||
@@ -36,30 +36,6 @@ namespace Netch.Forms
|
||||
MessageBoxX.Show(i18N.Translate("Please select an mode first"));
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 检查端口是否被占用
|
||||
if (PortHelper.PortInUse(Global.Settings.Socks5LocalPort))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("The Socks5 port is in use. Click OK to modify it."));
|
||||
SettingsButton.PerformClick();
|
||||
return;
|
||||
}
|
||||
|
||||
if (PortHelper.PortInUse(Global.Settings.HTTPLocalPort))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("The HTTP port is in use. Click OK to modify it."));
|
||||
SettingsButton.PerformClick();
|
||||
return;
|
||||
}
|
||||
|
||||
if (PortHelper.PortInUse(Global.Settings.RedirectorTCPPort, PortType.TCP))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("The RedirectorTCP port is in use. Click OK to modify it."));
|
||||
SettingsButton.PerformClick();
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
UpdateStatus(State.Starting);
|
||||
|
||||
|
||||
@@ -188,12 +188,7 @@
|
||||
"Exit": "退出",
|
||||
"Unable to start? Click me to download": "无法启动?点我下载依赖",
|
||||
|
||||
"The Socks5 port is in use. Click OK to modify it.": "Socks5端口已被占用,点击确定前往修改",
|
||||
"The Socks5 port is in use. Please reset.": "Socks5端口已被占用,请重新设置",
|
||||
"The HTTP port is in use. Click OK to modify it.": "HTTP端口已被占用,点击确定前往修改",
|
||||
"The HTTP port is in use. Please reset.": "HTTP端口已被占用,请重新设置",
|
||||
"The RedirectorTCP port is in use. Click OK to modify it.": "RedirectorTCP端口已被占用,点击确定前往修改",
|
||||
"The RedirectorTCP port is in use. Please reset.": "RedirectorTCP端口已被占用,请重新设置",
|
||||
"port is in use.": "端口已被占用",
|
||||
|
||||
"Bypass LAN": "[网页代理] 绕过局域网",
|
||||
"Bypass LAN (Non System Proxy)": "[网页代理] 绕过局域网(不设置系统代理)",
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Netch.Utils
|
||||
class PortHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 端口是否被使用
|
||||
/// 端口是否被使用
|
||||
/// </summary>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
@@ -16,7 +16,7 @@ namespace Netch.Utils
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定类型的端口是否已经被使用了
|
||||
/// 指定类型的端口是否已经被使用了
|
||||
/// </summary>
|
||||
/// <param name="port">端口号</param>
|
||||
/// <param name="type">端口类型</param>
|
||||
|
||||
Reference in New Issue
Block a user