Skip to content

Commit

Permalink
Merge pull request #823 from H1JK/patch-update
Browse files Browse the repository at this point in the history
Replace Xray-core with SagerNet/v2ray-core, with more protocol support
  • Loading branch information
AmazingDM authored Jun 9, 2022
2 parents 56a1d0d + 860b70b commit c55a5f6
Show file tree
Hide file tree
Showing 37 changed files with 454 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/setup-go@v3
if: steps.check_other.outputs.files_exists == 'false'
with:
go-version: 1.17.3
go-version: ^1.18.3

- name: Setup C++
uses: msys2/setup-msys2@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/setup-go@v3
if: steps.check_other.outputs.files_exists == 'false'
with:
go-version: 1.17.3
go-version: ^1.18.3

- name: Setup C++
uses: msys2/setup-msys2@v2
Expand Down
2 changes: 1 addition & 1 deletion Netch/Controllers/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static async Task StartAsync(Server server, Mode mode)
// Start Server Controller to get a local socks5 server
Log.Debug("Server Information: {Data}", $"{server.Type} {server.MaskedData()}");

ServerController = ServerHelper.GetUtilByTypeName(server.Type).GetController();
ServerController = new V2rayController();
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ServerController.Name));

TryReleaseTcpPort(ServerController.Socks5LocalPort(), "Socks5");
Expand Down
2 changes: 1 addition & 1 deletion Netch/Controllers/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class UpdateChecker
public const string Name = @"Netch";
public const string Copyright = @"Copyright © 2019 - 2022";

public const string AssemblyVersion = @"1.9.5";
public const string AssemblyVersion = @"1.9.6";
private const string Suffix = @"";

public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
Expand Down
4 changes: 4 additions & 0 deletions Netch/Resources/zh-CN
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"Plugin": "插件",
"Plugin Options": "插件参数",
"Remote Address": "远端地址",
"Local Addresses": "本地地址(可多个)",
"Public Key": "节点公钥",
"Private Key": "私钥",
"PSK": "节点预共享密钥",

"Subscription": "订阅",
"Manage Subscriptions": "管理订阅",
Expand Down
44 changes: 35 additions & 9 deletions Netch/Servers/Shadowsocks/ShadowsocksServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public override string MaskedData()
/// <summary>
/// 加密方式
/// </summary>
public string EncryptMethod { get; set; } = SSGlobal.EncryptMethods[0];
public string EncryptMethod { get; set; } = SSGlobal.EncryptMethods[4];

/// <summary>
/// 密码
Expand Down Expand Up @@ -43,24 +43,50 @@ public static class SSGlobal
/// </summary>
public static readonly List<string> EncryptMethods = new()
{
"rc4-md5",
"none",

// 2022 edition cipher
"2022-blake3-aes-128-gcm",
"2022-blake3-aes-256-gcm",
"2022-blake3-chacha20-poly1305",

// AEAD cipher
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",

// stream cipher
"rc4",
"rc4-md5",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-cfb8",
"aes-192-cfb8",
"aes-256-cfb8",
"aes-128-ofb",
"aes-192-ofb",
"aes-256-ofb",
"bf-cfb",
"cast5-cfb",
"des-cfb",
"idea-cfb",
"rc2-cfb",
"seed-cfb",
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb",
"bf-cfb",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",
"camellia-128-cfb8",
"camellia-192-cfb8",
"camellia-256-cfb8",
"salsa20",
"chacha20",
"chacha20-ietf"
"chacha20-ietf",
"xchacha20"
};
}
4 changes: 2 additions & 2 deletions Netch/Servers/Shadowsocks/ShadowsocksUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public ShadowsocksServer ParseSsUri(string text)
{
case "obfs-local":
case "simple-obfs":
plugin = "simple-obfs";
plugin = "obfs-local";
if (!pluginopts.Contains("obfs="))
pluginopts = "obfs=http;obfs-host=" + pluginopts;

break;
case "simple-obfs-tls":
plugin = "simple-obfs";
plugin = "obfs-local";
if (!pluginopts.Contains("obfs="))
pluginopts = "obfs=tls;obfs-host=" + pluginopts;

Expand Down
38 changes: 8 additions & 30 deletions Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override string MaskedData()
/// <summary>
/// 加密方式
/// </summary>
public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[0];
public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[4];

/// <summary>
/// 协议
Expand Down Expand Up @@ -49,11 +49,11 @@ public class SSRGlobal
public static readonly List<string> Protocols = new()
{
"origin",
"verify_deflate",
"auth_sha1_v4",
"auth_aes128_md5",
"auth_aes128_sha1",
"auth_chain_a"
"auth_chain_a",
"auth_chain_b"
};

/// <summary>
Expand All @@ -64,36 +64,14 @@ public class SSRGlobal
"plain",
"http_simple",
"http_post",
"tls1.2_ticket_auth"
"tls_simple",
"tls1.2_ticket_auth",
"tls1.2_ticket_fastauth",
"random_head"
};

