mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
refactor: Add in keyword as need
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Netch.Controllers
|
||||
/// </summary>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否启动成功</returns>
|
||||
public bool Start(Mode mode)
|
||||
public bool Start(in Mode mode)
|
||||
{
|
||||
RecordPrevious();
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace Netch.Controllers
|
||||
/// </summary>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否成功</returns>
|
||||
public abstract bool Start(Mode mode);
|
||||
public abstract bool Start(in Mode mode);
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ namespace Netch.Controllers
|
||||
/// <summary>
|
||||
/// 启动
|
||||
/// </summary>
|
||||
/// <param name="server">服务器</param>
|
||||
/// <param name="s">服务器</param>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否启动成功</returns>
|
||||
public abstract bool Start(Server server, Mode mode);
|
||||
public abstract bool Start(in Server s, in Mode mode);
|
||||
}
|
||||
|
||||
public static class ServerControllerExtension
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Netch.Controllers
|
||||
PortCheckAndShowMessageBox(controller.Socks5LocalPort(), "Socks5");
|
||||
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", controller.Name));
|
||||
if (controller.Start(server, mode))
|
||||
if (controller.Start(in server, mode))
|
||||
{
|
||||
UsingPorts.Add(StatusPortInfoText.Socks5Port = controller.Socks5LocalPort());
|
||||
StatusPortInfoText.ShareLan = controller.LocalAddress == "0.0.0.0";
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Netch.Controllers
|
||||
BinDriver = "bin\\" + fileName;
|
||||
}
|
||||
|
||||
public bool Start(Mode mode)
|
||||
public bool Start(in Mode mode)
|
||||
{
|
||||
Logging.Info("内置驱动版本: " + Utils.Utils.GetFileVersion(BinDriver));
|
||||
if (Utils.Utils.GetFileVersion(SystemDriver) != Utils.Utils.GetFileVersion(BinDriver))
|
||||
@@ -80,7 +80,7 @@ namespace Netch.Controllers
|
||||
return aio_init();
|
||||
}
|
||||
|
||||
private void SetServer(IServerController controller, PortType portType)
|
||||
private void SetServer(in IServerController controller, in PortType portType)
|
||||
{
|
||||
if (portType == PortType.Both)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Netch.Controllers
|
||||
public override string Name { get; protected set; } = "tun2socks";
|
||||
public override string MainFile { get; protected set; } = "tun2socks.exe";
|
||||
|
||||
public bool Start(Mode mode)
|
||||
public bool Start(in Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
_savedServer = MainController.ServerController.Server;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
string[] UriScheme { get; }
|
||||
|
||||
Server ParseJObject(JObject j);
|
||||
Server ParseJObject(in JObject j);
|
||||
|
||||
public void Edit(Server s);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Netch.Servers.Shadowsocks
|
||||
private Mode _savedMode;
|
||||
public bool DllFlag => Global.Settings.BootShadowsocksFromDLL && (_savedMode.Type == 0 || _savedMode.Type == 1 || _savedMode.Type == 2);
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
Server = s;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Netch.Servers.Shadowsocks
|
||||
public string ShortName { get; } = "SS";
|
||||
public string[] UriScheme { get; } = {"ss", "ssd"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<Shadowsocks>();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Netch.Servers.ShadowsocksR
|
||||
public ushort? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (ShadowsocksR) s;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Netch.Servers.ShadowsocksR
|
||||
public string ShortName { get; } = "SR";
|
||||
public string[] UriScheme { get; } = {"ssr"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<ShadowsocksR>();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Netch.Servers.Socks5
|
||||
public override string Name { get; protected set; } = "Socks5";
|
||||
public override string MainFile { get; protected set; } = "v2ray.exe";
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (Socks5) s;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Netch.Servers.Socks5
|
||||
public string ShortName { get; } = "S5";
|
||||
public string[] UriScheme { get; } = { };
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<Socks5>();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Netch.Servers.Trojan
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s, in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
var server = (Trojan) s;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Netch.Servers.Trojan
|
||||
public string ShortName { get; } = "TR";
|
||||
public string[] UriScheme { get; } = {"trojan"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<Trojan>();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Netch.Servers.VLESS
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s,in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Netch.Servers.VLESS
|
||||
public string ShortName { get; } = "VL";
|
||||
public string[] UriScheme { get; } = { };
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<VLESS>();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Netch.Servers.VMess
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
public bool Start(in Server s,in Mode mode)
|
||||
{
|
||||
Server = s;
|
||||
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Netch.Servers.VMess
|
||||
public string ShortName { get; } = "V2";
|
||||
public string[] UriScheme { get; } = {"vmess"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<VMess>();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Netch.Utils
|
||||
/// <summary>
|
||||
/// 根据程序名统计流量
|
||||
/// </summary>
|
||||
public static void NetTraffic(Server server, Mode mode)
|
||||
public static void NetTraffic(in Server server, in Mode mode)
|
||||
{
|
||||
if (!Global.Flags.IsWindows10Upper)
|
||||
return;
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Netch.Utils
|
||||
return list;
|
||||
}
|
||||
|
||||
private static IEnumerable<Server> ParseUri(string text)
|
||||
private static IEnumerable<Server> ParseUri(in string text)
|
||||
{
|
||||
var list = new List<Server>();
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace Netch.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static void ComponentIterator(Component component, Action<Component> func)
|
||||
public static void ComponentIterator(in Component component, in Action<Component> func)
|
||||
{
|
||||
func.Invoke(component);
|
||||
switch (component)
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Netch.Utils
|
||||
return translateFile;
|
||||
}
|
||||
|
||||
public static void TranslateForm(Control c)
|
||||
public static void TranslateForm(in Control c)
|
||||
{
|
||||
Utils.ComponentIterator(c, component =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user