Compare commits

...

18 Commits
1.9.6 ... 1.9.7

Author SHA1 Message Date
Netch
99480e99c3 Update UpdateChecker.cs 2022-06-24 15:03:58 +08:00
Netch
c696277b6b Update stale.yml 2022-06-23 13:29:25 +08:00
Netch
a7dd83448b Create stale.yml 2022-06-23 13:25:56 +08:00
离披
0aa4a981fc fix a bug that when using socks5 with authentication, username and password can't sent to server correctly (#856) 2022-06-23 13:09:51 +08:00
AmazingDM
2b7483b696 Merge pull request #850 from netchx/dependabot/nuget/Fody-6.6.3
Bump Fody from 6.6.2 to 6.6.3
2022-06-16 17:34:57 +08:00
AmazingDM
585a84321f Merge pull request #851 from H1JK/dev-tcpfastopen
Support TCP Fast Open (All Protocols)
2022-06-16 17:34:49 +08:00
Hellojack
dc7c48b1bb f 2022-06-16 17:05:54 +08:00
Hellojack
95aa3db415 [Netch] Support TCP Fast Open 2022-06-16 17:01:40 +08:00
dependabot[bot]
276e516396 Bump Fody from 6.6.2 to 6.6.3
Bumps [Fody](https://github.com/Fody/Fody) from 6.6.2 to 6.6.3.
- [Release notes](https://github.com/Fody/Fody/releases)
- [Commits](https://github.com/Fody/Fody/compare/6.6.2...6.6.3)

---
updated-dependencies:
- dependency-name: Fody
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-14 16:46:37 +00:00
Netch
3fa3c1cfcb Update build.ps1 2022-06-11 05:06:22 +08:00
AmazingDM
2d848f6708 Merge pull request #840 from H1JK/patch-flow-2
Netch : Remove Flow parameter from VLESS instance
2022-06-10 15:45:36 +08:00
Hellojack
504709b7da Netch : Remove Flow parameter from VLESS instance 2022-06-10 15:35:46 +08:00
AmazingDM
e37d1f21ba Merge pull request #838 from H1JK/uuid-generator
Support Xray UUIDv5 mapping standard
2022-06-10 15:21:33 +08:00
AmazingDM
e2a20d5bb0 Merge pull request #834 from H1JK/patch-update
SOCKS : Support version 4 & 4a
2022-06-10 15:21:25 +08:00
Hellojack
01cd51744f fix 2022-06-10 14:30:53 +08:00
Hellojack
d3582340b0 V2Ray : Support Xray UUIDv5 mapping standard 2022-06-10 14:21:53 +08:00
AmazingDM
98ece46832 Update Global.cs
Generate VLESS UUIDv5
https://github.com/XTLS/Xray-core/discussions/715
2022-06-10 13:48:35 +08:00
Hellojack
bedafc23d4 SOCKS : Support version 4 & 4a 2022-06-10 11:00:57 +08:00
19 changed files with 208 additions and 31 deletions

20
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Netch CII
on:
schedule:
- cron: "0 0 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 14
days-before-pr-stale: 30
days-before-pr-close: 14
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."

View File

@@ -15,7 +15,7 @@ public static class UpdateChecker
public const string Name = @"Netch"; public const string Name = @"Netch";
public const string Copyright = @"Copyright © 2019 - 2022"; public const string Copyright = @"Copyright © 2019 - 2022";
public const string AssemblyVersion = @"1.9.6"; public const string AssemblyVersion = @"1.9.7";
private const string Suffix = @""; private const string Suffix = @"";
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}"; public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
@@ -103,4 +103,4 @@ public static class UpdateChecker
var ordered = releases.OrderByDescending(release => release.tag_name, new VersionUtil.VersionComparer()); var ordered = releases.OrderByDescending(release => release.tag_name, new VersionUtil.VersionComparer());
return ordered.ElementAt(0); return ordered.ElementAt(0);
} }
} }

View File

