Add files via upload

This commit is contained in:
Netch
2021-06-15 21:44:03 +08:00
commit 334c9ba7a7
83 changed files with 3785 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
namespace Netch.Models.Config
{
public class AioDNS
{
/// <summary>
/// 国内 DNS 地址
/// </summary>
public string ChinaDNS = "tcp://119.29.29.29:53";
/// <summary>
/// 国外 DNS 地址
/// </summary>
public string OtherDNS = "tls://1.1.1.1:853";
}
}

View File

@@ -0,0 +1,73 @@
using System.Collections.Generic;
namespace Netch.Models.Config
{
public class Config
{
/// <summary>
/// 配置 版本
/// </summary>
[Newtonsoft.Json.JsonProperty("verCode")]
public int VerCode = 1;
/// <summary>
/// 通用 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("generic")]
public Generic Generic = new();
/// <summary>
/// 端口 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("ports")]
public Ports Ports = new();
/// <summary>
/// ProcessMode 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("processmode")]
public ProcessMode ProcessMode = new();
/// <summary>
/// ShareMode 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("sharemode")]
public ShareMode ShareMode = new();
/// <summary>
/// TapMode 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("tapmode")]
public TapMode TapMode = new();
/// <summary>
/// TunMode 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("tunmode")]
public TunMode TunMode = new();
/// <summary>
/// AioDNS 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("aiodns")]
public AioDNS AioDNS = new();
/// <summary>
/// V2Ray 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("v2ray")]
public V2Ray V2Ray = new();
/// <summary>
/// STUN 配置
/// </summary>
[Newtonsoft.Json.JsonProperty("stun")]
public STUN STUN = new();
/// <summary>
/// 订阅链接
/// </summary>
[Newtonsoft.Json.JsonProperty("subscriptions")]
public List<Subscription> Subscriptions = new();
}
}

View File

@@ -0,0 +1,15 @@
namespace Netch.Models.Config
{
public class Generic
{
/// <summary>
/// 检查 Unstable 更新
/// </summary>
public bool Unstable = false;
/// <summary>
/// 使用 ICMP 测试延迟
/// </summary>
public bool ICMPing = true;
}
}

View File

@@ -0,0 +1,23 @@
namespace Netch.Models.Config
{
public class Ports
{
/// <summary>
/// Socks 端口
/// </summary>
[Newtonsoft.Json.JsonProperty("socks")]
public int Socks = 2081;
/// <summary>
/// Mixed 端口
/// </summary>
[Newtonsoft.Json.JsonProperty("mixed")]
public int Mixed = 2082;
/// <summary>
/// Redir 端口
/// </summary>
[Newtonsoft.Json.JsonProperty("redir")]
public int Redir = 2083;
}
}

View File

@@ -0,0 +1,11 @@
namespace Netch.Models.Config
{
public class ProcessMode
{
/// <summary>
/// DNS
/// </summary>
[Newtonsoft.Json.JsonProperty("dns")]
public string DNS = "1.1.1.1:53";
}
}

View File

@@ -0,0 +1,11 @@
namespace Netch.Models.Config
{
public class STUN
{
/// <summary>
/// 主机名
/// </summary>
[Newtonsoft.Json.JsonProperty("host")]
public string Host = "stun.ekiga.net";
}
}

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
namespace Netch.Models.Config
{
public class ShareMode
{
/// <summary>
/// 硬件地址(用于 ARP 回复)
///
/// CuteCR
/// 43:75:74:65:43:52
///
/// NetchX
/// 4e:65:74:63:68:58
/// </summary>
[Newtonsoft.Json.JsonProperty("hardware")]
public string Hardware = "4e:65:74:63:68:58";
/// <summary>
/// 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("network")]
public string Network = "100.64.0.0/24";
/// <summary>
/// 网关
/// </summary>
[Newtonsoft.Json.JsonProperty("gateway")]
public string Gateway = "100.64.0.1";
/// <summary>
/// DNS
/// </summary>
[Newtonsoft.Json.JsonProperty("dns")]
public string DNS = "aiodns";
/// <summary>
/// 网卡名(默认自动检测)
/// </summary>
public string EthernetName = "auto";
/// <summary>
/// 绕过 IP 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassIPs = new();
}
}

View File

@@ -0,0 +1,23 @@
namespace Netch.Models.Config
{
public class Subscription
{
/// <summary>
/// 启用 / 禁用
/// </summary>
[Newtonsoft.Json.JsonProperty("enabled")]
public bool Checked = true;
/// <summary>
/// 备注
/// </summary>
[Newtonsoft.Json.JsonProperty("remark")]
public string Remark;
/// <summary>
/// 链接
/// </summary>
[Newtonsoft.Json.JsonProperty("address")]
public string Link;
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
namespace Netch.Models.Config
{
public class TapMode
{
/// <summary>
/// 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("network")]
public string Network = "100.64.0.100/24";
/// <summary>
/// 网关
/// </summary>
[Newtonsoft.Json.JsonProperty("gateway")]
public string Gateway = "100.64.0.1";
/// <summary>
/// DNS
/// </summary>
[Newtonsoft.Json.JsonProperty("dns")]
public string DNS = "aiodns";
/// <summary>
/// 绕过 IP 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassIPs = new();
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
namespace Netch.Models.Config
{
public class TunMode
{
/// <summary>
/// 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("network")]
public string Network = "100.64.0.100/24";
/// <summary>
/// 网关
/// </summary>
[Newtonsoft.Json.JsonProperty("gateway")]
public string Gateway = "100.64.0.1";
/// <summary>
/// DNS
/// </summary>
[Newtonsoft.Json.JsonProperty("dns")]
public string DNS = "aiodns";
/// <summary>
/// 绕过 IP 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassIPs = new();
}
}

View File

@@ -0,0 +1,63 @@
namespace Netch.Models.Config
{
public class V2Ray
{
/// <summary>
/// FullCone 支持(需要 xray-core 服务端版本 v1.3.0+
/// </summary>
public bool FullCone = false;
/// <summary>
/// 跳过证书认证
/// </summary>
public bool Insecure = false;
/// <summary>
/// 多路复用
/// </summary>
public bool Multiplex = false;
/// <summary>
/// KCP 设定
/// </summary>
public V2RayKCP KCP = new();
}
public class V2RayKCP
{
/// <summary>
/// MTU
/// </summary>
public int MTU = 1450;
/// <summary>
/// TTI
/// </summary>
public int TTI = 50;
/// <summary>
/// 上行链路流量
/// </summary>
public int UPC = 5;
/// <summary>
/// 下行链路流量
/// </summary>
public int DLC = 20;
/// <summary>
/// 读取缓冲区大小MB
/// </summary>
public int RBS = 2;
/// <summary>
/// 写入缓冲区大小MB
/// </summary>
public int WBS = 2;
/// <summary>
/// 拥塞控制
/// </summary>
public bool BBR = false;
}
}

View File

@@ -0,0 +1,23 @@
namespace Netch.Models.GitHub
{
public class Asset
{
/// <summary>
/// name
/// </summary>
[Newtonsoft.Json.JsonProperty("name")]
public string Name;
/// <summary>
/// browser_download_url
/// </summary>
[Newtonsoft.Json.JsonProperty("browser_download_url")]
public string URL;
/// <summary>
/// size
/// </summary>
[Newtonsoft.Json.JsonProperty("size")]
public ulong Size;
}
}

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
namespace Netch.Models.GitHub
{
/// <summary>
/// https://api.github.com/repos/{owner}/{repo}/releases
/// </summary>
public class Release
{
/// <summary>
/// id
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
public int ID;
/// <summary>
/// html_url
/// </summary>
[Newtonsoft.Json.JsonProperty("html_url")]
public string URL;
/// <summary>
/// tag_name
/// </summary>
[Newtonsoft.Json.JsonProperty("tag_name")]
public string VerCode;
/// <summary>
/// draft
/// </summary>
[Newtonsoft.Json.JsonProperty("draft")]
public bool Draft;
/// <summary>
/// prerelease
/// </summary>
[Newtonsoft.Json.JsonProperty("prerelease")]
public bool Unstable;
/// <summary>
/// assets
/// </summary>
[Newtonsoft.Json.JsonProperty("assets")]
public List<Asset> Files;
}
}

19
Netch/Models/Mode/Mode.cs Normal file
View File

@@ -0,0 +1,19 @@
namespace Netch.Models.Mode
{
public class Mode
{
/// <summary>
/// 类型
/// </summary>
[Newtonsoft.Json.JsonProperty("type")]
public ModeType Type;
/// <summary>
/// 备注
/// </summary>
[Newtonsoft.Json.JsonProperty("remark")]
public string Remark;
public override string ToString() => $"[{((int)this.Type) + 1}] {this.Remark}";
}
}

View File

@@ -0,0 +1,35 @@
namespace Netch.Models.Mode
{
public enum ModeType : int
{
/// <summary>
/// 进程代理
/// </summary>
ProcessMode,
/// <summary>
/// 网络共享
/// </summary>
ShareMode,
/// <summary>
/// 网卡代理
/// </summary>
TapMode,
/// <summary>
/// 网卡代理
/// </summary>
TunMode,
/// <summary>
/// 网页代理
/// </summary>
WebMode,
/// <summary>
/// 代理转发
/// </summary>
WmpMode
}
}

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
namespace Netch.Models.Mode.ProcessMode
{
public class ProcessMode : Mode
{
public ProcessMode()
{
this.Type = ModeType.ProcessMode;
}
/// <summary>
/// 过滤 IPv4 + IPv6 环路流量
/// </summary>
[Newtonsoft.Json.JsonProperty("filterLoopback")]
public bool Loopback = false;
/// <summary>
/// 过滤 ICMP 流量(伪造 ICMP 回复)
/// </summary>
[Newtonsoft.Json.JsonProperty("filterICMP")]
public bool ICMP = true;
/// <summary>
/// 过滤 TCP 流量
/// </summary>
[Newtonsoft.Json.JsonProperty("filterTCP")]
public bool TCP = true;
/// <summary>
/// 过滤 UDP 流量
/// </summary>
[Newtonsoft.Json.JsonProperty("filterUDP")]
public bool UDP = true;
/// <summary>
/// 绕过列表
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassList;
/// <summary>
/// 代理列表
/// </summary>
[Newtonsoft.Json.JsonProperty("handle")]
public List<string> HandleList;
}
}

View File

@@ -0,0 +1,18 @@
using System.Collections.Generic;
namespace Netch.Models.Mode.ShareMode
{
public class ShareMode : Mode
{
public ShareMode()
{
this.Type = ModeType.ShareMode;
}
/// <summary>
/// 绕过列表IP CIDR
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassList;
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace Netch.Models.Mode.TapMode
{
public class TapMode : Mode
{
public TapMode()
{
this.Type = ModeType.TapMode;
}
/// <summary>
/// 绕过列表IP CIDR
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassList;
/// <summary>
/// 代理列表IP CIDR
/// </summary>
[Newtonsoft.Json.JsonProperty("handle")]
public List<string> HandleList;
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace Netch.Models.Mode.TunMode
{
public class TunMode : Mode
{
public TunMode()
{
this.Type = ModeType.TunMode;
}
/// <summary>
/// 绕过列表IP CIDR
/// </summary>
[Newtonsoft.Json.JsonProperty("bypass")]
public List<string> BypassList;
/// <summary>
/// 代理列表IP CIDR
/// </summary>
[Newtonsoft.Json.JsonProperty("handle")]
public List<string> HandleList;
}
}

View File

@@ -0,0 +1,30 @@
using System.Collections.Generic;
namespace Netch.Models.Mode.WebMode
{
public class WebMode : Mode
{
public WebMode()
{
this.Type = ModeType.WebMode;
}
/// <summary>
/// 设置系统代理
/// </summary>
[Newtonsoft.Json.JsonProperty("setSystemProxy")]
public bool SetSystemProxy;
/// <summary>
/// 绕过域名后缀
/// </summary>
[Newtonsoft.Json.JsonProperty("bypassDomainSuffix")]
public List<string> BypassDomainSuffix;
/// <summary>
/// 绕过 IP 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("bypassIPs")]
public List<string> BypassIPs;
}
}

View File

@@ -0,0 +1,30 @@
namespace Netch.Models.Mode.WmpMode
{
public class WmpMode : Mode
{
public WmpMode()
{
this.Type = ModeType.WmpMode;
}
/// <summary>
/// 监听地址(为空则监听所有 IPv4 + IPv6 地址)
/// </summary>
public string ListenAddr;
/// <summary>
/// 监听端口
/// </summary>
public ushort ListenPort;
/// <summary>
/// 远端地址
/// </summary>
public string RemoteAddr;
/// <summary>
/// 远端端口
/// </summary>
public ushort RemotePort;
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Net;
namespace Netch.Models.Server
{
public class Server
{
/// <summary>
/// 类型
/// </summary>
[Newtonsoft.Json.JsonProperty("type")]
public ServerType Type;
/// <summary>
/// 备注
/// </summary>
[Newtonsoft.Json.JsonProperty("remark")]
public string Remark;
/// <summary>
/// 地址
/// </summary>
[Newtonsoft.Json.JsonProperty("host")]
public string Host;
/// <summary>
/// 端口
/// </summary>
[Newtonsoft.Json.JsonProperty("port")]
public ushort Port;
/// <summary>
/// 延迟
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public int Ping = -1;
/// <summary>
/// 测试延迟
/// </summary>
/// <returns></returns>
public void TestPing() => this.Ping = Utils.Ping.Fetch(this);
/// <summary>
/// 解析地址
/// </summary>
/// <returns></returns>
public string Resolve() => (Utils.DNS.Fetch(this.Host) != IPAddress.Any) ? Utils.DNS.Fetch(this.Host).ToString() : this.Host;
/// <summary>
/// 获取备注
/// </summary>
/// <returns></returns>
public override string ToString()
{
string name = this.Type switch
{
ServerType.Socks => "S5",
ServerType.Shadowsocks => "SS",
ServerType.ShadowsocksR => "SR",
ServerType.Trojan => "TR",
ServerType.VLess => "VL",
ServerType.VMess => "VM",
_ => "UN",
};
return String.Format("[{0}] {1}", name, String.IsNullOrEmpty(this.Remark) ? $"{this.Host}:{this.Port}" : this.Remark);
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace Netch.Models.Server
{
public class ServerList
{
/// <summary>
/// 群组
/// </summary>
[Newtonsoft.Json.JsonProperty("name")]
public string Group;
/// <summary>
/// 节点
/// </summary>
[Newtonsoft.Json.JsonProperty("list")]
public List<Server> List;
}
}

View File

@@ -0,0 +1,35 @@
namespace Netch.Models.Server
{
public enum ServerType : int
{
/// <summary>
/// Socks5
/// </summary>
Socks,
/// <summary>
/// Shadowsocks
/// </summary>
Shadowsocks,
/// <summary>
/// ShadowsocksR
/// </summary>
ShadowsocksR,
/// <summary>
/// Trojan
/// </summary>
Trojan,
/// <summary>
/// VLess
/// </summary>
VLess,
/// <summary>
/// VMess
/// </summary>
VMess
}
}

View File

@@ -0,0 +1,30 @@
using System.Collections.Generic;
namespace Netch.Models.Server.Shadowsocks
{
public static class Global
{
public static readonly List<string> Methods = new List<string>()
{
"bf-cfb",
"rc4-md5",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb",
"salsa20",
"chacha20",
"chacha20-ietf",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",
};
}
}

View File

@@ -0,0 +1,125 @@
using System;
using System.Text.RegularExpressions;
using System.Web;
namespace Netch.Models.Server.Shadowsocks
{
public class Shadowsocks : Server
{
public Shadowsocks()
{
this.Type = ServerType.Shadowsocks;
}
/// <summary>
/// 密码
/// </summary>
[Newtonsoft.Json.JsonProperty("passwd")]
public string Passwd;
/// <summary>
/// 加密
/// </summary>
[Newtonsoft.Json.JsonProperty("method")]
public string Method;
/// <summary>
/// 插件
/// </summary>
[Newtonsoft.Json.JsonProperty("obfs")]
public string OBFS;
/// <summary>
/// 插件参数
/// </summary>
[Newtonsoft.Json.JsonProperty("obfsparam")]
public string OBFSParam;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
if (link.Contains("#"))
{
this.Remark = HttpUtility.UrlDecode(link.Split('#')[1]);
link = link.Split('#')[0];
}
if (link.Contains("?"))
{
var finder = new Regex(@"^(?<data>.+?)\?(.+)$");
var matches = finder.Match(link);
if (matches.Success)
{
var plugin = HttpUtility.UrlDecode(HttpUtility.ParseQueryString(new Uri(link).Query).Get("plugin"));
if (plugin != null)
{
var obfs = plugin.Substring(0, plugin.IndexOf(";"));
var opts = plugin.Substring(plugin.IndexOf(";") + 1);
switch (obfs)
{
case "obfs-local":
case "simple-obfs":
case "simple-obfs-tls":
obfs = "simple-obfs";
break;
}
this.OBFS = obfs;
this.OBFSParam = opts;
}
link = matches.Groups["data"].Value;
}
else
{
return false;
}
}
if (link.Contains("@"))
{
var finder = new Regex(@"^ss://(?<base64>.+?)@(?<server>.+):(?<port>\d+)");
var parser = new Regex(@"^(?<method>.+?):(?<password>.+)$");
var matches = finder.Match(link);
if (!matches.Success)
{
return false;
}
this.Host = matches.Groups["server"].Value;
if (ushort.TryParse(matches.Groups["port"].Value, out var result))
{
this.Port = result;
}
else
{
return false;
}
matches = parser.Match(Utils.Base64.Decode.URLSafe(matches.Groups["base64"].Value));
if (!matches.Success)
{
return false;
}
this.Passwd = matches.Groups["password"].Value;
this.Method = matches.Groups["method"].Value;
}
else
{
return false;
}
this.Method = this.Method.ToLower();
return Global.Methods.Contains(this.Method);
}
}
}

View File

@@ -0,0 +1,47 @@
using System.Collections.Generic;
namespace Netch.Models.Server.ShadowsocksR
{
public static class Global
{
public static readonly List<string> Methods = new List<string>()
{
"rc4",
"bf-cfb",
"des-cfb",
"rc2-cfb",
"rc4-md5",
"idea-cfb",
"seed-cfb",
"cast5-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb",
"chacha20",
"chacha20-ietf"
};
public static readonly List<string> Prots = new List<string>()
{
"origin",
"auth_sha1_v4",
"auth_aes128_md5",
"auth_aes128_sha1",
"auth_chain_a",
};
public static readonly List<string> OBFSs = new List<string>()
{
"plain",
"http_post",
"http_simple",
"tls1.2_ticket_auth"
};
}
}

View File

@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Netch.Models.Server.ShadowsocksR
{
public class ShadowsocksR : Server
{
public ShadowsocksR()
{
this.Type = ServerType.ShadowsocksR;
}
/// <summary>
/// 密码
/// </summary>
[Newtonsoft.Json.JsonProperty("passwd")]
public string Passwd;
/// <summary>
/// 加密
/// </summary>
[Newtonsoft.Json.JsonProperty("method")]
public string Method;
/// <summary>
/// 协议
/// </summary>
[Newtonsoft.Json.JsonProperty("prot")]
public string Prot;
/// <summary>
/// 协议参数
/// </summary>
[Newtonsoft.Json.JsonProperty("protparam")]
public string ProtParam;
/// <summary>
/// 混淆
/// </summary>
[Newtonsoft.Json.JsonProperty("obfs")]
public string OBFS;
/// <summary>
/// 混淆参数
/// </summary>
[Newtonsoft.Json.JsonProperty("obfsparam")]
public string OBFSParam;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
try
{
var ssr = new Regex(@"ssr://([A-Za-z0-9+/=_-]+)", RegexOptions.IgnoreCase).Match(link);
if (!ssr.Success)
{
return false;
}
var data = Utils.Base64.Decode.URLSafe(ssr.Groups[1].Value);
var dict = new Dictionary<string, string>();
var offset = data.IndexOf(@"?", StringComparison.Ordinal);
if (offset > 0)
{
dict = ParseParam(data.Substring(offset + 1));
data = data.Substring(0, offset);
}
if (data.IndexOf("/", StringComparison.Ordinal) >= 0)
{
data = data.Substring(0, data.LastIndexOf("/", StringComparison.Ordinal));
}
var matches = new Regex(@"^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)").Match(data);
if (!matches.Success)
{
return false;
}
if (dict.ContainsKey("remarks"))
{
this.Remark = Utils.Base64.Decode.URLSafe(dict["remarks"]);
}
this.Host = matches.Groups[1].Value;
if (!ushort.TryParse(matches.Groups[2].Value, out this.Port))
{
return false;
}
this.Passwd = Utils.Base64.Decode.URLSafe(matches.Groups[6].Value);
this.Method = matches.Groups[4].Value.ToLower();
this.Prot = (matches.Groups[3].Value.Length == 0 ? "origin" : matches.Groups[3].Value).Replace("_compatible", String.Empty).ToLower();
if (dict.ContainsKey("protoparam"))
{
this.ProtParam = Utils.Base64.Decode.URLSafe(dict["protoparam"]);
}
this.OBFS = (matches.Groups[5].Value.Length == 0 ? @"plain" : matches.Groups[5].Value).Replace("_compatible", String.Empty).ToLower();
if (dict.ContainsKey("obfsparam"))
{
this.OBFSParam = Utils.Base64.Decode.URLSafe(dict["obfsparam"]);
}
}
catch (Exception e)
{
global::Netch.Global.Logger.Warning(e.ToString());
return false;
}
return true;
}
private static Dictionary<string, string> ParseParam(string str)
{
var dict = new Dictionary<string, string>();
var obfs = str.Split('&');
for (int i = 0; i < str.Length; i++)
{
if (obfs[i].IndexOf('=') > 0)
{
var index = obfs[i].IndexOf('=');
var k = obfs[i].Substring(0, index);
var v = obfs[i].Substring(index + 1);
dict[k] = v;
}
}
return dict;
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
namespace Netch.Models.Server.Socks
{
public class Socks : Server
{
public Socks()
{
this.Type = ServerType.Socks;
}
/// <summary>
/// 账号
/// </summary>
[Newtonsoft.Json.JsonProperty("username")]
public string Username;
/// <summary>
/// 密码
/// </summary>
[Newtonsoft.Json.JsonProperty("password")]
public string Password;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
var list = link
.Replace("tg://socks?", "")
.Replace("https://t.me/socks?", "")
.Split('&');
var dict = new Dictionary<string, string>();
for (int i = 0; i < list.Length; i++)
{
var s = list[i].Split('=');
if (s.Length != 2)
{
continue;
}
dict[s[0]] = s[1];
}
if (!dict.ContainsKey("server") || !dict.ContainsKey("port") || !ushort.TryParse(dict["port"], out _))
{
return false;
}
this.Host = dict["server"];
this.Port = ushort.Parse(dict["port"]);
if (dict.ContainsKey("user") && !String.IsNullOrEmpty(dict["user"]))
{
this.Username = dict["user"];
}
if (dict.ContainsKey("pass") && !String.IsNullOrEmpty(dict["pass"]))
{
this.Username = dict["pass"];
}
return true;
}
}
}

View File

@@ -0,0 +1,45 @@
namespace Netch.Models.Server.Trojan
{
public class Trojan : Server
{
public Trojan()
{
this.Type = ServerType.Trojan;
}
/// <summary>
/// 密码
/// </summary>
public string Passwd;
/// <summary>
/// 伪装 SNI 标头
/// </summary>
public string SNI;
/// <summary>
/// 复用会话
/// </summary>
public bool Reuse = true;
/// <summary>
/// Session Ticket
/// </summary>
public bool Ticket = false;
/// <summary>
/// 不安全模式(跳过证书验证、跳过主机名验证)
/// </summary>
public bool Insecure = true;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
return false;
}
}
}

View File

@@ -0,0 +1,30 @@
namespace Netch.Models.Server.VLess
{
public class VLess : Server
{
public VLess()
{
this.Type = ServerType.VLess;
}
/// <summary>
/// 自定义配置
/// </summary>
public bool Custom = true;
/// <summary>
/// 自定义配置文件路径
/// </summary>
public string FilePath;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
return false;
}
}
}

View File

@@ -0,0 +1,30 @@
namespace Netch.Models.Server.VMess
{
public class VMess : Server
{
public VMess()
{
this.Type = ServerType.VMess;
}
/// <summary>
/// 自定义配置
/// </summary>
public bool Custom = true;
/// <summary>
/// 自定义配置文件路径
/// </summary>
public string FilePath;
/// <summary>
/// 解析链接
/// </summary>
/// <param name="link">链接</param>
/// <returns>是否成功</returns>
public bool ParseLink(string link)
{
return false;
}
}
}