From 59b7daaef585ac8aa9616853f786bbb894452b02 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Thu, 14 Nov 2024 14:25:58 +0800
Subject: [PATCH 1/3] Improve UI
---
.../Views/ProfilesView.axaml.cs | 2 +-
.../v2rayN.Desktop/Views/SubEditWindow.axaml | 53 ++++++++++++-------
2 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
index 9983f8c7..a2bfa298 100644
--- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
@@ -198,7 +198,7 @@ namespace v2rayN.Desktop.Views
private void LstProfiles_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
{
var source = e.Source as Border;
- if (source == null || source.Name != "CellBorder") return;
+ if (source?.Name == "HeaderBackground") return;
if (_config.UiItem.DoubleClick2Activate)
{
ViewModel?.SetDefaultServer();
diff --git a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml
index bd7e01f0..f0b25fe7 100644
--- a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml
@@ -95,6 +95,41 @@
Classes="Margin8"
TextWrapping="Wrap"
Watermark="{x:Static resx:ResUI.SubUrlTips}" />
+
-
-
From b8a0293b52ea30b295055afdb89da2c5f6c47f57 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Thu, 14 Nov 2024 14:37:03 +0800
Subject: [PATCH 2/3] Add xhttp extra for xray
https://github.com/XTLS/Xray-core/pull/4000
---
v2rayN/ServiceLib/Handler/ConfigHandler.cs | 1 +
v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs | 5 ++
v2rayN/ServiceLib/Models/ProfileItem.cs | 44 ++++----------
v2rayN/ServiceLib/Models/V2rayConfig.cs | 1 +
v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 9 +++
v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 3 +
v2rayN/ServiceLib/Resx/ResUI.resx | 3 +
v2rayN/ServiceLib/Resx/ResUI.ru.resx | 3 +
v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 3 +
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 3 +
.../CoreConfig/CoreConfigV2rayService.cs | 4 ++
.../Views/AddServerWindow.axaml | 60 +++++++++++++++----
.../Views/AddServerWindow.axaml.cs | 5 +-
v2rayN/v2rayN/Views/AddServerWindow.xaml | 58 ++++++++++++++----
v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 5 +-
15 files changed, 151 insertions(+), 56 deletions(-)
diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
index 17271c57..9ebb928d 100644
--- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
@@ -240,6 +240,7 @@ namespace ServiceLib.Handler
item.PublicKey = profileItem.PublicKey;
item.ShortId = profileItem.ShortId;
item.SpiderX = profileItem.SpiderX;
+ item.Extra = profileItem.Extra;
}
var ret = item.ConfigType switch
diff --git a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs
index 374fd9cb..c39ffe01 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs
@@ -107,6 +107,10 @@ namespace ServiceLib.Handler.Fmt
{
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
}
+ if (Utils.IsNotEmpty(item.Extra))
+ {
+ dicQuery.Add("extra", Utils.UrlEncode(item.Extra));
+ }
break;
case nameof(ETransport.http):
@@ -180,6 +184,7 @@ namespace ServiceLib.Handler.Fmt
item.RequestHost = Utils.UrlDecode(query["host"] ?? "");
item.Path = Utils.UrlDecode(query["path"] ?? "/");
item.HeaderType = Utils.UrlDecode(query["mode"] ?? "");
+ item.Extra = Utils.UrlDecode(query["extra"] ?? "");
break;
case nameof(ETransport.http):
diff --git a/v2rayN/ServiceLib/Models/ProfileItem.cs b/v2rayN/ServiceLib/Models/ProfileItem.cs
index b6e9aa6a..8bf5405e 100644
--- a/v2rayN/ServiceLib/Models/ProfileItem.cs
+++ b/v2rayN/ServiceLib/Models/ProfileItem.cs
@@ -30,44 +30,25 @@ namespace ServiceLib.Models
public string GetSummary()
{
- string summary = string.Format("[{0}] ", (ConfigType).ToString());
- string[] arrAddr = Address.Split('.');
- string addr;
- if (arrAddr.Length > 2)
+ var summary = $"[{(ConfigType).ToString()}] ";
+ var arrAddr = Address.Split('.');
+ var addr = arrAddr.Length switch
{
- addr = $"{arrAddr.First()}***{arrAddr.Last()}";
- }
- else if (arrAddr.Length > 1)
+ > 2 => $"{arrAddr.First()}***{arrAddr.Last()}",
+ > 1 => $"***{arrAddr.Last()}",
+ _ => Address
+ };
+ summary += ConfigType switch
{
- addr = $"***{arrAddr.Last()}";
- }
- else
- {
- addr = Address;
- }
- switch (ConfigType)
- {
- case EConfigType.Custom:
- summary += string.Format("[{1}]{0}", Remarks, CoreType.ToString());
- break;
-
- default:
- summary += string.Format("{0}({1}:{2})", Remarks, addr, Port);
- break;
- }
+ EConfigType.Custom => $"[{CoreType.ToString()}]{Remarks}",
+ _ => $"{Remarks}({addr}:{Port})"
+ };
return summary;
}
public List? GetAlpn()
{
- if (Utils.IsNullOrEmpty(Alpn))
- {
- return null;
- }
- else
- {
- return Utils.String2List(Alpn);
- }
+ return Utils.IsNullOrEmpty(Alpn) ? null : Utils.String2List(Alpn);
}
public string GetNetwork()
@@ -110,5 +91,6 @@ namespace ServiceLib.Models
public string PublicKey { get; set; }
public string ShortId { get; set; }
public string SpiderX { get; set; }
+ public string Extra { get; set; }
}
}
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs
index 710d627f..725d616a 100644
--- a/v2rayN/ServiceLib/Models/V2rayConfig.cs
+++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs
@@ -353,6 +353,7 @@ namespace ServiceLib.Models
public string? scMaxConcurrentPosts { get; set; }
public string? scMinPostsIntervalMs { get; set; }
public Xmux4Ray? xmux { get; set; }
+ public object? extra { get; set; }
}
public class Xmux4Ray
diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
index 76229529..30568641 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
+++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
@@ -3697,6 +3697,15 @@ namespace ServiceLib.Resx {
}
}
+ ///
+ /// 查找类似 XHTTP Extra raw JSON, format: { XHTTPObject } 的本地化字符串。
+ ///
+ public static string TransportExtraTip {
+ get {
+ return ResourceManager.GetString("TransportExtraTip", resourceCulture);
+ }
+ }
+
///
/// 查找类似 *tcp camouflage type 的本地化字符串。
///
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
index 917a82fc..991c9fe2 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
@@ -1384,4 +1384,7 @@
*xhttp mode
+
+ XHTTP Extra raw JSON, format: { XHTTPObject }
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx
index 22f7d4c2..9c69dc95 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.resx
@@ -1384,4 +1384,7 @@
*xhttp mode
+
+ XHTTP Extra raw JSON, format: { XHTTPObject }
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
index a7e16f18..20395013 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
@@ -1384,4 +1384,7 @@
*xhttp mode
+
+ XHTTP Extra raw JSON, format: { XHTTPObject }
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index fc83b374..18631825 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -1381,4 +1381,7 @@
*xhttp 模式
+
+ XHTTP Extra 原始 JSON,格式: { XHTTPObject }
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index 898ab7f6..c68e0da6 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -1381,4 +1381,7 @@
*xhttp 模式
+
+ XHTTP Extra 原始 JSON,格式: { XHTTPObject }
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
index 511498b9..d8f787e8 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
@@ -949,6 +949,10 @@ namespace ServiceLib.Services.CoreConfig
{
xhttpSettings.mode = node.HeaderType;
}
+ if (Utils.IsNotEmpty(node.Extra))
+ {
+ xhttpSettings.extra = JsonUtils.ParseJson(node.Extra);
+ }
streamSettings.xhttpSettings = xhttpSettings;
diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
index 5c6dff35..849bd0ce 100644
--- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
@@ -112,7 +112,7 @@
x:Name="txtPort"
Grid.Row="3"
Grid.Column="1"
- Width="100"
+ Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
@@ -164,7 +164,7 @@
x:Name="txtAlterId"
Grid.Row="2"
Grid.Column="1"
- Width="100"
+ Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
@@ -458,7 +458,7 @@
x:Name="cmbHeaderType8"
Grid.Row="3"
Grid.Column="1"
- Width="100"
+ Width="200"
Classes="Margin8" />
@@ -584,7 +584,7 @@
x:Name="cmbNetwork"
Grid.Row="1"
Grid.Column="1"
- Width="100"
+ Width="200"
Classes="Margin8" />
-
+ VerticalAlignment="Center"
+ Orientation="Horizontal">
+
+
+
+
vm.SelectedSource.HeaderType, v => v.cmbHeaderType.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
-
+ this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
+
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.SelectedValue).DisposeWith(disposables);
@@ -326,6 +327,7 @@ namespace v2rayN.Desktop.Views
network = Global.DefaultNetwork;
}
labHeaderType.IsVisible = true;
+ btnExtra.IsVisible = false;
tipRequestHost.Text =
tipPath.Text =
tipHeaderType.Text = string.Empty;
@@ -354,6 +356,7 @@ namespace v2rayN.Desktop.Views
tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.IsVisible = false;
+ btnExtra.IsVisible = true;
break;
case nameof(ETransport.h2):
diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml b/v2rayN/v2rayN/Views/AddServerWindow.xaml
index bbec6703..c0f15fed 100644
--- a/v2rayN/v2rayN/Views/AddServerWindow.xaml
+++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml
@@ -17,6 +17,13 @@
Style="{StaticResource WindowGlobal}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
+
+
+
+
+
+
+
@@ -188,7 +195,7 @@
x:Name="txtAlterId"
Grid.Row="2"
Grid.Column="1"
- Width="100"
+ Width="200"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
@@ -513,7 +520,7 @@
x:Name="cmbHeaderType8"
Grid.Row="3"
Grid.Column="1"
- Width="100"
+ Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
@@ -606,7 +613,7 @@
x:Name="txtShortId9"
Grid.Row="5"
Grid.Column="1"
- Width="100"
+ Width="200"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
@@ -653,7 +660,7 @@
x:Name="cmbNetwork"
Grid.Row="1"
Grid.Column="1"
- Width="100"
+ Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
-
+ VerticalAlignment="Center"
+ Orientation="Horizontal">
+
+
+
+
+
+
+
+
+
@@ -842,7 +876,7 @@
x:Name="cmbAllowInsecure"
Grid.Row="4"
Grid.Column="1"
- Width="100"
+ Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
index 24c8d637..3d5985a4 100644
--- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
+++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
@@ -202,7 +202,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
-
+ this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
+
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.Text).DisposeWith(disposables);
@@ -321,6 +322,7 @@ namespace v2rayN.Views
network = Global.DefaultNetwork;
}
labHeaderType.Visibility = Visibility.Visible;
+ popExtra.Visibility = Visibility.Hidden;
tipRequestHost.Text =
tipPath.Text =
tipHeaderType.Text = string.Empty;
@@ -349,6 +351,7 @@ namespace v2rayN.Views
tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.Visibility = Visibility.Hidden;
+ popExtra.Visibility = Visibility.Visible;
break;
case nameof(ETransport.h2):
From 57f9c8158e6ef7afb65286dd440d2653c6b1084c Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Thu, 14 Nov 2024 15:20:14 +0800
Subject: [PATCH 3/3] up 7.1.0
---
v2rayN/ServiceLib/ServiceLib.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayN/ServiceLib/ServiceLib.csproj
index 18aeed52..83d73e70 100644
--- a/v2rayN/ServiceLib/ServiceLib.csproj
+++ b/v2rayN/ServiceLib/ServiceLib.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 7.0.9
+ 7.1.0