@@ -80,6 +80,7 @@ namespace Netch.Forms
this.XrayConeCheckBox = new System.Windows.Forms.CheckBox(); this.XrayConeCheckBox = new System.Windows.Forms.CheckBox();
this.TLSAllowInsecureCheckBox = new System.Windows.Forms.CheckBox(); this.TLSAllowInsecureCheckBox = new System.Windows.Forms.CheckBox();
this.UseMuxCheckBox = new System.Windows.Forms.CheckBox(); this.UseMuxCheckBox = new System.Windows.Forms.CheckBox();
this.TCPFastOpenBox = new System.Windows.Forms.CheckBox();
this.KCPGroupBox = new System.Windows.Forms.GroupBox(); this.KCPGroupBox = new System.Windows.Forms.GroupBox();
this.mtuLabel = new System.Windows.Forms.Label(); this.mtuLabel = new System.Windows.Forms.Label();
this.mtuTextBox = new System.Windows.Forms.TextBox(); this.mtuTextBox = new System.Windows.Forms.TextBox();
@@ -590,6 +591,7 @@ namespace Netch.Forms
this.v2rayTabPage.Controls.Add(this.XrayConeCheckBox); this.v2rayTabPage.Controls.Add(this.XrayConeCheckBox);
this.v2rayTabPage.Controls.Add(this.TLSAllowInsecureCheckBox); this.v2rayTabPage.Controls.Add(this.TLSAllowInsecureCheckBox);
this.v2rayTabPage.Controls.Add(this.UseMuxCheckBox); this.v2rayTabPage.Controls.Add(this.UseMuxCheckBox);
this.v2rayTabPage.Controls.Add(this.TCPFastOpenBox);
this.v2rayTabPage.Controls.Add(this.KCPGroupBox); this.v2rayTabPage.Controls.Add(this.KCPGroupBox);
this.v2rayTabPage.Location = new System.Drawing.Point(4, 29); this.v2rayTabPage.Location = new System.Drawing.Point(4, 29);
this.v2rayTabPage.Name = "v2rayTabPage"; this.v2rayTabPage.Name = "v2rayTabPage";
@@ -628,6 +630,16 @@ namespace Netch.Forms
this.UseMuxCheckBox.Text = "Use Mux"; this.UseMuxCheckBox.Text = "Use Mux";
this.UseMuxCheckBox.UseVisualStyleBackColor = true; this.UseMuxCheckBox.UseVisualStyleBackColor = true;
// //
// TCPFastOpenBox
//
this.TCPFastOpenBox.AutoSize = true;
this.TCPFastOpenBox.Location = new System.Drawing.Point(300, 42);
this.TCPFastOpenBox.Name = "TCPFastOpenBox";
this.TCPFastOpenBox.Size = new System.Drawing.Size(131, 21);
this.TCPFastOpenBox.TabIndex = 3;
this.TCPFastOpenBox.Text = "TCP FastOpen";
this.TCPFastOpenBox.UseVisualStyleBackColor = true;
//
// KCPGroupBox // KCPGroupBox
// //
this.KCPGroupBox.Controls.Add(this.mtuLabel); this.KCPGroupBox.Controls.Add(this.mtuLabel);
@@ -1063,6 +1075,7 @@ namespace Netch.Forms
private System.Windows.Forms.GroupBox KCPGroupBox; private System.Windows.Forms.GroupBox KCPGroupBox;
private System.Windows.Forms.CheckBox congestionCheckBox; private System.Windows.Forms.CheckBox congestionCheckBox;
private System.Windows.Forms.CheckBox TLSAllowInsecureCheckBox; private System.Windows.Forms.CheckBox TLSAllowInsecureCheckBox;
private System.Windows.Forms.CheckBox TCPFastOpenBox;
private System.Windows.Forms.Label mtuLabel; private System.Windows.Forms.Label mtuLabel;
private System.Windows.Forms.TextBox mtuTextBox; private System.Windows.Forms.TextBox mtuTextBox;
private System.Windows.Forms.Label writeBufferSizeLabel; private System.Windows.Forms.Label writeBufferSizeLabel;

View File

@@ -120,11 +120,11 @@ public partial class SettingForm : BindingForm
#endregion #endregion
#region V2Ray #region V2Ray
BindCheckBox(XrayConeCheckBox, b => Global.Settings.V2RayConfig.XrayCone = b, Global.Settings.V2RayConfig.XrayCone); BindCheckBox(XrayConeCheckBox, b => Global.Settings.V2RayConfig.XrayCone = b, Global.Settings.V2RayConfig.XrayCone);
BindCheckBox(TLSAllowInsecureCheckBox, b => Global.Settings.V2RayConfig.AllowInsecure = b, Global.Settings.V2RayConfig.AllowInsecure); BindCheckBox(TLSAllowInsecureCheckBox, b => Global.Settings.V2RayConfig.AllowInsecure = b, Global.Settings.V2RayConfig.AllowInsecure);
BindCheckBox(UseMuxCheckBox, b => Global.Settings.V2RayConfig.UseMux = b, Global.Settings.V2RayConfig.UseMux); BindCheckBox(UseMuxCheckBox, b => Global.Settings.V2RayConfig.UseMux = b, Global.Settings.V2RayConfig.UseMux);
BindCheckBox(TCPFastOpenBox, b => Global.Settings.V2RayConfig.TCPFastOpen = b, Global.Settings.V2RayConfig.TCPFastOpen);
BindTextBox<int>(mtuTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.mtu = i, Global.Settings.V2RayConfig.KcpConfig.mtu); BindTextBox<int>(mtuTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.mtu = i, Global.Settings.V2RayConfig.KcpConfig.mtu);
BindTextBox<int>(ttiTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.tti = i, Global.Settings.V2RayConfig.KcpConfig.tti); BindTextBox<int>(ttiTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.tti = i, Global.Settings.V2RayConfig.KcpConfig.tti);

View File

@@ -11,4 +11,6 @@ public class V2rayConfig
public bool V2rayNShareLink { get; set; } = true; public bool V2rayNShareLink { get; set; } = true;
public bool XrayCone { get; set; } = true; public bool XrayCone { get; set; } = true;
public bool TCPFastOpen { get; set; } = false;
} }

View File

@@ -41,7 +41,7 @@
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.1"> <PackageReference Include="ConfigureAwait.Fody" Version="3.3.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Fody" Version="6.6.2"> <PackageReference Include="Fody" Version="6.6.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -48,6 +48,7 @@
"Address": "地址", "Address": "地址",
"Username": "用户名", "Username": "用户名",
"Password": "密码", "Password": "密码",
"Version": "版本",
"User ID": "用户 ID", "User ID": "用户 ID",
"Alter ID": "额外 ID", "Alter ID": "额外 ID",
"Transfer Protocol": "传输协议", "Transfer Protocol": "传输协议",
@@ -182,6 +183,7 @@
"STUN Server": "STUN 服务器", "STUN Server": "STUN 服务器",
"Language": "语言", "Language": "语言",
"FullCone Support (Required Server Xray-core v1.3.0+)": "FullCone 支持(需服务端 Xray-core v1.3.0+", "FullCone Support (Required Server Xray-core v1.3.0+)": "FullCone 支持(需服务端 Xray-core v1.3.0+",
"TCP FastOpen": "TCP 快速打开",
"Disable Support Warning": "停用支持警告", "Disable Support Warning": "停用支持警告",
"Profile": "配置名", "Profile": "配置名",

View File

