From ff91a5dad9165539d962f46e3de56e8c8e76a8c4 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 22 Jan 2024 18:45:22 +0800 Subject: [PATCH] Add obfs 4 hysteria2 --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 1 + v2rayN/v2rayN/Handler/CoreConfigSingbox.cs | 9 +++++++++ v2rayN/v2rayN/Handler/ShareHandler.cs | 6 ++++++ v2rayN/v2rayN/Mode/SingboxConfig.cs | 7 +++++++ v2rayN/v2rayN/Resx/ResUI.Designer.cs | 9 +++++++++ v2rayN/v2rayN/Resx/ResUI.resx | 3 +++ v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 3 +++ v2rayN/v2rayN/Views/AddServerWindow.xaml | 16 ++++++++++++++++ v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 1 + 9 files changed, 55 insertions(+) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index d0177f28..4844c1f3 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -713,6 +713,7 @@ namespace v2rayN.Handler profileItem.address = profileItem.address.TrimEx(); profileItem.id = profileItem.id.TrimEx(); + profileItem.path = profileItem.path.TrimEx(); profileItem.network = string.Empty; if (Utils.IsNullOrEmpty(profileItem.streamSecurity)) diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs index c51fc8e8..e44ffe7e 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs @@ -283,6 +283,15 @@ namespace v2rayN.Handler outbound.password = node.id; + if (!Utils.IsNullOrEmpty(node.path)) + { + outbound.obfs = new() + { + type = "salamander", + password = node.path.TrimEx(), + }; + } + outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null; outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null; diff --git a/v2rayN/v2rayN/Handler/ShareHandler.cs b/v2rayN/v2rayN/Handler/ShareHandler.cs index ce965154..16508c93 100644 --- a/v2rayN/v2rayN/Handler/ShareHandler.cs +++ b/v2rayN/v2rayN/Handler/ShareHandler.cs @@ -180,6 +180,11 @@ namespace v2rayN.Handler { dicQuery.Add("alpn", Utils.UrlEncode(item.alpn)); } + if (!Utils.IsNullOrEmpty(item.path)) + { + dicQuery.Add("obfs", "salamander"); + dicQuery.Add("obfs-password", Utils.UrlEncode(item.path)); + } dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0"); string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray()); @@ -883,6 +888,7 @@ namespace v2rayN.Handler var query = Utils.ParseQueryString(url.Query); ResolveStdTransport(query, ref item); + item.path = Utils.UrlDecode(query["obfs-password"] ?? ""); item.allowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false"; return item; diff --git a/v2rayN/v2rayN/Mode/SingboxConfig.cs b/v2rayN/v2rayN/Mode/SingboxConfig.cs index 8253f4ed..ecde1b68 100644 --- a/v2rayN/v2rayN/Mode/SingboxConfig.cs +++ b/v2rayN/v2rayN/Mode/SingboxConfig.cs @@ -121,6 +121,7 @@ public Tls4Sbox tls { get; set; } public Multiplex4Sbox multiplex { get; set; } public Transport4Sbox transport { get; set; } + public HyObfs4Sbox obfs { get; set; } } public class Tls4Sbox @@ -174,6 +175,12 @@ public string? Host { get; set; } } + public class HyObfs4Sbox + { + public string? type { get; set; } + public string? password { get; set; } + } + public class Server4Sbox { public string tag { get; set; } diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index 35d926d5..256c941b 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -2185,6 +2185,15 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 obfs password 的本地化字符串。 + /// + public static string TbPath7 { + get { + return ResourceManager.GetString("TbPath7", resourceCulture); + } + } + /// /// 查找类似 Port 的本地化字符串。 /// diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 962c9de4..c8045e40 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -1180,4 +1180,7 @@ Address(Ip,Ipv6) + + obfs password + \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index e9fd31bf..0eb0bc73 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -1177,4 +1177,7 @@ Address(Ip,Ipv6) + + 混淆密码(obfs password) + \ No newline at end of file diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml b/v2rayN/v2rayN/Views/AddServerWindow.xaml index be1d03cf..8da7df19 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml @@ -429,6 +429,7 @@ + @@ -449,6 +450,21 @@ Width="400" Margin="{StaticResource ServerItemMargin}" Style="{StaticResource DefTextBox}" /> + + + vm.SelectedSource.id, v => v.txtId7.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath7.Text).DisposeWith(disposables); break; case EConfigType.Tuic: