mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
feat: VLESS support
This commit is contained in:
46
Netch/Servers/VLESS/VLESS.cs
Normal file
46
Netch/Servers/VLESS/VLESS.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.VMess;
|
||||
|
||||
namespace Netch.Servers.VLESS
|
||||
{
|
||||
public class VLESS : VMess.VMess
|
||||
{
|
||||
public VLESS()
|
||||
{
|
||||
Type = "VLESS";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加密方式
|
||||
/// </summary>
|
||||
public new string EncryptMethod { get; set; } = "none";
|
||||
|
||||
/// <summary>
|
||||
/// 传输协议
|
||||
/// </summary>
|
||||
public new string TransferProtocol { get; set; } = VLESSGlobal.TransferProtocols[0];
|
||||
|
||||
/// <summary>
|
||||
/// 伪装类型
|
||||
/// </summary>
|
||||
public new string FakeType { get; set; } = VLESSGlobal.FakeTypes[0];
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Flow { get; set; }
|
||||
}
|
||||
|
||||
public class VLESSGlobal
|
||||
{
|
||||
|
||||
public static List<string> TransferProtocols => VMessGlobal.TransferProtocols;
|
||||
|
||||
public static readonly List<string> FakeTypes = new List<string>
|
||||
{
|
||||
"none",
|
||||
"http"
|
||||
};
|
||||
}
|
||||
}
|
||||
36
Netch/Servers/VLESS/VLESSController.cs
Normal file
36
Netch/Servers/VLESS/VLESSController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.IO;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.Servers.VLESS
|
||||
{
|
||||
public class VLESSController : Guard, IServerController
|
||||
{
|
||||
public override string Name { get; protected set; } = "VLESS";
|
||||
public override string MainFile { get; protected set; } = "v2ray.exe";
|
||||
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
var server = (VLESS) s;
|
||||
|
||||
File.WriteAllText("data\\last.json", VMess.Utils.V2rayConfigUtils.GenerateClientConfig(server, mode));
|
||||
|
||||
if (StartInstanceAuto("-config ..\\data\\last.json"))
|
||||
{
|
||||
if (File.Exists("data\\last.json")) File.Delete("data\\last.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
StopInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
Netch/Servers/VLESS/VLESSForm/VLESSForm.cs
Normal file
46
Netch/Servers/VLESS/VLESSForm/VLESSForm.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.VLESS.VLESSForm
|
||||
{
|
||||
class VLESSForm : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "VLESS";
|
||||
|
||||
public VLESSForm(VLESS server = default)
|
||||
{
|
||||
server ??= new VLESS();
|
||||
Server = server;
|
||||
CreateTextBox("UUID", "UUID",
|
||||
s => true,
|
||||
s => server.UserID = s,
|
||||
server.UserID);
|
||||
CreateTextBox("EncryptMethod", "Encrypt Method",
|
||||
s => true,
|
||||
s => server.EncryptMethod = !string.IsNullOrWhiteSpace(s) ? s : "none",
|
||||
server.EncryptMethod);
|
||||
CreateTextBox("Flow", "Flow",
|
||||
s => true,
|
||||
s => server.Flow = s,
|
||||
server.Flow);
|
||||
CreateComboBox("TransferProtocol", "Transfer Protocol",
|
||||
VLESSGlobal.TransferProtocols,
|
||||
s => server.TransferProtocol = s,
|
||||
server.TransferProtocol);
|
||||
CreateComboBox("FakeType", "Fake Type",
|
||||
VLESSGlobal.FakeTypes,
|
||||
s => server.FakeType = s,
|
||||
server.FakeType);
|
||||
CreateTextBox("Host", "Host",
|
||||
s => true,
|
||||
s => server.Host = s,
|
||||
server.Host);
|
||||
CreateTextBox("Path", "Path",
|
||||
s => true,
|
||||
s => server.Path = s,
|
||||
server.Path);
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
b => server.TLSSecure = b,
|
||||
server.TLSSecure);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Netch/Servers/VLESS/VLESSUtil.cs
Normal file
53
Netch/Servers/VLESS/VLESSUtil.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.Servers.VLESS
|
||||
{
|
||||
public class VLESSUtil : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 2;
|
||||
public string TypeName { get; } = "VLESS";
|
||||
public string FullName { get; } = "VLESS";
|
||||
public string ShortName { get; } = "VL";
|
||||
public string[] UriScheme { get; } = { };
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
{
|
||||
return j.ToObject<VLESS>();
|
||||
}
|
||||
|
||||
public void Edit(Server s)
|
||||
{
|
||||
new VLESSForm.VLESSForm((VLESS) s).ShowDialog();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
new VLESSForm.VLESSForm().ShowDialog();
|
||||
}
|
||||
|
||||
public string GetShareLink(Server server)
|
||||
{
|
||||
// TODO
|
||||
return "";
|
||||
}
|
||||
|
||||
public IServerController GetController()
|
||||
{
|
||||
return new VLESSController();
|
||||
}
|
||||
|
||||
public IEnumerable<Server> ParseUri(string text)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool CheckServer(Server s)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user