@@ -12,6 +12,11 @@ public class Socks5Form : ServerForm
Server = server; Server = server;
CreateTextBox("Username", "Username", s => true, s => server.Username = s, server.Username.ValueOrDefault()); CreateTextBox("Username", "Username", s => true, s => server.Username = s, server.Username.ValueOrDefault());
CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password.ValueOrDefault()); CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password.ValueOrDefault());
CreateComboBox("Version",
"Version",
SOCKSGlobal.Versions,
s => server.Version = s,
server.Version);
(_remoteHostnameLabel, _remoteHostnameTextBox) = CreateTextBox("RemoteHostname", (_remoteHostnameLabel, _remoteHostnameTextBox) = CreateTextBox("RemoteHostname",
"Remote Address", "Remote Address",
s => true, s => true,

View File

@@ -4,7 +4,7 @@ namespace Netch.Servers;
public class Socks5Server : Server public class Socks5Server : Server
{ {
public override string Type { get; } = "Socks5"; public override string Type { get; } = "SOCKS";
/// <summary> /// <summary>
/// 密码 /// 密码
@@ -18,6 +18,11 @@ public class Socks5Server : Server
public string? RemoteHostname { get; set; } public string? RemoteHostname { get; set; }
/// <summary>
/// 版本
/// </summary>
public string Version { get; set; } = SOCKSGlobal.Versions[0];
public override string MaskedData() public override string MaskedData()
{ {
return $"Auth: {Auth()}"; return $"Auth: {Auth()}";
@@ -48,4 +53,14 @@ public class Socks5Server : Server
{ {
return !string.IsNullOrWhiteSpace(Username) && !string.IsNullOrWhiteSpace(Password); return !string.IsNullOrWhiteSpace(Username) && !string.IsNullOrWhiteSpace(Password);
} }
}
public class SOCKSGlobal
{
public static readonly List<string> Versions = new()
{
"5",
"4a",
"4"
};
} }

View File

@@ -7,11 +7,11 @@ public class Socks5Util : IServerUtil
{ {
public ushort Priority { get; } = 0; public ushort Priority { get; } = 0;
public string TypeName { get; } = "Socks5"; public string TypeName { get; } = "SOCKS";
public string FullName { get; } = "Socks5"; public string FullName { get; } = "SOCKS";
public string ShortName { get; } = "S5"; public string ShortName { get; } = "SOCKS";
public string[] UriScheme { get; } = { }; public string[] UriScheme { get; } = { };

View File

@@ -40,6 +40,8 @@ public class OutboundConfiguration
public object[] servers { get; set; } public object[] servers { get; set; }
public string version { get; set; }
public string address { get; set; } public string address { get; set; }
public ushort port { get; set; } public ushort port { get; set; }
@@ -81,6 +83,8 @@ public class ShadowsocksServerItem
public string method { get; set; } public string method { get; set; }
public string password { get; set; } public string password { get; set; }
public string flow { get; set; }
} }
public class Mux public class Mux
@@ -113,6 +117,8 @@ public class StreamSettings
public TlsSettings xtlsSettings { get; set; } public TlsSettings xtlsSettings { get; set; }
public GrpcSettings grpcSettings { get; set; } public GrpcSettings grpcSettings { get; set; }
public Sockopt sockopt { get; set; }
} }
#region Transport #region Transport
@@ -180,4 +186,9 @@ public class GrpcSettings
public bool multiMode { get; set; } public bool multiMode { get; set; }
} }
public class Sockopt
{
public bool tcpFastOpen { get; set; }
}
#endregion #endregion

View File

@@ -42,7 +42,7 @@ public static class V2rayConfigUtils
switch (server) switch (server)
{ {
case Socks5Server socks5: case Socks5Server socks:
{ {
outbound.protocol = "socks"; outbound.protocol = "socks";
outbound.settings.servers = new object[] outbound.settings.servers = new object[]
@@ -51,19 +51,20 @@ public static class V2rayConfigUtils
{ {
address = await server.AutoResolveHostnameAsync(), address = await server.AutoResolveHostnameAsync(),
port = server.Port, port = server.Port,
users = socks5.Auth() users = socks.Auth()
? new[] ? new[]
{ {
new new
{ {
user = socks5.Username, user = socks.Username,
pass = socks5.Password, pass = socks.Password,
level = 1 level = 1
} }
} }
: null : null
} }
}; };
outbound.settings.version = socks.Version;
outbound.mux.enabled = false; outbound.mux.enabled = false;
outbound.mux.concurrency = -1; outbound.mux.concurrency = -1;
@@ -82,8 +83,8 @@ public static class V2rayConfigUtils
{ {
new User new User
{ {
id = vless.UserID, id = getUUID(vless.UserID),
flow = vless.Flow.ValueOrDefault(), flow = vless.TLSSecureType == "xtls" ? "xtls-rprx-direct" : "",
encryption = vless.EncryptMethod encryption = vless.EncryptMethod
} }
} }
@@ -125,7 +126,7 @@ public static class V2rayConfigUtils
{ {
new User new User
{ {
id = vmess.UserID, id = getUUID(vmess.UserID),
alterId = vmess.AlterID, alterId = vmess.AlterID,
security = vmess.EncryptMethod security = vmess.EncryptMethod
} }
@@ -159,6 +160,17 @@ public static class V2rayConfigUtils
plugin = ss.Plugin ?? "", plugin = ss.Plugin ?? "",
pluginOpts = ss.PluginOption ?? "" pluginOpts = ss.PluginOption ?? ""
}; };
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break; break;
case ShadowsocksRServer ssr: case ShadowsocksRServer ssr:
outbound.protocol = "shadowsocks"; outbound.protocol = "shadowsocks";
@@ -183,6 +195,17 @@ public static class V2rayConfigUtils
"--protocol-param=" + ssr.ProtocolParam ?? "" "--protocol-param=" + ssr.ProtocolParam ?? ""
} }
}; };
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break; break;
case TrojanServer trojan: case TrojanServer trojan:
outbound.protocol = "trojan"; outbound.protocol = "trojan";
@@ -195,7 +218,8 @@ public static class V2rayConfigUtils
address = await server.AutoResolveHostnameAsync(), address = await server.AutoResolveHostnameAsync(),
port = server.Port, port = server.Port,
method = "", method = "",
password = trojan.Password password = trojan.Password,
flow = trojan.TLSSecureType == "xtls" ? "xtls-rprx-direct" : ""
} }
} }
}; };
@@ -223,6 +247,14 @@ public static class V2rayConfigUtils
break; break;
} }
} }
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings.sockopt = new Sockopt
{
tcpFastOpen = true
};
}
break; break;
case WireGuardServer wg: case WireGuardServer wg:
outbound.protocol = "wireguard"; outbound.protocol = "wireguard";
@@ -236,6 +268,17 @@ public static class V2rayConfigUtils
preSharedKey = wg.PreSharedKey, preSharedKey = wg.PreSharedKey,
mtu = wg.MTU mtu = wg.MTU
}; };
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break; break;
} }
@@ -364,6 +407,23 @@ public static class V2rayConfigUtils
throw new MessageException($"transfer protocol \"{server.TransferProtocol}\" not implemented yet"); throw new MessageException($"transfer protocol \"{server.TransferProtocol}\" not implemented yet");
} }
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
streamSettings.sockopt = new Sockopt
{
tcpFastOpen = true
};
}
return streamSettings; return streamSettings;
} }
public static string getUUID(string uuid)
{
if (uuid.Length == 36 || uuid.Length == 32)
{
return uuid;
}
return uuid.GenerateUUIDv5();
}
} }

View File

@@ -55,8 +55,6 @@ public static class V2rayUtils
if (server.TLSSecureType != "none") if (server.TLSSecureType != "none")
{ {
server.ServerName = parameter.Get("sni") ?? ""; server.ServerName = parameter.Get("sni") ?? "";
if (server.TLSSecureType == "xtls")
((VLESSServer)server).Flow = "xtls-rprx-direct"; // splice doesn't support Windows
} }
} }
@@ -137,9 +135,7 @@ public static class V2rayUtils
if (server.TLSSecureType == "xtls") if (server.TLSSecureType == "xtls")
{ {
var flow = ((VLESSServer)server).Flow; parameter.Add("flow", "xtls-rprx-direct");
if (!flow.IsNullOrWhiteSpace())
parameter.Add("flow", flow!.Replace("-udp443", ""));
} }
} }

View File

@@ -17,7 +17,6 @@ internal class VLESSForm : ServerForm
s => server.EncryptMethod = !string.IsNullOrWhiteSpace(s) ? s : "none", s => server.EncryptMethod = !string.IsNullOrWhiteSpace(s) ? s : "none",
server.EncryptMethod); server.EncryptMethod);
CreateTextBox("Flow", "Flow", s => true, s => server.Flow = s, server.Flow);
CreateComboBox("TransferProtocol", CreateComboBox("TransferProtocol",
"Transfer Protocol", "Transfer Protocol",
VLESSGlobal.TransferProtocols, VLESSGlobal.TransferProtocols,

View File

@@ -18,10 +18,6 @@ public class VLESSServer : VMessServer
/// 伪装类型 /// 伪装类型
/// </summary> /// </summary>
public override string FakeType { get; set; } = VLESSGlobal.FakeTypes[0]; public override string FakeType { get; set; } = VLESSGlobal.FakeTypes[0];
/// <summary>
/// </summary>
public string? Flow { get; set; } = "xtls-rprx-direct";
} }
public class VLESSGlobal public class VLESSGlobal

View File

