[Features] Json Format Mode

New ModeEditForm
Refactors and Cleanup
Update nuget packages
This commit is contained in:
ChsBuffer
2021-11-04 17:43:33 +08:00
parent 5826d1a1a6
commit 2d295a1449
49 changed files with 2017 additions and 1160 deletions

View File

@@ -4,10 +4,11 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Threading;
using Netch.Enums;
using Netch.Interfaces;
using Netch.Models;
using Netch.Models.Modes;
using Netch.Servers;
using Netch.Services;
using Netch.Utils;
using Serilog;
@@ -25,8 +26,6 @@ namespace Netch.Controllers
public static IModeController? ModeController { get; private set; }
public static ModeFeature ModeFeatures { get; private set; }
private static readonly AsyncSemaphore Lock = new(1);
public static async Task StartAsync(Server server, Mode mode)
@@ -49,12 +48,12 @@ namespace Netch.Controllers
try
{
(ModeController, ModeFeatures) = ModeHelper.GetModeControllerByType(mode.Type, out var modePort, out var portName);
ModeController = ModeService.GetModeControllerByType(mode.Type, out var modePort, out var portName);
if (modePort != null)
TryReleaseTcpPort((ushort)modePort, portName);
if (Server is Socks5Server socks5 && (!socks5.Auth() || ModeFeatures.HasFlag(ModeFeature.SupportSocks5Auth)))
if (Server is Socks5Server socks5 && (!socks5.Auth() || ModeController.Features.HasFlag(ModeFeature.SupportSocks5Auth)))
{
Socks5Server = socks5;
}
@@ -75,6 +74,7 @@ namespace Netch.Controllers
// Start Mode Controller
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ModeController.Name));
await ModeController.StartAsync(Socks5Server, mode);
}
catch (Exception e)
@@ -130,7 +130,6 @@ namespace Netch.Controllers
ServerController = null;
ModeController = null;
ModeFeatures = 0;
}
public static void PortCheck(ushort port, string portName, PortType portType = PortType.Both)