HTTPController.Stop check state validity

This commit is contained in:
ChsBuffer
2021-03-08 09:05:51 +08:00
parent 4b3d6fb3bf
commit 1aa32eaf3a
2 changed files with 22 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ namespace Netch.Controllers
Global.Settings.Pac_Port = PortHelper.GetAvailablePort();
}
pacUrl = PACServerHandle.InitPACServer("127.0.0.1");
pacUrl = PACServerHandle.InitPACServer();
}
if (mode.Type is 3)
@@ -76,7 +76,22 @@ namespace Netch.Controllers
if (_oldState != null)
{
using var service = new ProxyService();
service.Set(_oldState!);
try
{
if (_oldState.IsProxy && _oldState.ProxyServer == service.Query().ProxyServer ||
_oldState.IsAutoProxyUrl && _oldState.AutoConfigUrl!.StartsWith(PACServerHandle.PacPrefix))
{
service.Direct();
return;
}
service.Set(_oldState);
}
catch
{
service.Direct();
throw;
}
}
})
};