/// <summary>
/// SS/SSR 加密方式
/// </summary>
public static readonly List<string> EncryptMethods = new()
{
"none",
"table",
"rc4",
"rc4-md5",
"rc4-md5-6",
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"bf-cfb",
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb",
"cast5-cfb",
"des-cfb",
"idea-cfb",
"rc2-cfb",
"seed-cfb",
"salsa20",
"chacha20",
"chacha20-ietf"
};
public static readonly List<string> EncryptMethods = SSGlobal.EncryptMethods;
}
1 change: 1 addition & 0 deletions Netch/Servers/Trojan/TrojanForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public TrojanForm(TrojanServer? server = default)
Server = server;
CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password);
CreateTextBox("Host", "Host", s => true, s => server.Host = s, server.Host);
CreateComboBox("TLSSecure", "TLS Secure", VLESSGlobal.TLSSecure, s => server.TLSSecureType = s, server.TLSSecureType);
}

protected override string TypeName { get; } = "Trojan";
Expand Down
17 changes: 17 additions & 0 deletions Netch/Servers/Trojan/TrojanServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace Netch.Servers;

public class TrojanServer : Server
{
private string _tlsSecureType = VLESSGlobal.TLSSecure[1];

public override string Type { get; } = "Trojan";

public override string MaskedData()
Expand All @@ -20,4 +22,19 @@ public override string MaskedData()
/// 伪装域名
/// </summary>
public string? Host { get; set; }

/// <summary>
/// TLS 底层传输安全
/// </summary>
public string TLSSecureType
{
get => _tlsSecureType;
set
{
if (value == "")
value = VLESSGlobal.TLSSecure[1];

_tlsSecureType = value;
}
}
}
9 changes: 7 additions & 2 deletions Netch/Servers/Trojan/TrojanUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Create()
public string GetShareLink(Server s)
{
var server = (TrojanServer)s;
return $"trojan://{HttpUtility.UrlEncode(server.Password)}@{server.Hostname}:{server.Port}#{server.Remark}";
return $"trojan://{HttpUtility.UrlEncode(server.Password)}@{server.Hostname}:{server.Port}?sni={server.Host}#{server.Remark}";
}

public IServerController GetController()
Expand Down Expand Up @@ -61,8 +61,13 @@ public IEnumerable<Server> ParseUri(string text)

var peer = HttpUtility.UrlDecode(HttpUtility.ParseQueryString(new Uri(text).Query).Get("peer"));

if (peer != null)
if (peer != null) {
data.Host = peer;
} else {
peer = HttpUtility.UrlDecode(HttpUtility.ParseQueryString(new Uri(text).Query).Get("sni"));
if (peer != null)
data.Host = peer;
}

text = regmatch.Groups["data"].Value;
}
Expand Down
39 changes: 37 additions & 2 deletions Netch/Servers/V2ray/V2rayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,38 @@ public class Outbound

public OutboundConfiguration settings { get; set; }

public StreamSettings streamSettings { get; set; }
public StreamSettings? streamSettings { get; set; }

public Mux mux { get; set; }
public Mux? mux { get; set; }
}

public class OutboundConfiguration
{
public VnextItem[] vnext { get; set; }

public object[] servers { get; set; }

public string address { get; set; }

public ushort port { get; set; }

public string packetEncoding { get; set; }

public string plugin { get; set; }

public string pluginOpts { get; set; }

public string[] pluginArgs { get; set; }

public string[] localAddresses { get; set; }

public string peerPublicKey { get; set; }

public string privateKey { get; set; }

public string preSharedKey { get; set; }

public int mtu { get; set; }
}

public class VnextItem
Expand All @@ -50,10 +72,23 @@ public class VnextItem
public User[] users { get; set; }
}

public class ShadowsocksServerItem
{
public string address { get; set; }

public ushort port { get; set; }

public string method { get; set; }

public string password { get; set; }
}

public class Mux
{
public bool enabled { get; set; }

public string packetEncoding { get; set; }

public int concurrency { get; set; }
}

Expand Down
Loading

0 comments on commit c55a5f6

Please sign in to comment.