@@ -1,4 +1,5 @@
using System.Text; using System.Security.Cryptography;
using System.Text;
namespace Netch.Utils; namespace Netch.Utils;
@@ -78,4 +79,30 @@ public static class StringExtension
{ {
return !string.IsNullOrWhiteSpace(value) ? value.Split(',') : default; return !string.IsNullOrWhiteSpace(value) ? value.Split(',') : default;
} }
public static string GenerateUUIDv5(this string str)
{
// https://github.com/XTLS/Xray-core/discussions/715
// https://xray-uuid.ducksoft.site/
SHA1 sha1 = new SHA1CryptoServiceProvider();
// example string: "example"
List<byte> byteSource = new List<byte>();
byteSource.AddRange(new byte[16]);
byteSource.AddRange(Encoding.UTF8.GetBytes(str));
byte[] Sha1Bytes = sha1.ComputeHash(byteSource.ToArray()).Skip(0).Take(16).ToArray();
sha1.Dispose();
//UUIDv5: [254 181 68 49 48 27 82 187 166 221 225 233 62 129 187 158]
Sha1Bytes[6] = (byte)((Sha1Bytes[6] & 0x0f) | (5 << 4));
Sha1Bytes[8] = (byte)(Sha1Bytes[8] & (0xff >> 2) | (0x02 << 6));
return BitConverter.ToString(Sha1Bytes).Replace("-", "")
.Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-")
.ToLower();
//UUIDv5: feb54431-301b-52bb-a6dd-e1e93e81bb9e
}
} }

View File

@@ -89,10 +89,10 @@ bool SocksHelper::Handshake(SOCKET client)
} }
/* Password */ /* Password */
buffer[1 + plength] = 0x00; buffer[1 + 1 + ulength] = 0x00;
if (plength != 0) if (plength != 0)
{ {
buffer[1 + ulength] = plength; buffer[1 + 1 + ulength] = plength;
memcpy(buffer + 1 + 1 + ulength + 1, tgtPassword.c_str(), plength); memcpy(buffer + 1 + 1 + ulength + 1, tgtPassword.c_str(), plength);
} }

View File

@@ -1,5 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Tests namespace Tests
{ {
@@ -11,5 +15,32 @@ namespace Tests
{ {
Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
} }
[TestMethod]
public void VLESS_UUID5()
{
//https://github.com/XTLS/Xray-core/discussions/715
byte[] bytes = new byte[16];
var str = "example";
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] StrBytes = Encoding.UTF8.GetBytes(str);
List<byte> byteSource = new List<byte>();
byteSource.AddRange(bytes);
byteSource.AddRange(StrBytes);
byte[] Sha1Bytes = sha1.ComputeHash(byteSource.ToArray()).Skip(0).Take(16).ToArray();
sha1.Dispose();
//UUIDv5: [254 181 68 49 48 27 82 187 166 221 225 233 62 129 187 158]
Sha1Bytes[6] = (byte)((Sha1Bytes[6] & 0x0f) | (5 << 4));
Sha1Bytes[8] = (byte)(Sha1Bytes[8] & (0xff >> 2) | (0x02 << 6));
var result = BitConverter.ToString(Sha1Bytes).Replace("-", "").Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-").ToLower();
Console.WriteLine(result);
//UUIDv5: feb54431-301b-52bb-a6dd-e1e93e81bb9e
}
} }
} }

View File

@@ -60,7 +60,7 @@ if ( -Not ( Test-Path ".\Netch\bin\$Configuration" ) ) {
-c $Configuration ` -c $Configuration `
-r 'win-x64' ` -r 'win-x64' `
-p:Platform='x64' ` -p:Platform='x64' `
-p:SelfContained=$False ` -p:SelfContained=$SelfContained `
-p:PublishTrimmed=$PublishReadyToRun ` -p:PublishTrimmed=$PublishReadyToRun `
-p:PublishSingleFile=$PublishSingleFile ` -p:PublishSingleFile=$PublishSingleFile `
-p:PublishReadyToRun=$PublishReadyToRun ` -p:PublishReadyToRun=$PublishReadyToRun `
@@ -103,4 +103,4 @@ if ( $Configuration.Equals('Release') ) {
} }
Pop-Location Pop-Location
exit 0 exit 0