Compare commits

..

123 Commits
6.39 ... 6.53

Author SHA1 Message Date
2dust
6500c8d85e up 6.53 2024-07-26 11:05:53 +08:00
2dust
9866d436da Add Outbound DNS address
https://github.com/2dust/v2rayN/issues/5387
2024-07-26 11:00:07 +08:00
2dust
0f4884d9d8 Improve and refactor the code 2024-07-25 10:26:39 +08:00
2dust
5a81441351 Adjust resx 2024-07-24 20:14:07 +08:00
2dust
e8721bfb6b Default dns changed to whitelist 2024-07-24 20:01:26 +08:00
2dust
1b09d95209 Improve UI 2024-07-24 19:51:13 +08:00
Jabin Kong
35f3b5a50e 1 (#5394) 2024-07-23 20:41:00 +08:00
2dust
ff5203a561 alpn h2,h3 2024-07-23 20:33:02 +08:00
2dust
c3c1ced309 up 6.52 2024-07-21 15:15:51 +08:00
2dust
08b1c8ec83 Improve latency testing 2024-07-21 15:15:00 +08:00
NagisaEfi
1dd3ee4e0a Update English translations (#5381)
* Update ResUI.resx

* Update ResUI.resx
2024-07-21 11:48:55 +08:00
Random Guy
06d0c6517d fix: add real delay test for custom config (#5377) 2024-07-21 11:44:12 +08:00
2dust
4938ce6364 Code clean 2024-07-21 11:37:11 +08:00
2dust
25f3fc354f Add multi-server load balancing 2024-07-21 11:26:10 +08:00
2dust
ad1a1f8015 Main window layout orientation setting 2024-07-19 20:31:07 +08:00
2dust
5c070e2ca8 Improve UI 2024-07-19 10:51:14 +08:00
2dust
70ea21fca2 Improve UI 2024-07-18 19:59:46 +08:00
2dust
bc3593871b Refactor the main interface 2024-07-18 17:39:11 +08:00
2dust
355a424be2 Code clean 2024-07-18 17:31:49 +08:00
2dust
0ffa9a0cc8 Remove unused resx
Remove Batch export subscription to clipboard
2024-07-15 20:17:55 +08:00
2dust
72fecb2b9a Add clash_mode to rule 2024-07-14 20:17:48 +08:00
2dust
4e9dfe5478 Improve 2024-07-14 17:16:07 +08:00
2dust
c79e2e3ad4 Add functionality multi-server set as active
Implemented using sing-box Selector, which can be switched using the clash api
2024-07-14 16:13:28 +08:00
2dust
7c33c1c322 Add reload for ClashProxiesView 2024-07-14 14:28:45 +08:00
2dust
ea32f75925 Code clean 2024-07-14 11:00:22 +08:00
2dust
7eaed21b9a Improve 2024-07-14 10:59:36 +08:00
2dust
cfe8fcd28d up 6.51 2024-07-12 14:23:29 +08:00
2dust
9f4718af70 Code clean
Add allowInsecure to Share
2024-07-11 14:42:01 +08:00
2dust
39faccfd0b Bug fix 2024-07-10 17:32:26 +08:00
2dust
7545763dae Default domain strategy for resolving the outbound domain names -- singbox 2024-07-08 18:45:29 +08:00
2dust
c2928be35d Log messages are not displayed when in the background 2024-07-08 17:16:49 +08:00
2dust
449bb40d48 sing-box prioritizes the use of local srs 2024-07-08 14:20:41 +08:00
2dust
4caf1a1e63 Improve and refactor the code 2024-07-08 09:52:11 +08:00
2dust
01b205e6f1 Adjust information DispatcherPriority 2024-07-07 21:11:04 +08:00
2dust
160d3843a6 Bug fix 2024-07-05 15:28:28 +08:00
2dust
5efb784115 up 6.50 2024-07-05 11:18:36 +08:00
2dust
acde5b8384 Bug fix 2024-07-05 11:18:14 +08:00
2dust
373ee6586a Optimize system proxy code 2024-07-04 17:07:05 +08:00
2dust
215308c329 Change srs source
https://github.com/2dust/sing-box-rules
2024-07-04 16:27:44 +08:00
2dust
478cadba5e Bug fix 2024-06-30 20:43:06 +08:00
2dust
f4af4da791 Adjust res 2024-06-30 10:00:28 +08:00
2dust
22d4f435de Add tun and mixin functions to clash 2024-06-28 20:29:44 +08:00
2dust
ccb8cd5c04 up 6.49 2024-06-28 16:14:45 +08:00
2dust
e963f9e349 Add clash display in the main interface 2024-06-28 16:14:19 +08:00
2dust
e3c2a4b8da Bug fix 2024-06-28 10:41:17 +08:00
2dust
324f46cdad Bug fix
https://github.com/2dust/v2rayN/discussions/5268
2024-06-27 17:59:39 +08:00
2dust
691b19b5fd Adding support for the clash proxies interface 2024-06-27 16:36:36 +08:00
2dust
63ed2311dc Bug fix 2024-06-26 16:00:37 +08:00
2dust
d59e59ca40 up 6.48 2024-06-24 17:42:37 +08:00
2dust
c9a278b4a2 Check for updates mihomo 2024-06-24 17:41:53 +08:00
2dust
8ee5304148 Bug fix 2024-06-24 16:42:17 +08:00
2dust
3beaa8145f Bug fix 2024-06-24 16:19:00 +08:00
2dust
e30c55a0af up 6.47 2024-06-24 15:34:41 +08:00
2dust
b583590a64 Update ConfigHandler.cs
https://github.com/2dust/v2rayN/pull/5264
2024-06-24 15:25:00 +08:00
OnceUponATimeInAmerica
a28c63168a Support for setting subs-group remarks (group's name) from the (optional) "remark" query parameter in the pasted subs url (#5264) 2024-06-24 15:20:16 +08:00
2dust
620422350f Improved tun mode
Enabling tun mode.
Only one core will be run when using sing-box core;
When using a non-sing-box, the sing-box will be used to start an additional front Socks service to provide a tun entry, which will then run two cores
2024-06-24 15:19:42 +08:00
2dust
b77cc3c33b Add network attribute to route rule
https://github.com/2dust/v2rayN/discussions/5256
2024-06-22 16:44:15 +08:00
2dust
71bf9b4887 up 6.46 2024-06-21 16:02:08 +08:00
2dust
9039d401da set DOTNET_EnableWriteXorExecute=0 under win10
https://github.com/2dust/v2rayN/issues/5186
2024-06-21 14:09:57 +08:00
2dust
74a0a93201 Improve and refactor the code 2024-06-21 11:15:35 +08:00
2dust
522571f0b3 Add splithttp transport for xray
https://github.com/XTLS/Xray-core/releases/tag/v1.8.15
2024-06-20 16:20:05 +08:00
Lsyx-Good
123c49c22d Adjust singbox DNS server and rule position (#5229) 2024-06-20 16:08:08 +08:00
OnceUponATimeInAmerica
1ff88d29be Extend stats reporting to support custom configs with several load-balanced outbounds in them, with tags starting with "proxy" e.g. proxy1, proxy2 (fully compatible with existing configs) (#5225) 2024-06-20 15:32:10 +08:00
Lsyx-Good
63d5a2a1be Fix bug (#5213) 2024-06-10 15:12:39 +08:00
2dust
1e9a6cb06b Refactor code 2024-06-04 09:48:04 +08:00
2dust
31748aa660 Refactor code 2024-06-03 17:50:18 +08:00
2dust
d0c6ea6a63 remove http://cachefly.cachefly.net/100mb.test 2024-06-03 14:06:59 +08:00
2dust
7ffe286a56 Up PackageReference 2024-06-03 07:37:49 +08:00
2dust
b99b30163b Bug fix 2024-06-03 07:37:26 +08:00
kirilllivanov
83b4f1e660 Fix incorrect filenames (#5122) 2024-05-18 17:11:38 +08:00
2dust
b57ba6a98b up 6.45 2024-05-18 09:53:15 +08:00
2dust
d748e6eff4 Add destOverride 2024-05-14 15:31:19 +08:00
2dust
315d4b75b2 Optimize code 2024-05-14 13:42:42 +08:00
2dust
31267cbc33 Adjust Scan screen qrcode 2024-05-12 17:07:56 +08:00
2dust
c23379b3b6 Adjust sing-box dns 2024-05-12 15:42:28 +08:00
2dust
568144d6a2 TransitionAssist DisableTransitions 2024-05-12 14:59:23 +08:00
2dust
5857042963 Up 6.44 2024-05-08 13:40:24 +08:00
2dust
28e41dc621 Add open the file location 2024-05-08 11:43:03 +08:00
2dust
baef3b364b Bug fix 2024-05-08 11:42:01 +08:00
2dust
4b9ddb803f Bug fix 2024-05-07 14:15:08 +08:00
2dust
c07c7ad82f Added reminder that a reboot is required to modify settings 2024-05-06 17:19:29 +08:00
2dust
e223b80b95 Merge pull request #5066 from sincereliu/master
Optimize code for better performance
2024-05-06 09:55:30 +08:00
sincere liu
5fe468fa1b Optimize code for better performance 2024-05-05 22:07:51 +08:00
2dust
60068d8d16 Themes migrate 2024-05-05 16:19:47 +08:00
2dust
b6c5b46afe Up PackageReference 2024-05-05 10:10:19 +08:00
2dust
124cbfadb4 Add custom sing-box rule-set support 2024-05-04 13:54:22 +08:00
2dust
8d21f9b900 Bug fix 2024-05-04 13:24:13 +08:00
2dust
398dbbd2e5 Bug fix
https://github.com/2dust/v2rayN/issues/5035
2024-05-03 10:29:32 +08:00
2dust
e9b392d1c0 Optimized sorted storage 2024-04-30 14:44:02 +08:00
2dust
9d7c7e3225 Adjust the experimental and mux of sing-box 2024-04-27 10:05:13 +08:00
2dust
855fd4f0b7 Merge pull request #5026 from GibMeMyPacket/feat/singbox/exp_cachefile
Add `Enable cache file for sing-box`
2024-04-27 09:42:31 +08:00
GibMeMyPacket
807839929d Add Enable cache file for sing-box 2024-04-25 12:07:53 +00:00
2dust
870955fee1 Bug fix 2024-04-11 08:07:21 +08:00
2dust
e0cea929ea Up 6.43 2024-04-10 13:52:38 +08:00
2dust
315f4c35f0 Code clean 2024-04-10 13:32:50 +08:00
2dust
d961ea22a6 Built-in routing rule set upgraded to V2 2024-04-10 10:50:52 +08:00
2dust
5c0c07c78f Migrate geosite & geoip to rule sets (sing-box) 2024-04-10 08:42:53 +08:00
2dust
bba93a0fb7 Added tls fragment support (Xray-core)
https://github.com/2dust/v2rayN/issues/4900
2024-04-08 17:06:48 +08:00
2dust
5683df2fc0 Added outbound HTTP support (support group prefix proxy)
https://github.com/2dust/v2rayN/discussions/4550
2024-04-08 14:02:56 +08:00
2dust
b5cb9ce67e Set autoHideStartup default value is false 2024-04-05 17:24:53 +08:00
2dust
06a32dc895 Adjust sing-box dns default example 2024-04-05 11:05:45 +08:00
2dust
dff12a8a3a fix
https://github.com/2dust/v2rayN/issues/4928
2024-04-05 11:04:35 +08:00
2dust
dc3f07ee84 Bug fix 2024-04-03 09:51:07 +08:00
2dust
1aef49ee11 Custom configuration file to use Xray prefix in non-Tun mode
https://github.com/2dust/v2rayN/issues/4855
2024-04-01 08:22:14 +08:00
2dust
ee3159b00e Update 6.42 2024-03-31 17:26:02 +08:00
2dust
86d2c307f1 Bug fix 2024-03-31 17:23:33 +08:00
2dust
7823a217b4 Update 6.41 2024-03-31 08:09:13 +08:00
2dust
2004df8337 Rename Model to Models 2024-03-31 08:08:06 +08:00
2dust
13bc2d0340 Bug fix
https://github.com/2dust/v2rayN/issues/4902
2024-03-31 07:54:22 +08:00
2dust
edbc850346 Update 6.40 2024-03-30 18:12:37 +08:00
2dust
901d3c85ca Up PackageReference 2024-03-30 16:15:13 +08:00
2dust
abbe83f3c2 Fixed issues with multi-core traffic processing 2024-03-30 16:00:19 +08:00
2dust
bb3a04a9c8 Bug fix for exit app 2024-03-30 15:26:12 +08:00
2dust
bac13e8b71 Rename Utile to Utils 2024-03-26 14:26:03 +08:00
2dust
3871681de3 Improve remove Application.Current.Shutdown 2024-03-26 14:22:53 +08:00
2dust
ae6f2b6df6 Up PackageReference 2024-03-26 14:19:14 +08:00
2dust
f59bbc9981 Add authority for grpc 2024-03-23 18:26:44 +08:00
2dust
eac0c84e11 Improve IsNullOrEmpty 2024-03-23 18:26:04 +08:00
2dust
f814cc443d Improve 2024-03-23 10:47:06 +08:00
2dust
262466303b Import Multiple Custom v2ray-core Json Configs from Subscription
https://github.com/2dust/v2rayN/issues/4745
2024-03-23 10:46:45 +08:00
2dust
3b4cc2c5f2 Merge pull request #4848 from 1208nn/patch-2
Update schdtask related code
2024-03-16 16:25:58 +08:00
ShH Y
023d3fbf6f Update Utile.cs 2024-03-16 11:38:41 +08:00
2dust
fe01f290bc Improve 2024-03-13 16:38:37 +08:00
150 changed files with 9813 additions and 6230 deletions

View File

@@ -9,9 +9,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.25.3" /> <PackageReference Include="Google.Protobuf" Version="3.27.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.61.0" /> <PackageReference Include="Grpc.Net.Client" Version="2.63.0" />
<PackageReference Include="Grpc.Tools" Version="2.62.0"> <PackageReference Include="Grpc.Tools" Version="2.64.0">
<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

@@ -13,13 +13,14 @@
BaseTheme="Light" BaseTheme="Light"
PrimaryColor="Blue" PrimaryColor="Blue"
SecondaryColor="Lime" /> SecondaryColor="Lime" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<system:Double x:Key="MenuItemHeight">26</system:Double> <system:Double x:Key="MenuItemHeight">26</system:Double>
<system:Double x:Key="StdFontSize">12</system:Double> <system:Double x:Key="StdFontSize">12</system:Double>
<system:Double x:Key="StdFontSize1">13</system:Double> <system:Double x:Key="StdFontSize1">13</system:Double>
<system:Double x:Key="StdFontSize2">14</system:Double> <system:Double x:Key="StdFontSize2">14</system:Double>
<system:Double x:Key="StdFontSizeMsg">11</system:Double> <system:Double x:Key="StdFontSizeMsg">11</system:Double>
<system:Double x:Key="StdFontSize-1">11</system:Double>
<conv:InverseBooleanConverter x:Key="InverseBooleanConverter" /> <conv:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<Thickness <Thickness
@@ -68,16 +69,21 @@
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" /> <Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
</Style> </Style>
<Style x:Key="lvItemSelected" TargetType="{x:Type ListViewItem}"> <Style x:Key="lvItemSelected" TargetType="{x:Type ListViewItem}">
<Setter Property="Height" Value="20" /> <Setter Property="Margin" Value="2" />
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" /> <Setter Property="Template">
<Style.Triggers> <Setter.Value>
<Trigger Property="IsSelected" Value="true"> <ControlTemplate TargetType="ListViewItem">
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" /> <materialDesign:Card Name="_Card" SnapsToDevicePixels="true">
</Trigger> <ContentPresenter />
<Trigger Property="IsMouseOver" Value="true"> </materialDesign:Card>
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}" /> <ControlTemplate.Triggers>
</Trigger> <Trigger Property="IsSelected" Value="true">
</Style.Triggers> <Setter TargetName="_Card" Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> </Style>
<Style x:Key="GridViewColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}"> <Style x:Key="GridViewColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
@@ -156,6 +162,27 @@
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
<Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" /> <Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" />
</Style> </Style>
<Style x:Key="ListItemChip" TargetType="{x:Type materialDesign:Chip}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
</Style>
<Style
x:Key="ListItemTitle"
BasedOn="{StaticResource MaterialDesignTextBlock}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
</Style>
<Style
x:Key="ListItemSubTitle"
BasedOn="{StaticResource MaterialDesignTextBlock}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
</Style>
<Style
x:Key="ListItemSubTitle2"
BasedOn="{StaticResource MaterialDesignTextBlock}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize-1}" />
</Style>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@@ -1,7 +1,8 @@
using System.Windows; using System.Diagnostics;
using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Model; using v2rayN.Models;
namespace v2rayN namespace v2rayN
{ {
@@ -27,14 +28,13 @@ namespace v2rayN
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)
{ {
var exePathKey = Utile.GetMD5(Utile.GetExePath()); var exePathKey = Utils.GetMD5(Utils.GetExePath());
var rebootas = (e.Args ?? new string[] { }).Any(t => t == Global.RebootAs); var rebootas = (e.Args ?? new string[] { }).Any(t => t == Global.RebootAs);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew); ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
if (!rebootas && !bCreatedNew) if (!rebootas && !bCreatedNew)
{ {
ProgramStarted.Set(); ProgramStarted.Set();
Current.Shutdown();
Environment.Exit(0); Environment.Exit(0);
return; return;
} }
@@ -42,7 +42,8 @@ namespace v2rayN
Logging.Setup(); Logging.Setup();
Init(); Init();
Logging.LoggingEnabled(_config.guiItem.enableLog); Logging.LoggingEnabled(_config.guiItem.enableLog);
Logging.SaveLog($"v2rayN start up | {Utile.GetVersion()} | {Utile.GetExePath()}"); Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
Logging.ClearLogs(); Logging.ClearLogs();
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage); Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);
@@ -55,14 +56,15 @@ namespace v2rayN
if (ConfigHandler.LoadConfig(ref _config) != 0) if (ConfigHandler.LoadConfig(ref _config) != 0)
{ {
UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用"); UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
Application.Current.Shutdown();
Environment.Exit(0); Environment.Exit(0);
return; return;
} }
//if (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.X64)
//{ //Under Win10
// _config.guiItem.enableStatistics = false; if (Environment.OSVersion.Version.Major < 10)
//} {
Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.User);
}
} }
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
@@ -83,5 +85,12 @@ namespace v2rayN
{ {
Logging.SaveLog("TaskScheduler_UnobservedTaskException", e.Exception); Logging.SaveLog("TaskScheduler_UnobservedTaskException", e.Exception);
} }
protected override void OnExit(ExitEventArgs e)
{
Logging.SaveLog("OnExit");
base.OnExit(e);
Process.GetCurrentProcess().Kill();
}
} }
} }

View File

@@ -11,7 +11,7 @@ namespace v2rayN
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout) public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
{ {
if (string.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
return null; return null;
} }
@@ -19,9 +19,9 @@ namespace v2rayN
Uri uri = new(url); Uri uri = new(url);
//Authorization Header //Authorization Header
var headers = new WebHeaderCollection(); var headers = new WebHeaderCollection();
if (!Utile.IsNullOrEmpty(uri.UserInfo)) if (!Utils.IsNullOrEmpty(uri.UserInfo))
{ {
headers.Add(HttpRequestHeader.Authorization, "Basic " + Utile.Base64Encode(uri.UserInfo)); headers.Add(HttpRequestHeader.Authorization, "Basic " + Utils.Base64Encode(uri.UserInfo));
} }
var downloadOpt = new DownloadConfiguration() var downloadOpt = new DownloadConfiguration()
@@ -57,7 +57,7 @@ namespace v2rayN
public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout) public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout)
{ {
if (string.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
throw new ArgumentNullException(nameof(url)); throw new ArgumentNullException(nameof(url));
} }
@@ -120,11 +120,11 @@ namespace v2rayN
public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout) public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout)
{ {
if (string.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
throw new ArgumentNullException(nameof(url)); throw new ArgumentNullException(nameof(url));
} }
if (string.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
throw new ArgumentNullException(nameof(fileName)); throw new ArgumentNullException(nameof(fileName));
} }

View File

@@ -67,7 +67,7 @@ namespace v2rayN
} }
try try
{ {
if (!Utile.IsNullOrEmpty(ignoredName) && entry.Name.Contains(ignoredName)) if (!Utils.IsNullOrEmpty(ignoredName) && entry.Name.Contains(ignoredName))
{ {
continue; continue;
} }

View File

@@ -1,5 +1,6 @@
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime; using System.Net.Mime;
using System.Text; using System.Text;
@@ -21,26 +22,57 @@ namespace v2rayN
private HttpClientHelper(HttpClient httpClient) => this.httpClient = httpClient; private HttpClientHelper(HttpClient httpClient) => this.httpClient = httpClient;
public async Task<string?> TryGetAsync(string url)
{
if (string.IsNullOrEmpty(url))
return null;
try
{
HttpResponseMessage response = await httpClient.GetAsync(url);
return await response.Content.ReadAsStringAsync();
}
catch
{
return null;
}
}
public async Task<string?> GetAsync(string url) public async Task<string?> GetAsync(string url)
{ {
if (string.IsNullOrEmpty(url)) return null; if (Utils.IsNullOrEmpty(url)) return null;
return await httpClient.GetStringAsync(url); return await httpClient.GetStringAsync(url);
} }
public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default) public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default)
{ {
if (string.IsNullOrWhiteSpace(url)) return null; if (Utils.IsNullOrEmpty(url)) return null;
return await client.GetStringAsync(url, token); return await client.GetStringAsync(url, token);
} }
public async Task PutAsync(string url, Dictionary<string, string> headers) public async Task PutAsync(string url, Dictionary<string, string> headers)
{ {
var jsonContent = JsonUtile.Serialize(headers); var jsonContent = JsonUtils.Serialize(headers);
var content = new StringContent(jsonContent, Encoding.UTF8, MediaTypeNames.Application.Json); var content = new StringContent(jsonContent, Encoding.UTF8, MediaTypeNames.Application.Json);
var result = await httpClient.PutAsync(url, content); var result = await httpClient.PutAsync(url, content);
} }
public async Task PatchAsync(string url, Dictionary<string, string> headers)
{
var myContent = JsonUtils.Serialize(headers);
var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
await httpClient.PatchAsync(url, byteContent);
}
public async Task DeleteAsync(string url)
{
await httpClient.DeleteAsync(url);
}
public static async Task DownloadFileAsync(HttpClient client, string url, string fileName, IProgress<double>? progress, CancellationToken token = default) public static async Task DownloadFileAsync(HttpClient client, string url, string fileName, IProgress<double>? progress, CancellationToken token = default)
{ {
ArgumentNullException.ThrowIfNull(url); ArgumentNullException.ThrowIfNull(url);
@@ -76,19 +108,19 @@ namespace v2rayN
//if (progressPercentage != percent && percent % 10 == 0) //if (progressPercentage != percent && percent % 10 == 0)
{ {
progressPercentage = percent; progressPercentage = percent;
progress!.Report(percent); progress?.Report(percent);
} }
} }
} }
if (canReportProgress) if (canReportProgress)
{ {
progress!.Report(101); progress?.Report(101);
} }
} }
public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default) public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default)
{ {
if (string.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
throw new ArgumentNullException(nameof(url)); throw new ArgumentNullException(nameof(url));
} }

View File

@@ -5,7 +5,7 @@ using System.Text.Json.Serialization;
namespace v2rayN namespace v2rayN
{ {
internal class JsonUtile internal class JsonUtils
{ {
/// <summary> /// <summary>
/// DeepCopy /// DeepCopy
@@ -28,7 +28,7 @@ namespace v2rayN
{ {
try try
{ {
if (string.IsNullOrEmpty(strJson)) if (string.IsNullOrWhiteSpace(strJson))
{ {
return default; return default;
} }
@@ -49,7 +49,7 @@ namespace v2rayN
{ {
try try
{ {
if (string.IsNullOrEmpty(strJson)) if (string.IsNullOrWhiteSpace(strJson))
{ {
return null; return null;
} }
@@ -105,9 +105,12 @@ namespace v2rayN
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <param name="nullValue"></param> /// <param name="nullValue"></param>
/// <returns></returns> /// <returns></returns>
public static int ToFile(object? obj, string filePath, bool nullValue = true) public static int ToFile(object? obj, string? filePath, bool nullValue = true)
{ {
int result; if (filePath is null)
{
return -1;
}
try try
{ {
using FileStream file = File.Create(filePath); using FileStream file = File.Create(filePath);
@@ -119,14 +122,13 @@ namespace v2rayN
}; };
JsonSerializer.Serialize(file, obj, options); JsonSerializer.Serialize(file, obj, options);
result = 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(ex.Message, ex);
result = -1; return -1;
} }
return result;
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace v2rayN
FileTarget fileTarget = new(); FileTarget fileTarget = new();
config.AddTarget("file", fileTarget); config.AddTarget("file", fileTarget);
fileTarget.Layout = "${longdate}-${level:uppercase=true} ${message}"; fileTarget.Layout = "${longdate}-${level:uppercase=true} ${message}";
fileTarget.FileName = Utile.GetLogPath("${shortdate}.txt"); fileTarget.FileName = Utils.GetLogPath("${shortdate}.txt");
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget)); config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
LogManager.Configuration = config; LogManager.Configuration = config;
} }
@@ -33,7 +33,7 @@ namespace v2rayN
try try
{ {
var now = DateTime.Now.AddMonths(-1); var now = DateTime.Now.AddMonths(-1);
var dir = Utile.GetLogPath(); var dir = Utils.GetLogPath();
var files = Directory.GetFiles(dir, "*.txt"); var files = Directory.GetFiles(dir, "*.txt");
foreach (var filePath in files) foreach (var filePath in files)
{ {

View File

@@ -1,10 +1,38 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using static v2rayN.Handler.ProxySetting.InternetConnectionOption; using static v2rayN.Common.ProxySetting.InternetConnectionOption;
namespace v2rayN.Handler namespace v2rayN.Common
{ {
internal class ProxySetting internal class ProxySetting
{ {
private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
private static bool SetProxyFallback(string? strProxy, string? exceptions, int type)
{
if (type == 1)
{
Utils.RegWriteValue(_regPath, "ProxyEnable", 0);
Utils.RegWriteValue(_regPath, "ProxyServer", string.Empty);
Utils.RegWriteValue(_regPath, "ProxyOverride", string.Empty);
Utils.RegWriteValue(_regPath, "AutoConfigURL", string.Empty);
}
if (type == 2)
{
Utils.RegWriteValue(_regPath, "ProxyEnable", 1);
Utils.RegWriteValue(_regPath, "ProxyServer", strProxy ?? string.Empty);
Utils.RegWriteValue(_regPath, "ProxyOverride", exceptions ?? string.Empty);
Utils.RegWriteValue(_regPath, "AutoConfigURL", string.Empty);
}
else if (type == 4)
{
Utils.RegWriteValue(_regPath, "ProxyEnable", 0);
Utils.RegWriteValue(_regPath, "ProxyServer", string.Empty);
Utils.RegWriteValue(_regPath, "ProxyOverride", string.Empty);
Utils.RegWriteValue(_regPath, "AutoConfigURL", strProxy ?? string.Empty);
}
return true;
}
/// <summary> /// <summary>
// set to use no proxy // set to use no proxy
/// </summary> /// </summary>
@@ -29,15 +57,24 @@ namespace v2rayN.Handler
/// <returns>true: one of connection is successfully updated proxy settings</returns> /// <returns>true: one of connection is successfully updated proxy settings</returns>
public static bool SetProxy(string? strProxy, string? exceptions, int type) public static bool SetProxy(string? strProxy, string? exceptions, int type)
{ {
// set proxy for LAN try
bool result = SetConnectionProxy(null, strProxy, exceptions, type);
// set proxy for dial up connections
var connections = EnumerateRasEntries();
foreach (var connection in connections)
{ {
result |= SetConnectionProxy(connection, strProxy, exceptions, type); // set proxy for LAN
bool result = SetConnectionProxy(null, strProxy, exceptions, type);
// set proxy for dial up connections
var connections = EnumerateRasEntries();
foreach (var connection in connections)
{
result |= SetConnectionProxy(connection, strProxy, exceptions, type);
}
return result;
}
catch (Exception ex)
{
SetProxyFallback(strProxy, exceptions, type);
Logging.SaveLog(ex.Message, ex);
return false;
} }
return result;
} }
private static bool SetConnectionProxy(string? connectionName, string? strProxy, string? exceptions, int type) private static bool SetConnectionProxy(string? connectionName, string? strProxy, string? exceptions, int type)
@@ -51,7 +88,7 @@ namespace v2rayN.Handler
} }
else if (type is 2 or 4) // named proxy or autoproxy script URL else if (type is 2 or 4) // named proxy or autoproxy script URL
{ {
optionCount = Utile.IsNullOrEmpty(exceptions) ? 2 : 3; optionCount = Utils.IsNullOrEmpty(exceptions) ? 2 : 3;
} }
int m_Int = (int)PerConnFlags.PROXY_TYPE_DIRECT; int m_Int = (int)PerConnFlags.PROXY_TYPE_DIRECT;
@@ -94,25 +131,25 @@ namespace v2rayN.Handler
} }
else else
{ {
list.szConnection = IntPtr.Zero; list.szConnection = nint.Zero;
} }
list.dwOptionCount = options.Length; list.dwOptionCount = options.Length;
list.dwOptionError = 0; list.dwOptionError = 0;
int optSize = Marshal.SizeOf(typeof(InternetConnectionOption)); int optSize = Marshal.SizeOf(typeof(InternetConnectionOption));
// make a pointer out of all that ... // make a pointer out of all that ...
IntPtr optionsPtr = Marshal.AllocCoTaskMem(optSize * options.Length); // !! remember to deallocate memory 4 nint optionsPtr = Marshal.AllocCoTaskMem(optSize * options.Length); // !! remember to deallocate memory 4
// copy the array over into that spot in memory ... // copy the array over into that spot in memory ...
for (int i = 0; i < options.Length; ++i) for (int i = 0; i < options.Length; ++i)
{ {
if (Environment.Is64BitOperatingSystem) if (Environment.Is64BitOperatingSystem)
{ {
IntPtr opt = new(optionsPtr.ToInt64() + (i * optSize)); nint opt = new(optionsPtr.ToInt64() + i * optSize);
Marshal.StructureToPtr(options[i], opt, false); Marshal.StructureToPtr(options[i], opt, false);
} }
else else
{ {
IntPtr opt = new(optionsPtr.ToInt32() + (i * optSize)); nint opt = new(optionsPtr.ToInt32() + i * optSize);
Marshal.StructureToPtr(options[i], opt, false); Marshal.StructureToPtr(options[i], opt, false);
} }
} }
@@ -120,11 +157,11 @@ namespace v2rayN.Handler
list.options = optionsPtr; list.options = optionsPtr;
// and then make a pointer out of the whole list // and then make a pointer out of the whole list
IntPtr ipcoListPtr = Marshal.AllocCoTaskMem(list.dwSize); // !! remember to deallocate memory 5 nint ipcoListPtr = Marshal.AllocCoTaskMem(list.dwSize); // !! remember to deallocate memory 5
Marshal.StructureToPtr(list, ipcoListPtr, false); Marshal.StructureToPtr(list, ipcoListPtr, false);
// and finally, call the API method! // and finally, call the API method!
bool isSuccess = NativeMethods.InternetSetOption(IntPtr.Zero, bool isSuccess = NativeMethods.InternetSetOption(nint.Zero,
InternetOption.INTERNET_OPTION_PER_CONNECTION_OPTION, InternetOption.INTERNET_OPTION_PER_CONNECTION_OPTION,
ipcoListPtr, list.dwSize); ipcoListPtr, list.dwSize);
int returnvalue = 0; // ERROR_SUCCESS int returnvalue = 0; // ERROR_SUCCESS
@@ -135,12 +172,12 @@ namespace v2rayN.Handler
else else
{ {
// Notify the system that the registry settings have been changed and cause them to be refreshed // Notify the system that the registry settings have been changed and cause them to be refreshed
NativeMethods.InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0); NativeMethods.InternetSetOption(nint.Zero, InternetOption.INTERNET_OPTION_SETTINGS_CHANGED, nint.Zero, 0);
NativeMethods.InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0); NativeMethods.InternetSetOption(nint.Zero, InternetOption.INTERNET_OPTION_REFRESH, nint.Zero, 0);
} }
// FREE the data ASAP // FREE the data ASAP
if (list.szConnection != IntPtr.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3 if (list.szConnection != nint.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3
if (optionCount > 1) if (optionCount > 1)
{ {
Marshal.FreeHGlobal(options[1].m_Value.m_StringPtr); // release mem 1 Marshal.FreeHGlobal(options[1].m_Value.m_StringPtr); // release mem 1
@@ -204,12 +241,12 @@ namespace v2rayN.Handler
public struct InternetPerConnOptionList public struct InternetPerConnOptionList
{ {
public int dwSize; // size of the INTERNET_PER_CONN_OPTION_LIST struct public int dwSize; // size of the INTERNET_PER_CONN_OPTION_LIST struct
public IntPtr szConnection; // connection name to set/query options public nint szConnection; // connection name to set/query options
public int dwOptionCount; // number of options to set/query public int dwOptionCount; // number of options to set/query
public int dwOptionError; // on error, which option failed public int dwOptionError; // on error, which option failed
//[MarshalAs(UnmanagedType.)] //[MarshalAs(UnmanagedType.)]
public IntPtr options; public nint options;
}; };
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
@@ -236,7 +273,7 @@ namespace v2rayN.Handler
public int m_Int; public int m_Int;
[FieldOffset(0)] [FieldOffset(0)]
public IntPtr m_StringPtr; public nint m_StringPtr;
} }
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
@@ -308,7 +345,7 @@ namespace v2rayN.Handler
{ {
[DllImport("WinInet.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("WinInet.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InternetSetOption(IntPtr hInternet, InternetOption dwOption, IntPtr lpBuffer, int dwBufferLength); public static extern bool InternetSetOption(nint hInternet, InternetOption dwOption, nint lpBuffer, int dwBufferLength);
[DllImport("Rasapi32.dll", CharSet = CharSet.Auto)] [DllImport("Rasapi32.dll", CharSet = CharSet.Auto)]
public static extern uint RasEnumEntries( public static extern uint RasEnumEntries(

View File

@@ -1,6 +1,13 @@
using QRCoder; using QRCoder;
using QRCoder.Xaml; using QRCoder.Xaml;
using System.Drawing;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
using ZXing.Windows.Compatibility;
namespace v2rayN namespace v2rayN
{ {
@@ -28,5 +35,70 @@ namespace v2rayN
return null; return null;
} }
} }
public static string ScanScreen(float dpiX, float dpiY)
{
try
{
var left = (int)(SystemParameters.WorkArea.Left);
var top = (int)(SystemParameters.WorkArea.Top);
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
using Bitmap fullImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(fullImage))
{
g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
}
int maxTry = 10;
for (int i = 0; i < maxTry; i++)
{
int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry);
int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry);
Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2);
Bitmap target = new(width, height);
double imageScale = (double)width / (double)cropRect.Width;
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
BitmapLuminanceSource source = new(target);
QRCodeReader reader = new();
BinaryBitmap bitmap = new(new HybridBinarizer(source));
var result = reader.decode(bitmap);
if (result != null)
{
return result.Text;
}
else
{
BinaryBitmap bitmap2 = new(new HybridBinarizer(source.invert()));
var result2 = reader.decode(bitmap2);
if (result2 != null)
{
return result2.Text;
}
}
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
return string.Empty;
}
public static Tuple<float, float> GetDpiXY(Window window)
{
IntPtr hWnd = new WindowInteropHelper(window).EnsureHandle();
Graphics g = Graphics.FromHwnd(hWnd);
return new(96 / g.DpiX, 96 / g.DpiY);
}
} }
} }

View File

@@ -15,7 +15,7 @@ namespace v2rayN
public SQLiteHelper() public SQLiteHelper()
{ {
_connstr = Utile.GetConfigPath(_configDB); _connstr = Utils.GetConfigPath(_configDB);
_db = new SQLiteConnection(_connstr, false); _db = new SQLiteConnection(_connstr, false);
_dbAsync = new SQLiteAsyncConnection(_connstr, false); _dbAsync = new SQLiteAsyncConnection(_connstr, false);
} }

View File

@@ -18,14 +18,10 @@ using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
using ZXing.Windows.Compatibility;
namespace v2rayN namespace v2rayN
{ {
internal class Utile internal class Utils
{ {
#region Json操作 #region Json操作
@@ -57,11 +53,14 @@ namespace v2rayN
/// 取得存储资源 /// 取得存储资源
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static string? LoadResource(string res) public static string? LoadResource(string? res)
{ {
try try
{ {
if (!File.Exists(res)) return null; if (!File.Exists(res))
{
return null;
}
return File.ReadAllText(res); return File.ReadAllText(res);
} }
catch (Exception ex) catch (Exception ex)
@@ -80,7 +79,7 @@ namespace v2rayN
/// </summary> /// </summary>
/// <param name="lst"></param> /// <param name="lst"></param>
/// <returns></returns> /// <returns></returns>
public static string List2String(List<string> lst, bool wrap = false) public static string List2String(List<string>? lst, bool wrap = false)
{ {
try try
{ {
@@ -361,7 +360,7 @@ namespace v2rayN
/// <returns></returns> /// <returns></returns>
public static string GetPunycode(string url) public static string GetPunycode(string url)
{ {
if (string.IsNullOrWhiteSpace(url)) if (Utils.IsNullOrEmpty(url))
{ {
return url; return url;
} }
@@ -391,7 +390,7 @@ namespace v2rayN
public static string Convert2Comma(string text) public static string Convert2Comma(string text)
{ {
if (string.IsNullOrWhiteSpace(text)) if (Utils.IsNullOrEmpty(text))
{ {
return text; return text;
} }
@@ -428,7 +427,7 @@ namespace v2rayN
/// <returns></returns> /// <returns></returns>
public static bool IsNullOrEmpty(string? text) public static bool IsNullOrEmpty(string? text)
{ {
if (string.IsNullOrEmpty(text)) if (string.IsNullOrWhiteSpace(text))
{ {
return true; return true;
} }
@@ -478,7 +477,7 @@ namespace v2rayN
/// 验证Domain地址是否合法 /// 验证Domain地址是否合法
/// </summary> /// </summary>
/// <param name="domain"></param> /// <param name="domain"></param>
public static bool IsDomain(string domain) public static bool IsDomain(string? domain)
{ {
//如果为空 //如果为空
if (IsNullOrEmpty(domain)) if (IsNullOrEmpty(domain))
@@ -583,7 +582,7 @@ namespace v2rayN
{ {
try try
{ {
if (!Utile.PortInUse(defaultPort)) if (!Utils.PortInUse(defaultPort))
{ {
return defaultPort; return defaultPort;
} }
@@ -741,11 +740,11 @@ namespace v2rayN
return Guid.TryParse(strSrc, out Guid g); return Guid.TryParse(strSrc, out Guid g);
} }
public static void ProcessStart(string fileName) public static void ProcessStart(string fileName, string arguments = "")
{ {
try try
{ {
Process.Start(new ProcessStartInfo(fileName) { UseShellExecute = true }); Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -840,7 +839,7 @@ namespace v2rayN
{ {
Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_tempPath);
} }
if (string.IsNullOrEmpty(filename)) if (Utils.IsNullOrEmpty(filename))
{ {
return _tempPath; return _tempPath;
} }
@@ -876,7 +875,7 @@ namespace v2rayN
{ {
Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_tempPath);
} }
if (string.IsNullOrEmpty(filename)) if (Utils.IsNullOrEmpty(filename))
{ {
return _tempPath; return _tempPath;
} }
@@ -901,7 +900,7 @@ namespace v2rayN
Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_tempPath);
} }
} }
if (string.IsNullOrEmpty(filename)) if (Utils.IsNullOrEmpty(filename))
{ {
return _tempPath; return _tempPath;
} }
@@ -918,7 +917,7 @@ namespace v2rayN
{ {
Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_tempPath);
} }
if (string.IsNullOrEmpty(filename)) if (Utils.IsNullOrEmpty(filename))
{ {
return _tempPath; return _tempPath;
} }
@@ -935,7 +934,7 @@ namespace v2rayN
{ {
Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_tempPath);
} }
if (string.IsNullOrEmpty(filename)) if (Utils.IsNullOrEmpty(filename))
{ {
return _tempPath; return _tempPath;
} }
@@ -947,66 +946,6 @@ namespace v2rayN
#endregion TempPath #endregion TempPath
#region scan screen
public static string ScanScreen(float dpiX, float dpiY)
{
try
{
var left = (int)(SystemParameters.WorkArea.Left);
var top = (int)(SystemParameters.WorkArea.Top);
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
using Bitmap fullImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(fullImage))
{
g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
}
int maxTry = 10;
for (int i = 0; i < maxTry; i++)
{
int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry);
int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry);
Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2);
Bitmap target = new(width, height);
double imageScale = (double)width / (double)cropRect.Width;
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
BitmapLuminanceSource source = new(target);
BinaryBitmap bitmap = new(new HybridBinarizer(source));
QRCodeReader reader = new();
Result result = reader.decode(bitmap);
if (result != null)
{
string ret = result.Text;
return ret;
}
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
return string.Empty;
}
public static Tuple<float, float> GetDpiXY(Window window)
{
IntPtr hWnd = new WindowInteropHelper(window).EnsureHandle();
Graphics g = Graphics.FromHwnd(hWnd);
return new(96 / g.DpiX, 96 / g.DpiY);
}
#endregion scan screen
#region #region
/// <summary> /// <summary>
@@ -1029,14 +968,14 @@ namespace v2rayN
if (run) if (run)
{ {
string exePath = $"\"{GetExePath()}\""; string exePath = GetExePath();
if (IsAdministrator()) if (IsAdministrator())
{ {
AutoStart(autoRunName, exePath, ""); AutoStart(autoRunName, exePath, "");
} }
else else
{ {
RegWriteValue(AutoRunRegPath, autoRunName, exePath); RegWriteValue(AutoRunRegPath, autoRunName, exePath.AppendQuotes());
} }
} }
} }
@@ -1107,7 +1046,7 @@ namespace v2rayN
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
public static void AutoStart(string taskName, string fileName, string description) public static void AutoStart(string taskName, string fileName, string description)
{ {
if (string.IsNullOrEmpty(taskName)) if (Utils.IsNullOrEmpty(taskName))
{ {
return; return;
} }
@@ -1122,7 +1061,7 @@ namespace v2rayN
{ {
taskService.RootFolder.DeleteTask(t.Name); taskService.RootFolder.DeleteTask(t.Name);
} }
if (string.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
return; return;
} }
@@ -1136,7 +1075,7 @@ namespace v2rayN
task.Settings.ExecutionTimeLimit = TimeSpan.Zero; task.Settings.ExecutionTimeLimit = TimeSpan.Zero;
task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromSeconds(10) }); task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromSeconds(10) });
task.Principal.RunLevel = TaskRunLevel.Highest; task.Principal.RunLevel = TaskRunLevel.Highest;
task.Actions.Add(new ExecAction(deamonFileName)); task.Actions.Add(new ExecAction(deamonFileName.AppendQuotes(), null, Path.GetDirectoryName(deamonFileName)));
taskService.RootFolder.RegisterTaskDefinition(TaskName, task); taskService.RootFolder.RegisterTaskDefinition(TaskName, task);
} }
@@ -1145,8 +1084,10 @@ namespace v2rayN
{ {
try try
{ {
var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun"));
var guid = new Guid(sum);
string pnputilPath = @"C:\Windows\System32\pnputil.exe"; string pnputilPath = @"C:\Windows\System32\pnputil.exe";
string arg = $" /remove-device /deviceid \"wintun\""; string arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
// Try to remove the device // Try to remove the device
Process proc = new() Process proc = new()

View File

@@ -0,0 +1,58 @@
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace v2rayN.Common
{
internal class YamlUtils
{
#region YAML
/// <summary>
/// 反序列化成对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="str"></param>
/// <returns></returns>
public static T FromYaml<T>(string str)
{
var deserializer = new DeserializerBuilder()
.WithNamingConvention(PascalCaseNamingConvention.Instance)
.Build();
try
{
T obj = deserializer.Deserialize<T>(str);
return obj;
}
catch (Exception ex)
{
Logging.SaveLog("FromYaml", ex);
return deserializer.Deserialize<T>("");
}
}
/// <summary>
/// 序列化
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ToYaml(Object obj)
{
var serializer = new SerializerBuilder()
.WithNamingConvention(HyphenatedNamingConvention.Instance)
.Build();
string result = string.Empty;
try
{
result = serializer.Serialize(obj);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
return result;
}
#endregion YAML
}
}

View File

@@ -11,7 +11,7 @@ namespace v2rayN.Converters
if (delay <= 0) if (delay <= 0)
return new SolidColorBrush(Colors.Red); return new SolidColorBrush(Colors.Red);
if (delay <= 200) if (delay <= 500)
return new SolidColorBrush(Colors.Green); return new SolidColorBrush(Colors.Green);
else else
return new SolidColorBrush(Colors.IndianRed); return new SolidColorBrush(Colors.IndianRed);

View File

@@ -12,9 +12,9 @@ namespace v2rayN.Converters
try try
{ {
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily; var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
if (!string.IsNullOrEmpty(fontFamily)) if (!Utils.IsNullOrEmpty(fontFamily))
{ {
var fontPath = Utile.GetFontsPath(); var fontPath = Utils.GetFontsPath();
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}"); MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
} }
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EConfigType public enum EConfigType
{ {
@@ -10,6 +10,7 @@
Trojan = 6, Trojan = 6,
Hysteria2 = 7, Hysteria2 = 7,
Tuic = 8, Tuic = 8,
Wireguard = 9 Wireguard = 9,
Http = 10
} }
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum ECoreType public enum ECoreType
{ {

View File

@@ -0,0 +1,9 @@
namespace v2rayN.Enums
{
public enum EGirdOrientation
{
Horizontal,
Vertical,
Tab,
}
}

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EGlobalHotkey public enum EGlobalHotkey
{ {

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EInboundProtocol public enum EInboundProtocol
{ {
@@ -8,6 +8,7 @@
http2, http2,
pac, pac,
api, api,
api2,
speedtest = 21 speedtest = 21
} }
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EMove public enum EMove
{ {

View File

@@ -0,0 +1,10 @@
namespace v2rayN.Enums
{
public enum ERuleMode
{
Rule = 0,
Global = 1,
Direct = 2,
Unchanged = 3
}
}

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EServerColName public enum EServerColName
{ {

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum ESpeedActionType public enum ESpeedActionType
{ {

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum ESysProxyType public enum ESysProxyType
{ {

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum ETransport public enum ETransport
{ {
@@ -6,6 +6,7 @@
kcp, kcp,
ws, ws,
httpupgrade, httpupgrade,
splithttp,
h2, h2,
http, http,
quic, quic,

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Enums
{ {
public enum EViewAction public enum EViewAction
{ {

View File

@@ -1,4 +1,4 @@
using v2rayN.Model; using v2rayN.Enums;
namespace v2rayN namespace v2rayN
{ {
@@ -23,12 +23,15 @@ namespace v2rayN
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204"; public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases"; public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/"; public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw="; public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json"; public const string ConfigFileName = "guiNConfig.json";
public const string CoreConfigFileName = "config.json"; public const string CoreConfigFileName = "config.json";
public const string CorePreConfigFileName = "configPre.json"; public const string CorePreConfigFileName = "configPre.json";
public const string CoreSpeedtestConfigFileName = "configSpeedtest.json"; public const string CoreSpeedtestConfigFileName = "configSpeedtest.json";
public const string CoreMultipleLoadConfigFileName = "configMultipleLoad.json";
public const string ClashMixinConfigFileName = "Mixin.yaml";
public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig"; public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig"; public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
public const string V2raySampleHttpRequestFileName = "v2rayN.Sample.SampleHttpRequest"; public const string V2raySampleHttpRequestFileName = "v2rayN.Sample.SampleHttpRequest";
@@ -42,6 +45,8 @@ namespace v2rayN
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules"; public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal"; public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal"; public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
public const string ClashMixinYaml = "v2rayN.Sample.clash_mixin_yaml";
public const string ClashTunYaml = "v2rayN.Sample.clash_tun_yaml";
public const string DefaultSecurity = "auto"; public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp"; public const string DefaultNetwork = "tcp";
@@ -69,6 +74,7 @@ namespace v2rayN
public const string CommandClearMsg = "CommandClearMsg"; public const string CommandClearMsg = "CommandClearMsg";
public const string CommandSendMsgView = "CommandSendMsgView"; public const string CommandSendMsgView = "CommandSendMsgView";
public const string CommandStopSpeedTest = "CommandStopSpeedTest"; public const string CommandStopSpeedTest = "CommandStopSpeedTest";
public const string CommandRefreshProfiles = "CommandRefreshProfiles";
public const string DelayUnit = ""; public const string DelayUnit = "";
public const string SpeedUnit = ""; public const string SpeedUnit = "";
public const int MinFontSize = 10; public const int MinFontSize = 10;
@@ -105,12 +111,12 @@ namespace v2rayN
@"https://speed.cloudflare.com/__down?bytes=100000000", @"https://speed.cloudflare.com/__down?bytes=100000000",
@"https://speed.cloudflare.com/__down?bytes=10000000", @"https://speed.cloudflare.com/__down?bytes=10000000",
@"http://cachefly.cachefly.net/50mb.test", @"http://cachefly.cachefly.net/50mb.test",
@"http://cachefly.cachefly.net/100mb.test",
@"http://cachefly.cachefly.net/10mb.test" @"http://cachefly.cachefly.net/10mb.test"
}; };
public static readonly List<string> SpeedPingTestUrls = new() { public static readonly List<string> SpeedPingTestUrls = new() {
@"https://www.google.com/generate_204", @"https://www.google.com/generate_204",
@"https://www.gstatic.com/generate_204",
@"https://www.apple.com/library/test/success.html", @"https://www.apple.com/library/test/success.html",
@"http://www.msftconnecttest.com/connecttest.txt", @"http://www.msftconnecttest.com/connecttest.txt",
}; };
@@ -143,6 +149,7 @@ namespace v2rayN
{EConfigType.VMess,"vmess"}, {EConfigType.VMess,"vmess"},
{EConfigType.Shadowsocks,"shadowsocks"}, {EConfigType.Shadowsocks,"shadowsocks"},
{EConfigType.Socks,"socks"}, {EConfigType.Socks,"socks"},
{EConfigType.Http,"http"},
{EConfigType.VLESS,"vless"}, {EConfigType.VLESS,"vless"},
{EConfigType.Trojan,"trojan"}, {EConfigType.Trojan,"trojan"},
{EConfigType.Hysteria2,"hysteria2"}, {EConfigType.Hysteria2,"hysteria2"},
@@ -156,7 +163,7 @@ namespace v2rayN
public static readonly List<string> SsSecuritiesInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" }; public static readonly List<string> SsSecuritiesInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> SsSecuritiesInSingbox = new() { "aes-256-gcm", "aes-192-gcm", "aes-128-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "rc4-md5", "chacha20-ietf", "xchacha20" }; public static readonly List<string> SsSecuritiesInSingbox = new() { "aes-256-gcm", "aes-192-gcm", "aes-128-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "rc4-md5", "chacha20-ietf", "xchacha20" };
public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "h2", "quic", "grpc" }; public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" }; public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" }; public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" }; public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };
@@ -168,17 +175,26 @@ namespace v2rayN
public static readonly List<string> AllowInsecure = new() { "true", "false", "" }; public static readonly List<string> AllowInsecure = new() { "true", "false", "" };
public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" }; public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
public static readonly List<string> SingboxDomainStrategy4Out = new() { "ipv4_only", "prefer_ipv4", "prefer_ipv6", "ipv6_only", "" };
public static readonly List<string> DomainDNSAddress = ["223.5.5.5", "223.6.6.6", "localhost"];
public static readonly List<string> SingboxDomainDNSAddress = ["223.5.5.5", "223.6.6.6", "dhcp://auto"];
public static readonly List<string> Languages = new() { "zh-Hans", "zh-Hant", "en", "fa-Ir", "ru" }; public static readonly List<string> Languages = new() { "zh-Hans", "zh-Hant", "en", "fa-Ir", "ru" };
public static readonly List<string> Alpns = new() { "h3", "h2", "http/1.1", "h3,h2,http/1.1", "h3,h2", "h2,http/1.1", "" }; public static readonly List<string> Alpns = new() { "h3", "h2", "http/1.1", "h3,h2,http/1.1", "h2,h3", "h2,http/1.1", "" };
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" }; public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" }; public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" }; public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> RuleNetworks = new() { "", "tcp", "udp", "tcp,udp" };
public static readonly List<string> destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"];
public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" }; public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" };
public static readonly List<string> TunStacks = new() { "gvisor", "system" }; public static readonly List<string> TunStacks = new() { "gvisor", "system" };
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" }; public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };
public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" }; public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" };
public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" }; public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" };
public static readonly List<string> allowSelectType = new List<string> { "selector", "urltest", "loadbalance", "fallback" };
public static readonly List<string> notAllowTestType = new List<string> { "selector", "urltest", "direct", "reject", "compatible", "pass", "loadbalance", "fallback" };
public static readonly List<string> proxyVehicleType = new List<string> { "file", "http" };
#endregion const #endregion const
} }
} }

View File

@@ -0,0 +1,218 @@
using v2rayN.Models;
using static v2rayN.Models.ClashProxies;
namespace v2rayN.Handler
{
public sealed class ClashApiHandler
{
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
public static ClashApiHandler Instance => instance.Value;
private Dictionary<String, ProxiesItem> _proxies;
public Dictionary<string, object> ProfileContent { get; set; }
public void SetProxies(Dictionary<String, ProxiesItem> proxies)
{
_proxies = proxies;
}
public Dictionary<String, ProxiesItem> GetProxies()
{
return _proxies;
}
public void GetClashProxies(Config config, Action<ClashProxies, ClashProviders> update)
{
Task.Run(() => GetClashProxiesAsync(config, update));
}
private async Task GetClashProxiesAsync(Config config, Action<ClashProxies, ClashProviders> update)
{
for (var i = 0; i < 5; i++)
{
var url = $"{GetApiUrl()}/proxies";
var result = await HttpClientHelper.Instance.TryGetAsync(url);
var clashProxies = JsonUtils.Deserialize<ClashProxies>(result);
var url2 = $"{GetApiUrl()}/providers/proxies";
var result2 = await HttpClientHelper.Instance.TryGetAsync(url2);
var clashProviders = JsonUtils.Deserialize<ClashProviders>(result2);
if (clashProxies != null || clashProviders != null)
{
update(clashProxies, clashProviders);
return;
}
Thread.Sleep(5000);
}
update(null, null);
}
public void ClashProxiesDelayTest(bool blAll, List<ClashProxyModel> lstProxy, Action<ClashProxyModel?, string> update)
{
Task.Run(() =>
{
if (blAll)
{
for (int i = 0; i < 5; i++)
{
if (GetProxies() != null)
{
break;
}
Thread.Sleep(5000);
}
var proxies = GetProxies();
if (proxies == null)
{
return;
}
lstProxy = new List<ClashProxyModel>();
foreach (KeyValuePair<string, ProxiesItem> kv in proxies)
{
if (Global.notAllowTestType.Contains(kv.Value.type.ToLower()))
{
continue;
}
lstProxy.Add(new ClashProxyModel()
{
name = kv.Value.name,
type = kv.Value.type.ToLower(),
});
}
}
if (lstProxy == null)
{
return;
}
var urlBase = $"{GetApiUrl()}/proxies";
urlBase += @"/{0}/delay?timeout=10000&url=" + LazyConfig.Instance.GetConfig().speedTestItem.speedPingTestUrl;
List<Task> tasks = new List<Task>();
foreach (var it in lstProxy)
{
if (Global.notAllowTestType.Contains(it.type.ToLower()))
{
continue;
}
var name = it.name;
var url = string.Format(urlBase, name);
tasks.Add(Task.Run(async () =>
{
var result = await HttpClientHelper.Instance.TryGetAsync(url);
update(it, result);
}));
}
Task.WaitAll(tasks.ToArray());
Thread.Sleep(1000);
update(null, "");
});
}
public List<ProxiesItem>? GetClashProxyGroups()
{
try
{
var fileContent = ProfileContent;
if (fileContent is null || fileContent?.ContainsKey("proxy-groups") == false)
{
return null;
}
return JsonUtils.Deserialize<List<ProxiesItem>>(JsonUtils.Serialize(fileContent["proxy-groups"]));
}
catch (Exception ex)
{
Logging.SaveLog("GetClashProxyGroups", ex);
return null;
}
}
public async void ClashSetActiveProxy(string name, string nameNode)
{
try
{
var url = $"{GetApiUrl()}/proxies/{name}";
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("name", nameNode);
await HttpClientHelper.Instance.PutAsync(url, headers);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
}
public void ClashConfigUpdate(Dictionary<string, string> headers)
{
Task.Run(async () =>
{
var proxies = GetProxies();
if (proxies == null)
{
return;
}
var urlBase = $"{GetApiUrl()}/configs";
await HttpClientHelper.Instance.PatchAsync(urlBase, headers);
});
}
public async void ClashConfigReload(string filePath)
{
ClashConnectionClose("");
try
{
var url = $"{GetApiUrl()}/configs?force=true";
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("path", filePath);
await HttpClientHelper.Instance.PutAsync(url, headers);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
}
public void GetClashConnections(Config config, Action<ClashConnections> update)
{
Task.Run(() => GetClashConnectionsAsync(config, update));
}
private async Task GetClashConnectionsAsync(Config config, Action<ClashConnections> update)
{
try
{
var url = $"{GetApiUrl()}/connections";
var result = await HttpClientHelper.Instance.TryGetAsync(url);
var clashConnections = JsonUtils.Deserialize<ClashConnections>(result);
update(clashConnections);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
}
public async void ClashConnectionClose(string id)
{
try
{
var url = $"{GetApiUrl()}/connections/{id}";
await HttpClientHelper.Instance.DeleteAsync(url);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
}
private string GetApiUrl()
{
return $"{Global.HttpProtocol}{Global.Loopback}:{LazyConfig.Instance.StatePort2}";
}
}
}

View File

@@ -1,7 +1,11 @@
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using v2rayN.Model; using System.Web;
using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
using v2rayN.Handler.Fmt;
using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@@ -23,15 +27,15 @@ namespace v2rayN.Handler
public static int LoadConfig(ref Config? config) public static int LoadConfig(ref Config? config)
{ {
//载入配置文件 //载入配置文件
var result = Utile.LoadResource(Utile.GetConfigPath(configRes)); var result = Utils.LoadResource(Utils.GetConfigPath(configRes));
if (!Utile.IsNullOrEmpty(result)) if (!Utils.IsNullOrEmpty(result))
{ {
//转成Json //转成Json
config = JsonUtile.Deserialize<Config>(result); config = JsonUtils.Deserialize<Config>(result);
} }
else else
{ {
if (File.Exists(Utile.GetConfigPath(configRes))) if (File.Exists(Utils.GetConfigPath(configRes)))
{ {
Logging.SaveLog("LoadConfig Exception"); Logging.SaveLog("LoadConfig Exception");
return -1; return -1;
@@ -50,7 +54,6 @@ namespace v2rayN.Handler
{ {
logEnabled = false, logEnabled = false,
loglevel = "warning", loglevel = "warning",
muxEnabled = false, muxEnabled = false,
}; };
} }
@@ -85,7 +88,7 @@ namespace v2rayN.Handler
}; };
} }
//路由规则 //路由规则
if (Utile.IsNullOrEmpty(config.routingBasicItem.domainStrategy)) if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
{ {
config.routingBasicItem.domainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch"; config.routingBasicItem.domainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch";
} }
@@ -144,7 +147,7 @@ namespace v2rayN.Handler
{ {
config.uiItem.mainColumnItem = new(); config.uiItem.mainColumnItem = new();
} }
if (Utile.IsNullOrEmpty(config.uiItem.currentLanguage)) if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage))
{ {
config.uiItem.currentLanguage = Global.Languages[0]; config.uiItem.currentLanguage = Global.Languages[0];
} }
@@ -153,7 +156,7 @@ namespace v2rayN.Handler
{ {
config.constItem = new ConstItem(); config.constItem = new ConstItem();
} }
if (Utile.IsNullOrEmpty(config.constItem.defIEProxyExceptions)) if (Utils.IsNullOrEmpty(config.constItem.defIEProxyExceptions))
{ {
config.constItem.defIEProxyExceptions = Global.IEProxyExceptions; config.constItem.defIEProxyExceptions = Global.IEProxyExceptions;
} }
@@ -166,11 +169,11 @@ namespace v2rayN.Handler
{ {
config.speedTestItem.speedTestTimeout = 10; config.speedTestItem.speedTestTimeout = 10;
} }
if (Utile.IsNullOrEmpty(config.speedTestItem.speedTestUrl)) if (Utils.IsNullOrEmpty(config.speedTestItem.speedTestUrl))
{ {
config.speedTestItem.speedTestUrl = Global.SpeedTestUrls[0]; config.speedTestItem.speedTestUrl = Global.SpeedTestUrls[0];
} }
if (Utile.IsNullOrEmpty(config.speedTestItem.speedPingTestUrl)) if (Utils.IsNullOrEmpty(config.speedTestItem.speedPingTestUrl))
{ {
config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl; config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl;
} }
@@ -180,7 +183,7 @@ namespace v2rayN.Handler
config.mux4SboxItem = new() config.mux4SboxItem = new()
{ {
protocol = Global.SingboxMuxs[0], protocol = Global.SingboxMuxs[0],
max_connections = 4 max_connections = 8
}; };
} }
@@ -192,6 +195,16 @@ namespace v2rayN.Handler
down_mbps = 100 down_mbps = 100
}; };
} }
config.clashUIItem ??= new();
if (config.systemProxyItem == null)
{
config.systemProxyItem = new()
{
systemProxyExceptions = config.systemProxyExceptions,
systemProxyAdvancedProtocol = config.systemProxyAdvancedProtocol,
};
}
LazyConfig.Instance.SetConfig(config); LazyConfig.Instance.SetConfig(config);
return 0; return 0;
@@ -220,9 +233,9 @@ namespace v2rayN.Handler
try try
{ {
//save temp file //save temp file
var resPath = Utile.GetConfigPath(configRes); var resPath = Utils.GetConfigPath(configRes);
var tempPath = $"{resPath}_temp"; var tempPath = $"{resPath}_temp";
if (JsonUtile.ToFile(config, tempPath) != 0) if (JsonUtils.ToFile(config, tempPath) != 0)
{ {
return; return;
} }
@@ -241,103 +254,103 @@ namespace v2rayN.Handler
} }
} }
public static int ImportOldGuiConfig(Config config, string fileName) //public static int ImportOldGuiConfig(Config config, string fileName)
{ //{
var result = Utile.LoadResource(fileName); // var result = Utils.LoadResource(fileName);
if (Utile.IsNullOrEmpty(result)) // if (Utils.IsNullOrEmpty(result))
{ // {
return -1; // return -1;
} // }
var configOld = JsonUtile.Deserialize<ConfigOld>(result); // var configOld = JsonUtils.Deserialize<ConfigOld>(result);
if (configOld == null) // if (configOld == null)
{ // {
return -1; // return -1;
} // }
var subItem = JsonUtile.Deserialize<List<SubItem>>(JsonUtile.Serialize(configOld.subItem)); // var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
foreach (var it in subItem) // foreach (var it in subItem)
{ // {
if (Utile.IsNullOrEmpty(it.id)) // if (Utils.IsNullOrEmpty(it.id))
{ // {
it.id = Utile.GetGUID(false); // it.id = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(it); // SQLiteHelper.Instance.Replace(it);
} // }
var profileItems = JsonUtile.Deserialize<List<ProfileItem>>(JsonUtile.Serialize(configOld.vmess)); // var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
foreach (var it in profileItems) // foreach (var it in profileItems)
{ // {
if (Utile.IsNullOrEmpty(it.indexId)) // if (Utils.IsNullOrEmpty(it.indexId))
{ // {
it.indexId = Utile.GetGUID(false); // it.indexId = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(it); // SQLiteHelper.Instance.Replace(it);
} // }
foreach (var it in configOld.routings) // foreach (var it in configOld.routings)
{ // {
if (it.locked) // if (it.locked)
{ // {
continue; // continue;
} // }
var routing = JsonUtile.Deserialize<RoutingItem>(JsonUtile.Serialize(it)); // var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
foreach (var it2 in it.rules) // foreach (var it2 in it.rules)
{ // {
it2.id = Utile.GetGUID(false); // it2.id = Utils.GetGUID(false);
} // }
routing.ruleNum = it.rules.Count; // routing.ruleNum = it.rules.Count;
routing.ruleSet = JsonUtile.Serialize(it.rules, false); // routing.ruleSet = JsonUtils.Serialize(it.rules, false);
if (Utile.IsNullOrEmpty(routing.id)) // if (Utils.IsNullOrEmpty(routing.id))
{ // {
routing.id = Utile.GetGUID(false); // routing.id = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(routing); // SQLiteHelper.Instance.Replace(routing);
} // }
config = JsonUtile.Deserialize<Config>(JsonUtile.Serialize(configOld)); // config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
if (config.coreBasicItem == null) // if (config.coreBasicItem == null)
{ // {
config.coreBasicItem = new() // config.coreBasicItem = new()
{ // {
logEnabled = configOld.logEnabled, // logEnabled = configOld.logEnabled,
loglevel = configOld.loglevel, // loglevel = configOld.loglevel,
muxEnabled = configOld.muxEnabled, // muxEnabled = configOld.muxEnabled,
}; // };
} // }
if (config.routingBasicItem == null) // if (config.routingBasicItem == null)
{ // {
config.routingBasicItem = new() // config.routingBasicItem = new()
{ // {
enableRoutingAdvanced = configOld.enableRoutingAdvanced, // enableRoutingAdvanced = configOld.enableRoutingAdvanced,
domainStrategy = configOld.domainStrategy // domainStrategy = configOld.domainStrategy
}; // };
} // }
if (config.guiItem == null) // if (config.guiItem == null)
{ // {
config.guiItem = new() // config.guiItem = new()
{ // {
enableStatistics = configOld.enableStatistics, // enableStatistics = configOld.enableStatistics,
keepOlderDedupl = configOld.keepOlderDedupl, // keepOlderDedupl = configOld.keepOlderDedupl,
ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore, // ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
autoUpdateInterval = configOld.autoUpdateInterval, // autoUpdateInterval = configOld.autoUpdateInterval,
checkPreReleaseUpdate = configOld.checkPreReleaseUpdate, // checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13, // enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
trayMenuServersLimit = configOld.trayMenuServersLimit, // trayMenuServersLimit = configOld.trayMenuServersLimit,
}; // };
} // }
GetDefaultServer(config); // GetDefaultServer(config);
GetDefaultRouting(config); // GetDefaultRouting(config);
SaveConfig(config); // SaveConfig(config);
LoadConfig(ref config); // LoadConfig(ref config);
return 0; // return 0;
} //}
#endregion ConfigHandler #endregion ConfigHandler
@@ -412,13 +425,13 @@ namespace v2rayN.Handler
continue; continue;
} }
ProfileItem profileItem = JsonUtile.DeepCopy(item); ProfileItem profileItem = JsonUtils.DeepCopy(item);
profileItem.indexId = string.Empty; profileItem.indexId = string.Empty;
profileItem.remarks = $"{item.remarks}-clone"; profileItem.remarks = $"{item.remarks}-clone";
if (profileItem.configType == EConfigType.Custom) if (profileItem.configType == EConfigType.Custom)
{ {
profileItem.address = Utile.GetConfigPath(profileItem.address); profileItem.address = Utils.GetConfigPath(profileItem.address);
if (AddCustomServer(config, profileItem, false) == 0) if (AddCustomServer(config, profileItem, false) == 0)
{ {
} }
@@ -440,7 +453,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int SetDefaultServerIndex(Config config, string? indexId) public static int SetDefaultServerIndex(Config config, string? indexId)
{ {
if (Utile.IsNullOrEmpty(indexId)) if (Utils.IsNullOrEmpty(indexId))
{ {
return -1; return -1;
} }
@@ -570,12 +583,12 @@ namespace v2rayN.Handler
return -1; return -1;
} }
var ext = Path.GetExtension(fileName); var ext = Path.GetExtension(fileName);
string newFileName = $"{Utile.GetGUID()}{ext}"; string newFileName = $"{Utils.GetGUID()}{ext}";
//newFileName = Path.Combine(Utile.GetTempPath(), newFileName); //newFileName = Path.Combine(Utile.GetTempPath(), newFileName);
try try
{ {
File.Copy(fileName, Utile.GetConfigPath(newFileName)); File.Copy(fileName, Utils.GetConfigPath(newFileName));
if (blDelete) if (blDelete)
{ {
File.Delete(fileName); File.Delete(fileName);
@@ -589,7 +602,7 @@ namespace v2rayN.Handler
profileItem.address = newFileName; profileItem.address = newFileName;
profileItem.configType = EConfigType.Custom; profileItem.configType = EConfigType.Custom;
if (Utile.IsNullOrEmpty(profileItem.remarks)) if (Utils.IsNullOrEmpty(profileItem.remarks))
{ {
profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}"; profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
} }
@@ -664,6 +677,23 @@ namespace v2rayN.Handler
return 0; return 0;
} }
/// <summary>
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Http;
profileItem.address = profileItem.address.TrimEx();
AddServerCommon(config, profileItem, toFile);
return 0;
}
/// <summary> /// <summary>
/// Add or edit server /// Add or edit server
/// </summary> /// </summary>
@@ -676,7 +706,7 @@ namespace v2rayN.Handler
profileItem.address = profileItem.address.TrimEx(); profileItem.address = profileItem.address.TrimEx();
profileItem.id = profileItem.id.TrimEx(); profileItem.id = profileItem.id.TrimEx();
if (Utile.IsNullOrEmpty(profileItem.streamSecurity)) if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{ {
profileItem.streamSecurity = Global.StreamSecurity; profileItem.streamSecurity = Global.StreamSecurity;
} }
@@ -706,7 +736,7 @@ namespace v2rayN.Handler
profileItem.path = profileItem.path.TrimEx(); profileItem.path = profileItem.path.TrimEx();
profileItem.network = string.Empty; profileItem.network = string.Empty;
if (Utile.IsNullOrEmpty(profileItem.streamSecurity)) if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{ {
profileItem.streamSecurity = Global.StreamSecurity; profileItem.streamSecurity = Global.StreamSecurity;
} }
@@ -741,11 +771,11 @@ namespace v2rayN.Handler
profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!; profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!;
} }
if (Utile.IsNullOrEmpty(profileItem.streamSecurity)) if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{ {
profileItem.streamSecurity = Global.StreamSecurity; profileItem.streamSecurity = Global.StreamSecurity;
} }
if (Utile.IsNullOrEmpty(profileItem.alpn)) if (Utils.IsNullOrEmpty(profileItem.alpn))
{ {
profileItem.alpn = "h3"; profileItem.alpn = "h3";
} }
@@ -913,7 +943,7 @@ namespace v2rayN.Handler
{ {
return -1; return -1;
} }
if (!Utile.IsNullOrEmpty(profileItem.security) && profileItem.security != Global.None) if (!Utils.IsNullOrEmpty(profileItem.security) && profileItem.security != Global.None)
{ {
profileItem.security = Global.None; profileItem.security = Global.None;
} }
@@ -951,7 +981,7 @@ namespace v2rayN.Handler
{ {
profileItem.configVersion = 2; profileItem.configVersion = 2;
if (!Utile.IsNullOrEmpty(profileItem.streamSecurity)) if (!Utils.IsNullOrEmpty(profileItem.streamSecurity))
{ {
if (profileItem.streamSecurity != Global.StreamSecurity if (profileItem.streamSecurity != Global.StreamSecurity
&& profileItem.streamSecurity != Global.StreamSecurityReality) && profileItem.streamSecurity != Global.StreamSecurityReality)
@@ -960,26 +990,26 @@ namespace v2rayN.Handler
} }
else else
{ {
if (Utile.IsNullOrEmpty(profileItem.allowInsecure)) if (Utils.IsNullOrEmpty(profileItem.allowInsecure))
{ {
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower(); profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower();
} }
if (Utile.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality) if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality)
{ {
profileItem.fingerprint = config.coreBasicItem.defFingerprint; profileItem.fingerprint = config.coreBasicItem.defFingerprint;
} }
} }
} }
if (!Utile.IsNullOrEmpty(profileItem.network) && !Global.Networks.Contains(profileItem.network)) if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.Networks.Contains(profileItem.network))
{ {
profileItem.network = Global.DefaultNetwork; profileItem.network = Global.DefaultNetwork;
} }
var maxSort = -1; var maxSort = -1;
if (Utile.IsNullOrEmpty(profileItem.indexId)) if (Utils.IsNullOrEmpty(profileItem.indexId))
{ {
profileItem.indexId = Utile.GetGUID(false); profileItem.indexId = Utils.GetGUID(false);
maxSort = ProfileExHandler.Instance.GetMaxSort(); maxSort = ProfileExHandler.Instance.GetMaxSort();
} }
if (!toFile && maxSort < 0) if (!toFile && maxSort < 0)
@@ -1032,7 +1062,7 @@ namespace v2rayN.Handler
} }
if (item.configType == EConfigType.Custom) if (item.configType == EConfigType.Custom)
{ {
File.Delete(Utile.GetConfigPath(item.address)); File.Delete(Utils.GetConfigPath(item.address));
} }
SQLiteHelper.Instance.Delete(item); SQLiteHelper.Instance.Delete(item);
@@ -1045,6 +1075,33 @@ namespace v2rayN.Handler
return 0; return 0;
} }
public static int AddCustomServer4Multiple(Config config, List<ProfileItem> selecteds, ECoreType coreType, out string indexId)
{
indexId = Utils.GetMD5(Global.CoreMultipleLoadConfigFileName);
string configPath = Utils.GetConfigPath(Global.CoreMultipleLoadConfigFileName);
if (CoreConfigHandler.GenerateClientMultipleLoadConfig(config, configPath, selecteds, coreType, out string msg) != 0)
{
return -1;
}
var fileName = configPath;
if (!File.Exists(fileName))
{
return -1;
}
var profileItem = LazyConfig.Instance.GetProfileItem(indexId) ?? new();
profileItem.indexId = indexId;
profileItem.remarks = coreType == ECoreType.sing_box ? Resx.ResUI.menuSetDefaultMultipleServer : Resx.ResUI.menuSetDefaultLoadBalanceServer;
profileItem.address = Global.CoreMultipleLoadConfigFileName;
profileItem.configType = EConfigType.Custom;
profileItem.coreType = coreType;
AddServerCommon(config, profileItem, true);
return 0;
}
#endregion Server #endregion Server
#region Batch add servers #region Batch add servers
@@ -1053,19 +1110,19 @@ namespace v2rayN.Handler
/// 批量添加服务器 /// 批量添加服务器
/// </summary> /// </summary>
/// <param name="config"></param> /// <param name="config"></param>
/// <param name="clipboardData"></param> /// <param name="strData"></param>
/// <param name="subid"></param> /// <param name="subid"></param>
/// <returns>成功导入的数量</returns> /// <returns>成功导入的数量</returns>
private static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub) private static int AddBatchServers(Config config, string strData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{ {
if (Utile.IsNullOrEmpty(clipboardData)) if (Utils.IsNullOrEmpty(strData))
{ {
return -1; return -1;
} }
string subFilter = string.Empty; string subFilter = string.Empty;
//remove sub items //remove sub items
if (isSub && !Utile.IsNullOrEmpty(subid)) if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
RemoveServerViaSubid(config, subid, isSub); RemoveServerViaSubid(config, subid, isSub);
subFilter = LazyConfig.Instance.GetSubItem(subid)?.filter ?? ""; subFilter = LazyConfig.Instance.GetSubItem(subid)?.filter ?? "";
@@ -1075,7 +1132,7 @@ namespace v2rayN.Handler
//Check for duplicate indexId //Check for duplicate indexId
List<string>? lstDbIndexId = null; List<string>? lstDbIndexId = null;
List<ProfileItem> lstAdd = new(); List<ProfileItem> lstAdd = new();
var arrData = clipboardData.Split(Environment.NewLine.ToCharArray()).Where(t => !t.IsNullOrEmpty()); var arrData = strData.Split(Environment.NewLine.ToCharArray()).Where(t => !t.IsNullOrEmpty());
if (isSub) if (isSub)
{ {
arrData = arrData.Distinct(); arrData = arrData.Distinct();
@@ -1091,14 +1148,14 @@ namespace v2rayN.Handler
} }
continue; continue;
} }
var profileItem = ShareHandler.ImportFromClipboardConfig(str, out string msg); var profileItem = FmtHandler.ResolveConfig(str, out string msg);
if (profileItem is null) if (profileItem is null)
{ {
continue; continue;
} }
//exist sub items //exist sub items
if (isSub && !Utile.IsNullOrEmpty(subid)) if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub
&& config.uiItem.enableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true)); && config.uiItem.enableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true));
@@ -1120,7 +1177,7 @@ namespace v2rayN.Handler
} }
} }
//filter //filter
if (!Utile.IsNullOrEmpty(subFilter)) if (!Utils.IsNullOrEmpty(subFilter))
{ {
if (!Regex.IsMatch(profileItem.remarks, subFilter)) if (!Regex.IsMatch(profileItem.remarks, subFilter))
{ {
@@ -1160,78 +1217,83 @@ namespace v2rayN.Handler
return countServers; return countServers;
} }
private static int AddBatchServers4Custom(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub) private static int AddBatchServers4Custom(Config config, string strData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{ {
if (Utile.IsNullOrEmpty(clipboardData)) if (Utils.IsNullOrEmpty(strData))
{ {
return -1; return -1;
} }
var subRemarks = LazyConfig.Instance.GetSubItem(subid)?.remarks;
//判断str是否包含s的任意一个字符串 List<ProfileItem>? lstProfiles = null;
static bool Contains(string str, params string[] s) //Is sing-box array configuration
if (lstProfiles is null || lstProfiles.Count <= 0)
{ {
foreach (var item in s) lstProfiles = SingboxFmt.ResolveFullArray(strData, subRemarks);
}
//Is v2ray array configuration
if (lstProfiles is null || lstProfiles.Count <= 0)
{
lstProfiles = V2rayFmt.ResolveFullArray(strData, subRemarks);
}
if (lstProfiles != null && lstProfiles.Count > 0)
{
if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
if (str.Contains(item, StringComparison.OrdinalIgnoreCase)) return true; RemoveServerViaSubid(config, subid, isSub);
}
int count = 0;
foreach (var it in lstProfiles)
{
it.subid = subid;
it.isSub = isSub;
if (AddCustomServer(config, it, true) == 0)
{
count++;
}
}
if (count > 0)
{
return count;
} }
return false;
} }
ProfileItem profileItem = new(); ProfileItem? profileItem = null;
//Is v2ray configuration //Is sing-box configuration
var v2rayConfig = JsonUtile.Deserialize<V2rayConfig>(clipboardData); if (profileItem is null)
if (v2rayConfig?.inbounds?.Count > 0
&& v2rayConfig.outbounds?.Count > 0)
{ {
var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.json"); profileItem = SingboxFmt.ResolveFull(strData, subRemarks);
File.WriteAllText(fileName, clipboardData); }
//Is v2ray configuration
profileItem.coreType = ECoreType.Xray; if (profileItem is null)
profileItem.address = fileName; {
profileItem.remarks = "v2ray_custom"; profileItem = V2rayFmt.ResolveFull(strData, subRemarks);
} }
//Is Clash configuration //Is Clash configuration
else if (Contains(clipboardData, "port", "socks-port", "proxies")) if (profileItem is null)
{ {
var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.yaml"); profileItem = ClashFmt.ResolveFull(strData, subRemarks);
File.WriteAllText(fileName, clipboardData);
profileItem.coreType = ECoreType.mihomo;
profileItem.address = fileName;
profileItem.remarks = "clash_custom";
} }
//Is hysteria configuration //Is hysteria configuration
else if (Contains(clipboardData, "server", "up", "down", "listen", "<html>", "<body>")) if (profileItem is null)
{ {
var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.json"); profileItem = Hysteria2Fmt.ResolveFull2(strData, subRemarks);
File.WriteAllText(fileName, clipboardData); }
if (profileItem is null)
profileItem.coreType = ECoreType.hysteria; {
profileItem.address = fileName; profileItem = Hysteria2Fmt.ResolveFull(strData, subRemarks);
profileItem.remarks = "hysteria_custom";
} }
//Is naiveproxy configuration //Is naiveproxy configuration
else if (Contains(clipboardData, "listen", "proxy", "<html>", "<body>")) if (profileItem is null)
{ {
var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.json"); profileItem = NaiveproxyFmt.ResolveFull(strData, subRemarks);
File.WriteAllText(fileName, clipboardData);
profileItem.coreType = ECoreType.naiveproxy;
profileItem.address = fileName;
profileItem.remarks = "naiveproxy_custom";
} }
//Is Other configuration if (profileItem is null || Utils.IsNullOrEmpty(profileItem.address))
else
{ {
return -1; return -1;
//var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.txt");
//File.WriteAllText(fileName, clipboardData);
//profileItem.address = fileName;
//profileItem.remarks = "other_custom";
} }
if (isSub && !Utile.IsNullOrEmpty(subid)) if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
RemoveServerViaSubid(config, subid, isSub); RemoveServerViaSubid(config, subid, isSub);
} }
@@ -1241,12 +1303,6 @@ namespace v2rayN.Handler
} }
profileItem.subid = subid; profileItem.subid = subid;
profileItem.isSub = isSub; profileItem.isSub = isSub;
if (Utile.IsNullOrEmpty(profileItem.address))
{
return -1;
}
if (AddCustomServer(config, profileItem, true) == 0) if (AddCustomServer(config, profileItem, true) == 0)
{ {
return 1; return 1;
@@ -1257,43 +1313,24 @@ namespace v2rayN.Handler
} }
} }
private static int AddBatchServers4SsSIP008(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub) private static int AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{ {
if (Utile.IsNullOrEmpty(clipboardData)) if (Utils.IsNullOrEmpty(strData))
{ {
return -1; return -1;
} }
if (isSub && !Utile.IsNullOrEmpty(subid)) if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
RemoveServerViaSubid(config, subid, isSub); RemoveServerViaSubid(config, subid, isSub);
} }
//SsSIP008 var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
var lstSsServer = JsonUtile.Deserialize<List<SsServer>>(clipboardData);
if (lstSsServer?.Count <= 0)
{
var ssSIP008 = JsonUtile.Deserialize<SsSIP008>(clipboardData);
if (ssSIP008?.servers?.Count > 0)
{
lstSsServer = ssSIP008.servers;
}
}
if (lstSsServer?.Count > 0) if (lstSsServer?.Count > 0)
{ {
int counter = 0; int counter = 0;
foreach (var it in lstSsServer) foreach (var ssItem in lstSsServer)
{ {
var ssItem = new ProfileItem()
{
subid = subid,
remarks = it.remarks,
security = it.method,
id = it.password,
address = it.server,
port = Utile.ToInt(it.server_port)
};
ssItem.subid = subid; ssItem.subid = subid;
ssItem.isSub = isSub; ssItem.isSub = isSub;
if (AddShadowsocksServer(config, ssItem) == 0) if (AddShadowsocksServer(config, ssItem) == 0)
@@ -1308,37 +1345,37 @@ namespace v2rayN.Handler
return -1; return -1;
} }
public static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub) public static int AddBatchServers(Config config, string strData, string subid, bool isSub)
{ {
List<ProfileItem>? lstOriSub = null; List<ProfileItem>? lstOriSub = null;
if (isSub && !Utile.IsNullOrEmpty(subid)) if (isSub && !Utils.IsNullOrEmpty(subid))
{ {
lstOriSub = LazyConfig.Instance.ProfileItems(subid); lstOriSub = LazyConfig.Instance.ProfileItems(subid);
} }
var counter = 0; var counter = 0;
if (Utile.IsBase64String(clipboardData)) if (Utils.IsBase64String(strData))
{ {
counter = AddBatchServers(config, Utile.Base64Decode(clipboardData), subid, isSub, lstOriSub); counter = AddBatchServers(config, Utils.Base64Decode(strData), subid, isSub, lstOriSub);
} }
if (counter < 1) if (counter < 1)
{ {
counter = AddBatchServers(config, clipboardData, subid, isSub, lstOriSub); counter = AddBatchServers(config, strData, subid, isSub, lstOriSub);
} }
if (counter < 1) if (counter < 1)
{ {
counter = AddBatchServers(config, Utile.Base64Decode(clipboardData), subid, isSub, lstOriSub); counter = AddBatchServers(config, Utils.Base64Decode(strData), subid, isSub, lstOriSub);
} }
if (counter < 1) if (counter < 1)
{ {
counter = AddBatchServers4SsSIP008(config, clipboardData, subid, isSub, lstOriSub); counter = AddBatchServers4SsSIP008(config, strData, subid, isSub, lstOriSub);
} }
//maybe other sub //maybe other sub
if (counter < 1) if (counter < 1)
{ {
counter = AddBatchServers4Custom(config, clipboardData, subid, isSub, lstOriSub); counter = AddBatchServers4Custom(config, strData, subid, isSub, lstOriSub);
} }
return counter; return counter;
@@ -1357,26 +1394,35 @@ namespace v2rayN.Handler
public static int AddSubItem(Config config, string url) public static int AddSubItem(Config config, string url)
{ {
//already exists //already exists
if (SQLiteHelper.Instance.Table<SubItem>().Where(e => e.url == url).Count() > 0) if (SQLiteHelper.Instance.Table<SubItem>().Any(e => e.url == url))
{ {
return 0; return 0;
} }
SubItem subItem = new() SubItem subItem = new()
{ {
id = string.Empty, id = string.Empty,
remarks = "import_sub",
url = url url = url
}; };
try
{
var uri = new Uri(url);
var queryVars = HttpUtility.ParseQueryString(uri.Query);
subItem.remarks = queryVars["remarks"] ?? "import_sub";
}
catch (UriFormatException)
{
return 0;
}
return AddSubItem(config, subItem); return AddSubItem(config, subItem);
} }
public static int AddSubItem(Config config, SubItem subItem) public static int AddSubItem(Config config, SubItem subItem)
{ {
if (Utile.IsNullOrEmpty(subItem.id)) if (Utils.IsNullOrEmpty(subItem.id))
{ {
subItem.id = Utile.GetGUID(false); subItem.id = Utils.GetGUID(false);
if (subItem.sort <= 0) if (subItem.sort <= 0)
{ {
@@ -1406,7 +1452,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int RemoveServerViaSubid(Config config, string subid, bool isSub) public static int RemoveServerViaSubid(Config config, string subid, bool isSub)
{ {
if (Utile.IsNullOrEmpty(subid)) if (Utils.IsNullOrEmpty(subid))
{ {
return -1; return -1;
} }
@@ -1421,7 +1467,7 @@ namespace v2rayN.Handler
} }
foreach (var item in customProfile) foreach (var item in customProfile)
{ {
File.Delete(Utile.GetConfigPath(item.address)); File.Delete(Utils.GetConfigPath(item.address));
} }
return 0; return 0;
@@ -1457,9 +1503,9 @@ namespace v2rayN.Handler
public static int SaveRoutingItem(Config config, RoutingItem item) public static int SaveRoutingItem(Config config, RoutingItem item)
{ {
if (Utile.IsNullOrEmpty(item.id)) if (Utils.IsNullOrEmpty(item.id))
{ {
item.id = Utile.GetGUID(false); item.id = Utils.GetGUID(false);
} }
if (SQLiteHelper.Instance.Replace(item) > 0) if (SQLiteHelper.Instance.Replace(item) > 0)
@@ -1476,16 +1522,16 @@ namespace v2rayN.Handler
/// AddBatchRoutingRules /// AddBatchRoutingRules
/// </summary> /// </summary>
/// <param name="config"></param> /// <param name="config"></param>
/// <param name="clipboardData"></param> /// <param name="strData"></param>
/// <returns></returns> /// <returns></returns>
public static int AddBatchRoutingRules(ref RoutingItem routingItem, string clipboardData) public static int AddBatchRoutingRules(ref RoutingItem routingItem, string strData)
{ {
if (Utile.IsNullOrEmpty(clipboardData)) if (Utils.IsNullOrEmpty(strData))
{ {
return -1; return -1;
} }
var lstRules = JsonUtile.Deserialize<List<RulesItem>>(clipboardData); var lstRules = JsonUtils.Deserialize<List<RulesItem>>(strData);
if (lstRules == null) if (lstRules == null)
{ {
return -1; return -1;
@@ -1493,14 +1539,14 @@ namespace v2rayN.Handler
foreach (var item in lstRules) foreach (var item in lstRules)
{ {
item.id = Utile.GetGUID(false); item.id = Utils.GetGUID(false);
} }
routingItem.ruleNum = lstRules.Count; routingItem.ruleNum = lstRules.Count;
routingItem.ruleSet = JsonUtile.Serialize(lstRules, false); routingItem.ruleSet = JsonUtils.Serialize(lstRules, false);
if (Utile.IsNullOrEmpty(routingItem.id)) if (Utils.IsNullOrEmpty(routingItem.id))
{ {
routingItem.id = Utile.GetGUID(false); routingItem.id = Utils.GetGUID(false);
} }
if (SQLiteHelper.Instance.Replace(routingItem) > 0) if (SQLiteHelper.Instance.Replace(routingItem) > 0)
@@ -1535,7 +1581,7 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
var item = JsonUtile.DeepCopy(rules[index]); var item = JsonUtils.DeepCopy(rules[index]);
rules.RemoveAt(index); rules.RemoveAt(index);
rules.Insert(0, item); rules.Insert(0, item);
@@ -1547,7 +1593,7 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
var item = JsonUtile.DeepCopy(rules[index]); var item = JsonUtils.DeepCopy(rules[index]);
rules.RemoveAt(index); rules.RemoveAt(index);
rules.Insert(index - 1, item); rules.Insert(index - 1, item);
@@ -1560,7 +1606,7 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
var item = JsonUtile.DeepCopy(rules[index]); var item = JsonUtils.DeepCopy(rules[index]);
rules.RemoveAt(index); rules.RemoveAt(index);
rules.Insert(index + 1, item); rules.Insert(index + 1, item);
@@ -1572,7 +1618,7 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
var item = JsonUtile.DeepCopy(rules[index]); var item = JsonUtils.DeepCopy(rules[index]);
rules.RemoveAt(index); rules.RemoveAt(index);
rules.Add(item); rules.Add(item);
@@ -1581,7 +1627,7 @@ namespace v2rayN.Handler
case EMove.Position: case EMove.Position:
{ {
var removeItem = rules[index]; var removeItem = rules[index];
var item = JsonUtile.DeepCopy(rules[index]); var item = JsonUtils.DeepCopy(rules[index]);
rules.Insert(pos, item); rules.Insert(pos, item);
rules.Remove(removeItem); rules.Remove(removeItem);
break; break;
@@ -1617,36 +1663,37 @@ namespace v2rayN.Handler
public static int InitBuiltinRouting(Config config, bool blImportAdvancedRules = false) public static int InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
{ {
var ver = "V3-";
var items = LazyConfig.Instance.RoutingItems(); var items = LazyConfig.Instance.RoutingItems();
if (blImportAdvancedRules || items.Count <= 0) if (blImportAdvancedRules || items.Where(t => t.remarks.StartsWith(ver)).ToList().Count <= 0)
{ {
var maxSort = items.Count; var maxSort = items.Count;
//Bypass the mainland //Bypass the mainland
var item2 = new RoutingItem() var item2 = new RoutingItem()
{ {
remarks = "绕过大陆(Whitelist)", remarks = $"{ver}绕过大陆(Whitelist)",
url = string.Empty, url = string.Empty,
sort = maxSort + 1, sort = maxSort + 1,
}; };
AddBatchRoutingRules(ref item2, Utile.GetEmbedText(Global.CustomRoutingFileName + "white")); AddBatchRoutingRules(ref item2, Utils.GetEmbedText(Global.CustomRoutingFileName + "white"));
//Blacklist //Blacklist
var item3 = new RoutingItem() var item3 = new RoutingItem()
{ {
remarks = "黑名单(Blacklist)", remarks = $"{ver}黑名单(Blacklist)",
url = string.Empty, url = string.Empty,
sort = maxSort + 2, sort = maxSort + 2,
}; };
AddBatchRoutingRules(ref item3, Utile.GetEmbedText(Global.CustomRoutingFileName + "black")); AddBatchRoutingRules(ref item3, Utils.GetEmbedText(Global.CustomRoutingFileName + "black"));
//Global //Global
var item1 = new RoutingItem() var item1 = new RoutingItem()
{ {
remarks = "全局(Global)", remarks = $"{ver}全局(Global)",
url = string.Empty, url = string.Empty,
sort = maxSort + 3, sort = maxSort + 3,
}; };
AddBatchRoutingRules(ref item1, Utile.GetEmbedText(Global.CustomRoutingFileName + "global")); AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "global"));
if (!blImportAdvancedRules) if (!blImportAdvancedRules)
{ {
@@ -1662,7 +1709,7 @@ namespace v2rayN.Handler
url = string.Empty, url = string.Empty,
locked = true, locked = true,
}; };
AddBatchRoutingRules(ref item1, Utile.GetEmbedText(Global.CustomRoutingFileName + "locked")); AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "locked"));
} }
return 0; return 0;
} }
@@ -1706,9 +1753,9 @@ namespace v2rayN.Handler
public static int SaveDNSItems(Config config, DNSItem item) public static int SaveDNSItems(Config config, DNSItem item)
{ {
if (Utile.IsNullOrEmpty(item.id)) if (Utils.IsNullOrEmpty(item.id))
{ {
item.id = Utile.GetGUID(false); item.id = Utils.GetGUID(false);
} }
if (SQLiteHelper.Instance.Replace(item) > 0) if (SQLiteHelper.Instance.Replace(item) > 0)

View File

@@ -0,0 +1,271 @@
using System.IO;
using v2rayN.Common;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.CoreConfig
{
/// <summary>
/// Core configuration file processing class
/// </summary>
internal class CoreConfigClash
{
private Config _config;
public CoreConfigClash(Config config)
{
_config = config;
}
/// <summary>
/// 生成配置文件
/// </summary>
/// <param name="node"></param>
/// <param name="fileName"></param>
/// <param name="msg"></param>
/// <returns></returns>
public int GenerateClientCustomConfig(ProfileItem node, string? fileName, out string msg)
{
if (node == null || fileName is null)
{
msg = ResUI.CheckServerSettings;
return -1;
}
msg = ResUI.InitialConfiguration;
try
{
if (node == null)
{
msg = ResUI.CheckServerSettings;
return -1;
}
if (File.Exists(fileName))
{
File.Delete(fileName);
}
string addressFileName = node.address;
if (string.IsNullOrEmpty(addressFileName))
{
msg = ResUI.FailedGetDefaultConfiguration;
return -1;
}
if (!File.Exists(addressFileName))
{
addressFileName = Path.Combine(Utils.GetConfigPath(), addressFileName);
}
if (!File.Exists(addressFileName))
{
msg = ResUI.FailedReadConfiguration + "1";
return -1;
}
string tagYamlStr1 = "!<str>";
string tagYamlStr2 = "__strn__";
string tagYamlStr3 = "!!str";
var txtFile = File.ReadAllText(addressFileName);
txtFile = txtFile.Replace(tagYamlStr1, tagYamlStr2);
var fileContent = YamlUtils.FromYaml<Dictionary<string, object>>(txtFile);
if (fileContent == null)
{
msg = ResUI.FailedConversionConfiguration;
return -1;
}
//port
fileContent["port"] = LazyConfig.Instance.GetLocalPort(EInboundProtocol.http);
//socks-port
fileContent["socks-port"] = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks);
//log-level
fileContent["log-level"] = GetLogLevel(_config.coreBasicItem.loglevel);
//external-controller
fileContent["external-controller"] = $"{Global.Loopback}:{LazyConfig.Instance.StatePort2}";
//allow-lan
if (_config.inbound[0].allowLANConn)
{
fileContent["allow-lan"] = "true";
fileContent["bind-address"] = "*";
}
else
{
fileContent["allow-lan"] = "false";
}
//ipv6
fileContent["ipv6"] = _config.clashUIItem.enableIPv6;
//mode
if (!fileContent.ContainsKey("mode"))
{
fileContent["mode"] = ERuleMode.Rule.ToString().ToLower();
}
else
{
if (_config.clashUIItem.ruleMode != ERuleMode.Unchanged)
{
fileContent["mode"] = _config.clashUIItem.ruleMode.ToString().ToLower();
}
}
//enable tun mode
if (_config.tunModeItem.enableTun)
{
string tun = Utils.GetEmbedText(Global.ClashTunYaml);
if (!string.IsNullOrEmpty(tun))
{
var tunContent = YamlUtils.FromYaml<Dictionary<string, object>>(tun);
if (tunContent != null)
fileContent["tun"] = tunContent["tun"];
}
}
//Mixin
try
{
MixinContent(fileContent, node);
}
catch (Exception ex)
{
Logging.SaveLog("GenerateClientConfigClash-Mixin", ex);
}
var txtFileNew = YamlUtils.ToYaml(fileContent).Replace(tagYamlStr2, tagYamlStr3);
File.WriteAllText(fileName, txtFileNew);
//check again
if (!File.Exists(fileName))
{
msg = ResUI.FailedReadConfiguration + "2";
return -1;
}
ClashApiHandler.Instance.ProfileContent = fileContent;
msg = string.Format(ResUI.SuccessfulConfiguration, $"{node.GetSummary()}");
}
catch (Exception ex)
{
Logging.SaveLog("GenerateClientConfigClash", ex);
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
return 0;
}
private void MixinContent(Dictionary<string, object> fileContent, ProfileItem node)
{
//if (!_config.clashUIItem.enableMixinContent)
//{
// return;
//}
var path = Utils.GetConfigPath(Global.ClashMixinConfigFileName);
if (!File.Exists(path))
{
return;
}
var txtFile = File.ReadAllText(Utils.GetConfigPath(Global.ClashMixinConfigFileName));
var mixinContent = YamlUtils.FromYaml<Dictionary<string, object>>(txtFile);
if (mixinContent == null)
{
return;
}
foreach (var item in mixinContent)
{
if (!_config.tunModeItem.enableTun && item.Key == "tun")
{
continue;
}
if (item.Key.StartsWith("prepend-")
|| item.Key.StartsWith("append-")
|| item.Key.StartsWith("removed-"))
{
ModifyContentMerge(fileContent, item.Key, item.Value);
}
else
{
fileContent[item.Key] = item.Value;
}
}
return;
}
private void ModifyContentMerge(Dictionary<string, object> fileContent, string key, object value)
{
bool blPrepend = false;
bool blRemoved = false;
if (key.StartsWith("prepend-"))
{
blPrepend = true;
key = key.Replace("prepend-", "");
}
else if (key.StartsWith("append-"))
{
blPrepend = false;
key = key.Replace("append-", "");
}
else if (key.StartsWith("removed-"))
{
blRemoved = true;
key = key.Replace("removed-", "");
}
else
{
return;
}
if (!blRemoved && !fileContent.ContainsKey(key))
{
fileContent.Add(key, value);
return;
}
var lstOri = (List<object>)fileContent[key];
var lstValue = (List<object>)value;
if (blRemoved)
{
foreach (var item in lstValue)
{
lstOri.RemoveAll(t => t.ToString().StartsWith(item.ToString()));
}
return;
}
if (blPrepend)
{
lstValue.Reverse();
foreach (var item in lstValue)
{
lstOri.Insert(0, item);
}
}
else
{
foreach (var item in lstValue)
{
lstOri.Add(item);
}
}
}
private string GetLogLevel(string level)
{
if (level == "none")
{
return "silent";
}
else
{
return level;
}
}
}
}

View File

@@ -1,8 +1,9 @@
using System.IO; using System.IO;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler.CoreConfig
{ {
/// <summary> /// <summary>
/// Core configuration file processing class /// Core configuration file processing class
@@ -24,22 +25,35 @@ namespace v2rayN.Handler
msg = ResUI.InitialConfiguration; msg = ResUI.InitialConfiguration;
if (node.configType == EConfigType.Custom) if (node.configType == EConfigType.Custom)
{ {
return GenerateClientCustomConfig(node, fileName, out msg); if (node.coreType is ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo)
{
var configGenClash = new CoreConfigClash(config);
return configGenClash.GenerateClientCustomConfig(node, fileName, out msg);
}
if (node.coreType is ECoreType.sing_box)
{
var configGenSingbox = new CoreConfigSingbox(config);
return configGenSingbox.GenerateClientCustomConfig(node, fileName, out msg);
}
else
{
return GenerateClientCustomConfig(node, fileName, out msg);
}
} }
else if (config.tunModeItem.enableTun || LazyConfig.Instance.GetCoreType(node, node.configType) == ECoreType.sing_box) else if (LazyConfig.Instance.GetCoreType(node, node.configType) == ECoreType.sing_box)
{ {
var configGenSingbox = new CoreConfigSingbox(config); var configGenSingbox = new CoreConfigSingbox(config);
if (configGenSingbox.GenerateClientConfigContent(node, out SingboxConfig? singboxConfig, out msg) != 0) if (configGenSingbox.GenerateClientConfigContent(node, out SingboxConfig? singboxConfig, out msg) != 0)
{ {
return -1; return -1;
} }
if (Utile.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
content = JsonUtile.Serialize(singboxConfig); content = JsonUtils.Serialize(singboxConfig);
} }
else else
{ {
JsonUtile.ToFile(singboxConfig, fileName, false); JsonUtils.ToFile(singboxConfig, fileName, false);
} }
} }
else else
@@ -49,13 +63,13 @@ namespace v2rayN.Handler
{ {
return -1; return -1;
} }
if (Utile.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
content = JsonUtile.Serialize(v2rayConfig); content = JsonUtils.Serialize(v2rayConfig);
} }
else else
{ {
JsonUtile.ToFile(v2rayConfig, fileName, false); JsonUtils.ToFile(v2rayConfig, fileName, false);
} }
} }
} }
@@ -87,7 +101,7 @@ namespace v2rayN.Handler
string addressFileName = node.address; string addressFileName = node.address;
if (!File.Exists(addressFileName)) if (!File.Exists(addressFileName))
{ {
addressFileName = Utile.GetConfigPath(addressFileName); addressFileName = Utils.GetConfigPath(addressFileName);
} }
if (!File.Exists(addressFileName)) if (!File.Exists(addressFileName))
{ {
@@ -104,41 +118,6 @@ namespace v2rayN.Handler
return -1; return -1;
} }
//overwrite port
if (node.preSocksPort <= 0)
{
var fileContent = File.ReadAllLines(fileName).ToList();
var coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
switch (coreType)
{
case ECoreType.v2fly:
case ECoreType.SagerNet:
case ECoreType.Xray:
case ECoreType.v2fly_v5:
break;
case ECoreType.clash:
case ECoreType.clash_meta:
case ECoreType.mihomo:
//remove the original
var indexPort = fileContent.FindIndex(t => t.Contains("port:"));
if (indexPort >= 0)
{
fileContent.RemoveAt(indexPort);
}
indexPort = fileContent.FindIndex(t => t.Contains("socks-port:"));
if (indexPort >= 0)
{
fileContent.RemoveAt(indexPort);
}
fileContent.Add($"port: {LazyConfig.Instance.GetLocalPort(EInboundProtocol.http)}");
fileContent.Add($"socks-port: {LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)}");
break;
}
File.WriteAllLines(fileName, fileContent);
}
msg = string.Format(ResUI.SuccessfulConfiguration, ""); msg = string.Format(ResUI.SuccessfulConfiguration, "");
} }
catch (Exception ex) catch (Exception ex)
@@ -154,21 +133,44 @@ namespace v2rayN.Handler
{ {
if (coreType == ECoreType.sing_box) if (coreType == ECoreType.sing_box)
{ {
if ((new CoreConfigSingbox(config)).GenerateClientSpeedtestConfig(selecteds, out SingboxConfig? singboxConfig, out msg) != 0) if (new CoreConfigSingbox(config).GenerateClientSpeedtestConfig(selecteds, out SingboxConfig? singboxConfig, out msg) != 0)
{ {
return -1; return -1;
} }
JsonUtile.ToFile(singboxConfig, fileName, false); JsonUtils.ToFile(singboxConfig, fileName, false);
} }
else else
{ {
if ((new CoreConfigV2ray(config)).GenerateClientSpeedtestConfig(selecteds, out V2rayConfig? v2rayConfig, out msg) != 0) if (new CoreConfigV2ray(config).GenerateClientSpeedtestConfig(selecteds, out V2rayConfig? v2rayConfig, out msg) != 0)
{ {
return -1; return -1;
} }
JsonUtile.ToFile(v2rayConfig, fileName, false); JsonUtils.ToFile(v2rayConfig, fileName, false);
} }
return 0; return 0;
} }
public static int GenerateClientMultipleLoadConfig(Config config, string fileName, List<ProfileItem> selecteds, ECoreType coreType, out string msg)
{
msg = ResUI.CheckServerSettings;
if (coreType == ECoreType.sing_box)
{
if (new CoreConfigSingbox(config).GenerateClientMultipleLoadConfig(selecteds, out SingboxConfig? singboxConfig, out msg) != 0)
{
return -1;
}
JsonUtils.ToFile(singboxConfig, fileName, false);
}
else if (coreType == ECoreType.Xray)
{
if (new CoreConfigV2ray(config).GenerateClientMultipleLoadConfig(selecteds, out V2rayConfig? v2rayConfig, out msg) != 0)
{
return -1;
}
JsonUtils.ToFile(v2rayConfig, fileName, false);
}
return 0;
}
} }
} }

View File

@@ -1,8 +1,9 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reactive.Linq;
using System.Text; using System.Text;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -22,23 +23,23 @@ namespace v2rayN.Handler
_config = config; _config = config;
_updateFunc = update; _updateFunc = update;
Environment.SetEnvironmentVariable("v2ray.location.asset", Utile.GetBinPath(""), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("v2ray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("xray.location.asset", Utile.GetBinPath(""), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("xray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
} }
public void LoadCore() public void LoadCore(ProfileItem? node)
{ {
var node = ConfigHandler.GetDefaultServer(_config);
if (node == null) if (node == null)
{ {
ShowMsg(false, ResUI.CheckServerSettings); ShowMsg(false, ResUI.CheckServerSettings);
return; return;
} }
string fileName = Utile.GetConfigPath(Global.CoreConfigFileName); string fileName = Utils.GetConfigPath(Global.CoreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0) if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0)
{ {
ShowMsg(false, msg); ShowMsg(false, msg);
return;
} }
else else
{ {
@@ -48,28 +49,28 @@ namespace v2rayN.Handler
if (_config.tunModeItem.enableTun) if (_config.tunModeItem.enableTun)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
Utile.RemoveTunDevice(); Utils.RemoveTunDevice();
} }
CoreStart(node); CoreStart(node);
//In tun mode, do a delay check and restart the core //In tun mode, do a delay check and restart the core
if (_config.tunModeItem.enableTun) //if (_config.tunModeItem.enableTun)
{ //{
Observable.Range(1, 1) // Observable.Range(1, 1)
.Delay(TimeSpan.FromSeconds(15)) // .Delay(TimeSpan.FromSeconds(15))
.Subscribe(x => // .Subscribe(x =>
{ // {
{ // {
if (_process == null || _process.HasExited) // if (_process == null || _process.HasExited)
{ // {
CoreStart(node); // CoreStart(node);
ShowMsg(false, "Tun mode restart the core once"); // ShowMsg(false, "Tun mode restart the core once");
Logging.SaveLog("Tun mode restart the core once"); // Logging.SaveLog("Tun mode restart the core once");
} // }
} // }
}); // });
} //}
} }
} }
@@ -77,7 +78,7 @@ namespace v2rayN.Handler
{ {
int pid = -1; int pid = -1;
var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic || t.configType == EConfigType.Wireguard) ? ECoreType.sing_box : ECoreType.Xray; var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic || t.configType == EConfigType.Wireguard) ? ECoreType.sing_box : ECoreType.Xray;
string configPath = Utile.GetConfigPath(Global.CoreSpeedtestConfigFileName); string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0) if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0)
{ {
ShowMsg(false, msg); ShowMsg(false, msg);
@@ -126,7 +127,7 @@ namespace v2rayN.Handler
foreach (Process p in existing) foreach (Process p in existing)
{ {
string? path = p.MainModule?.FileName; string? path = p.MainModule?.FileName;
if (path == $"{Utile.GetBinPath(vName, it.coreType.ToString())}.exe") if (path == $"{Utils.GetBinPath(vName, it.coreType.ToString())}.exe")
{ {
KillProcess(p); KillProcess(p);
} }
@@ -162,16 +163,16 @@ namespace v2rayN.Handler
foreach (string name in coreInfo.coreExes) foreach (string name in coreInfo.coreExes)
{ {
string vName = $"{name}.exe"; string vName = $"{name}.exe";
vName = Utile.GetBinPath(vName, coreInfo.coreType.ToString()); vName = Utils.GetBinPath(vName, coreInfo.coreType.ToString());
if (File.Exists(vName)) if (File.Exists(vName))
{ {
fileName = vName; fileName = vName;
break; break;
} }
} }
if (Utile.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
string msg = string.Format(ResUI.NotFoundCore, Utile.GetBinPath("", coreInfo.coreType.ToString()), string.Join(", ", coreInfo.coreExes.ToArray()), coreInfo.coreUrl); string msg = string.Format(ResUI.NotFoundCore, Utils.GetBinPath("", coreInfo.coreType.ToString()), string.Join(", ", coreInfo.coreExes.ToArray()), coreInfo.coreUrl);
Logging.SaveLog(msg); Logging.SaveLog(msg);
ShowMsg(false, msg); ShowMsg(false, msg);
} }
@@ -183,15 +184,17 @@ namespace v2rayN.Handler
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
ECoreType coreType; //ECoreType coreType;
if (node.configType != EConfigType.Custom && _config.tunModeItem.enableTun) //if (node.configType != EConfigType.Custom && _config.tunModeItem.enableTun)
{ //{
coreType = ECoreType.sing_box; // coreType = ECoreType.sing_box;
} //}
else //else
{ //{
coreType = LazyConfig.Instance.GetCoreType(node, node.configType); // coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
} //}
var coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
_config.runningCoreType = coreType;
var coreInfo = LazyConfig.Instance.GetCoreInfo(coreType); var coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
var displayLog = node.configType != EConfigType.Custom || node.displayLog; var displayLog = node.configType != EConfigType.Custom || node.displayLog;
@@ -202,22 +205,40 @@ namespace v2rayN.Handler
} }
_process = proc; _process = proc;
//start a socks service //start a pre service
if (_process != null && !_process.HasExited) if (_process != null && !_process.HasExited)
{ {
if ((node.configType == EConfigType.Custom && node.preSocksPort > 0)) ProfileItem? itemSocks = null;
var preCoreType = ECoreType.sing_box;
if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.tunModeItem.enableTun)
{ {
var itemSocks = new ProfileItem() itemSocks = new ProfileItem()
{ {
coreType = ECoreType.sing_box, coreType = preCoreType,
configType = EConfigType.Socks,
address = Global.Loopback,
sni = node.address, //Tun2SocksAddress
port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)
};
}
else if ((node.configType == EConfigType.Custom && node.preSocksPort > 0))
{
preCoreType = _config.tunModeItem.enableTun ? ECoreType.sing_box : ECoreType.Xray;
itemSocks = new ProfileItem()
{
coreType = preCoreType,
configType = EConfigType.Socks, configType = EConfigType.Socks,
address = Global.Loopback, address = Global.Loopback,
port = node.preSocksPort port = node.preSocksPort
}; };
string fileName2 = Utile.GetConfigPath(Global.CorePreConfigFileName); _config.runningCoreType = preCoreType;
}
if (itemSocks != null)
{
string fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2, out string msg2, out string configStr) == 0) if (CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2, out string msg2, out string configStr) == 0)
{ {
var coreInfo2 = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box); var coreInfo2 = LazyConfig.Instance.GetCoreInfo(preCoreType);
var proc2 = RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true); var proc2 = RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true);
if (proc2 is not null) if (proc2 is not null)
{ {
@@ -267,7 +288,7 @@ namespace v2rayN.Handler
try try
{ {
string fileName = CoreFindExe(coreInfo); string fileName = CoreFindExe(coreInfo);
if (Utile.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
return null; return null;
} }
@@ -277,7 +298,7 @@ namespace v2rayN.Handler
{ {
FileName = fileName, FileName = fileName,
Arguments = string.Format(coreInfo.arguments, configPath), Arguments = string.Format(coreInfo.arguments, configPath),
WorkingDirectory = Utile.GetConfigPath(), WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = displayLog, RedirectStandardOutput = displayLog,
RedirectStandardError = displayLog, RedirectStandardError = displayLog,
@@ -292,7 +313,7 @@ namespace v2rayN.Handler
{ {
proc.OutputDataReceived += (sender, e) => proc.OutputDataReceived += (sender, e) =>
{ {
if (!string.IsNullOrEmpty(e.Data)) if (!Utils.IsNullOrEmpty(e.Data))
{ {
string msg = e.Data + Environment.NewLine; string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg); ShowMsg(false, msg);
@@ -300,7 +321,7 @@ namespace v2rayN.Handler
}; };
proc.ErrorDataReceived += (sender, e) => proc.ErrorDataReceived += (sender, e) =>
{ {
if (!string.IsNullOrEmpty(e.Data)) if (!Utils.IsNullOrEmpty(e.Data))
{ {
string msg = e.Data + Environment.NewLine; string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg); ShowMsg(false, msg);

View File

@@ -4,7 +4,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Sockets; using System.Net.Sockets;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -34,7 +34,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
Utile.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
var progress = new Progress<string>(); var progress = new Progress<string>();
progress.ProgressChanged += (sender, value) => progress.ProgressChanged += (sender, value) =>
@@ -66,7 +66,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
Utile.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, $"{ResUI.Downloading} {url}")); UpdateCompleted?.Invoke(this, new ResultEventArgs(false, $"{ResUI.Downloading} {url}"));
var progress = new Progress<double>(); var progress = new Progress<double>();
@@ -78,7 +78,7 @@ namespace v2rayN.Handler
var webProxy = GetWebProxy(blProxy); var webProxy = GetWebProxy(blProxy);
await DownloaderHelper.Instance.DownloadFileAsync(webProxy, await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
url, url,
Utile.GetTempPath(Utile.GetDownloadFileName(url)), Utils.GetTempPath(Utils.GetDownloadFileName(url)),
progress, progress,
downloadTimeout); downloadTimeout);
} }
@@ -96,7 +96,7 @@ namespace v2rayN.Handler
public async Task<string?> UrlRedirectAsync(string url, bool blProxy) public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
{ {
Utile.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
var webRequestHandler = new SocketsHttpHandler var webRequestHandler = new SocketsHttpHandler
{ {
AllowAutoRedirect = false, AllowAutoRedirect = false,
@@ -121,7 +121,7 @@ namespace v2rayN.Handler
try try
{ {
var result1 = await DownloadStringAsync(url, blProxy, userAgent); var result1 = await DownloadStringAsync(url, blProxy, userAgent);
if (!Utile.IsNullOrEmpty(result1)) if (!Utils.IsNullOrEmpty(result1))
{ {
return result1; return result1;
} }
@@ -139,7 +139,7 @@ namespace v2rayN.Handler
try try
{ {
var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent); var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent);
if (!Utile.IsNullOrEmpty(result2)) if (!Utils.IsNullOrEmpty(result2))
{ {
return result2; return result2;
} }
@@ -159,7 +159,7 @@ namespace v2rayN.Handler
using var wc = new WebClient(); using var wc = new WebClient();
wc.Proxy = GetWebProxy(blProxy); wc.Proxy = GetWebProxy(blProxy);
var result3 = await wc.DownloadStringTaskAsync(url); var result3 = await wc.DownloadStringTaskAsync(url);
if (!Utile.IsNullOrEmpty(result3)) if (!Utils.IsNullOrEmpty(result3))
{ {
return result3; return result3;
} }
@@ -185,7 +185,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
Utile.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
var webProxy = GetWebProxy(blProxy); var webProxy = GetWebProxy(blProxy);
var client = new HttpClient(new SocketsHttpHandler() var client = new HttpClient(new SocketsHttpHandler()
{ {
@@ -193,17 +193,17 @@ namespace v2rayN.Handler
UseProxy = webProxy != null UseProxy = webProxy != null
}); });
if (Utile.IsNullOrEmpty(userAgent)) if (Utils.IsNullOrEmpty(userAgent))
{ {
userAgent = Utile.GetVersion(false); userAgent = Utils.GetVersion(false);
} }
client.DefaultRequestHeaders.UserAgent.TryParseAdd(userAgent); client.DefaultRequestHeaders.UserAgent.TryParseAdd(userAgent);
Uri uri = new(url); Uri uri = new(url);
//Authorization Header //Authorization Header
if (!Utile.IsNullOrEmpty(uri.UserInfo)) if (!Utils.IsNullOrEmpty(uri.UserInfo))
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utile.Base64Encode(uri.UserInfo)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
} }
using var cts = new CancellationTokenSource(); using var cts = new CancellationTokenSource();
@@ -230,13 +230,13 @@ namespace v2rayN.Handler
{ {
try try
{ {
Utile.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
var webProxy = GetWebProxy(blProxy); var webProxy = GetWebProxy(blProxy);
if (Utile.IsNullOrEmpty(userAgent)) if (Utils.IsNullOrEmpty(userAgent))
{ {
userAgent = Utile.GetVersion(false); userAgent = Utils.GetVersion(false);
} }
var result = await DownloaderHelper.Instance.DownloadStringAsync(webProxy, url, userAgent, 30); var result = await DownloaderHelper.Instance.DownloadStringAsync(webProxy, url, userAgent, 30);
return result; return result;
@@ -286,8 +286,6 @@ namespace v2rayN.Handler
int responseTime = -1; int responseTime = -1;
try try
{ {
Stopwatch timer = Stopwatch.StartNew();
using var cts = new CancellationTokenSource(); using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(downloadTimeout)); cts.CancelAfter(TimeSpan.FromSeconds(downloadTimeout));
using var client = new HttpClient(new SocketsHttpHandler() using var client = new HttpClient(new SocketsHttpHandler()
@@ -295,9 +293,17 @@ namespace v2rayN.Handler
Proxy = webProxy, Proxy = webProxy,
UseProxy = webProxy != null UseProxy = webProxy != null
}); });
await client.GetAsync(url, cts.Token);
responseTime = timer.Elapsed.Milliseconds; List<int> oneTime = [];
for (int i = 0; i < 2; i++)
{
var timer = Stopwatch.StartNew();
await client.GetAsync(url, cts.Token);
timer.Stop();
oneTime.Add((int)timer.Elapsed.TotalMilliseconds);
await Task.Delay(100);
}
responseTime = oneTime.Where(x => x > 0).OrderBy(x => x).FirstOrDefault();
} }
catch //(Exception ex) catch //(Exception ex)
{ {

View File

@@ -0,0 +1,208 @@
using System.Collections.Specialized;
using System.IO;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{
internal class BaseFmt
{
protected static string GetIpv6(string address)
{
if (Utils.IsIpv6(address))
{
// 检查地址是否已经被方括号包围,如果没有,则添加方括号
return address.StartsWith('[') && address.EndsWith(']') ? address : $"[{address}]";
}
return address; // 如果不是IPv6地址直接返回原地址
}
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
{
if (!Utils.IsNullOrEmpty(item.flow))
{
dicQuery.Add("flow", item.flow);
}
if (!Utils.IsNullOrEmpty(item.streamSecurity))
{
dicQuery.Add("security", item.streamSecurity);
}
else
{
if (securityDef != null)
{
dicQuery.Add("security", securityDef);
}
}
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utils.UrlEncode(item.alpn));
}
if (!Utils.IsNullOrEmpty(item.fingerprint))
{
dicQuery.Add("fp", Utils.UrlEncode(item.fingerprint));
}
if (!Utils.IsNullOrEmpty(item.publicKey))
{
dicQuery.Add("pbk", Utils.UrlEncode(item.publicKey));
}
if (!Utils.IsNullOrEmpty(item.shortId))
{
dicQuery.Add("sid", Utils.UrlEncode(item.shortId));
}
if (!Utils.IsNullOrEmpty(item.spiderX))
{
dicQuery.Add("spx", Utils.UrlEncode(item.spiderX));
}
if (item.allowInsecure.Equals("true"))
{
dicQuery.Add("allowInsecure", "1");
}
dicQuery.Add("type", !Utils.IsNullOrEmpty(item.network) ? item.network : nameof(ETransport.tcp));
switch (item.network)
{
case nameof(ETransport.tcp):
dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
break;
case nameof(ETransport.kcp):
dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("seed", Utils.UrlEncode(item.path));
}
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
case nameof(ETransport.splithttp):
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case nameof(ETransport.http):
case nameof(ETransport.h2):
dicQuery["type"] = nameof(ETransport.http);
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case nameof(ETransport.quic):
dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.requestHost));
dicQuery.Add("key", Utils.UrlEncode(item.path));
break;
case nameof(ETransport.grpc):
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("authority", Utils.UrlEncode(item.requestHost));
dicQuery.Add("serviceName", Utils.UrlEncode(item.path));
if (item.headerType is Global.GrpcGunMode or Global.GrpcMultiMode)
{
dicQuery.Add("mode", Utils.UrlEncode(item.headerType));
}
}
break;
}
return 0;
}
protected static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item)
{
item.flow = query["flow"] ?? "";
item.streamSecurity = query["security"] ?? "";
item.sni = query["sni"] ?? "";
item.alpn = Utils.UrlDecode(query["alpn"] ?? "");
item.fingerprint = Utils.UrlDecode(query["fp"] ?? "");
item.publicKey = Utils.UrlDecode(query["pbk"] ?? "");
item.shortId = Utils.UrlDecode(query["sid"] ?? "");
item.spiderX = Utils.UrlDecode(query["spx"] ?? "");
item.allowInsecure = (query["allowInsecure"] ?? "") == "1" ? "true" : "";
item.network = query["type"] ?? nameof(ETransport.tcp);
switch (item.network)
{
case nameof(ETransport.tcp):
item.headerType = query["headerType"] ?? Global.None;
item.requestHost = Utils.UrlDecode(query["host"] ?? "");
break;
case nameof(ETransport.kcp):
item.headerType = query["headerType"] ?? Global.None;
item.path = Utils.UrlDecode(query["seed"] ?? "");
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
case nameof(ETransport.splithttp):
item.requestHost = Utils.UrlDecode(query["host"] ?? "");
item.path = Utils.UrlDecode(query["path"] ?? "/");
break;
case nameof(ETransport.http):
case nameof(ETransport.h2):
item.network = nameof(ETransport.h2);
item.requestHost = Utils.UrlDecode(query["host"] ?? "");
item.path = Utils.UrlDecode(query["path"] ?? "/");
break;
case nameof(ETransport.quic):
item.headerType = query["headerType"] ?? Global.None;
item.requestHost = query["quicSecurity"] ?? Global.None;
item.path = Utils.UrlDecode(query["key"] ?? "");
break;
case nameof(ETransport.grpc):
item.requestHost = Utils.UrlDecode(query["authority"] ?? "");
item.path = Utils.UrlDecode(query["serviceName"] ?? "");
item.headerType = Utils.UrlDecode(query["mode"] ?? Global.GrpcGunMode);
break;
default:
break;
}
return 0;
}
protected static bool Contains(string str, params string[] s)
{
foreach (var item in s)
{
if (str.Contains(item, StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
protected static string WriteAllText(string strData, string ext = "json")
{
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.{ext}");
File.WriteAllText(fileName, strData);
return fileName;
}
}
}

View File

@@ -0,0 +1,26 @@
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{
internal class ClashFmt : BaseFmt
{
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{
if (Contains(strData, "port", "socks-port", "proxies"))
{
var fileName = WriteAllText(strData, "yaml");
var profileItem = new ProfileItem
{
coreType = ECoreType.mihomo,
address = fileName,
remarks = subRemarks ?? "clash_custom"
};
return profileItem;
}
return null;
}
}
}

View File

@@ -0,0 +1,94 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class FmtHandler
{
public static string? GetShareUri(ProfileItem item)
{
try
{
var url = item.configType switch
{
EConfigType.VMess => VmessFmt.ToUri(item),
EConfigType.Shadowsocks => ShadowsocksFmt.ToUri(item),
EConfigType.Socks => SocksFmt.ToUri(item),
EConfigType.Trojan => TrojanFmt.ToUri(item),
EConfigType.VLESS => VLESSFmt.ToUri(item),
EConfigType.Hysteria2 => Hysteria2Fmt.ToUri(item),
EConfigType.Tuic => TuicFmt.ToUri(item),
EConfigType.Wireguard => WireguardFmt.ToUri(item),
_ => null,
};
return url;
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
return "";
}
}
public static ProfileItem? ResolveConfig(string config, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
try
{
string str = config.TrimEx();
if (Utils.IsNullOrEmpty(str))
{
msg = ResUI.FailedReadConfiguration;
return null;
}
if (str.StartsWith(Global.ProtocolShares[EConfigType.VMess]))
{
return VmessFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Shadowsocks]))
{
return ShadowsocksFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
{
return SocksFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Trojan]))
{
return TrojanFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.VLESS]))
{
return VLESSFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || str.StartsWith(Global.Hysteria2ProtocolShare))
{
return Hysteria2Fmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
{
return TuicFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Wireguard]))
{
return WireguardFmt.Resolve(str, out msg);
}
else
{
msg = ResUI.NonvmessOrssProtocol;
return null;
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
msg = ResUI.Incorrectconfiguration;
return null;
}
}
}
}

View File

@@ -0,0 +1,104 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class Hysteria2Fmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem item = new()
{
configType = EConfigType.Hysteria2
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utils.UrlDecode(url.UserInfo);
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;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.alpn))
{
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());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}/{query}{remark}";
return url;
}
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{
if (Contains(strData, "server", "up", "down", "listen", "<html>", "<body>"))
{
var fileName = WriteAllText(strData);
var profileItem = new ProfileItem
{
coreType = ECoreType.hysteria,
address = fileName,
remarks = subRemarks ?? "hysteria_custom"
};
return profileItem;
}
return null;
}
public static ProfileItem? ResolveFull2(string strData, string? subRemarks)
{
if (Contains(strData, "server", "auth", "up", "down", "listen"))
{
var fileName = WriteAllText(strData);
var profileItem = new ProfileItem
{
coreType = ECoreType.hysteria2,
address = fileName,
remarks = subRemarks ?? "hysteria2_custom"
};
return profileItem;
}
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{
internal class NaiveproxyFmt : BaseFmt
{
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{
if (Contains(strData, "listen", "proxy", "<html>", "<body>"))
{
var fileName = WriteAllText(strData);
var profileItem = new ProfileItem
{
coreType = ECoreType.naiveproxy,
address = fileName,
remarks = subRemarks ?? "naiveproxy_custom"
};
return profileItem;
}
return null;
}
}
}

View File

@@ -0,0 +1,183 @@
using System.Text.RegularExpressions;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class ShadowsocksFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem? item;
item = ResolveSSLegacy(str) ?? ResolveSip002(str);
if (item == null)
{
return null;
}
if (item.address.Length == 0 || item.port == 0 || item.security.Length == 0 || item.id.Length == 0)
{
return null;
}
item.configType = EConfigType.Shadowsocks;
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
//url = string.Format("{0}:{1}@{2}:{3}",
// item.security,
// item.id,
// item.address,
// item.port);
//url = Utile.Base64Encode(url);
//new Sip002
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
return url;
}
private static readonly Regex UrlFinder = new(@"ss://(?<base64>[A-Za-z0-9+-/=_]+)(?:#(?<tag>\S+))?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex DetailsParser = new(@"^((?<method>.+?):(?<password>.*)@(?<hostname>.+?):(?<port>\d+?))$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static ProfileItem? ResolveSSLegacy(string result)
{
var match = UrlFinder.Match(result);
if (!match.Success)
return null;
ProfileItem item = new();
var base64 = match.Groups["base64"].Value.TrimEnd('/');
var tag = match.Groups["tag"].Value;
if (!Utils.IsNullOrEmpty(tag))
{
item.remarks = Utils.UrlDecode(tag);
}
Match details;
try
{
details = DetailsParser.Match(Utils.Base64Decode(base64));
}
catch (FormatException)
{
return null;
}
if (!details.Success)
return null;
item.security = details.Groups["method"].Value;
item.id = details.Groups["password"].Value;
item.address = details.Groups["hostname"].Value;
item.port = Utils.ToInt(details.Groups["port"].Value);
return item;
}
private static ProfileItem? ResolveSip002(string result)
{
Uri parsedUrl;
try
{
parsedUrl = new Uri(result);
}
catch (UriFormatException)
{
return null;
}
ProfileItem item = new()
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
address = parsedUrl.IdnHost,
port = parsedUrl.Port,
};
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.UriEscaped);
//2022-blake3
if (rawUserInfo.Contains(':'))
{
string[] userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length != 2)
{
return null;
}
item.security = userInfoParts[0];
item.id = Utils.UrlDecode(userInfoParts[1]);
}
else
{
// parse base64 UserInfo
string userInfo = Utils.Base64Decode(rawUserInfo);
string[] userInfoParts = userInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length != 2)
{
return null;
}
item.security = userInfoParts[0];
item.id = userInfoParts[1];
}
var queryParameters = Utils.ParseQueryString(parsedUrl.Query);
if (queryParameters["plugin"] != null)
{
//obfs-host exists
var obfsHost = queryParameters["plugin"]?.Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
if (queryParameters["plugin"].Contains("obfs=http") && !Utils.IsNullOrEmpty(obfsHost))
{
obfsHost = obfsHost?.Replace("obfs-host=", "");
item.network = Global.DefaultNetwork;
item.headerType = Global.TcpHeaderHttp;
item.requestHost = obfsHost ?? "";
}
else
{
return null;
}
}
return item;
}
public static List<ProfileItem>? ResolveSip008(string result)
{
//SsSIP008
var lstSsServer = JsonUtils.Deserialize<List<SsServer>>(result);
if (lstSsServer?.Count <= 0)
{
var ssSIP008 = JsonUtils.Deserialize<SsSIP008>(result);
if (ssSIP008?.servers?.Count > 0)
{
lstSsServer = ssSIP008.servers;
}
}
if (lstSsServer?.Count > 0)
{
List<ProfileItem> lst = [];
foreach (var it in lstSsServer)
{
var ssItem = new ProfileItem()
{
remarks = it.remarks,
security = it.method,
id = it.password,
address = it.server,
port = Utils.ToInt(it.server_port)
};
lst.Add(ssItem);
}
return lst;
}
return null;
}
}
}

View File

@@ -0,0 +1,58 @@
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{
internal class SingboxFmt : BaseFmt
{
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
{
var configObjects = JsonUtils.Deserialize<Object[]>(strData);
if (configObjects != null && configObjects.Length > 0)
{
List<ProfileItem> lstResult = [];
foreach (var configObject in configObjects)
{
var objectString = JsonUtils.Serialize(configObject);
var singboxCon = JsonUtils.Deserialize<SingboxConfig>(objectString);
if (singboxCon?.inbounds?.Count > 0
&& singboxCon.outbounds?.Count > 0
&& singboxCon.route != null)
{
var fileName = WriteAllText(objectString);
var profileIt = new ProfileItem
{
coreType = ECoreType.sing_box,
address = fileName,
remarks = subRemarks ?? "singbox_custom",
};
lstResult.Add(profileIt);
}
}
return lstResult;
}
return null;
}
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(strData);
if (singboxConfig?.inbounds?.Count > 0
&& singboxConfig.outbounds?.Count > 0
&& singboxConfig.route != null)
{
var fileName = WriteAllText(strData);
var profileItem = new ProfileItem
{
coreType = ECoreType.sing_box,
address = fileName,
remarks = subRemarks ?? "singbox_custom"
};
return profileItem;
}
return null;
}
}
}

View File

@@ -0,0 +1,131 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class SocksFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem? item;
item = ResolveSocksNew(str) ?? ResolveSocks(str);
if (item == null)
{
return null;
}
if (item.address.Length == 0 || item.port == 0)
{
return null;
}
item.configType = EConfigType.Socks;
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
//url = string.Format("{0}:{1}@{2}:{3}",
// item.security,
// item.id,
// item.address,
// item.port);
//url = Utile.Base64Encode(url);
//new
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
return url;
}
private static ProfileItem? ResolveSocks(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Socks
};
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
//remark
int indexRemark = result.IndexOf("#");
if (indexRemark > 0)
{
try
{
item.remarks = Utils.UrlDecode(result.Substring(indexRemark + 1, result.Length - indexRemark - 1));
}
catch { }
result = result[..indexRemark];
}
//part decode
int indexS = result.IndexOf("@");
if (indexS > 0)
{
}
else
{
result = Utils.Base64Decode(result);
}
string[] arr1 = result.Split('@');
if (arr1.Length != 2)
{
return null;
}
string[] arr21 = arr1[0].Split(':');
//string[] arr22 = arr1[1].Split(':');
int indexPort = arr1[1].LastIndexOf(":");
if (arr21.Length != 2 || indexPort < 0)
{
return null;
}
item.address = arr1[1][..indexPort];
item.port = Utils.ToInt(arr1[1][(indexPort + 1)..]);
item.security = arr21[0];
item.id = arr21[1];
return item;
}
private static ProfileItem? ResolveSocksNew(string result)
{
Uri parsedUrl;
try
{
parsedUrl = new Uri(result);
}
catch (UriFormatException)
{
return null;
}
ProfileItem item = new()
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
address = parsedUrl.IdnHost,
port = parsedUrl.Port,
};
// parse base64 UserInfo
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
string userInfo = Utils.Base64Decode(rawUserInfo);
string[] userInfoParts = userInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2)
{
item.security = userInfoParts[0];
item.id = userInfoParts[1];
}
return item;
}
}
}

View File

@@ -0,0 +1,53 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class TrojanFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem item = new()
{
configType = EConfigType.Trojan
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
GetStdTransport(item, null, ref dicQuery);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
return url;
}
}
}

View File

@@ -0,0 +1,68 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class TuicFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem item = new()
{
configType = EConfigType.Tuic
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
var userInfoParts = url.UserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2)
{
item.id = userInfoParts[0];
item.security = userInfoParts[1];
}
var query = Utils.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.headerType = query["congestion_control"] ?? "";
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utils.UrlEncode(item.alpn));
}
dicQuery.Add("congestion_control", item.headerType);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
$"{item.id}:{item.security}",
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
return url;
}
}
}

View File

@@ -0,0 +1,59 @@
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{
internal class V2rayFmt : BaseFmt
{
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
{
var configObjects = JsonUtils.Deserialize<Object[]>(strData);
if (configObjects != null && configObjects.Length > 0)
{
List<ProfileItem> lstResult = [];
foreach (var configObject in configObjects)
{
var objectString = JsonUtils.Serialize(configObject);
var v2rayCon = JsonUtils.Deserialize<V2rayConfig>(objectString);
if (v2rayCon?.inbounds?.Count > 0
&& v2rayCon.outbounds?.Count > 0
&& v2rayCon.routing != null)
{
var fileName = WriteAllText(objectString);
var profileIt = new ProfileItem
{
coreType = ECoreType.Xray,
address = fileName,
remarks = v2rayCon.remarks ?? subRemarks ?? "v2ray_custom",
};
lstResult.Add(profileIt);
}
}
return lstResult;
}
return null;
}
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(strData);
if (v2rayConfig?.inbounds?.Count > 0
&& v2rayConfig.outbounds?.Count > 0
&& v2rayConfig.routing != null)
{
var fileName = WriteAllText(strData);
var profileItem = new ProfileItem
{
coreType = ECoreType.Xray,
address = fileName,
remarks = v2rayConfig.remarks ?? subRemarks ?? "v2ray_custom"
};
return profileItem;
}
return null;
}
}
}

View File

@@ -0,0 +1,64 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class VLESSFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem item = new()
{
configType = EConfigType.VLESS,
security = Global.None
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query);
item.security = query["encryption"] ?? Global.None;
item.streamSecurity = query["security"] ?? "";
ResolveStdTransport(query, ref item);
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.security))
{
dicQuery.Add("encryption", item.security);
}
else
{
dicQuery.Add("encryption", Global.None);
}
GetStdTransport(item, Global.None, ref dicQuery);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
return url;
}
}
}

View File

@@ -0,0 +1,126 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class VmessFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem? item;
if (str.IndexOf('?') > 0 && str.IndexOf('&') > 0)
{
item = ResolveStdVmess(str);
}
else
{
item = ResolveVmess(str, out msg);
}
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
VmessQRCode vmessQRCode = new()
{
v = item.configVersion,
ps = item.remarks.TrimEx(),
add = item.address,
port = item.port,
id = item.id,
aid = item.alterId,
scy = item.security,
net = item.network,
type = item.headerType,
host = item.requestHost,
path = item.path,
tls = item.streamSecurity,
sni = item.sni,
alpn = item.alpn,
fp = item.fingerprint
};
url = JsonUtils.Serialize(vmessQRCode);
url = Utils.Base64Encode(url);
url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}";
return url;
}
private static ProfileItem? ResolveVmess(string result, out string msg)
{
msg = string.Empty;
var item = new ProfileItem
{
configType = EConfigType.VMess
};
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
result = Utils.Base64Decode(result);
//转成Json
VmessQRCode? vmessQRCode = JsonUtils.Deserialize<VmessQRCode>(result);
if (vmessQRCode == null)
{
msg = ResUI.FailedConversionConfiguration;
return null;
}
item.network = Global.DefaultNetwork;
item.headerType = Global.None;
item.configVersion = Utils.ToInt(vmessQRCode.v);
item.remarks = Utils.ToString(vmessQRCode.ps);
item.address = Utils.ToString(vmessQRCode.add);
item.port = Utils.ToInt(vmessQRCode.port);
item.id = Utils.ToString(vmessQRCode.id);
item.alterId = Utils.ToInt(vmessQRCode.aid);
item.security = Utils.ToString(vmessQRCode.scy);
item.security = !Utils.IsNullOrEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity;
if (!Utils.IsNullOrEmpty(vmessQRCode.net))
{
item.network = vmessQRCode.net;
}
if (!Utils.IsNullOrEmpty(vmessQRCode.type))
{
item.headerType = vmessQRCode.type;
}
item.requestHost = Utils.ToString(vmessQRCode.host);
item.path = Utils.ToString(vmessQRCode.path);
item.streamSecurity = Utils.ToString(vmessQRCode.tls);
item.sni = Utils.ToString(vmessQRCode.sni);
item.alpn = Utils.ToString(vmessQRCode.alpn);
item.fingerprint = Utils.ToString(vmessQRCode.fp);
return item;
}
public static ProfileItem? ResolveStdVmess(string str)
{
ProfileItem item = new()
{
configType = EConfigType.VMess,
security = "auto"
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
return item;
}
}
}

View File

@@ -0,0 +1,73 @@
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{
internal class WireguardFmt : BaseFmt
{
public static ProfileItem? Resolve(string str, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem item = new()
{
configType = EConfigType.Wireguard
};
Uri url = new(str);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query);
item.publicKey = Utils.UrlDecode(query["publickey"] ?? "");
item.path = Utils.UrlDecode(query["reserved"] ?? "");
item.requestHost = Utils.UrlDecode(query["address"] ?? "");
item.shortId = Utils.UrlDecode(query["mtu"] ?? "");
return item;
}
public static string? ToUri(ProfileItem? item)
{
if (item == null) return null;
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.publicKey))
{
dicQuery.Add("publickey", Utils.UrlEncode(item.publicKey));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("reserved", Utils.UrlEncode(item.path));
}
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("address", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.shortId))
{
dicQuery.Add("mtu", Utils.UrlEncode(item.shortId));
}
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
Utils.UrlEncode(item.id),
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Wireguard]}{url}/{query}{remark}";
return url;
}
}
}

View File

@@ -4,7 +4,8 @@ using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop; using System.Windows.Interop;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler

View File

@@ -1,5 +1,6 @@
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@@ -12,20 +13,26 @@ namespace v2rayN.Handler
public static LazyConfig Instance => _instance.Value; public static LazyConfig Instance => _instance.Value;
private int? _statePort; private int? _statePort;
private int? _statePort2;
public int StatePort public int StatePort
{ {
get get
{ {
if (_statePort is null) _statePort ??= Utils.GetFreePort(GetLocalPort(EInboundProtocol.api));
{
_statePort = Utile.GetFreePort(GetLocalPort(EInboundProtocol.api));
}
return _statePort.Value; return _statePort.Value;
} }
} }
public int StatePort2
{
get
{
_statePort2 ??= Utils.GetFreePort(GetLocalPort(EInboundProtocol.api2));
return _statePort2.Value;
}
}
private Job _processJob = new(); private Job _processJob = new();
public LazyConfig() public LazyConfig()
@@ -77,7 +84,7 @@ namespace v2rayN.Handler
public List<ProfileItem> ProfileItems(string subid) public List<ProfileItem> ProfileItems(string subid)
{ {
if (Utile.IsNullOrEmpty(subid)) if (Utils.IsNullOrEmpty(subid))
{ {
return SQLiteHelper.Instance.Table<ProfileItem>().ToList(); return SQLiteHelper.Instance.Table<ProfileItem>().ToList();
} }
@@ -89,7 +96,7 @@ namespace v2rayN.Handler
public List<string> ProfileItemIndexes(string subid) public List<string> ProfileItemIndexes(string subid)
{ {
if (Utile.IsNullOrEmpty(subid)) if (Utils.IsNullOrEmpty(subid))
{ {
return SQLiteHelper.Instance.Table<ProfileItem>().Select(t => t.indexId).ToList(); return SQLiteHelper.Instance.Table<ProfileItem>().Select(t => t.indexId).ToList();
} }
@@ -106,11 +113,11 @@ namespace v2rayN.Handler
from ProfileItem a from ProfileItem a
left join SubItem b on a.subid = b.id left join SubItem b on a.subid = b.id
where 1=1 "; where 1=1 ";
if (!Utile.IsNullOrEmpty(subid)) if (!Utils.IsNullOrEmpty(subid))
{ {
sql += $" and a.subid = '{subid}'"; sql += $" and a.subid = '{subid}'";
} }
if (!Utile.IsNullOrEmpty(filter)) if (!Utils.IsNullOrEmpty(filter))
{ {
if (filter.Contains('\'')) if (filter.Contains('\''))
{ {
@@ -124,7 +131,7 @@ namespace v2rayN.Handler
public ProfileItem? GetProfileItem(string indexId) public ProfileItem? GetProfileItem(string indexId)
{ {
if (Utile.IsNullOrEmpty(indexId)) if (Utils.IsNullOrEmpty(indexId))
{ {
return null; return null;
} }
@@ -133,7 +140,7 @@ namespace v2rayN.Handler
public ProfileItem? GetProfileItemViaRemarks(string remarks) public ProfileItem? GetProfileItemViaRemarks(string remarks)
{ {
if (Utile.IsNullOrEmpty(remarks)) if (Utils.IsNullOrEmpty(remarks))
{ {
return null; return null;
} }
@@ -206,7 +213,7 @@ namespace v2rayN.Handler
{ {
InitCoreInfo(); InitCoreInfo();
} }
return coreInfo!.FirstOrDefault(t => t.coreType == coreType); return coreInfo?.FirstOrDefault(t => t.coreType == coreType);
} }
public List<CoreInfo> GetCoreInfo() public List<CoreInfo> GetCoreInfo()
@@ -329,7 +336,11 @@ namespace v2rayN.Handler
arguments = "-f config.json", arguments = "-f config.json",
coreUrl = Global.MihomoCoreUrl, coreUrl = Global.MihomoCoreUrl,
coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-386-{0}.zip",
coreDownloadUrl64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-amd64-compatible-{0}.zip",
coreDownloadUrlArm64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-arm64-{0}.zip",
match = "Mihomo", match = "Mihomo",
versionArg = "-v",
redirectInfo = true, redirectInfo = true,
}); });

View File

@@ -2,8 +2,13 @@
using Splat; using Splat;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -17,7 +22,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
int index = (int)config.sysProxyType; int index = (int)config.systemProxyItem.sysProxyType;
//Load from routing setting //Load from routing setting
var createdIcon = GetNotifyIcon4Routing(config); var createdIcon = GetNotifyIcon4Routing(config);
@@ -27,7 +32,7 @@ namespace v2rayN.Handler
} }
//Load from local file //Load from local file
var fileName = Utile.GetPath($"NotifyIcon{index + 1}.ico"); var fileName = Utils.GetPath($"NotifyIcon{index + 1}.ico");
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
return new Icon(fileName); return new Icon(fileName);
@@ -51,7 +56,7 @@ namespace v2rayN.Handler
public System.Windows.Media.ImageSource GetAppIcon(Config config) public System.Windows.Media.ImageSource GetAppIcon(Config config)
{ {
int index = 1; int index = 1;
switch (config.sysProxyType) switch (config.systemProxyItem.sysProxyType)
{ {
case ESysProxyType.ForcedClear: case ESysProxyType.ForcedClear:
index = 1; index = 1;
@@ -79,13 +84,13 @@ namespace v2rayN.Handler
} }
var item = ConfigHandler.GetDefaultRouting(config); var item = ConfigHandler.GetDefaultRouting(config);
if (item == null || Utile.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon)) if (item == null || Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon))
{ {
return null; return null;
} }
Color color = ColorTranslator.FromHtml("#3399CC"); Color color = ColorTranslator.FromHtml("#3399CC");
int index = (int)config.sysProxyType; int index = (int)config.systemProxyItem.sysProxyType;
if (index > 0) if (index > 0)
{ {
color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1]; color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1];
@@ -124,11 +129,6 @@ namespace v2rayN.Handler
{ {
return; return;
} }
if (item.configType == EConfigType.Custom)
{
Locator.Current.GetService<NoticeHandler>()?.Enqueue(ResUI.NonVmessService);
return;
}
SaveFileDialog fileDialog = new() SaveFileDialog fileDialog = new()
{ {
@@ -141,7 +141,7 @@ namespace v2rayN.Handler
return; return;
} }
string fileName = fileDialog.FileName; string fileName = fileDialog.FileName;
if (Utile.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
return; return;
} }
@@ -226,5 +226,27 @@ namespace v2rayN.Handler
HotkeyHandler.Instance.HotkeyTriggerEvent += handler; HotkeyHandler.Instance.HotkeyTriggerEvent += handler;
HotkeyHandler.Instance.Load(); HotkeyHandler.Instance.Load();
} }
public void RegisterSystemColorSet(Config config, Window window, Action<bool> update)
{
var helper = new WindowInteropHelper(window);
var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());
hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
{
if (config.uiItem.followSystemTheme)
{
const int WM_SETTINGCHANGE = 0x001A;
if (msg == WM_SETTINGCHANGE)
{
if (wParam == IntPtr.Zero && Marshal.PtrToStringUni(lParam) == "ImmersiveColorSet")
{
update(!Utils.IsLightTheme());
}
}
}
return IntPtr.Zero;
});
}
} }
} }

View File

@@ -12,7 +12,7 @@ namespace v2rayN.Handler
_snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue)); _snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue));
} }
public void Enqueue(string content) public void Enqueue(string? content)
{ {
if (content.IsNullOrEmpty()) if (content.IsNullOrEmpty())
{ {
@@ -21,18 +21,26 @@ namespace v2rayN.Handler
_snackbarMessageQueue?.Enqueue(content); _snackbarMessageQueue?.Enqueue(content);
} }
public void SendMessage(string msg) public void SendMessage(string? content)
{ {
MessageBus.Current.SendMessage(msg, Global.CommandSendMsgView); if (content.IsNullOrEmpty())
{
return;
}
MessageBus.Current.SendMessage(content, Global.CommandSendMsgView);
} }
public void SendMessage(string msg, bool time) public void SendMessage(string? content, bool time)
{ {
msg = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {msg}"; if (content.IsNullOrEmpty())
SendMessage(msg); {
return;
}
content = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {content}";
SendMessage(content);
} }
public void SendMessageAndEnqueue(string msg) public void SendMessageAndEnqueue(string? msg)
{ {
Enqueue(msg); Enqueue(msg);
SendMessage(msg); SendMessage(msg);

View File

@@ -1,13 +1,13 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Reactive.Linq; using System.Reactive.Linq;
using v2rayN.Model; using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
internal class ProfileExHandler internal class ProfileExHandler
{ {
private static readonly Lazy<ProfileExHandler> _instance = new(() => new()); private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
private ConcurrentBag<ProfileExItem> _lstProfileEx; private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
private Queue<string> _queIndexIds = new(); private Queue<string> _queIndexIds = new();
public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx; public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx;
public static ProfileExHandler Instance => _instance.Value; public static ProfileExHandler Instance => _instance.Value;
@@ -15,6 +15,15 @@ namespace v2rayN.Handler
public ProfileExHandler() public ProfileExHandler()
{ {
Init(); Init();
Task.Run(async () =>
{
while (true)
{
SaveQueueIndexIds();
await Task.Delay(1000 * 600);
}
});
} }
private void Init() private void Init()
@@ -22,34 +31,59 @@ namespace v2rayN.Handler
SQLiteHelper.Instance.Execute($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )"); SQLiteHelper.Instance.Execute($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
_lstProfileEx = new(SQLiteHelper.Instance.Table<ProfileExItem>()); _lstProfileEx = new(SQLiteHelper.Instance.Table<ProfileExItem>());
Task.Run(async () =>
{
while (true)
{
var cnt = _queIndexIds.Count;
for (int i = 0; i < cnt; i++)
{
var id = _queIndexIds.Dequeue();
var item = _lstProfileEx.FirstOrDefault(t => t.indexId == id);
if (item is not null)
{
SQLiteHelper.Instance.Replace(item);
}
}
await Task.Delay(1000 * 60);
}
});
} }
private void IndexIdEnqueue(string indexId) private void IndexIdEnqueue(string indexId)
{ {
if (!Utile.IsNullOrEmpty(indexId) && !_queIndexIds.Contains(indexId)) if (!Utils.IsNullOrEmpty(indexId) && !_queIndexIds.Contains(indexId))
{ {
_queIndexIds.Enqueue(indexId); _queIndexIds.Enqueue(indexId);
} }
} }
private void SaveQueueIndexIds()
{
var cnt = _queIndexIds.Count;
if (cnt > 0)
{
var lstExists = SQLiteHelper.Instance.Table<ProfileExItem>();
List<ProfileExItem> lstInserts = [];
List<ProfileExItem> lstUpdates = [];
for (int i = 0; i < cnt; i++)
{
var id = _queIndexIds.Dequeue();
var item = lstExists.FirstOrDefault(t => t.indexId == id);
var itemNew = _lstProfileEx?.FirstOrDefault(t => t.indexId == id);
if (itemNew is null)
{
continue;
}
if (item is not null)
{
lstUpdates.Add(itemNew);
}
else
{
lstInserts.Add(itemNew);
}
}
try
{
if (lstInserts.Count() > 0)
SQLiteHelper.Instance.InsertAll(lstInserts);
if (lstUpdates.Count() > 0)
SQLiteHelper.Instance.UpdateAll(lstUpdates);
}
catch (Exception ex)
{
Logging.SaveLog("ProfileExHandler", ex);
}
}
}
private void AddProfileEx(string indexId, ref ProfileExItem? profileEx) private void AddProfileEx(string indexId, ref ProfileExItem? profileEx)
{ {
profileEx = new() profileEx = new()
@@ -73,11 +107,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
//foreach (var item in _lstProfileEx) SaveQueueIndexIds();
//{
// SQLiteHelper.Instance.Replace(item);
//}
SQLiteHelper.Instance.UpdateAll(_lstProfileEx);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -1,996 +0,0 @@
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using v2rayN.Model;
using v2rayN.Resx;
namespace v2rayN.Handler
{
internal class ShareHandler
{
#region GetShareUrl
/// <summary>
/// GetShareUrl
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public static string? GetShareUrl(ProfileItem item)
{
try
{
string? url = string.Empty;
url = item.configType switch
{
EConfigType.VMess => ShareVmess(item),
EConfigType.Shadowsocks => ShareShadowsocks(item),
EConfigType.Socks => ShareSocks(item),
EConfigType.Trojan => ShareTrojan(item),
EConfigType.VLESS => ShareVLESS(item),
EConfigType.Hysteria2 => ShareHysteria2(item),
EConfigType.Tuic => ShareTuic(item),
EConfigType.Wireguard => ShareWireguard(item),
_ => null,
};
return url;
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
return "";
}
}
private static string ShareVmess(ProfileItem item)
{
string url = string.Empty;
VmessQRCode vmessQRCode = new()
{
v = item.configVersion,
ps = item.remarks.TrimEx(),
add = item.address,
port = item.port,
id = item.id,
aid = item.alterId,
scy = item.security,
net = item.network,
type = item.headerType,
host = item.requestHost,
path = item.path,
tls = item.streamSecurity,
sni = item.sni,
alpn = item.alpn,
fp = item.fingerprint
};
url = JsonUtile.Serialize(vmessQRCode);
url = Utile.Base64Encode(url);
url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}";
return url;
}
private static string ShareShadowsocks(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
//url = string.Format("{0}:{1}@{2}:{3}",
// item.security,
// item.id,
// item.address,
// item.port);
//url = Utile.Base64Encode(url);
//new Sip002
var pw = Utile.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
return url;
}
private static string ShareSocks(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
//url = string.Format("{0}:{1}@{2}:{3}",
// item.security,
// item.id,
// item.address,
// item.port);
//url = Utile.Base64Encode(url);
//new
var pw = Utile.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
return url;
}
private static string ShareTrojan(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
GetStdTransport(item, null, ref dicQuery);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
return url;
}
private static string ShareVLESS(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utile.IsNullOrEmpty(item.security))
{
dicQuery.Add("encryption", item.security);
}
else
{
dicQuery.Add("encryption", Global.None);
}
GetStdTransport(item, Global.None, ref dicQuery);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
return url;
}
private static string ShareHysteria2(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utile.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utile.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utile.UrlEncode(item.alpn));
}
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("obfs", "salamander");
dicQuery.Add("obfs-password", Utile.UrlEncode(item.path));
}
dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0");
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}/{query}{remark}";
return url;
}
private static string ShareTuic(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utile.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utile.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utile.UrlEncode(item.alpn));
}
dicQuery.Add("congestion_control", item.headerType);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
$"{item.id}:{item.security}",
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
return url;
}
private static string ShareWireguard(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utile.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utile.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utile.IsNullOrEmpty(item.publicKey))
{
dicQuery.Add("publickey", Utile.UrlEncode(item.publicKey));
}
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("reserved", Utile.UrlEncode(item.path));
}
if (!Utile.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("address", Utile.UrlEncode(item.requestHost));
}
if (!Utile.IsNullOrEmpty(item.shortId))
{
dicQuery.Add("mtu", Utile.UrlEncode(item.shortId));
}
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
Utile.UrlEncode(item.id),
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Wireguard]}{url}/{query}{remark}";
return url;
}
private static string GetIpv6(string address)
{
return Utile.IsIpv6(address) ? $"[{address}]" : address;
}
private static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
{
if (!Utile.IsNullOrEmpty(item.flow))
{
dicQuery.Add("flow", item.flow);
}
if (!Utile.IsNullOrEmpty(item.streamSecurity))
{
dicQuery.Add("security", item.streamSecurity);
}
else
{
if (securityDef != null)
{
dicQuery.Add("security", securityDef);
}
}
if (!Utile.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utile.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utile.UrlEncode(item.alpn));
}
if (!Utile.IsNullOrEmpty(item.fingerprint))
{
dicQuery.Add("fp", Utile.UrlEncode(item.fingerprint));
}
if (!Utile.IsNullOrEmpty(item.publicKey))
{
dicQuery.Add("pbk", Utile.UrlEncode(item.publicKey));
}
if (!Utile.IsNullOrEmpty(item.shortId))
{
dicQuery.Add("sid", Utile.UrlEncode(item.shortId));
}
if (!Utile.IsNullOrEmpty(item.spiderX))
{
dicQuery.Add("spx", Utile.UrlEncode(item.spiderX));
}
dicQuery.Add("type", !Utile.IsNullOrEmpty(item.network) ? item.network : nameof(ETransport.tcp));
switch (item.network)
{
case nameof(ETransport.tcp):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utile.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
}
break;
case nameof(ETransport.kcp):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("seed", Utile.UrlEncode(item.path));
}
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
if (!Utile.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
}
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utile.UrlEncode(item.path));
}
break;
case nameof(ETransport.http):
case nameof(ETransport.h2):
dicQuery["type"] = nameof(ETransport.http);
if (!Utile.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
}
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utile.UrlEncode(item.path));
}
break;
case nameof(ETransport.quic):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
dicQuery.Add("quicSecurity", Utile.UrlEncode(item.requestHost));
dicQuery.Add("key", Utile.UrlEncode(item.path));
break;
case nameof(ETransport.grpc):
if (!Utile.IsNullOrEmpty(item.path))
{
dicQuery.Add("serviceName", Utile.UrlEncode(item.path));
if (item.headerType is Global.GrpcGunMode or Global.GrpcMultiMode)
{
dicQuery.Add("mode", Utile.UrlEncode(item.headerType));
}
}
break;
}
return 0;
}
#endregion GetShareUrl
#region ImportShareUrl
/// <summary>
/// 从剪贴板导入URL
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public static ProfileItem? ImportFromClipboardConfig(string clipboardData, out string msg)
{
msg = ResUI.ConfigurationFormatIncorrect;
ProfileItem? profileItem;
try
{
string result = clipboardData.TrimEx();
if (Utile.IsNullOrEmpty(result))
{
msg = ResUI.FailedReadConfiguration;
return null;
}
if (result.StartsWith(Global.ProtocolShares[EConfigType.VMess]))
{
int indexSplit = result.IndexOf("?");
if (indexSplit > 0)
{
profileItem = ResolveStdVmess(result) ?? ResolveVmess4Kitsunebi(result);
}
else
{
profileItem = ResolveVmess(result, out msg);
}
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Shadowsocks]))
{
profileItem = ResolveSSLegacy(result) ?? ResolveSip002(result);
if (profileItem == null)
{
return null;
}
if (profileItem.address.Length == 0 || profileItem.port == 0 || profileItem.security.Length == 0 || profileItem.id.Length == 0)
{
return null;
}
profileItem.configType = EConfigType.Shadowsocks;
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
{
profileItem = ResolveSocksNew(result) ?? ResolveSocks(result);
if (profileItem == null)
{
return null;
}
if (profileItem.address.Length == 0 || profileItem.port == 0)
{
return null;
}
profileItem.configType = EConfigType.Socks;
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Trojan]))
{
profileItem = ResolveTrojan(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.VLESS]))
{
profileItem = ResolveStdVLESS(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || result.StartsWith(Global.Hysteria2ProtocolShare))
{
profileItem = ResolveHysteria2(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
{
profileItem = ResolveTuic(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Wireguard]))
{
profileItem = ResolveWireguard(result);
}
else
{
msg = ResUI.NonvmessOrssProtocol;
return null;
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
msg = ResUI.Incorrectconfiguration;
return null;
}
return profileItem;
}
private static ProfileItem? ResolveVmess(string result, out string msg)
{
msg = string.Empty;
var profileItem = new ProfileItem
{
configType = EConfigType.VMess
};
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
result = Utile.Base64Decode(result);
//转成Json
VmessQRCode? vmessQRCode = JsonUtile.Deserialize<VmessQRCode>(result);
if (vmessQRCode == null)
{
msg = ResUI.FailedConversionConfiguration;
return null;
}
profileItem.network = Global.DefaultNetwork;
profileItem.headerType = Global.None;
profileItem.configVersion = Utile.ToInt(vmessQRCode.v);
profileItem.remarks = Utile.ToString(vmessQRCode.ps);
profileItem.address = Utile.ToString(vmessQRCode.add);
profileItem.port = Utile.ToInt(vmessQRCode.port);
profileItem.id = Utile.ToString(vmessQRCode.id);
profileItem.alterId = Utile.ToInt(vmessQRCode.aid);
profileItem.security = Utile.ToString(vmessQRCode.scy);
profileItem.security = !Utile.IsNullOrEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity;
if (!Utile.IsNullOrEmpty(vmessQRCode.net))
{
profileItem.network = vmessQRCode.net;
}
if (!Utile.IsNullOrEmpty(vmessQRCode.type))
{
profileItem.headerType = vmessQRCode.type;
}
profileItem.requestHost = Utile.ToString(vmessQRCode.host);
profileItem.path = Utile.ToString(vmessQRCode.path);
profileItem.streamSecurity = Utile.ToString(vmessQRCode.tls);
profileItem.sni = Utile.ToString(vmessQRCode.sni);
profileItem.alpn = Utile.ToString(vmessQRCode.alpn);
profileItem.fingerprint = Utile.ToString(vmessQRCode.fp);
return profileItem;
}
private static ProfileItem? ResolveVmess4Kitsunebi(string result)
{
ProfileItem profileItem = new()
{
configType = EConfigType.VMess
};
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
int indexSplit = result.IndexOf("?");
if (indexSplit > 0)
{
result = result[..indexSplit];
}
result = Utile.Base64Decode(result);
string[] arr1 = result.Split('@');
if (arr1.Length != 2)
{
return null;
}
string[] arr21 = arr1[0].Split(':');
string[] arr22 = arr1[1].Split(':');
if (arr21.Length != 2 || arr22.Length != 2)
{
return null;
}
profileItem.address = arr22[0];
profileItem.port = Utile.ToInt(arr22[1]);
profileItem.security = arr21[0];
profileItem.id = arr21[1];
profileItem.network = Global.DefaultNetwork;
profileItem.headerType = Global.None;
profileItem.remarks = "Alien";
return profileItem;
}
private static ProfileItem? ResolveStdVmess(string result)
{
ProfileItem i = new()
{
configType = EConfigType.VMess,
security = "auto"
};
Uri u = new(result);
i.address = u.IdnHost;
i.port = u.Port;
i.remarks = u.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
var query = Utile.ParseQueryString(u.Query);
var m = StdVmessUserInfo.Match(u.UserInfo);
if (!m.Success) return null;
i.id = m.Groups["id"].Value;
if (m.Groups["streamSecurity"].Success)
{
i.streamSecurity = m.Groups["streamSecurity"].Value;
}
switch (i.streamSecurity)
{
case Global.StreamSecurity:
break;
default:
if (!string.IsNullOrWhiteSpace(i.streamSecurity))
return null;
break;
}
i.network = m.Groups["network"].Value;
switch (i.network)
{
case nameof(ETransport.tcp):
string t1 = query["type"] ?? Global.None;
i.headerType = t1;
break;
case nameof(ETransport.kcp):
i.headerType = query["type"] ?? Global.None;
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
string p1 = query["path"] ?? "/";
string h1 = query["host"] ?? "";
i.requestHost = Utile.UrlDecode(h1);
i.path = p1;
break;
case nameof(ETransport.http):
case nameof(ETransport.h2):
i.network = nameof(ETransport.h2);
string p2 = query["path"] ?? "/";
string h2 = query["host"] ?? "";
i.requestHost = Utile.UrlDecode(h2);
i.path = p2;
break;
case nameof(ETransport.quic):
string s = query["security"] ?? Global.None;
string k = query["key"] ?? "";
string t3 = query["type"] ?? Global.None;
i.headerType = t3;
i.requestHost = Utile.UrlDecode(s);
i.path = k;
break;
default:
return null;
}
return i;
}
private static ProfileItem? ResolveSip002(string result)
{
Uri parsedUrl;
try
{
parsedUrl = new Uri(result);
}
catch (UriFormatException)
{
return null;
}
ProfileItem server = new()
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
address = parsedUrl.IdnHost,
port = parsedUrl.Port,
};
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.UriEscaped);
//2022-blake3
if (rawUserInfo.Contains(':'))
{
string[] userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length != 2)
{
return null;
}
server.security = userInfoParts[0];
server.id = Utile.UrlDecode(userInfoParts[1]);
}
else
{
// parse base64 UserInfo
string userInfo = Utile.Base64Decode(rawUserInfo);
string[] userInfoParts = userInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length != 2)
{
return null;
}
server.security = userInfoParts[0];
server.id = userInfoParts[1];
}
var queryParameters = Utile.ParseQueryString(parsedUrl.Query);
if (queryParameters["plugin"] != null)
{
//obfs-host exists
var obfsHost = queryParameters["plugin"]?.Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
if (queryParameters["plugin"].Contains("obfs=http") && !Utile.IsNullOrEmpty(obfsHost))
{
obfsHost = obfsHost?.Replace("obfs-host=", "");
server.network = Global.DefaultNetwork;
server.headerType = Global.TcpHeaderHttp;
server.requestHost = obfsHost ?? "";
}
else
{
return null;
}
}
return server;
}
private static readonly Regex UrlFinder = new(@"ss://(?<base64>[A-Za-z0-9+-/=_]+)(?:#(?<tag>\S+))?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex DetailsParser = new(@"^((?<method>.+?):(?<password>.*)@(?<hostname>.+?):(?<port>\d+?))$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static ProfileItem? ResolveSSLegacy(string result)
{
var match = UrlFinder.Match(result);
if (!match.Success)
return null;
ProfileItem server = new();
var base64 = match.Groups["base64"].Value.TrimEnd('/');
var tag = match.Groups["tag"].Value;
if (!Utile.IsNullOrEmpty(tag))
{
server.remarks = Utile.UrlDecode(tag);
}
Match details;
try
{
details = DetailsParser.Match(Utile.Base64Decode(base64));
}
catch (FormatException)
{
return null;
}
if (!details.Success)
return null;
server.security = details.Groups["method"].Value;
server.id = details.Groups["password"].Value;
server.address = details.Groups["hostname"].Value;
server.port = Utile.ToInt(details.Groups["port"].Value);
return server;
}
private static readonly Regex StdVmessUserInfo = new(
@"^(?<network>[a-z]+)(\+(?<streamSecurity>[a-z]+))?:(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$", RegexOptions.Compiled);
private static ProfileItem? ResolveSocks(string result)
{
ProfileItem profileItem = new()
{
configType = EConfigType.Socks
};
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
//remark
int indexRemark = result.IndexOf("#");
if (indexRemark > 0)
{
try
{
profileItem.remarks = Utile.UrlDecode(result.Substring(indexRemark + 1, result.Length - indexRemark - 1));
}
catch { }
result = result[..indexRemark];
}
//part decode
int indexS = result.IndexOf("@");
if (indexS > 0)
{
}
else
{
result = Utile.Base64Decode(result);
}
string[] arr1 = result.Split('@');
if (arr1.Length != 2)
{
return null;
}
string[] arr21 = arr1[0].Split(':');
//string[] arr22 = arr1[1].Split(':');
int indexPort = arr1[1].LastIndexOf(":");
if (arr21.Length != 2 || indexPort < 0)
{
return null;
}
profileItem.address = arr1[1][..indexPort];
profileItem.port = Utile.ToInt(arr1[1][(indexPort + 1)..]);
profileItem.security = arr21[0];
profileItem.id = arr21[1];
return profileItem;
}
private static ProfileItem? ResolveSocksNew(string result)
{
Uri parsedUrl;
try
{
parsedUrl = new Uri(result);
}
catch (UriFormatException)
{
return null;
}
ProfileItem server = new()
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
address = parsedUrl.IdnHost,
port = parsedUrl.Port,
};
// parse base64 UserInfo
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
string userInfo = Utile.Base64Decode(rawUserInfo);
string[] userInfoParts = userInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2)
{
server.security = userInfoParts[0];
server.id = userInfoParts[1];
}
return server;
}
private static ProfileItem ResolveTrojan(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Trojan
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utile.UrlDecode(url.UserInfo);
var query = Utile.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
return item;
}
private static ProfileItem ResolveStdVLESS(string result)
{
ProfileItem item = new()
{
configType = EConfigType.VLESS,
security = Global.None
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utile.UrlDecode(url.UserInfo);
var query = Utile.ParseQueryString(url.Query);
item.security = query["encryption"] ?? Global.None;
item.streamSecurity = query["security"] ?? "";
ResolveStdTransport(query, ref item);
return item;
}
private static ProfileItem ResolveHysteria2(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Hysteria2
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utile.UrlDecode(url.UserInfo);
var query = Utile.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.path = Utile.UrlDecode(query["obfs-password"] ?? "");
item.allowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false";
return item;
}
private static ProfileItem ResolveTuic(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Tuic
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
var userInfoParts = url.UserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2)
{
item.id = userInfoParts[0];
item.security = userInfoParts[1];
}
var query = Utile.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.headerType = query["congestion_control"] ?? "";
return item;
}
private static ProfileItem ResolveWireguard(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Wireguard
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = Utile.UrlDecode(url.UserInfo);
var query = Utile.ParseQueryString(url.Query);
item.publicKey = Utile.UrlDecode(query["publickey"] ?? "");
item.path = Utile.UrlDecode(query["reserved"] ?? "");
item.requestHost = Utile.UrlDecode(query["address"] ?? "");
item.shortId = Utile.UrlDecode(query["mtu"] ?? "");
return item;
}
private static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item)
{
item.flow = query["flow"] ?? "";
item.streamSecurity = query["security"] ?? "";
item.sni = query["sni"] ?? "";
item.alpn = Utile.UrlDecode(query["alpn"] ?? "");
item.fingerprint = Utile.UrlDecode(query["fp"] ?? "");
item.publicKey = Utile.UrlDecode(query["pbk"] ?? "");
item.shortId = Utile.UrlDecode(query["sid"] ?? "");
item.spiderX = Utile.UrlDecode(query["spx"] ?? "");
item.network = query["type"] ?? nameof(ETransport.tcp);
switch (item.network)
{
case nameof(ETransport.tcp):
item.headerType = query["headerType"] ?? Global.None;
item.requestHost = Utile.UrlDecode(query["host"] ?? "");
break;
case nameof(ETransport.kcp):
item.headerType = query["headerType"] ?? Global.None;
item.path = Utile.UrlDecode(query["seed"] ?? "");
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
item.requestHost = Utile.UrlDecode(query["host"] ?? "");
item.path = Utile.UrlDecode(query["path"] ?? "/");
break;
case nameof(ETransport.http):
case nameof(ETransport.h2):
item.network = nameof(ETransport.h2);
item.requestHost = Utile.UrlDecode(query["host"] ?? "");
item.path = Utile.UrlDecode(query["path"] ?? "/");
break;
case nameof(ETransport.quic):
item.headerType = query["headerType"] ?? Global.None;
item.requestHost = query["quicSecurity"] ?? Global.None;
item.path = Utile.UrlDecode(query["key"] ?? "");
break;
case nameof(ETransport.grpc):
item.path = Utile.UrlDecode(query["serviceName"] ?? "");
item.headerType = Utile.UrlDecode(query["mode"] ?? Global.GrpcGunMode);
break;
default:
break;
}
return 0;
}
#endregion ImportShareUrl
}
}

View File

@@ -2,7 +2,8 @@
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -376,19 +377,18 @@ namespace v2rayN.Handler
ipAddress = ipHostInfo.AddressList[0]; ipAddress = ipHostInfo.AddressList[0];
} }
Stopwatch timer = new(); var timer = Stopwatch.StartNew();
timer.Start();
IPEndPoint endPoint = new(ipAddress, port); IPEndPoint endPoint = new(ipAddress, port);
using Socket clientSocket = new(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); using Socket clientSocket = new(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null); var result = clientSocket.BeginConnect(endPoint, null, null);
if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5))) if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5)))
throw new TimeoutException("connect timeout (5s): " + url); throw new TimeoutException("connect timeout (5s): " + url);
clientSocket.EndConnect(result); clientSocket.EndConnect(result);
timer.Stop(); timer.Stop();
responseTime = timer.Elapsed.Milliseconds; responseTime = (int)timer.Elapsed.TotalMilliseconds;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -1,9 +1,12 @@
using v2rayN.Model; using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler.Statistics
{ {
internal class StatisticsHandler internal class StatisticsHandler
{ {
private static readonly Lazy<StatisticsHandler> instance = new(() => new());
public static StatisticsHandler Instance => instance.Value;
private Config _config; private Config _config;
private ServerStatItem? _serverStatItem; private ServerStatItem? _serverStatItem;
private List<ServerStatItem> _lstServerStat; private List<ServerStatItem> _lstServerStat;
@@ -12,20 +15,17 @@ namespace v2rayN.Handler
private StatisticsSingbox? _statisticsSingbox; private StatisticsSingbox? _statisticsSingbox;
public List<ServerStatItem> ServerStat => _lstServerStat; public List<ServerStatItem> ServerStat => _lstServerStat;
public bool Enable { get; set; }
public StatisticsHandler(Config config, Action<ServerSpeedItem> update) public void Init(Config config, Action<ServerSpeedItem> update)
{ {
_config = config; _config = config;
Enable = config.guiItem.enableStatistics; _updateFunc = update;
if (!Enable) if (!config.guiItem.enableStatistics)
{ {
return; return;
} }
_updateFunc = update; InitData();
Init();
_statisticsV2Ray = new StatisticsV2ray(config, UpdateServerStat); _statisticsV2Ray = new StatisticsV2ray(config, UpdateServerStat);
_statisticsSingbox = new StatisticsSingbox(config, UpdateServerStat); _statisticsSingbox = new StatisticsSingbox(config, UpdateServerStat);
@@ -55,7 +55,10 @@ namespace v2rayN.Handler
{ {
try try
{ {
SQLiteHelper.Instance.UpdateAll(_lstServerStat); if (_lstServerStat != null)
{
SQLiteHelper.Instance.UpdateAll(_lstServerStat);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -63,7 +66,7 @@ namespace v2rayN.Handler
} }
} }
private void Init() private void InitData()
{ {
SQLiteHelper.Instance.Execute($"delete from ServerStatItem where indexId not in ( select indexId from ProfileItem )"); SQLiteHelper.Instance.Execute($"delete from ServerStatItem where indexId not in ( select indexId from ProfileItem )");

View File

@@ -1,8 +1,9 @@
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Text; using System.Text;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler.Statistics
{ {
internal class StatisticsSingbox internal class StatisticsSingbox
{ {
@@ -27,7 +28,7 @@ namespace v2rayN.Handler
try try
{ {
url = $"ws://{Global.Loopback}:{LazyConfig.Instance.StatePort}/traffic"; url = $"ws://{Global.Loopback}:{LazyConfig.Instance.StatePort2}/traffic";
if (webSocket == null) if (webSocket == null)
{ {
@@ -61,8 +62,13 @@ namespace v2rayN.Handler
while (!_exitFlag) while (!_exitFlag)
{ {
await Task.Delay(1000);
try try
{ {
if (!(_config.IsRunningCore(ECoreType.clash)))
{
continue;
}
if (webSocket != null) if (webSocket != null)
{ {
if (webSocket.State == WebSocketState.Aborted if (webSocket.State == WebSocketState.Aborted
@@ -84,7 +90,7 @@ namespace v2rayN.Handler
while (!res.CloseStatus.HasValue) while (!res.CloseStatus.HasValue)
{ {
var result = Encoding.UTF8.GetString(buffer, 0, res.Count); var result = Encoding.UTF8.GetString(buffer, 0, res.Count);
if (!string.IsNullOrEmpty(result)) if (!Utils.IsNullOrEmpty(result))
{ {
ParseOutput(result, out ulong up, out ulong down); ParseOutput(result, out ulong up, out ulong down);
@@ -101,10 +107,6 @@ namespace v2rayN.Handler
catch catch
{ {
} }
finally
{
await Task.Delay(1000);
}
} }
} }
@@ -113,7 +115,7 @@ namespace v2rayN.Handler
up = 0; down = 0; up = 0; down = 0;
try try
{ {
var trafficItem = JsonUtile.Deserialize<TrafficItem>(source); var trafficItem = JsonUtils.Deserialize<TrafficItem>(source);
if (trafficItem != null) if (trafficItem != null)
{ {
up = trafficItem.up; up = trafficItem.up;

View File

@@ -1,19 +1,20 @@
using Grpc.Core; using Grpc.Core;
using Grpc.Net.Client; using Grpc.Net.Client;
using ProtosLib.Statistics; using ProtosLib.Statistics;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler.Statistics
{ {
internal class StatisticsV2ray internal class StatisticsV2ray
{ {
private Model.Config _config; private Models.Config _config;
private GrpcChannel? _channel; private GrpcChannel? _channel;
private StatsService.StatsServiceClient? _client; private StatsService.StatsServiceClient? _client;
private bool _exitFlag; private bool _exitFlag;
private Action<ServerSpeedItem> _updateFunc; private Action<ServerSpeedItem> _updateFunc;
public StatisticsV2ray(Model.Config config, Action<ServerSpeedItem> update) public StatisticsV2ray(Models.Config config, Action<ServerSpeedItem> update)
{ {
_config = config; _config = config;
_updateFunc = update; _updateFunc = update;
@@ -49,14 +50,20 @@ namespace v2rayN.Handler
{ {
while (!_exitFlag) while (!_exitFlag)
{ {
await Task.Delay(1000);
try try
{ {
if (!(_config.IsRunningCore(ECoreType.Xray)))
{
continue;
}
if (_channel?.State == ConnectivityState.Ready) if (_channel?.State == ConnectivityState.Ready)
{ {
QueryStatsResponse? res = null; QueryStatsResponse? res = null;
try try
{ {
res = await _client.QueryStatsAsync(new QueryStatsRequest() { Pattern = "", Reset = true }); if (_client != null)
res = await _client.QueryStatsAsync(new QueryStatsRequest() { Pattern = "", Reset = true });
} }
catch catch
{ {
@@ -68,8 +75,8 @@ namespace v2rayN.Handler
_updateFunc(server); _updateFunc(server);
} }
} }
await Task.Delay(1000); if (_channel != null)
if (_channel != null) await _channel.ConnectAsync(); await _channel.ConnectAsync();
} }
catch catch
{ {
@@ -80,6 +87,8 @@ namespace v2rayN.Handler
private void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ServerSpeedItem server) private void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ServerSpeedItem server)
{ {
server = new(); server = new();
long aggregateProxyUp = 0;
long aggregateProxyDown = 0;
try try
{ {
foreach (Stat stat in source) foreach (Stat stat in source)
@@ -94,15 +103,15 @@ namespace v2rayN.Handler
name = nStr[1]; name = nStr[1];
type = nStr[3]; type = nStr[3];
if (name == Global.ProxyTag) if (name.StartsWith(Global.ProxyTag))
{ {
if (type == "uplink") if (type == "uplink")
{ {
server.proxyUp = value; aggregateProxyUp += value;
} }
else if (type == "downlink") else if (type == "downlink")
{ {
server.proxyDown = value; aggregateProxyDown += value;
} }
} }
else if (name == Global.DirectTag) else if (name == Global.DirectTag)
@@ -117,6 +126,8 @@ namespace v2rayN.Handler
} }
} }
} }
server.proxyUp = aggregateProxyUp;
server.proxyDown = aggregateProxyDown;
} }
catch catch
{ {

View File

@@ -1,38 +1,17 @@
using PacLib; using PacLib;
using v2rayN.Model; using v2rayN.Common;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
public static class SysProxyHandle public static class SysProxyHandle
{ {
//private const string _userWininetConfigFile = "user-wininet.json"; private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
//private static string _queryStr;
// In general, this won't change
// format:
// <flags><CR-LF>
// <proxy-server><CR-LF>
// <bypass-list><CR-LF>
// <pac-url>
private enum RET_ERRORS : int
{
RET_NO_ERROR = 0,
INVALID_FORMAT = 1,
NO_PERMISSION = 2,
SYSCALL_FAILED = 3,
NO_MEMORY = 4,
INVAILD_OPTION_COUNT = 5,
};
static SysProxyHandle()
{
}
public static bool UpdateSysProxy(Config config, bool forceDisable) public static bool UpdateSysProxy(Config config, bool forceDisable)
{ {
var type = config.sysProxyType; var type = config.systemProxyItem.sysProxyType;
if (forceDisable && type != ESysProxyType.Unchanged) if (forceDisable && type != ESysProxyType.Unchanged)
{ {
@@ -50,34 +29,38 @@ namespace v2rayN.Handler
} }
if (type == ESysProxyType.ForcedChange) if (type == ESysProxyType.ForcedChange)
{ {
var strExceptions = $"<local>;{config.constItem.defIEProxyExceptions};{config.systemProxyExceptions}"; var strExceptions = "";
if (config.systemProxyItem.notProxyLocalAddress)
{
strExceptions = $"<local>;{config.constItem.defIEProxyExceptions};{config.systemProxyItem.systemProxyExceptions}";
}
var strProxy = string.Empty; var strProxy = string.Empty;
if (Utile.IsNullOrEmpty(config.systemProxyAdvancedProtocol)) if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol))
{ {
strProxy = $"{Global.Loopback}:{port}"; strProxy = $"{Global.Loopback}:{port}";
} }
else else
{ {
strProxy = config.systemProxyAdvancedProtocol strProxy = config.systemProxyItem.systemProxyAdvancedProtocol
.Replace("{ip}", Global.Loopback) .Replace("{ip}", Global.Loopback)
.Replace("{http_port}", port.ToString()) .Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString()); .Replace("{socks_port}", portSocks.ToString());
} }
ProxySetting.SetProxy(strProxy, strExceptions, 2); // set a named proxy ProxySetting.SetProxy(strProxy, strExceptions, 2);
} }
else if (type == ESysProxyType.ForcedClear) else if (type == ESysProxyType.ForcedClear)
{ {
ProxySetting.UnsetProxy(); // set to no proxy ProxySetting.UnsetProxy();
} }
else if (type == ESysProxyType.Unchanged) else if (type == ESysProxyType.Unchanged)
{ {
} }
else if (type == ESysProxyType.Pac) else if (type == ESysProxyType.Pac)
{ {
PacHandler.Start(Utile.GetConfigPath(), port, portPac); PacHandler.Start(Utils.GetConfigPath(), port, portPac);
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}"; var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
ProxySetting.SetProxy(strProxy, "", 4); // use pac script url for auto-config proxy ProxySetting.SetProxy(strProxy, "", 4);
} }
if (type != ESysProxyType.Pac) if (type != ESysProxyType.Pac)
@@ -94,14 +77,7 @@ namespace v2rayN.Handler
public static void ResetIEProxy4WindowsShutDown() public static void ResetIEProxy4WindowsShutDown()
{ {
try ProxySetting.UnsetProxy();
{
//TODO To be verified
Utile.RegWriteValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0);
}
catch
{
}
} }
} }
} }

View File

@@ -6,7 +6,8 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows; using System.Windows;
using v2rayN.Model; using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -47,15 +48,15 @@ namespace v2rayN.Handler
try try
{ {
string fileName = Utile.GetTempPath(Utile.GetDownloadFileName(url)); string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
fileName = Utile.UrlEncode(fileName); fileName = Utils.UrlEncode(fileName);
Process process = new() Process process = new()
{ {
StartInfo = new ProcessStartInfo StartInfo = new ProcessStartInfo
{ {
FileName = "v2rayUpgrade.exe", FileName = "v2rayUpgrade.exe",
Arguments = fileName.AppendQuotes(), Arguments = fileName.AppendQuotes(),
WorkingDirectory = Utile.StartupPath() WorkingDirectory = Utils.StartupPath()
} }
}; };
process.Start(); process.Start();
@@ -179,7 +180,7 @@ namespace v2rayN.Handler
string url = item.url.TrimEx(); string url = item.url.TrimEx();
string userAgent = item.userAgent.TrimEx(); string userAgent = item.userAgent.TrimEx();
string hashCode = $"{item.remarks}->"; string hashCode = $"{item.remarks}->";
if (Utile.IsNullOrEmpty(id) || Utile.IsNullOrEmpty(url) || (!Utile.IsNullOrEmpty(subId) && item.id != subId)) if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || (!Utils.IsNullOrEmpty(subId) && item.id != subId))
{ {
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}"); //_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
continue; continue;
@@ -203,12 +204,12 @@ namespace v2rayN.Handler
_updateFunc(false, $"{hashCode}{ResUI.MsgStartGettingSubscriptions}"); _updateFunc(false, $"{hashCode}{ResUI.MsgStartGettingSubscriptions}");
//one url //one url
url = Utile.GetPunycode(url); url = Utils.GetPunycode(url);
//convert //convert
if (!Utile.IsNullOrEmpty(item.convertTarget)) if (!Utils.IsNullOrEmpty(item.convertTarget))
{ {
var subConvertUrl = string.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl; var subConvertUrl = Utils.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl;
url = string.Format(subConvertUrl!, Utile.UrlEncode(url)); url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
if (!url.Contains("target=")) if (!url.Contains("target="))
{ {
url += string.Format("&target={0}", item.convertTarget); url += string.Format("&target={0}", item.convertTarget);
@@ -219,17 +220,17 @@ namespace v2rayN.Handler
} }
} }
var result = await downloadHandle.TryDownloadString(url, blProxy, userAgent); var result = await downloadHandle.TryDownloadString(url, blProxy, userAgent);
if (blProxy && Utile.IsNullOrEmpty(result)) if (blProxy && Utils.IsNullOrEmpty(result))
{ {
result = await downloadHandle.TryDownloadString(url, false, userAgent); result = await downloadHandle.TryDownloadString(url, false, userAgent);
} }
//more url //more url
if (Utile.IsNullOrEmpty(item.convertTarget) && !Utile.IsNullOrEmpty(item.moreUrl.TrimEx())) if (Utils.IsNullOrEmpty(item.convertTarget) && !Utils.IsNullOrEmpty(item.moreUrl.TrimEx()))
{ {
if (!Utile.IsNullOrEmpty(result) && Utile.IsBase64String(result!)) if (!Utils.IsNullOrEmpty(result) && Utils.IsBase64String(result!))
{ {
result = Utile.Base64Decode(result); result = Utils.Base64Decode(result);
} }
var lstUrl = new List<string> var lstUrl = new List<string>
@@ -238,22 +239,22 @@ namespace v2rayN.Handler
}; };
foreach (var it in lstUrl) foreach (var it in lstUrl)
{ {
var url2 = Utile.GetPunycode(it); var url2 = Utils.GetPunycode(it);
if (Utile.IsNullOrEmpty(url2)) if (Utils.IsNullOrEmpty(url2))
{ {
continue; continue;
} }
var result2 = await downloadHandle.TryDownloadString(url2, blProxy, userAgent); var result2 = await downloadHandle.TryDownloadString(url2, blProxy, userAgent);
if (blProxy && Utile.IsNullOrEmpty(result2)) if (blProxy && Utils.IsNullOrEmpty(result2))
{ {
result2 = await downloadHandle.TryDownloadString(url2, false, userAgent); result2 = await downloadHandle.TryDownloadString(url2, false, userAgent);
} }
if (!Utile.IsNullOrEmpty(result2)) if (!Utils.IsNullOrEmpty(result2))
{ {
if (Utile.IsBase64String(result2!)) if (Utils.IsBase64String(result2!))
{ {
result += Utile.Base64Decode(result2); result += Utils.Base64Decode(result2);
} }
else else
{ {
@@ -263,14 +264,14 @@ namespace v2rayN.Handler
} }
} }
if (Utile.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
_updateFunc(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}"); _updateFunc(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}");
} }
else else
{ {
_updateFunc(false, $"{hashCode}{ResUI.MsgGetSubscriptionSuccessfully}"); _updateFunc(false, $"{hashCode}{ResUI.MsgGetSubscriptionSuccessfully}");
if (result!.Length < 99) if (result?.Length < 99)
{ {
_updateFunc(false, $"{hashCode}{result}"); _updateFunc(false, $"{hashCode}{result}");
} }
@@ -299,9 +300,6 @@ namespace v2rayN.Handler
{ {
await UpdateGeoFile("geosite", _config, update); await UpdateGeoFile("geosite", _config, update);
await UpdateGeoFile("geoip", _config, update); await UpdateGeoFile("geoip", _config, update);
//await UpdateGeoFile4Singbox("geosite", _config, false, update);
//await UpdateGeoFile4Singbox("geoip", _config, true, update);
}); });
} }
@@ -325,9 +323,9 @@ namespace v2rayN.Handler
string url = coreInfo.coreReleaseApiUrl; string url = coreInfo.coreReleaseApiUrl;
var result = await (new DownloadHandle()).DownloadStringAsync(url, true, ""); var result = await (new DownloadHandle()).DownloadStringAsync(url, true, "");
if (!Utile.IsNullOrEmpty(result)) if (!Utils.IsNullOrEmpty(result))
{ {
responseHandler(type, result, preRelease); ResponseHandler(type, result, preRelease);
} }
else else
{ {
@@ -345,7 +343,7 @@ namespace v2rayN.Handler
/// <summary> /// <summary>
/// 获取V2RayCore版本 /// 获取V2RayCore版本
/// </summary> /// </summary>
private SemanticVersion getCoreVersion(ECoreType type) private SemanticVersion GetCoreVersion(ECoreType type)
{ {
try try
{ {
@@ -354,7 +352,7 @@ namespace v2rayN.Handler
foreach (string name in coreInfo.coreExes) foreach (string name in coreInfo.coreExes)
{ {
string vName = $"{name}.exe"; string vName = $"{name}.exe";
vName = Utile.GetBinPath(vName, coreInfo.coreType.ToString()); vName = Utils.GetBinPath(vName, coreInfo.coreType.ToString());
if (File.Exists(vName)) if (File.Exists(vName))
{ {
filePath = vName; filePath = vName;
@@ -372,7 +370,7 @@ namespace v2rayN.Handler
using Process p = new(); using Process p = new();
p.StartInfo.FileName = filePath.AppendQuotes(); p.StartInfo.FileName = filePath.AppendQuotes();
p.StartInfo.Arguments = coreInfo.versionArg; p.StartInfo.Arguments = coreInfo.versionArg;
p.StartInfo.WorkingDirectory = Utile.StartupPath(); p.StartInfo.WorkingDirectory = Utils.StartupPath();
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true; p.StartInfo.CreateNoWindow = true;
@@ -410,14 +408,14 @@ namespace v2rayN.Handler
} }
} }
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease) private void ResponseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
{ {
try try
{ {
var gitHubReleases = JsonUtile.Deserialize<List<GitHubRelease>>(gitHubReleaseApi); var gitHubReleases = JsonUtils.Deserialize<List<GitHubRelease>>(gitHubReleaseApi);
var gitHubRelease = preRelease ? gitHubReleases!.First() : gitHubReleases!.First(r => r.Prerelease == false); var gitHubRelease = preRelease ? gitHubReleases?.First() : gitHubReleases?.First(r => r.Prerelease == false);
var version = new SemanticVersion(gitHubRelease!.TagName); var version = new SemanticVersion(gitHubRelease?.TagName!);
var body = gitHubRelease!.Body; var body = gitHubRelease?.Body;
var coreInfo = LazyConfig.Instance.GetCoreInfo(type); var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
@@ -431,7 +429,7 @@ namespace v2rayN.Handler
case ECoreType.Xray: case ECoreType.Xray:
case ECoreType.v2fly_v5: case ECoreType.v2fly_v5:
{ {
curVersion = getCoreVersion(type); curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v")); message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
string osBit = "64"; string osBit = "64";
switch (RuntimeInformation.ProcessArchitecture) switch (RuntimeInformation.ProcessArchitecture)
@@ -456,7 +454,7 @@ namespace v2rayN.Handler
case ECoreType.clash_meta: case ECoreType.clash_meta:
case ECoreType.mihomo: case ECoreType.mihomo:
{ {
curVersion = getCoreVersion(type); curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion); message = string.Format(ResUI.IsLatestCore, type, curVersion);
switch (RuntimeInformation.ProcessArchitecture) switch (RuntimeInformation.ProcessArchitecture)
{ {
@@ -477,7 +475,7 @@ namespace v2rayN.Handler
} }
case ECoreType.sing_box: case ECoreType.sing_box:
{ {
curVersion = getCoreVersion(type); curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v")); message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
switch (RuntimeInformation.ProcessArchitecture) switch (RuntimeInformation.ProcessArchitecture)
{ {
@@ -498,7 +496,7 @@ namespace v2rayN.Handler
} }
case ECoreType.v2rayN: case ECoreType.v2rayN:
{ {
curVersion = new SemanticVersion(FileVersionInfo.GetVersionInfo(Utile.GetExePath()).FileVersion.ToString()); curVersion = new SemanticVersion(FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString());
message = string.Format(ResUI.IsLatestN, type, curVersion); message = string.Format(ResUI.IsLatestN, type, curVersion);
switch (RuntimeInformation.ProcessArchitecture) switch (RuntimeInformation.ProcessArchitecture)
{ {
@@ -570,7 +568,7 @@ namespace v2rayN.Handler
try try
{ {
string fileName = Utile.GetTempPath(Utile.GetDownloadFileName(url)); string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
//Global.coreTypes.ForEach(it => //Global.coreTypes.ForEach(it =>
@@ -578,7 +576,7 @@ namespace v2rayN.Handler
// string targetPath = Utile.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it)); // string targetPath = Utile.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it));
// File.Copy(fileName, targetPath, true); // File.Copy(fileName, targetPath, true);
//}); //});
string targetPath = Utile.GetBinPath($"{geoName}.dat"); string targetPath = Utils.GetBinPath($"{geoName}.dat");
File.Copy(fileName, targetPath, true); File.Copy(fileName, targetPath, true);
File.Delete(fileName); File.Delete(fileName);

View File

@@ -1,440 +0,0 @@
namespace v2rayN.Model
{
[Serializable]
public class ConfigOld
{
#region property
/// <summary>
/// 允许日志
/// </summary>
public bool logEnabled
{
get; set;
}
/// <summary>
/// 日志等级
/// </summary>
public string loglevel
{
get; set;
}
public string indexId
{
get; set;
}
/// <summary>
/// 允许Mux多路复用
/// </summary>
public bool muxEnabled
{
get; set;
}
/// <summary>
///
/// </summary>
public ESysProxyType sysProxyType
{
get; set;
}
/// <summary>
/// 启用实时网速和流量统计
/// </summary>
public bool enableStatistics
{
get; set;
}
/// <summary>
/// 去重时优先保留较旧(顶部)节点
/// </summary>
public bool keepOlderDedupl
{
get; set;
}
/// <summary>
/// 视图刷新率
/// </summary>
public int statisticsFreshRate
{
get; set;
}
/// <summary>
/// 自定义远程DNS
/// </summary>
public string remoteDNS
{
get; set;
}
/// <summary>
/// Outbound Freedom domainStrategy
/// </summary>
public string domainStrategy4Freedom
{
get; set;
}
/// <summary>
/// 是否允许不安全连接
/// </summary>
public bool defAllowInsecure
{
get; set;
}
/// <summary>
/// 域名解析策略
/// </summary>
public string domainStrategy
{
get; set;
}
public string domainMatcher
{
get; set;
}
public int routingIndex
{
get; set;
}
public bool enableRoutingAdvanced
{
get; set;
}
public bool ignoreGeoUpdateCore
{
get; set;
}
/// <summary>
/// systemProxyExceptions
/// </summary>
public string systemProxyExceptions
{
get; set;
}
public string systemProxyAdvancedProtocol { get; set; }
public int autoUpdateInterval { get; set; } = 0;
public int autoUpdateSubInterval { get; set; } = 0;
public bool checkPreReleaseUpdate { get; set; } = false;
public bool enableSecurityProtocolTls13
{
get; set;
}
public int trayMenuServersLimit { get; set; }
#endregion property
#region other entities
/// <summary>
/// 本地监听
/// </summary>
public List<InItem> inbound
{
get; set;
}
/// <summary>
/// vmess服务器信息
/// </summary>
public List<VmessItem> vmess
{
get; set;
}
/// <summary>
/// KcpItem
/// </summary>
public KcpItem kcpItem
{
get; set;
}
/// <summary>
/// 订阅
/// </summary>
public List<SubItem> subItem
{
get; set;
}
/// <summary>
/// UI
/// </summary>
public UIItem uiItem
{
get; set;
}
public List<RoutingItemOld> routings
{
get; set;
}
public ConstItem constItem
{
get; set;
}
public List<KeyEventItem> globalHotkeys
{
get; set;
}
public List<CoreTypeItem> coreTypeItem
{
get; set;
}
#endregion other entities
}
[Serializable]
public class VmessItem
{
public VmessItem()
{
indexId = string.Empty;
configType = EConfigType.VMess;
configVersion = 2;
sort = 0;
address = string.Empty;
port = 0;
id = string.Empty;
alterId = 0;
security = string.Empty;
network = string.Empty;
remarks = string.Empty;
headerType = string.Empty;
requestHost = string.Empty;
path = string.Empty;
streamSecurity = string.Empty;
allowInsecure = string.Empty;
testResult = string.Empty;
subid = string.Empty;
flow = string.Empty;
groupId = string.Empty;
}
public string indexId
{
get; set;
}
/// <summary>
/// config type(1=normal,2=custom)
/// </summary>
public EConfigType configType
{
get; set;
}
/// <summary>
/// 版本(现在=2)
/// </summary>
public int configVersion
{
get; set;
}
public int sort
{
get; set;
}
/// <summary>
/// 远程服务器地址
/// </summary>
public string address
{
get; set;
}
/// <summary>
/// 远程服务器端口
/// </summary>
public int port
{
get; set;
}
/// <summary>
/// 远程服务器ID
/// </summary>
public string id
{
get; set;
}
/// <summary>
/// 远程服务器额外ID
/// </summary>
public int alterId
{
get; set;
}
/// <summary>
/// 本地安全策略
/// </summary>
public string security
{
get; set;
}
/// <summary>
/// tcp,kcp,ws,h2,quic
/// </summary>
public string network
{
get; set;
}
/// <summary>
///
/// </summary>
public string remarks
{
get; set;
}
/// <summary>
/// 伪装类型
/// </summary>
public string headerType
{
get; set;
}
/// <summary>
/// 伪装的域名
/// </summary>
public string requestHost
{
get; set;
}
/// <summary>
/// ws h2 path
/// </summary>
public string path
{
get; set;
}
/// <summary>
/// 传输层安全
/// </summary>
public string streamSecurity
{
get; set;
}
/// <summary>
/// 是否允许不安全连接(用于客户端)
/// </summary>
public string allowInsecure
{
get; set;
}
/// <summary>
///
/// </summary>
public string testResult
{
get; set;
}
/// <summary>
/// SubItem id
/// </summary>
public string subid
{
get; set;
}
/// <summary>
/// VLESS flow
/// </summary>
public string flow
{
get; set;
}
/// <summary>
/// tls sni
/// </summary>
public string sni
{
get; set;
}
public string groupId
{
get; set;
} = string.Empty;
public ECoreType? coreType
{
get; set;
}
public int preSocksPort
{
get; set;
}
public string fingerprint { get; set; }
}
[Serializable]
public class RoutingItemOld
{
public string remarks
{
get; set;
}
public string url
{
get; set;
}
public List<RulesItem> rules
{
get; set;
}
public bool enabled { get; set; } = true;
public bool locked
{
get; set;
}
public string customIcon
{
get; set;
}
}
}

View File

@@ -1,25 +0,0 @@
namespace v2rayN.Model
{
[Serializable]
public class RulesItem
{
public string id { get; set; }
public string type { get; set; }
public string port { get; set; }
public List<string> inboundTag { get; set; }
public string outboundTag { get; set; }
public List<string> ip { get; set; }
public List<string> domain { get; set; }
public List<string> protocol { get; set; }
public List<string> process { get; set; }
public bool enabled { get; set; } = true;
}
}

View File

@@ -0,0 +1,17 @@
namespace v2rayN.Models
{
public class ClashConnectionModel
{
public string id { get; set; }
public string network { get; set; }
public string type { get; set; }
public string host { get; set; }
public ulong upload { get; set; }
public ulong download { get; set; }
public string uploadTraffic { get; set; }
public string downloadTraffic { get; set; }
public double time { get; set; }
public string elapsed { get; set; }
public string chain { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
namespace v2rayN.Models
{
public class ClashConnections
{
public ulong downloadTotal { get; set; }
public ulong uploadTotal { get; set; }
public List<ConnectionItem>? connections { get; set; }
}
public class ConnectionItem
{
public string id { get; set; } = string.Empty;
public MetadataItem metadata { get; set; }
public ulong upload { get; set; }
public ulong download { get; set; }
public DateTime start { get; set; }
public List<string>? chains { get; set; }
public string rule { get; set; }
public string rulePayload { get; set; }
}
public class MetadataItem
{
public string network { get; set; }
public string type { get; set; }
public string sourceIP { get; set; }
public string destinationIP { get; set; }
public string sourcePort { get; set; }
public string destinationPort { get; set; }
public string host { get; set; }
public string nsMode { get; set; }
public object uid { get; set; }
public string process { get; set; }
public string processPath { get; set; }
public string remoteDestination { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using static v2rayN.Models.ClashProxies;
namespace v2rayN.Models
{
public class ClashProviders
{
public Dictionary<String, ProvidersItem> providers { get; set; }
public class ProvidersItem
{
public string name { get; set; }
public ProxiesItem[] proxies { get; set; }
public string type { get; set; }
public string vehicleType { get; set; }
}
}
}

View File

@@ -0,0 +1,24 @@
namespace v2rayN.Models
{
public class ClashProxies
{
public Dictionary<String, ProxiesItem> proxies { get; set; }
public class ProxiesItem
{
public string[] all { get; set; }
public List<HistoryItem> history { get; set; }
public string name { get; set; }
public string type { get; set; }
public bool udp { get; set; }
public string now { get; set; }
public int delay { get; set; }
}
public class HistoryItem
{
public string time { get; set; }
public int delay { get; set; }
}
}
}

View File

@@ -0,0 +1,26 @@
using ReactiveUI.Fody.Helpers;
namespace v2rayN.Models
{
[Serializable]
public class ClashProxyModel
{
[Reactive]
public string name { get; set; }
[Reactive]
public string type { get; set; }
[Reactive]
public string now { get; set; }
[Reactive]
public int delay { get; set; }
[Reactive]
public string delayName { get; set; }
[Reactive]
public bool isActive { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
public class ComboItem public class ComboItem
{ {

View File

@@ -1,4 +1,6 @@
namespace v2rayN.Model using v2rayN.Enums;
namespace v2rayN.Models
{ {
/// <summary> /// <summary>
/// 本软件配置文件实体类 /// 本软件配置文件实体类
@@ -10,10 +12,24 @@
public string indexId { get; set; } public string indexId { get; set; }
public string subIndexId { get; set; } public string subIndexId { get; set; }
public ESysProxyType sysProxyType { get; set; }
public string systemProxyExceptions { get; set; } public string systemProxyExceptions { get; set; }
public string systemProxyAdvancedProtocol { get; set; } public string systemProxyAdvancedProtocol { get; set; }
public ECoreType runningCoreType { get; set; }
public bool IsRunningCore(ECoreType type)
{
if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5 or ECoreType.SagerNet)
{
return true;
}
if (type == ECoreType.clash && runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo)
{
return true;
}
return false;
}
#endregion property #endregion property
#region other entities #region other entities
@@ -29,6 +45,8 @@
public SpeedTestItem speedTestItem { get; set; } public SpeedTestItem speedTestItem { get; set; }
public Mux4SboxItem mux4SboxItem { get; set; } public Mux4SboxItem mux4SboxItem { get; set; }
public HysteriaItem hysteriaItem { get; set; } public HysteriaItem hysteriaItem { get; set; }
public ClashUIItem clashUIItem { get; set; }
public SystemProxyItem systemProxyItem { get; set; }
public List<InItem> inbound { get; set; } public List<InItem> inbound { get; set; }
public List<KeyEventItem> globalHotkeys { get; set; } public List<KeyEventItem> globalHotkeys { get; set; }
public List<CoreTypeItem> coreTypeItem { get; set; } public List<CoreTypeItem> coreTypeItem { get; set; }

View File

@@ -1,6 +1,7 @@
using System.Windows.Input; using System.Windows.Input;
using v2rayN.Enums;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class CoreBasicItem public class CoreBasicItem
@@ -31,6 +32,10 @@ namespace v2rayN.Model
/// 默认用户代理 /// 默认用户代理
/// </summary> /// </summary>
public string defUserAgent { get; set; } public string defUserAgent { get; set; }
public bool enableFragment { get; set; }
public bool enableCacheFile4Sbox { get; set; } = true;
} }
[Serializable] [Serializable]
@@ -43,8 +48,8 @@ namespace v2rayN.Model
public bool udpEnabled { get; set; } public bool udpEnabled { get; set; }
public bool sniffingEnabled { get; set; } = true; public bool sniffingEnabled { get; set; } = true;
public List<string>? destOverride { get; set; } = ["http", "tls"];
public bool routeOnly { get; set; } public bool routeOnly { get; set; }
public bool allowLANConn { get; set; } public bool allowLANConn { get; set; }
public bool newPort4LAN { get; set; } public bool newPort4LAN { get; set; }
@@ -114,6 +119,7 @@ namespace v2rayN.Model
public double mainHeight { get; set; } public double mainHeight { get; set; }
public double mainGirdHeight1 { get; set; } public double mainGirdHeight1 { get; set; }
public double mainGirdHeight2 { get; set; } public double mainGirdHeight2 { get; set; }
public EGirdOrientation mainGirdOrientation { get; set; } = EGirdOrientation.Vertical;
public bool colorModeDark { get; set; } public bool colorModeDark { get; set; }
public bool followSystemTheme { get; set; } public bool followSystemTheme { get; set; }
public string? colorPrimaryName { get; set; } public string? colorPrimaryName { get; set; }
@@ -122,9 +128,10 @@ namespace v2rayN.Model
public int currentFontSize { get; set; } public int currentFontSize { get; set; }
public bool enableDragDropSort { get; set; } public bool enableDragDropSort { get; set; }
public bool doubleClick2Activate { get; set; } public bool doubleClick2Activate { get; set; }
public bool autoHideStartup { get; set; } = true; public bool autoHideStartup { get; set; }
public string mainMsgFilter { get; set; } public string mainMsgFilter { get; set; }
public List<ColumnItem> mainColumnItem { get; set; } public List<ColumnItem> mainColumnItem { get; set; }
public bool showInTaskbar { get; set; }
} }
[Serializable] [Serializable]
@@ -164,7 +171,7 @@ namespace v2rayN.Model
public string stack { get; set; } public string stack { get; set; }
public int mtu { get; set; } public int mtu { get; set; }
public bool enableExInbound { get; set; } public bool enableExInbound { get; set; }
public bool enableIPv6Address { get; set; } = true; public bool enableIPv6Address { get; set; }
} }
[Serializable] [Serializable]
@@ -178,13 +185,8 @@ namespace v2rayN.Model
[Serializable] [Serializable]
public class RoutingBasicItem public class RoutingBasicItem
{ {
/// <summary>
/// 域名解析策略
/// </summary>
public string domainStrategy { get; set; } public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; } public string domainStrategy4Singbox { get; set; }
public string domainMatcher { get; set; } public string domainMatcher { get; set; }
public string routingIndexId { get; set; } public string routingIndexId { get; set; }
public bool enableRoutingAdvanced { get; set; } public bool enableRoutingAdvanced { get; set; }
@@ -211,4 +213,27 @@ namespace v2rayN.Model
public int up_mbps { get; set; } public int up_mbps { get; set; }
public int down_mbps { get; set; } public int down_mbps { get; set; }
} }
[Serializable]
public class ClashUIItem
{
public ERuleMode ruleMode { get; set; }
public bool enableIPv6 { get; set; }
public bool enableMixinContent { get; set; }
public int proxiesSorting { get; set; }
public bool proxiesAutoRefresh { get; set; }
public int proxiesAutoDelayTestInterval { get; set; } = 10;
public int connectionsSorting { get; set; }
public bool connectionsAutoRefresh { get; set; }
public int connectionsRefreshInterval { get; set; } = 2;
}
[Serializable]
public class SystemProxyItem
{
public ESysProxyType sysProxyType { get; set; }
public string systemProxyExceptions { get; set; }
public bool notProxyLocalAddress { get; set; } = true;
public string systemProxyAdvancedProtocol { get; set; }
}
} }

View File

@@ -1,4 +1,6 @@
namespace v2rayN.Model using v2rayN.Enums;
namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class CoreInfo public class CoreInfo

View File

@@ -1,6 +1,7 @@
using SQLite; using SQLite;
using v2rayN.Enums;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class DNSItem public class DNSItem
@@ -15,5 +16,6 @@ namespace v2rayN.Model
public string? normalDNS { get; set; } public string? normalDNS { get; set; }
public string? tunDNS { get; set; } public string? tunDNS { get; set; }
public string? domainStrategy4Freedom { get; set; } public string? domainStrategy4Freedom { get; set; }
public string? domainDNSAddress { get; set; }
} }
} }

View File

@@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Model namespace v2rayN.Models
{ {
public class GitHubReleaseAsset public class GitHubReleaseAsset
{ {

View File

@@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class ProfileExItem public class ProfileExItem

View File

@@ -1,6 +1,7 @@
using SQLite; using SQLite;
using v2rayN.Enums;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class ProfileItem public class ProfileItem
@@ -48,7 +49,7 @@ namespace v2rayN.Model
switch (configType) switch (configType)
{ {
case EConfigType.Custom: case EConfigType.Custom:
summary += string.Format("{0}", remarks); summary += string.Format("[{1}]{0}", remarks, coreType.ToString());
break; break;
default: default:
@@ -60,19 +61,19 @@ namespace v2rayN.Model
public List<string> GetAlpn() public List<string> GetAlpn()
{ {
if (Utile.IsNullOrEmpty(alpn)) if (Utils.IsNullOrEmpty(alpn))
{ {
return null; return null;
} }
else else
{ {
return Utile.String2List(alpn); return Utils.String2List(alpn);
} }
} }
public string GetNetwork() public string GetNetwork()
{ {
if (Utile.IsNullOrEmpty(network) || !Global.Networks.Contains(network)) if (Utils.IsNullOrEmpty(network) || !Global.Networks.Contains(network))
{ {
return Global.DefaultNetwork; return Global.DefaultNetwork;
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class ProfileItemModel : ProfileItem public class ProfileItemModel : ProfileItem

View File

@@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class RoutingItem public class RoutingItem
@@ -15,6 +15,7 @@ namespace v2rayN.Model
public bool enabled { get; set; } = true; public bool enabled { get; set; } = true;
public bool locked { get; set; } public bool locked { get; set; }
public string customIcon { get; set; } public string customIcon { get; set; }
public string customRulesetPath4Singbox { get; set; }
public string domainStrategy { get; set; } public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; } public string domainStrategy4Singbox { get; set; }
public int sort { get; set; } public int sort { get; set; }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class RoutingItemModel : RoutingItem public class RoutingItemModel : RoutingItem

View File

@@ -0,0 +1,26 @@
namespace v2rayN.Models
{
[Serializable]
public class RulesItem
{
public string id { get; set; }
public string? type { get; set; }
public string? port { get; set; }
public string? network { get; set; }
public List<string>? inboundTag { get; set; }
public string? outboundTag { get; set; }
public List<string>? ip { get; set; }
public List<string>? domain { get; set; }
public List<string>? protocol { get; set; }
public List<string>? process { get; set; }
public bool enabled { get; set; } = true;
}
}

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class RulesItemModel : RulesItem public class RulesItemModel : RulesItem

View File

@@ -1,7 +1,7 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
internal class ServerSpeedItem : ServerStatItem public class ServerSpeedItem : ServerStatItem
{ {
public long proxyUp public long proxyUp
{ {

View File

@@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class ServerStatItem public class ServerStatItem

View File

@@ -1,4 +1,6 @@
namespace v2rayN.Model using v2rayN.Enums;
namespace v2rayN.Models
{ {
[Serializable] [Serializable]
internal class ServerTestItem internal class ServerTestItem

View File

@@ -1,13 +1,13 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
public class SingboxConfig public class SingboxConfig
{ {
public Log4Sbox log { get; set; } public Log4Sbox log { get; set; }
public object dns { get; set; } public Dns4Sbox? dns { get; set; }
public List<Inbound4Sbox> inbounds { get; set; } public List<Inbound4Sbox> inbounds { get; set; }
public List<Outbound4Sbox> outbounds { get; set; } public List<Outbound4Sbox> outbounds { get; set; }
public Route4Sbox route { get; set; } public Route4Sbox route { get; set; }
public Experimental4Sbox experimental { get; set; } public Experimental4Sbox? experimental { get; set; }
} }
public class Log4Sbox public class Log4Sbox
@@ -28,6 +28,7 @@
public bool? disable_expire { get; set; } public bool? disable_expire { get; set; }
public bool? independent_cache { get; set; } public bool? independent_cache { get; set; }
public bool? reverse_mapping { get; set; } public bool? reverse_mapping { get; set; }
public string? client_subnet { get; set; }
public Fakeip4Sbox? fakeip { get; set; } public Fakeip4Sbox? fakeip { get; set; }
} }
@@ -35,19 +36,24 @@
{ {
public bool? auto_detect_interface { get; set; } public bool? auto_detect_interface { get; set; }
public List<Rule4Sbox> rules { get; set; } public List<Rule4Sbox> rules { get; set; }
public List<Ruleset4Sbox>? rule_set { get; set; }
} }
[Serializable] [Serializable]
public class Rule4Sbox public class Rule4Sbox
{ {
public string outbound { get; set; } public string? outbound { get; set; }
public string server { get; set; } public string? server { get; set; }
public bool? disable_cache { get; set; } public bool? disable_cache { get; set; }
public string? type { get; set; }
public string? mode { get; set; }
public bool? ip_is_private { get; set; }
public string? client_subnet { get; set; }
public bool? invert { get; set; }
public string? clash_mode { get; set; }
public List<string>? inbound { get; set; } public List<string>? inbound { get; set; }
public List<string>? protocol { get; set; } public List<string>? protocol { get; set; }
public string type { get; set; } public List<string>? network { get; set; }
public string mode { get; set; }
public string network { get; set; }
public List<int>? port { get; set; } public List<int>? port { get; set; }
public List<string>? port_range { get; set; } public List<string>? port_range { get; set; }
public List<string>? geosite { get; set; } public List<string>? geosite { get; set; }
@@ -58,8 +64,9 @@
public List<string>? geoip { get; set; } public List<string>? geoip { get; set; }
public List<string>? ip_cidr { get; set; } public List<string>? ip_cidr { get; set; }
public List<string>? source_ip_cidr { get; set; } public List<string>? source_ip_cidr { get; set; }
public List<string>? process_name { get; set; } public List<string>? process_name { get; set; }
public List<string>? rule_set { get; set; }
public List<Rule4Sbox>? rules { get; set; }
} }
[Serializable] [Serializable]
@@ -93,7 +100,7 @@
{ {
public string type { get; set; } public string type { get; set; }
public string tag { get; set; } public string tag { get; set; }
public string server { get; set; } public string? server { get; set; }
public int? server_port { get; set; } public int? server_port { get; set; }
public string uuid { get; set; } public string uuid { get; set; }
public string security { get; set; } public string security { get; set; }
@@ -124,6 +131,8 @@
public Multiplex4Sbox? multiplex { get; set; } public Multiplex4Sbox? multiplex { get; set; }
public Transport4Sbox? transport { get; set; } public Transport4Sbox? transport { get; set; }
public HyObfs4Sbox? obfs { get; set; } public HyObfs4Sbox? obfs { get; set; }
public List<string>? outbounds { get; set; }
public bool? interrupt_exist_connections { get; set; }
} }
public class Tls4Sbox public class Tls4Sbox
@@ -182,11 +191,13 @@
public class Server4Sbox public class Server4Sbox
{ {
public string tag { get; set; } public string? tag { get; set; }
public string address { get; set; } public string? address { get; set; }
public string address_resolver { get; set; } public string? address_resolver { get; set; }
public string strategy { get; set; } public string? address_strategy { get; set; }
public string detour { get; set; } public string? strategy { get; set; }
public string? detour { get; set; }
public string? client_subnet { get; set; }
} }
public class Experimental4Sbox public class Experimental4Sbox
@@ -230,4 +241,15 @@
public string? cache_id { get; set; } public string? cache_id { get; set; }
public bool? store_fakeip { get; set; } public bool? store_fakeip { get; set; }
} }
public class Ruleset4Sbox
{
public string? tag { get; set; }
public string? type { get; set; }
public string? format { get; set; }
public string? path { get; set; }
public string? url { get; set; }
public string? download_detour { get; set; }
public string? update_interval { get; set; }
}
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
public class SsSIP008 public class SsSIP008
{ {

View File

@@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Model namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class SubItem public class SubItem

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
internal class SysProxyConfig internal class SysProxyConfig
{ {

View File

@@ -1,12 +1,17 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Model namespace v2rayN.Models
{ {
/// <summary> /// <summary>
/// v2ray配置文件实体类 例子SampleConfig.txt /// v2ray配置文件实体类 例子SampleConfig.txt
/// </summary> /// </summary>
public class V2rayConfig public class V2rayConfig
{ {
/// <summary>
/// Properties that do not belong to Ray
/// </summary>
public string? remarks { get; set; }
/// <summary> /// <summary>
/// 日志配置 /// 日志配置
/// </summary> /// </summary>
@@ -190,7 +195,7 @@ namespace v2rayN.Model
public class Sniffing4Ray public class Sniffing4Ray
{ {
public bool enabled { get; set; } public bool enabled { get; set; }
public List<string> destOverride { get; set; } public List<string>? destOverride { get; set; }
public bool routeOnly { get; set; } public bool routeOnly { get; set; }
} }
@@ -227,7 +232,7 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public List<VnextItem4Ray> vnext { get; set; } public List<VnextItem4Ray>? vnext { get; set; }
/// <summary> /// <summary>
/// ///
@@ -248,6 +253,8 @@ namespace v2rayN.Model
/// ///
/// </summary> /// </summary>
public int? userLevel { get; set; } public int? userLevel { get; set; }
public FragmentItem4Ray? fragment { get; set; }
} }
public class VnextItem4Ray public class VnextItem4Ray
@@ -283,17 +290,17 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public string method { get; set; } public string? method { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public bool ota { get; set; } public bool? ota { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public string password { get; set; } public string? password { get; set; }
/// <summary> /// <summary>
/// ///
@@ -303,7 +310,7 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int level { get; set; } public int? level { get; set; }
/// <summary> /// <summary>
/// trojan /// trojan
@@ -331,7 +338,7 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int level { get; set; } public int? level { get; set; }
} }
public class Mux4Ray public class Mux4Ray
@@ -363,6 +370,12 @@ namespace v2rayN.Model
public List<string> servers { get; set; } public List<string> servers { get; set; }
} }
public class DnsServer4Ray
{
public string? address { get; set; }
public List<string>? domains { get; set; }
}
public class Routing4Ray public class Routing4Ray
{ {
/// <summary> /// <summary>
@@ -373,30 +386,47 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public string domainMatcher { get; set; } public string? domainMatcher { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public List<RulesItem4Ray> rules { get; set; } public List<RulesItem4Ray> rules { get; set; }
public List<BalancersItem4Ray>? balancers { get; set; }
} }
[Serializable] [Serializable]
public class RulesItem4Ray public class RulesItem4Ray
{ {
public string type { get; set; } public string? type { get; set; }
public string port { get; set; } public string? port { get; set; }
public string? network { get; set; }
public List<string> inboundTag { get; set; } public List<string>? inboundTag { get; set; }
public string outboundTag { get; set; } public string? outboundTag { get; set; }
public List<string> ip { get; set; } public string? balancerTag { get; set; }
public List<string> domain { get; set; } public List<string>? ip { get; set; }
public List<string> protocol { get; set; } public List<string>? domain { get; set; }
public List<string>? protocol { get; set; }
}
public class BalancersItem4Ray
{
public List<string>? selector { get; set; }
public BalancersStrategy4Ray? strategy { get; set; }
public string? tag { get; set; }
}
public class BalancersStrategy4Ray
{
public string? type { get; set; }
} }
public class StreamSettings4Ray public class StreamSettings4Ray
@@ -414,47 +444,52 @@ namespace v2rayN.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public TlsSettings4Ray tlsSettings { get; set; } public TlsSettings4Ray? tlsSettings { get; set; }
/// <summary> /// <summary>
/// Tcp传输额外设置 /// Tcp传输额外设置
/// </summary> /// </summary>
public TcpSettings4Ray tcpSettings { get; set; } public TcpSettings4Ray? tcpSettings { get; set; }
/// <summary> /// <summary>
/// Kcp传输额外设置 /// Kcp传输额外设置
/// </summary> /// </summary>
public KcpSettings4Ray kcpSettings { get; set; } public KcpSettings4Ray? kcpSettings { get; set; }
/// <summary> /// <summary>
/// ws传输额外设置 /// ws传输额外设置
/// </summary> /// </summary>
public WsSettings4Ray wsSettings { get; set; } public WsSettings4Ray? wsSettings { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; } public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; }
/// <summary>
///
/// </summary>
public SplithttpSettings4Ray? splithttpSettings { get; set; }
/// <summary> /// <summary>
/// h2传输额外设置 /// h2传输额外设置
/// </summary> /// </summary>
public HttpSettings4Ray httpSettings { get; set; } public HttpSettings4Ray? httpSettings { get; set; }
/// <summary> /// <summary>
/// QUIC /// QUIC
/// </summary> /// </summary>
public QuicSettings4Ray quicSettings { get; set; } public QuicSettings4Ray? quicSettings { get; set; }
/// <summary> /// <summary>
/// VLESS only /// VLESS only
/// </summary> /// </summary>
public TlsSettings4Ray realitySettings { get; set; } public TlsSettings4Ray? realitySettings { get; set; }
/// <summary> /// <summary>
/// grpc /// grpc
/// </summary> /// </summary>
public GrpcSettings4Ray grpcSettings { get; set; } public GrpcSettings4Ray? grpcSettings { get; set; }
/// <summary> /// <summary>
/// sockopt /// sockopt
@@ -481,7 +516,7 @@ namespace v2rayN.Model
public string? fingerprint { get; set; } public string? fingerprint { get; set; }
public bool? show { get; set; } = false; public bool? show { get; set; }
public string? publicKey { get; set; } public string? publicKey { get; set; }
public string? shortId { get; set; } public string? shortId { get; set; }
public string? spiderX { get; set; } public string? spiderX { get; set; }
@@ -601,6 +636,17 @@ namespace v2rayN.Model
public string? host { get; set; } public string? host { get; set; }
} }
public class SplithttpSettings4Ray
{
public string? path { get; set; }
public string? host { get; set; }
public int? maxUploadSize { get; set; }
public int? maxConcurrentUploads { get; set; }
}
public class HttpSettings4Ray public class HttpSettings4Ray
{ {
/// <summary> /// <summary>
@@ -634,7 +680,8 @@ namespace v2rayN.Model
public class GrpcSettings4Ray public class GrpcSettings4Ray
{ {
public string serviceName { get; set; } public string? authority { get; set; }
public string? serviceName { get; set; }
public bool multiMode { get; set; } public bool multiMode { get; set; }
public int idle_timeout { get; set; } public int idle_timeout { get; set; }
public int health_check_timeout { get; set; } public int health_check_timeout { get; set; }
@@ -659,4 +706,11 @@ namespace v2rayN.Model
{ {
public string? dialerProxy { get; set; } public string? dialerProxy { get; set; }
} }
public class FragmentItem4Ray
{
public string? packets { get; set; }
public string? length { get; set; }
public string? interval { get; set; }
}
} }

View File

@@ -1,4 +1,4 @@
namespace v2rayN.Model namespace v2rayN.Models
{ {
/// <summary> /// <summary>
/// Tcp伪装http的Request只要Host /// Tcp伪装http的Request只要Host

View File

@@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Model namespace v2rayN.Models
{ {
/// <summary> /// <summary>
/// https://github.com/2dust/v2rayN/wiki/ /// https://github.com/2dust/v2rayN/wiki/

View File

@@ -78,15 +78,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Batch export subscription to clipboard successfully 的本地化字符串。
/// </summary>
public static string BatchExportSubscriptionSuccessfully {
get {
return ResourceManager.GetString("BatchExportSubscriptionSuccessfully", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Batch export share URL to clipboard successfully 的本地化字符串。 /// 查找类似 Batch export share URL to clipboard successfully 的本地化字符串。
/// </summary> /// </summary>
@@ -222,15 +213,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Please fill in the KCP parameters correctly 的本地化字符串。
/// </summary>
public static string FillKcpParameters {
get {
return ResourceManager.GetString("FillKcpParameters", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Please fill in the local listening port 的本地化字符串。 /// 查找类似 Please fill in the local listening port 的本地化字符串。
/// </summary> /// </summary>
@@ -285,15 +267,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Is not the correct client configuration file, please check 的本地化字符串。
/// </summary>
public static string IncorrectClientConfiguration {
get {
return ResourceManager.GetString("IncorrectClientConfiguration", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Is not the correct configuration, please check 的本地化字符串。 /// 查找类似 Is not the correct configuration, please check 的本地化字符串。
/// </summary> /// </summary>
@@ -303,15 +276,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Is not the correct server configuration file, please check 的本地化字符串。
/// </summary>
public static string IncorrectServerConfiguration {
get {
return ResourceManager.GetString("IncorrectServerConfiguration", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Initial Configuration 的本地化字符串。 /// 查找类似 Initial Configuration 的本地化字符串。
/// </summary> /// </summary>
@@ -367,7 +331,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Automatic update interval(minutes) 的本地化字符串。 /// 查找类似 Automatic update interval (minutes) 的本地化字符串。
/// </summary> /// </summary>
public static string LvAutoUpdateInterval { public static string LvAutoUpdateInterval {
get { get {
@@ -412,7 +376,16 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Enabled Update 的本地化字符串。 /// 查找类似 Custom the rule-set of sing-box 的本地化字符串。
/// </summary>
public static string LvCustomRulesetPath4Singbox {
get {
return ResourceManager.GetString("LvCustomRulesetPath4Singbox", resourceCulture);
}
}
/// <summary>
/// 查找类似 Enable update 的本地化字符串。
/// </summary> /// </summary>
public static string LvEnabled { public static string LvEnabled {
get { get {
@@ -439,7 +412,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 More urls, separated by commas;Subscription conversion will be invalid 的本地化字符串。 /// 查找类似 More URLs, separated by commas; Subscription conversion will be invalid 的本地化字符串。
/// </summary> /// </summary>
public static string LvMoreUrl { public static string LvMoreUrl {
get { get {
@@ -618,6 +591,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Add [Http] server 的本地化字符串。
/// </summary>
public static string menuAddHttpServer {
get {
return ResourceManager.GetString("menuAddHttpServer", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Add [Hysteria2] server 的本地化字符串。 /// 查找类似 Add [Hysteria2] server 的本地化字符串。
/// </summary> /// </summary>
@@ -735,6 +717,24 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Close Connection 的本地化字符串。
/// </summary>
public static string menuConnectionClose {
get {
return ResourceManager.GetString("menuConnectionClose", resourceCulture);
}
}
/// <summary>
/// 查找类似 Close All Connection 的本地化字符串。
/// </summary>
public static string menuConnectionCloseAll {
get {
return ResourceManager.GetString("menuConnectionCloseAll", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Clone selected server 的本地化字符串。 /// 查找类似 Clone selected server 的本地化字符串。
/// </summary> /// </summary>
@@ -789,15 +789,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Export subscription (base64) share to clipboard 的本地化字符串。
/// </summary>
public static string menuExport2SubContent {
get {
return ResourceManager.GetString("menuExport2SubContent", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Global Hotkey Setting 的本地化字符串。 /// 查找类似 Global Hotkey Setting 的本地化字符串。
/// </summary> /// </summary>
@@ -861,6 +852,42 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Direct 的本地化字符串。
/// </summary>
public static string menuModeDirect {
get {
return ResourceManager.GetString("menuModeDirect", resourceCulture);
}
}
/// <summary>
/// 查找类似 Global 的本地化字符串。
/// </summary>
public static string menuModeGlobal {
get {
return ResourceManager.GetString("menuModeGlobal", resourceCulture);
}
}
/// <summary>
/// 查找类似 Do not change 的本地化字符串。
/// </summary>
public static string menuModeNothing {
get {
return ResourceManager.GetString("menuModeNothing", resourceCulture);
}
}
/// <summary>
/// 查找类似 Rule 的本地化字符串。
/// </summary>
public static string menuModeRule {
get {
return ResourceManager.GetString("menuModeRule", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Move to bottom (B) 的本地化字符串。 /// 查找类似 Move to bottom (B) 的本地化字符串。
/// </summary> /// </summary>
@@ -942,15 +969,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Set message filters 的本地化字符串。
/// </summary>
public static string menuMsgViewFilter {
get {
return ResourceManager.GetString("menuMsgViewFilter", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Select all (Ctrl+A) 的本地化字符串。 /// 查找类似 Select all (Ctrl+A) 的本地化字符串。
/// </summary> /// </summary>
@@ -960,6 +978,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Open the storage location 的本地化字符串。
/// </summary>
public static string menuOpenTheFileLocation {
get {
return ResourceManager.GetString("menuOpenTheFileLocation", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Option Setting 的本地化字符串。 /// 查找类似 Option Setting 的本地化字符串。
/// </summary> /// </summary>
@@ -978,6 +1005,42 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Latency Test 的本地化字符串。
/// </summary>
public static string menuProxiesDelaytest {
get {
return ResourceManager.GetString("menuProxiesDelaytest", resourceCulture);
}
}
/// <summary>
/// 查找类似 Part Node Latency Test 的本地化字符串。
/// </summary>
public static string menuProxiesDelaytestPart {
get {
return ResourceManager.GetString("menuProxiesDelaytestPart", resourceCulture);
}
}
/// <summary>
/// 查找类似 Refresh Proxies 的本地化字符串。
/// </summary>
public static string menuProxiesReload {
get {
return ResourceManager.GetString("menuProxiesReload", resourceCulture);
}
}
/// <summary>
/// 查找类似 Select active node (Enter) 的本地化字符串。
/// </summary>
public static string menuProxiesSelectActivity {
get {
return ResourceManager.GetString("menuProxiesSelectActivity", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Test servers real delay (Ctrl+R) 的本地化字符串。 /// 查找类似 Test servers real delay (Ctrl+R) 的本地化字符串。
/// </summary> /// </summary>
@@ -1149,6 +1212,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Rule mode 的本地化字符串。
/// </summary>
public static string menuRulemode {
get {
return ResourceManager.GetString("menuRulemode", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Remove Rule (Delete) 的本地化字符串。 /// 查找类似 Remove Rule (Delete) 的本地化字符串。
/// </summary> /// </summary>
@@ -1176,6 +1248,24 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Multi-server load balancing 的本地化字符串。
/// </summary>
public static string menuSetDefaultLoadBalanceServer {
get {
return ResourceManager.GetString("menuSetDefaultLoadBalanceServer", resourceCulture);
}
}
/// <summary>
/// 查找类似 Multi-Server lowest latency 的本地化字符串。
/// </summary>
public static string menuSetDefaultMultipleServer {
get {
return ResourceManager.GetString("menuSetDefaultMultipleServer", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Set as active server (Enter) 的本地化字符串。 /// 查找类似 Set as active server (Enter) 的本地化字符串。
/// </summary> /// </summary>
@@ -1267,7 +1357,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Subscription group 的本地化字符串。 /// 查找类似 Subscription Group 的本地化字符串。
/// </summary> /// </summary>
public static string menuSubscription { public static string menuSubscription {
get { get {
@@ -1294,7 +1384,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Update subscription without proxy 的本地化字符串。 /// 查找类似 Update subscriptions without proxy 的本地化字符串。
/// </summary> /// </summary>
public static string menuSubUpdate { public static string menuSubUpdate {
get { get {
@@ -1303,7 +1393,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Update subscription with proxy 的本地化字符串。 /// 查找类似 Update subscriptions with proxy 的本地化字符串。
/// </summary> /// </summary>
public static string menuSubUpdateViaProxy { public static string menuSubUpdateViaProxy {
get { get {
@@ -1365,15 +1455,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Test current service status 的本地化字符串。
/// </summary>
public static string menuTestMe {
get {
return ResourceManager.GetString("menuTestMe", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 {0} Website 的本地化字符串。 /// 查找类似 {0} Website 的本地化字符串。
/// </summary> /// </summary>
@@ -1528,7 +1609,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Update subscription end 的本地化字符串。 /// 查找类似 Update subscriptions end 的本地化字符串。
/// </summary> /// </summary>
public static string MsgUpdateSubscriptionEnd { public static string MsgUpdateSubscriptionEnd {
get { get {
@@ -1537,7 +1618,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Update subscription starts 的本地化字符串。 /// 查找类似 Update subscriptions start 的本地化字符串。
/// </summary> /// </summary>
public static string MsgUpdateSubscriptionStart { public static string MsgUpdateSubscriptionStart {
get { get {
@@ -1563,6 +1644,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Successful operation. Click the settings menu to reboot the app. 的本地化字符串。
/// </summary>
public static string NeedRebootTips {
get {
return ResourceManager.GetString("NeedRebootTips", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Non-VMess or ss protocol 的本地化字符串。 /// 查找类似 Non-VMess or ss protocol 的本地化字符串。
/// </summary> /// </summary>
@@ -1572,15 +1662,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Non-standard service, this feature is invalid 的本地化字符串。
/// </summary>
public static string NonVmessService {
get {
return ResourceManager.GetString("NonVmessService", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2} 的本地化字符串。 /// 查找类似 The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2} 的本地化字符串。
/// </summary> /// </summary>
@@ -1807,7 +1888,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Group please leave blank here 的本地化字符串。 /// 查找类似 For group please leave blank here 的本地化字符串。
/// </summary> /// </summary>
public static string SubUrlTips { public static string SubUrlTips {
get { get {
@@ -1852,15 +1933,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 System proxy 的本地化字符串。
/// </summary>
public static string SystemProxy {
get {
return ResourceManager.GetString("SystemProxy", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Address 的本地化字符串。 /// 查找类似 Address 的本地化字符串。
/// </summary> /// </summary>
@@ -1960,6 +2032,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Connections 的本地化字符串。
/// </summary>
public static string TbConnections {
get {
return ResourceManager.GetString("TbConnections", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Core Type 的本地化字符串。 /// 查找类似 Core Type 的本地化字符串。
/// </summary> /// </summary>
@@ -2230,6 +2311,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Proxies 的本地化字符串。
/// </summary>
public static string TbProxies {
get {
return ResourceManager.GetString("TbProxies", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 PublicKey 的本地化字符串。 /// 查找类似 PublicKey 的本地化字符串。
/// </summary> /// </summary>
@@ -2572,6 +2662,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Outbound DNS address 的本地化字符串。
/// </summary>
public static string TbSettingsDomainDNSAddress {
get {
return ResourceManager.GetString("TbSettingsDomainDNSAddress", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Outbound Freedom domainStrategy 的本地化字符串。 /// 查找类似 Outbound Freedom domainStrategy 的本地化字符串。
/// </summary> /// </summary>
@@ -2581,6 +2680,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Default domain strategy for outbound 的本地化字符串。
/// </summary>
public static string TbSettingsDomainStrategy4Out {
get {
return ResourceManager.GetString("TbSettingsDomainStrategy4Out", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Double-click server make active 的本地化字符串。 /// 查找类似 Double-click server make active 的本地化字符串。
/// </summary> /// </summary>
@@ -2599,6 +2707,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Enable cache file for sing-box (ruleset files) 的本地化字符串。
/// </summary>
public static string TbSettingsEnableCacheFile4Sbox {
get {
return ResourceManager.GetString("TbSettingsEnableCacheFile4Sbox", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Check for pre-release updates 的本地化字符串。 /// 查找类似 Check for pre-release updates 的本地化字符串。
/// </summary> /// </summary>
@@ -2626,6 +2743,24 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Enable fragment 的本地化字符串。
/// </summary>
public static string TbSettingsEnableFragment {
get {
return ResourceManager.GetString("TbSettingsEnableFragment", resourceCulture);
}
}
/// <summary>
/// 查找类似 Use Xray and enable non-Tun mode, which conflicts with the group previous proxy 的本地化字符串。
/// </summary>
public static string TbSettingsEnableFragmentTips {
get {
return ResourceManager.GetString("TbSettingsEnableFragmentTips", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Enable hardware acceleration(Require restart) 的本地化字符串。 /// 查找类似 Enable hardware acceleration(Require restart) 的本地化字符串。
/// </summary> /// </summary>
@@ -2761,6 +2896,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Main layout orientation(Require restart) 的本地化字符串。
/// </summary>
public static string TbSettingsMainGirdOrientation {
get {
return ResourceManager.GetString("TbSettingsMainGirdOrientation", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 sing-box Mux Protocol 的本地化字符串。 /// 查找类似 sing-box Mux Protocol 的本地化字符串。
/// </summary> /// </summary>
@@ -2797,6 +2941,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Do not use proxy servers for local (intranet) addresses 的本地化字符串。
/// </summary>
public static string TbSettingsNotProxyLocalAddress {
get {
return ResourceManager.GetString("TbSettingsNotProxyLocalAddress", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Auth pass 的本地化字符串。 /// 查找类似 Auth pass 的本地化字符串。
/// </summary> /// </summary>
@@ -2852,7 +3005,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 HTTP port=SOCKS port+1;Pac port=SOCKS port+4;API port=SOCKS port+5; 的本地化字符串。 /// 查找类似 http port = +1; Pac port = +4; *ray API port = +5; mihomo API port = +6; 的本地化字符串。
/// </summary> /// </summary>
public static string TbSettingsSocksPortTip { public static string TbSettingsSocksPortTip {
get { get {
@@ -2959,78 +3112,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Bypass Mode 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeBypassMode {
get {
return ResourceManager.GetString("TbSettingsTunModeBypassMode", resourceCulture);
}
}
/// <summary>
/// 查找类似 Custom Template 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeCustomTemplate {
get {
return ResourceManager.GetString("TbSettingsTunModeCustomTemplate", resourceCulture);
}
}
/// <summary>
/// 查找类似 Direct IP CIDR, separated by commas (,) 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeDirectIP {
get {
return ResourceManager.GetString("TbSettingsTunModeDirectIP", resourceCulture);
}
}
/// <summary>
/// 查找类似 Direct Process name, separated by commas (,) 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeDirectProcess {
get {
return ResourceManager.GetString("TbSettingsTunModeDirectProcess", resourceCulture);
}
}
/// <summary>
/// 查找类似 DNS object, e.g. {&quot;servers&quot;:[]} 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeDNS {
get {
return ResourceManager.GetString("TbSettingsTunModeDNS", resourceCulture);
}
}
/// <summary>
/// 查找类似 Proxy IP CIDR, separated by commas (,) 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeProxyIP {
get {
return ResourceManager.GetString("TbSettingsTunModeProxyIP", resourceCulture);
}
}
/// <summary>
/// 查找类似 Proxy Process name, separated by commas (,) 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeProxyProcess {
get {
return ResourceManager.GetString("TbSettingsTunModeProxyProcess", resourceCulture);
}
}
/// <summary>
/// 查找类似 Show console 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeShowWindow {
get {
return ResourceManager.GetString("TbSettingsTunModeShowWindow", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Enable UDP 的本地化字符串。 /// 查找类似 Enable UDP 的本地化字符串。
/// </summary> /// </summary>
@@ -3076,6 +3157,123 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Sorting 的本地化字符串。
/// </summary>
public static string TbSorting {
get {
return ResourceManager.GetString("TbSorting", resourceCulture);
}
}
/// <summary>
/// 查找类似 Chain 的本地化字符串。
/// </summary>
public static string TbSortingChain {
get {
return ResourceManager.GetString("TbSortingChain", resourceCulture);
}
}
/// <summary>
/// 查找类似 Default 的本地化字符串。
/// </summary>
public static string TbSortingDefault {
get {
return ResourceManager.GetString("TbSortingDefault", resourceCulture);
}
}
/// <summary>
/// 查找类似 Delay 的本地化字符串。
/// </summary>
public static string TbSortingDelay {
get {
return ResourceManager.GetString("TbSortingDelay", resourceCulture);
}
}
/// <summary>
/// 查找类似 Download Speed 的本地化字符串。
/// </summary>
public static string TbSortingDownSpeed {
get {
return ResourceManager.GetString("TbSortingDownSpeed", resourceCulture);
}
}
/// <summary>
/// 查找类似 Download Traffic 的本地化字符串。
/// </summary>
public static string TbSortingDownTraffic {
get {
return ResourceManager.GetString("TbSortingDownTraffic", resourceCulture);
}
}
/// <summary>
/// 查找类似 Host 的本地化字符串。
/// </summary>
public static string TbSortingHost {
get {
return ResourceManager.GetString("TbSortingHost", resourceCulture);
}
}
/// <summary>
/// 查找类似 Name 的本地化字符串。
/// </summary>
public static string TbSortingName {
get {
return ResourceManager.GetString("TbSortingName", resourceCulture);
}
}
/// <summary>
/// 查找类似 Network 的本地化字符串。
/// </summary>
public static string TbSortingNetwork {
get {
return ResourceManager.GetString("TbSortingNetwork", resourceCulture);
}
}
/// <summary>
/// 查找类似 Time 的本地化字符串。
/// </summary>
public static string TbSortingTime {
get {
return ResourceManager.GetString("TbSortingTime", resourceCulture);
}
}
/// <summary>
/// 查找类似 Type 的本地化字符串。
/// </summary>
public static string TbSortingType {
get {
return ResourceManager.GetString("TbSortingType", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upload Speed 的本地化字符串。
/// </summary>
public static string TbSortingUpSpeed {
get {
return ResourceManager.GetString("TbSortingUpSpeed", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upload Traffic 的本地化字符串。
/// </summary>
public static string TbSortingUpTraffic {
get {
return ResourceManager.GetString("TbSortingUpTraffic", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 SpiderX 的本地化字符串。 /// 查找类似 SpiderX 的本地化字符串。
/// </summary> /// </summary>
@@ -3149,7 +3347,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 * After setting this value, an socks service will be started using sing-box to provide functions such as speed display 的本地化字符串。 /// 查找类似 * After setting this value, an socks service will be started using Xray/sing-box(Tun) to provide functions such as speed display 的本地化字符串。
/// </summary> /// </summary>
public static string TipPreSocksPort { public static string TipPreSocksPort {
get { get {
@@ -3157,15 +3355,6 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Too many servers, please open the main interface 的本地化字符串。
/// </summary>
public static string TooManyServersTip {
get {
return ResourceManager.GetString("TooManyServersTip", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 *tcp camouflage type 的本地化字符串。 /// 查找类似 *tcp camouflage type 的本地化字符串。
/// </summary> /// </summary>
@@ -3203,7 +3392,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *ws/httpupgrade path 的本地化字符串。 /// 查找类似 *ws/httpupgrade/splithttp path 的本地化字符串。
/// </summary> /// </summary>
public static string TransportPathTip1 { public static string TransportPathTip1 {
get { get {
@@ -3257,7 +3446,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *ws/httpupgrade host 的本地化字符串。 /// 查找类似 *ws/httpupgrade/splithttp host 的本地化字符串。
/// </summary> /// </summary>
public static string TransportRequestHostTip2 { public static string TransportRequestHostTip2 {
get { get {
@@ -3283,6 +3472,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 *grpc Authority 的本地化字符串。
/// </summary>
public static string TransportRequestHostTip5 {
get {
return ResourceManager.GetString("TransportRequestHostTip5", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Ungrouped 的本地化字符串。 /// 查找类似 Ungrouped 的本地化字符串。
/// </summary> /// </summary>

View File

@@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportSubscriptionSuccessfully" xml:space="preserve">
<value>صادرات دسته ای محتوای اشتراک به کلیپ بورد با موفقیت انجام شد</value>
</data>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>Batch export share URL to clipboard successfully</value> <value>Batch export share URL to clipboard successfully</value>
</data> </data>
@@ -159,9 +156,6 @@
<data name="FillCorrectServerPort" xml:space="preserve"> <data name="FillCorrectServerPort" xml:space="preserve">
<value>لطفا فرمت صحیح پورت سرور را پر کنید</value> <value>لطفا فرمت صحیح پورت سرور را پر کنید</value>
</data> </data>
<data name="FillKcpParameters" xml:space="preserve">
<value>لطفاً پارامترهای KCP را به درستی پر کنید</value>
</data>
<data name="FillLocalListeningPort" xml:space="preserve"> <data name="FillLocalListeningPort" xml:space="preserve">
<value>لطفاً پورت گوش دادن محلی را پر کنید</value> <value>لطفاً پورت گوش دادن محلی را پر کنید</value>
</data> </data>
@@ -174,15 +168,9 @@
<data name="FillUUID" xml:space="preserve"> <data name="FillUUID" xml:space="preserve">
<value>لطفا شناسه کاربری را وارد کنید</value> <value>لطفا شناسه کاربری را وارد کنید</value>
</data> </data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value>فایل پیکربندی مشتری صحیح نیست، لطفا بررسی کنید</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve"> <data name="Incorrectconfiguration" xml:space="preserve">
<value>پیکربندی درستی نیست، لطفا بررسی کنید</value> <value>پیکربندی درستی نیست، لطفا بررسی کنید</value>
</data> </data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value>فایل پیکربندی سرور صحیح نیست، لطفا بررسی کنید</value>
</data>
<data name="InitialConfiguration" xml:space="preserve"> <data name="InitialConfiguration" xml:space="preserve">
<value>پیکربندی اولیه</value> <value>پیکربندی اولیه</value>
</data> </data>
@@ -267,9 +255,6 @@
<data name="NonvmessOrssProtocol" xml:space="preserve"> <data name="NonvmessOrssProtocol" xml:space="preserve">
<value>Non-VMess or ss protocol</value> <value>Non-VMess or ss protocol</value>
</data> </data>
<data name="NonVmessService" xml:space="preserve">
<value> non-standard service, this feature is invalid</value>
</data>
<data name="NotFoundCore" xml:space="preserve"> <data name="NotFoundCore" xml:space="preserve">
<value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value> <value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value>
</data> </data>
@@ -415,15 +400,9 @@
<data name="FillServerAddressCustom" xml:space="preserve"> <data name="FillServerAddressCustom" xml:space="preserve">
<value>Please browse to import server configuration</value> <value>Please browse to import server configuration</value>
</data> </data>
<data name="SystemProxy" xml:space="preserve">
<value>پروکسی سیستم</value>
</data>
<data name="Speedtesting" xml:space="preserve"> <data name="Speedtesting" xml:space="preserve">
<value>درحال تست کردن...</value> <value>درحال تست کردن...</value>
</data> </data>
<data name="TooManyServersTip" xml:space="preserve">
<value>تعداد سرورها خیلی زیاد است، لطفا رابط اصلی را باز کنید</value>
</data>
<data name="LabLAN" xml:space="preserve"> <data name="LabLAN" xml:space="preserve">
<value>LAN</value> <value>LAN</value>
</data> </data>
@@ -541,18 +520,12 @@
<data name="menuTcpingServer" xml:space="preserve"> <data name="menuTcpingServer" xml:space="preserve">
<value>تست سرورها با tcping (Ctrl+O)</value> <value>تست سرورها با tcping (Ctrl+O)</value>
</data> </data>
<data name="menuTestMe" xml:space="preserve">
<value>وضعیت سرویس فعلی را تست کنید</value>
</data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>سرور انتخابی را برای پیکربندی کلاینت صادر کنید</value> <value>سرور انتخابی را برای پیکربندی کلاینت صادر کنید</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>URL های اشتراک گذاری را به کلیپ بورد صادر کنید (Ctrl+C)</value> <value>URL های اشتراک گذاری را به کلیپ بورد صادر کنید (Ctrl+C)</value>
</data> </data>
<data name="menuExport2SubContent" xml:space="preserve">
<value>اشتراک (base64) را به کلیپ بورد صادر کنید</value>
</data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>یک سرور پیکربندی سفارشی اضافه شود</value> <value>یک سرور پیکربندی سفارشی اضافه شود</value>
</data> </data>
@@ -583,9 +556,6 @@
<data name="menuMsgViewCopyAll" xml:space="preserve"> <data name="menuMsgViewCopyAll" xml:space="preserve">
<value>کپی همه</value> <value>کپی همه</value>
</data> </data>
<data name="menuMsgViewFilter" xml:space="preserve">
<value>فیلترهای پیام را تنظیم کنید</value>
</data>
<data name="menuMsgViewSelectAll" xml:space="preserve"> <data name="menuMsgViewSelectAll" xml:space="preserve">
<value>انتخاب همه (Ctrl+A)</value> <value>انتخاب همه (Ctrl+A)</value>
</data> </data>
@@ -698,7 +668,7 @@
<value>txtPreSocksPort</value> <value>txtPreSocksPort</value>
</data> </data>
<data name="TipPreSocksPort" xml:space="preserve"> <data name="TipPreSocksPort" xml:space="preserve">
<value>* After setting this value, an socks service will be started using sing-box to provide functions such as speed display</value> <value>* After setting this value, an socks service will be started using Xray/sing-box(Tun) to provide functions such as speed display</value>
</data> </data>
<data name="TbBrowse" xml:space="preserve"> <data name="TbBrowse" xml:space="preserve">
<value>Browse</value> <value>Browse</value>
@@ -955,6 +925,9 @@
<data name="TbSettingsRouteOnly" xml:space="preserve"> <data name="TbSettingsRouteOnly" xml:space="preserve">
<value>فقط مسیر</value> <value>فقط مسیر</value>
</data> </data>
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
<value>يەرلىك (Intranet) ئادرېسلارغا ۋاكالەتچى مۇلازىمېتىر ئىشلەتمەڭ</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve"> <data name="menuMixedTestServer" xml:space="preserve">
<value>One-click test Latency and speed (Ctrl+E)</value> <value>One-click test Latency and speed (Ctrl+E)</value>
</data> </data>
@@ -985,15 +958,6 @@
<data name="TbSettingsTunMode" xml:space="preserve"> <data name="TbSettingsTunMode" xml:space="preserve">
<value>تنظیمات TunMode</value> <value>تنظیمات TunMode</value>
</data> </data>
<data name="TbSettingsTunModeDirectIP" xml:space="preserve">
<value>Direct IP CIDR, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeDirectProcess" xml:space="preserve">
<value>Direct Process name, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
<value>نمایش کنسول</value>
</data>
<data name="TbSettingsDefUserAgent" xml:space="preserve"> <data name="TbSettingsDefUserAgent" xml:space="preserve">
<value>User-Agent</value> <value>User-Agent</value>
</data> </data>
@@ -1003,4 +967,70 @@
<data name="TbSettingsEnableHWA" xml:space="preserve"> <data name="TbSettingsEnableHWA" xml:space="preserve">
<value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value> <value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value>
</data> </data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>فعال کردن کش فایل مجموعه قوانین برای sing-box</value>
</data>
<data name="TbSorting" xml:space="preserve">
<value>مرتب سازی</value>
</data>
<data name="TbSortingDefault" xml:space="preserve">
<value>Default</value>
</data>
<data name="TbSortingDelay" xml:space="preserve">
<value>تاخیر</value>
</data>
<data name="TbSortingDownSpeed" xml:space="preserve">
<value>سرعت دانلود</value>
</data>
<data name="TbSortingDownTraffic" xml:space="preserve">
<value>ترافیک دانلود</value>
</data>
<data name="TbSortingName" xml:space="preserve">
<value>نام</value>
</data>
<data name="TbSortingTime" xml:space="preserve">
<value>زمان</value>
</data>
<data name="TbSortingUpSpeed" xml:space="preserve">
<value>سرعت اپلود</value>
</data>
<data name="TbSortingUpTraffic" xml:space="preserve">
<value>ترافیک آپلود</value>
</data>
<data name="TbConnections" xml:space="preserve">
<value>اتصالات</value>
</data>
<data name="menuConnectionClose" xml:space="preserve">
<value>بستن اتصال</value>
</data>
<data name="menuConnectionCloseAll" xml:space="preserve">
<value>تمام اتصالات را ببندید</value>
</data>
<data name="TbProxies" xml:space="preserve">
<value>پروکسی</value>
</data>
<data name="menuRulemode" xml:space="preserve">
<value>نوع قانون</value>
</data>
<data name="menuModeDirect" xml:space="preserve">
<value>Direct</value>
</data>
<data name="menuModeGlobal" xml:space="preserve">
<value>Global</value>
</data>
<data name="menuModeNothing" xml:space="preserve">
<value>تغییر نده</value>
</data>
<data name="menuModeRule" xml:space="preserve">
<value>قانون</value>
</data>
<data name="menuProxiesDelaytest" xml:space="preserve">
<value>Latency Test</value>
</data>
<data name="menuProxiesDelaytestPart" xml:space="preserve">
<value>Part Node Latency Test</value>
</data>
<data name="menuProxiesSelectActivity" xml:space="preserve">
<value>Select active node (Enter)</value>
</data>
</root> </root>

View File

@@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportSubscriptionSuccessfully" xml:space="preserve">
<value>Batch export subscription to clipboard successfully</value>
</data>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>Batch export share URL to clipboard successfully</value> <value>Batch export share URL to clipboard successfully</value>
</data> </data>
@@ -159,9 +156,6 @@
<data name="FillCorrectServerPort" xml:space="preserve"> <data name="FillCorrectServerPort" xml:space="preserve">
<value>Please fill in the correct format server port</value> <value>Please fill in the correct format server port</value>
</data> </data>
<data name="FillKcpParameters" xml:space="preserve">
<value>Please fill in the KCP parameters correctly</value>
</data>
<data name="FillLocalListeningPort" xml:space="preserve"> <data name="FillLocalListeningPort" xml:space="preserve">
<value>Please fill in the local listening port</value> <value>Please fill in the local listening port</value>
</data> </data>
@@ -174,15 +168,9 @@
<data name="FillUUID" xml:space="preserve"> <data name="FillUUID" xml:space="preserve">
<value>Please fill in the user ID</value> <value>Please fill in the user ID</value>
</data> </data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value>Is not the correct client configuration file, please check</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve"> <data name="Incorrectconfiguration" xml:space="preserve">
<value>Is not the correct configuration, please check</value> <value>Is not the correct configuration, please check</value>
</data> </data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value>Is not the correct server configuration file, please check</value>
</data>
<data name="InitialConfiguration" xml:space="preserve"> <data name="InitialConfiguration" xml:space="preserve">
<value>Initial Configuration</value> <value>Initial Configuration</value>
</data> </data>
@@ -253,10 +241,10 @@
<value>Is unpacking......</value> <value>Is unpacking......</value>
</data> </data>
<data name="MsgUpdateSubscriptionEnd" xml:space="preserve"> <data name="MsgUpdateSubscriptionEnd" xml:space="preserve">
<value>Update subscription end</value> <value>Update subscriptions end</value>
</data> </data>
<data name="MsgUpdateSubscriptionStart" xml:space="preserve"> <data name="MsgUpdateSubscriptionStart" xml:space="preserve">
<value>Update subscription starts</value> <value>Update subscriptions start</value>
</data> </data>
<data name="MsgUpdateV2rayCoreSuccessfully" xml:space="preserve"> <data name="MsgUpdateV2rayCoreSuccessfully" xml:space="preserve">
<value>Update Core successfully</value> <value>Update Core successfully</value>
@@ -267,9 +255,6 @@
<data name="NonvmessOrssProtocol" xml:space="preserve"> <data name="NonvmessOrssProtocol" xml:space="preserve">
<value>Non-VMess or ss protocol</value> <value>Non-VMess or ss protocol</value>
</data> </data>
<data name="NonVmessService" xml:space="preserve">
<value>Non-standard service, this feature is invalid</value>
</data>
<data name="NotFoundCore" xml:space="preserve"> <data name="NotFoundCore" xml:space="preserve">
<value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value> <value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value>
</data> </data>
@@ -359,7 +344,7 @@
<value>Please fill in the correct custom DNS</value> <value>Please fill in the correct custom DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value> <value>*ws/httpupgrade/splithttp path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -374,7 +359,7 @@
<value>*http host Separated by commas (,)</value> <value>*http host Separated by commas (,)</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value> <value>*ws/httpupgrade/splithttp host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host Separated by commas (,)</value> <value>*h2 host Separated by commas (,)</value>
@@ -415,15 +400,9 @@
<data name="FillServerAddressCustom" xml:space="preserve"> <data name="FillServerAddressCustom" xml:space="preserve">
<value>Please browse to import server configuration</value> <value>Please browse to import server configuration</value>
</data> </data>
<data name="SystemProxy" xml:space="preserve">
<value>System proxy</value>
</data>
<data name="Speedtesting" xml:space="preserve"> <data name="Speedtesting" xml:space="preserve">
<value>Testing...</value> <value>Testing...</value>
</data> </data>
<data name="TooManyServersTip" xml:space="preserve">
<value>Too many servers, please open the main interface</value>
</data>
<data name="LabLAN" xml:space="preserve"> <data name="LabLAN" xml:space="preserve">
<value>LAN</value> <value>LAN</value>
</data> </data>
@@ -473,16 +452,16 @@
<value>Update current subscription with proxy</value> <value>Update current subscription with proxy</value>
</data> </data>
<data name="menuSubscription" xml:space="preserve"> <data name="menuSubscription" xml:space="preserve">
<value>Subscription group</value> <value>Subscription Group</value>
</data> </data>
<data name="menuSubSetting" xml:space="preserve"> <data name="menuSubSetting" xml:space="preserve">
<value>Subscription group settings</value> <value>Subscription group settings</value>
</data> </data>
<data name="menuSubUpdate" xml:space="preserve"> <data name="menuSubUpdate" xml:space="preserve">
<value>Update subscription without proxy</value> <value>Update subscriptions without proxy</value>
</data> </data>
<data name="menuSubUpdateViaProxy" xml:space="preserve"> <data name="menuSubUpdateViaProxy" xml:space="preserve">
<value>Update subscription with proxy</value> <value>Update subscriptions with proxy</value>
</data> </data>
<data name="menuSystemproxy" xml:space="preserve"> <data name="menuSystemproxy" xml:space="preserve">
<value>System proxy</value> <value>System proxy</value>
@@ -544,18 +523,12 @@
<data name="menuTcpingServer" xml:space="preserve"> <data name="menuTcpingServer" xml:space="preserve">
<value>Test servers with tcping (Ctrl+O)</value> <value>Test servers with tcping (Ctrl+O)</value>
</data> </data>
<data name="menuTestMe" xml:space="preserve">
<value>Test current service status</value>
</data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>Export selected server for client configuration</value> <value>Export selected server for client configuration</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>Export share URLs to clipboard (Ctrl+C)</value> <value>Export share URLs to clipboard (Ctrl+C)</value>
</data> </data>
<data name="menuExport2SubContent" xml:space="preserve">
<value>Export subscription (base64) share to clipboard</value>
</data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>Add a custom configuration server</value> <value>Add a custom configuration server</value>
</data> </data>
@@ -586,9 +559,6 @@
<data name="menuMsgViewCopyAll" xml:space="preserve"> <data name="menuMsgViewCopyAll" xml:space="preserve">
<value>Copy all</value> <value>Copy all</value>
</data> </data>
<data name="menuMsgViewFilter" xml:space="preserve">
<value>Set message filters</value>
</data>
<data name="menuMsgViewSelectAll" xml:space="preserve"> <data name="menuMsgViewSelectAll" xml:space="preserve">
<value>Select all (Ctrl+A)</value> <value>Select all (Ctrl+A)</value>
</data> </data>
@@ -605,7 +575,7 @@
<value>Share</value> <value>Share</value>
</data> </data>
<data name="LvEnabled" xml:space="preserve"> <data name="LvEnabled" xml:space="preserve">
<value>Enabled Update</value> <value>Enable update</value>
</data> </data>
<data name="LvSort" xml:space="preserve"> <data name="LvSort" xml:space="preserve">
<value>Sort</value> <value>Sort</value>
@@ -701,7 +671,7 @@
<value>txtPreSocksPort</value> <value>txtPreSocksPort</value>
</data> </data>
<data name="TipPreSocksPort" xml:space="preserve"> <data name="TipPreSocksPort" xml:space="preserve">
<value>* After setting this value, an socks service will be started using sing-box to provide functions such as speed display</value> <value>* After setting this value, an socks service will be started using Xray/sing-box(Tun) to provide functions such as speed display</value>
</data> </data>
<data name="TbBrowse" xml:space="preserve"> <data name="TbBrowse" xml:space="preserve">
<value>Browse</value> <value>Browse</value>
@@ -947,7 +917,7 @@
<value>Support DnsObject, Click to view the document</value> <value>Support DnsObject, Click to view the document</value>
</data> </data>
<data name="SubUrlTips" xml:space="preserve"> <data name="SubUrlTips" xml:space="preserve">
<value>Group please leave blank here</value> <value>For group please leave blank here</value>
</data> </data>
<data name="TipChangeRouting" xml:space="preserve"> <data name="TipChangeRouting" xml:space="preserve">
<value>Routing setting is changed</value> <value>Routing setting is changed</value>
@@ -958,6 +928,9 @@
<data name="TbSettingsRouteOnly" xml:space="preserve"> <data name="TbSettingsRouteOnly" xml:space="preserve">
<value>RouteOnly</value> <value>RouteOnly</value>
</data> </data>
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
<value>Do not use proxy servers for local (intranet) addresses</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve"> <data name="menuMixedTestServer" xml:space="preserve">
<value>One-click multi test Latency and speed (Ctrl+E)</value> <value>One-click multi test Latency and speed (Ctrl+E)</value>
</data> </data>
@@ -988,21 +961,9 @@
<data name="TbSettingsTunMode" xml:space="preserve"> <data name="TbSettingsTunMode" xml:space="preserve">
<value>TunMode settings</value> <value>TunMode settings</value>
</data> </data>
<data name="TbSettingsTunModeDirectIP" xml:space="preserve">
<value>Direct IP CIDR, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeDirectProcess" xml:space="preserve">
<value>Direct Process name, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
<value>Show console</value>
</data>
<data name="menuMoveToGroup" xml:space="preserve"> <data name="menuMoveToGroup" xml:space="preserve">
<value>Move to group</value> <value>Move to group</value>
</data> </data>
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>Custom Template</value>
</data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve"> <data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>Enable Server Drag Drop Sort(Require restart)</value> <value>Enable Server Drag Drop Sort(Require restart)</value>
</data> </data>
@@ -1037,7 +998,7 @@
<value>Copy the font TTF/TTC file to the directory guiFonts, restart the settings</value> <value>Copy the font TTF/TTC file to the directory guiFonts, restart the settings</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve"> <data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>HTTP port=SOCKS port+1;Pac port=SOCKS port+4;API port=SOCKS port+5;</value> <value>http port = +1; Pac port = +4; *ray API port = +5; mihomo API port = +6;</value>
</data> </data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>Set this with admin privileges, get admin privileges after startup</value> <value>Set this with admin privileges, get admin privileges after startup</value>
@@ -1045,24 +1006,12 @@
<data name="TbSettingsFontSize" xml:space="preserve"> <data name="TbSettingsFontSize" xml:space="preserve">
<value>Font Size</value> <value>Font Size</value>
</data> </data>
<data name="TbSettingsTunModeProxyIP" xml:space="preserve">
<value>Proxy IP CIDR, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeProxyProcess" xml:space="preserve">
<value>Proxy Process name, separated by commas (,)</value>
</data>
<data name="TbSettingsTunModeBypassMode" xml:space="preserve">
<value>Bypass Mode</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve"> <data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>SpeedTest Single Timeout Value</value> <value>SpeedTest Single Timeout Value</value>
</data> </data>
<data name="TbSettingsSpeedTestUrl" xml:space="preserve"> <data name="TbSettingsSpeedTestUrl" xml:space="preserve">
<value>SpeedTest URL</value> <value>SpeedTest URL</value>
</data> </data>
<data name="TbSettingsTunModeDNS" xml:space="preserve">
<value>DNS object, e.g. {"servers":[]}</value>
</data>
<data name="menuMoveTo" xml:space="preserve"> <data name="menuMoveTo" xml:space="preserve">
<value>Move up and down</value> <value>Move up and down</value>
</data> </data>
@@ -1091,13 +1040,13 @@
<value>Restart as Administrator</value> <value>Restart as Administrator</value>
</data> </data>
<data name="LvMoreUrl" xml:space="preserve"> <data name="LvMoreUrl" xml:space="preserve">
<value>More urls, separated by commas;Subscription conversion will be invalid</value> <value>More URLs, separated by commas; Subscription conversion will be invalid</value>
</data> </data>
<data name="SpeedDisplayText" xml:space="preserve"> <data name="SpeedDisplayText" xml:space="preserve">
<value>{0} : {1}/s↑ | {2}/s↓</value> <value>{0} : {1}/s↑ | {2}/s↓</value>
</data> </data>
<data name="LvAutoUpdateInterval" xml:space="preserve"> <data name="LvAutoUpdateInterval" xml:space="preserve">
<value>Automatic update interval(minutes)</value> <value>Automatic update interval (minutes)</value>
</data> </data>
<data name="TbSettingsLogEnabledToFile" xml:space="preserve"> <data name="TbSettingsLogEnabledToFile" xml:space="preserve">
<value>Enable logging to file</value> <value>Enable logging to file</value>
@@ -1195,4 +1144,121 @@
<data name="SpeedtestingStop" xml:space="preserve"> <data name="SpeedtestingStop" xml:space="preserve">
<value>Test terminating...</value> <value>Test terminating...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value>
</data>
<data name="menuAddHttpServer" xml:space="preserve">
<value>Add [Http] server</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>Use Xray and enable non-Tun mode, which conflicts with the group previous proxy</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>Enable fragment</value>
</data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>Enable cache file for sing-box (ruleset files)</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>Custom the rule-set of sing-box</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>Successful operation. Click the settings menu to reboot the app.</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>Open the storage location</value>
</data>
<data name="TbSorting" xml:space="preserve">
<value>Sorting</value>
</data>
<data name="TbSortingChain" xml:space="preserve">
<value>Chain</value>
</data>
<data name="TbSortingDefault" xml:space="preserve">
<value>Default</value>
</data>
<data name="TbSortingDelay" xml:space="preserve">
<value>Delay</value>
</data>
<data name="TbSortingDownSpeed" xml:space="preserve">
<value>Download Speed</value>
</data>
<data name="TbSortingDownTraffic" xml:space="preserve">
<value>Download Traffic</value>
</data>
<data name="TbSortingHost" xml:space="preserve">
<value>Host</value>
</data>
<data name="TbSortingName" xml:space="preserve">
<value>Name</value>
</data>
<data name="TbSortingNetwork" xml:space="preserve">
<value>Network</value>
</data>
<data name="TbSortingTime" xml:space="preserve">
<value>Time</value>
</data>
<data name="TbSortingType" xml:space="preserve">
<value>Type</value>
</data>
<data name="TbSortingUpSpeed" xml:space="preserve">
<value>Upload Speed</value>
</data>
<data name="TbSortingUpTraffic" xml:space="preserve">
<value>Upload Traffic</value>
</data>
<data name="TbConnections" xml:space="preserve">
<value>Connections</value>
</data>
<data name="menuConnectionClose" xml:space="preserve">
<value>Close Connection</value>
</data>
<data name="menuConnectionCloseAll" xml:space="preserve">
<value>Close All Connection</value>
</data>
<data name="TbProxies" xml:space="preserve">
<value>Proxies</value>
</data>
<data name="menuRulemode" xml:space="preserve">
<value>Rule mode</value>
</data>
<data name="menuModeDirect" xml:space="preserve">
<value>Direct</value>
</data>
<data name="menuModeGlobal" xml:space="preserve">
<value>Global</value>
</data>
<data name="menuModeNothing" xml:space="preserve">
<value>Do not change</value>
</data>
<data name="menuModeRule" xml:space="preserve">
<value>Rule</value>
</data>
<data name="menuProxiesDelaytest" xml:space="preserve">
<value>Latency Test</value>
</data>
<data name="menuProxiesDelaytestPart" xml:space="preserve">
<value>Part Node Latency Test</value>
</data>
<data name="menuProxiesReload" xml:space="preserve">
<value>Refresh Proxies</value>
</data>
<data name="menuProxiesSelectActivity" xml:space="preserve">
<value>Select active node (Enter)</value>
</data>
<data name="TbSettingsDomainStrategy4Out" xml:space="preserve">
<value>Default domain strategy for outbound</value>
</data>
<data name="menuSetDefaultMultipleServer" xml:space="preserve">
<value>Multi-Server lowest latency</value>
</data>
<data name="TbSettingsMainGirdOrientation" xml:space="preserve">
<value>Main layout orientation(Require restart)</value>
</data>
<data name="menuSetDefaultLoadBalanceServer" xml:space="preserve">
<value>Multi-server load balancing</value>
</data>
<data name="TbSettingsDomainDNSAddress" xml:space="preserve">
<value>Outbound DNS address</value>
</data>
</root> </root>

View File

@@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportSubscriptionSuccessfully" xml:space="preserve">
<value>Экспортирование подписок в буфер обмена успешно завершено</value>
</data>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>Экспортирование URL в буфер обмена успешно завершено</value> <value>Экспортирование URL в буфер обмена успешно завершено</value>
</data> </data>
@@ -159,9 +156,6 @@
<data name="FillCorrectServerPort" xml:space="preserve"> <data name="FillCorrectServerPort" xml:space="preserve">
<value>Пожалуйста, укажите порт сервера в правильном формате</value> <value>Пожалуйста, укажите порт сервера в правильном формате</value>
</data> </data>
<data name="FillKcpParameters" xml:space="preserve">
<value>Пожалуйста, заполните параметры KCP корректно</value>
</data>
<data name="FillLocalListeningPort" xml:space="preserve"> <data name="FillLocalListeningPort" xml:space="preserve">
<value>Пожалуйста, укажите локальный порт прослушивания</value> <value>Пожалуйста, укажите локальный порт прослушивания</value>
</data> </data>
@@ -174,15 +168,9 @@
<data name="FillUUID" xml:space="preserve"> <data name="FillUUID" xml:space="preserve">
<value>Пожалуйста, заполните идентификатор пользователя</value> <value>Пожалуйста, заполните идентификатор пользователя</value>
</data> </data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value>Некорректный файл конфигурации клиента, пожалуйста, проверьте</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve"> <data name="Incorrectconfiguration" xml:space="preserve">
<value>Некорректная конфигурация, пожалуйста, проверьте</value> <value>Некорректная конфигурация, пожалуйста, проверьте</value>
</data> </data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value>Некорректный файл конфигурации сервера, пожалуйста, проверьте</value>
</data>
<data name="InitialConfiguration" xml:space="preserve"> <data name="InitialConfiguration" xml:space="preserve">
<value>Исходная конфигурация</value> <value>Исходная конфигурация</value>
</data> </data>
@@ -267,9 +255,6 @@
<data name="NonvmessOrssProtocol" xml:space="preserve"> <data name="NonvmessOrssProtocol" xml:space="preserve">
<value>Не является протоколом Vmess или SS</value> <value>Не является протоколом Vmess или SS</value>
</data> </data>
<data name="NonVmessService" xml:space="preserve">
<value> нестандартный сервис, эта функция недействительна</value>
</data>
<data name="NotFoundCore" xml:space="preserve"> <data name="NotFoundCore" xml:space="preserve">
<value>Файл Core (имя файла: {1}) не найден в папке ({0}), загрузите и поместите его в папку, адрес загрузки: {2}</value> <value>Файл Core (имя файла: {1}) не найден в папке ({0}), загрузите и поместите его в папку, адрес загрузки: {2}</value>
</data> </data>
@@ -415,15 +400,9 @@
<data name="FillServerAddressCustom" xml:space="preserve"> <data name="FillServerAddressCustom" xml:space="preserve">
<value>Пожалуйста, просмотрите, чтобы импортировать конфигурацию сервера</value> <value>Пожалуйста, просмотрите, чтобы импортировать конфигурацию сервера</value>
</data> </data>
<data name="SystemProxy" xml:space="preserve">
<value>Системный прокси</value>
</data>
<data name="Speedtesting" xml:space="preserve"> <data name="Speedtesting" xml:space="preserve">
<value>Тестирование...</value> <value>Тестирование...</value>
</data> </data>
<data name="TooManyServersTip" xml:space="preserve">
<value>Слишком много серверов, пожалуйста, откройте главный интерфейс</value>
</data>
<data name="LabLAN" xml:space="preserve"> <data name="LabLAN" xml:space="preserve">
<value>LAN</value> <value>LAN</value>
</data> </data>
@@ -544,18 +523,12 @@
<data name="menuTcpingServer" xml:space="preserve"> <data name="menuTcpingServer" xml:space="preserve">
<value>Тест задержки с tcping (Ctrl+O)</value> <value>Тест задержки с tcping (Ctrl+O)</value>
</data> </data>
<data name="menuTestMe" xml:space="preserve">
<value>Проверить текущий статус службы</value>
</data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>Экспортировать выбранный сервер для клиента</value> <value>Экспортировать выбранный сервер для клиента</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>Экспорт URL-адресов общего доступа в буфер обмена (Ctrl+C)</value> <value>Экспорт URL-адресов общего доступа в буфер обмена (Ctrl+C)</value>
</data> </data>
<data name="menuExport2SubContent" xml:space="preserve">
<value>Экспортировать ссылку-подписку (base64) в буфер обмена</value>
</data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>Добавить сервер пользовательской конфигурации</value> <value>Добавить сервер пользовательской конфигурации</value>
</data> </data>
@@ -586,9 +559,6 @@
<data name="menuMsgViewCopyAll" xml:space="preserve"> <data name="menuMsgViewCopyAll" xml:space="preserve">
<value>Скопировать все</value> <value>Скопировать все</value>
</data> </data>
<data name="menuMsgViewFilter" xml:space="preserve">
<value>Установить фильтры сообщений</value>
</data>
<data name="menuMsgViewSelectAll" xml:space="preserve"> <data name="menuMsgViewSelectAll" xml:space="preserve">
<value>Выбрать все (Ctrl+A)</value> <value>Выбрать все (Ctrl+A)</value>
</data> </data>
@@ -701,7 +671,7 @@
<value>txtPreSocksPort</value> <value>txtPreSocksPort</value>
</data> </data>
<data name="TipPreSocksPort" xml:space="preserve"> <data name="TipPreSocksPort" xml:space="preserve">
<value>* После установки этого значения служба socks будет запущена с использованием sing-box для обеспечения таких функций, как отображение скорости</value> <value>* После установки этого значения служба socks будет запущена с использованием Xray/sing-box(Tun) для обеспечения таких функций, как отображение скорости</value>
</data> </data>
<data name="TbBrowse" xml:space="preserve"> <data name="TbBrowse" xml:space="preserve">
<value>Просмотр</value> <value>Просмотр</value>
@@ -964,6 +934,9 @@
<data name="TbSettingsRouteOnly" xml:space="preserve"> <data name="TbSettingsRouteOnly" xml:space="preserve">
<value>Только маршрут</value> <value>Только маршрут</value>
</data> </data>
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
<value>Не используйте прокси-серверы для локальных (интранет) адресов</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve"> <data name="menuMixedTestServer" xml:space="preserve">
<value>Тест задержки и скорости всех серверов (Ctrl+E)</value> <value>Тест задержки и скорости всех серверов (Ctrl+E)</value>
</data> </data>
@@ -994,21 +967,9 @@
<data name="TbSettingsTunMode" xml:space="preserve"> <data name="TbSettingsTunMode" xml:space="preserve">
<value>Настройки TunMode</value> <value>Настройки TunMode</value>
</data> </data>
<data name="TbSettingsTunModeDirectIP" xml:space="preserve">
<value>Прямой IP CIDR, разделенный запятыми (,)</value>
</data>
<data name="TbSettingsTunModeDirectProcess" xml:space="preserve">
<value>Имя процесса, разделенное запятыми (,)</value>
</data>
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
<value>Показать консоль</value>
</data>
<data name="menuMoveToGroup" xml:space="preserve"> <data name="menuMoveToGroup" xml:space="preserve">
<value>Перейти в группу</value> <value>Перейти в группу</value>
</data> </data>
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>Пользовательский шаблон</value>
</data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve"> <data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>Включить сортировку перетаскиванием сервера (требуется перезагрузка)</value> <value>Включить сортировку перетаскиванием сервера (требуется перезагрузка)</value>
</data> </data>
@@ -1042,9 +1003,6 @@
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve"> <data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
<value>Скопируйте файл шрифта TTF/TTC в каталог guiFonts, перезапустите настройки</value> <value>Скопируйте файл шрифта TTF/TTC в каталог guiFonts, перезапустите настройки</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>HTTP port=socks port+1</value>
</data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>Установите это с правами администратора</value> <value>Установите это с правами администратора</value>
</data> </data>

View File

@@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportSubscriptionSuccessfully" xml:space="preserve">
<value>批量导出订阅内容至剪贴板成功</value>
</data>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>批量导出分享URL至剪贴板成功</value> <value>批量导出分享URL至剪贴板成功</value>
</data> </data>
@@ -159,9 +156,6 @@
<data name="FillCorrectServerPort" xml:space="preserve"> <data name="FillCorrectServerPort" xml:space="preserve">
<value>请填写正确格式服务器端口</value> <value>请填写正确格式服务器端口</value>
</data> </data>
<data name="FillKcpParameters" xml:space="preserve">
<value>请正确填写KCP参数</value>
</data>
<data name="FillLocalListeningPort" xml:space="preserve"> <data name="FillLocalListeningPort" xml:space="preserve">
<value>请填写本地监听端口</value> <value>请填写本地监听端口</value>
</data> </data>
@@ -174,15 +168,9 @@
<data name="FillUUID" xml:space="preserve"> <data name="FillUUID" xml:space="preserve">
<value>请填写用户ID</value> <value>请填写用户ID</value>
</data> </data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value>不是正确的客户端配置文件,请检查</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve"> <data name="Incorrectconfiguration" xml:space="preserve">
<value>不是正确的配置,请检查</value> <value>不是正确的配置,请检查</value>
</data> </data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value>不是正确的服务端配置文件,请检查</value>
</data>
<data name="InitialConfiguration" xml:space="preserve"> <data name="InitialConfiguration" xml:space="preserve">
<value>初始化配置</value> <value>初始化配置</value>
</data> </data>
@@ -267,9 +255,6 @@
<data name="NonvmessOrssProtocol" xml:space="preserve"> <data name="NonvmessOrssProtocol" xml:space="preserve">
<value>非VMess或ss协议</value> <value>非VMess或ss协议</value>
</data> </data>
<data name="NonVmessService" xml:space="preserve">
<value>非标准服务,此功能无效</value>
</data>
<data name="NotFoundCore" xml:space="preserve"> <data name="NotFoundCore" xml:space="preserve">
<value>在文件夹 ({0}) 下未找到Core文件 (文件名:{1}),请下载后放入文件夹,下载地址: {2}</value> <value>在文件夹 ({0}) 下未找到Core文件 (文件名:{1}),请下载后放入文件夹,下载地址: {2}</value>
</data> </data>
@@ -359,7 +344,7 @@
<value>请填写正确的自定义DNS</value> <value>请填写正确的自定义DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value> <value>*ws/httpupgrade/splithttp path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -374,7 +359,7 @@
<value>*http host中间逗号(,)分隔</value> <value>*http host中间逗号(,)分隔</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value> <value>*ws/httpupgrade/splithttp host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中间逗号(,)分隔</value> <value>*h2 host中间逗号(,)分隔</value>
@@ -415,15 +400,9 @@
<data name="FillServerAddressCustom" xml:space="preserve"> <data name="FillServerAddressCustom" xml:space="preserve">
<value>请浏览导入服务器配置</value> <value>请浏览导入服务器配置</value>
</data> </data>
<data name="SystemProxy" xml:space="preserve">
<value>系统代理</value>
</data>
<data name="Speedtesting" xml:space="preserve"> <data name="Speedtesting" xml:space="preserve">
<value>测试中...</value> <value>测试中...</value>
</data> </data>
<data name="TooManyServersTip" xml:space="preserve">
<value>服务器太多,请打开主界面操作</value>
</data>
<data name="LabLAN" xml:space="preserve"> <data name="LabLAN" xml:space="preserve">
<value>局域网</value> <value>局域网</value>
</data> </data>
@@ -544,18 +523,12 @@
<data name="menuTcpingServer" xml:space="preserve"> <data name="menuTcpingServer" xml:space="preserve">
<value>测试服务器延迟Tcping(多选) (Ctrl+O)</value> <value>测试服务器延迟Tcping(多选) (Ctrl+O)</value>
</data> </data>
<data name="menuTestMe" xml:space="preserve">
<value>测试当前服务状态</value>
</data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>导出所选服务器为客户端配置</value> <value>导出所选服务器为客户端配置</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>批量导出分享URL至剪贴板(多选) (Ctrl+C)</value> <value>批量导出分享URL至剪贴板(多选) (Ctrl+C)</value>
</data> </data>
<data name="menuExport2SubContent" xml:space="preserve">
<value>批量导出订阅内容至剪贴板(多选)</value>
</data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>添加自定义配置服务器</value> <value>添加自定义配置服务器</value>
</data> </data>
@@ -586,9 +559,6 @@
<data name="menuMsgViewCopyAll" xml:space="preserve"> <data name="menuMsgViewCopyAll" xml:space="preserve">
<value>复制所有</value> <value>复制所有</value>
</data> </data>
<data name="menuMsgViewFilter" xml:space="preserve">
<value>设置信息过滤器</value>
</data>
<data name="menuMsgViewSelectAll" xml:space="preserve"> <data name="menuMsgViewSelectAll" xml:space="preserve">
<value>全选 (Ctrl+A)</value> <value>全选 (Ctrl+A)</value>
</data> </data>
@@ -701,7 +671,7 @@
<value>Socks端口</value> <value>Socks端口</value>
</data> </data>
<data name="TipPreSocksPort" xml:space="preserve"> <data name="TipPreSocksPort" xml:space="preserve">
<value>* 自定义配置的Socks端口值可不设置当设置此值后将使用sing-box额外启动一个前置Socks服务提供分流和速度显示等功能</value> <value>* 自定义配置的Socks端口值可不设置当设置此值后将使用Xray/sing-box(Tun)额外启动一个前置Socks服务提供分流和速度显示等功能</value>
</data> </data>
<data name="TbBrowse" xml:space="preserve"> <data name="TbBrowse" xml:space="preserve">
<value>浏览</value> <value>浏览</value>
@@ -958,6 +928,9 @@
<data name="TbSettingsRouteOnly" xml:space="preserve"> <data name="TbSettingsRouteOnly" xml:space="preserve">
<value>RouteOnly</value> <value>RouteOnly</value>
</data> </data>
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
<value>请勿将代理服务器用于本地Intranet地址</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve"> <data name="menuMixedTestServer" xml:space="preserve">
<value>一键多线程测试延迟和速度 (Ctrl+E)</value> <value>一键多线程测试延迟和速度 (Ctrl+E)</value>
</data> </data>
@@ -988,21 +961,9 @@
<data name="TbSettingsTunMode" xml:space="preserve"> <data name="TbSettingsTunMode" xml:space="preserve">
<value>Tun模式设置</value> <value>Tun模式设置</value>
</data> </data>
<data name="TbSettingsTunModeDirectIP" xml:space="preserve">
<value>直连的IP CIDR用逗号(,)分隔</value>
</data>
<data name="TbSettingsTunModeDirectProcess" xml:space="preserve">
<value>直连的进程名,用逗号(,)分隔</value>
</data>
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
<value>显示控制台</value>
</data>
<data name="menuMoveToGroup" xml:space="preserve"> <data name="menuMoveToGroup" xml:space="preserve">
<value>移至订阅分组</value> <value>移至订阅分组</value>
</data> </data>
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>自定义配置模板</value>
</data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve"> <data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>启用服务器拖放排序(需重启)</value> <value>启用服务器拖放排序(需重启)</value>
</data> </data>
@@ -1037,7 +998,7 @@
<value>拷贝字体TTF/TTC文件到目录guiFonts重启设置</value> <value>拷贝字体TTF/TTC文件到目录guiFonts重启设置</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve"> <data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>http端口=socks端口+1Pac端口=socks端口+4API端口=socks端口+5</value> <value>http端口= +1Pac端口= +4*ray API端口= +5mihomo API端口= +6</value>
</data> </data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>以管理员权限设置此项,在启动后获得管理员权限</value> <value>以管理员权限设置此项,在启动后获得管理员权限</value>
@@ -1045,24 +1006,12 @@
<data name="TbSettingsFontSize" xml:space="preserve"> <data name="TbSettingsFontSize" xml:space="preserve">
<value>字体大小</value> <value>字体大小</value>
</data> </data>
<data name="TbSettingsTunModeProxyIP" xml:space="preserve">
<value>代理的IP CIDR用逗号(,)分隔</value>
</data>
<data name="TbSettingsTunModeProxyProcess" xml:space="preserve">
<value>代理的进程名,用逗号(,)分隔</value>
</data>
<data name="TbSettingsTunModeBypassMode" xml:space="preserve">
<value>绕行模式</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve"> <data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>测速单个超时值</value> <value>测速单个超时值</value>
</data> </data>
<data name="TbSettingsSpeedTestUrl" xml:space="preserve"> <data name="TbSettingsSpeedTestUrl" xml:space="preserve">
<value>测速文件地址</value> <value>测速文件地址</value>
</data> </data>
<data name="TbSettingsTunModeDNS" xml:space="preserve">
<value>DNS对象例如 {"servers":[]}</value>
</data>
<data name="menuMoveTo" xml:space="preserve"> <data name="menuMoveTo" xml:space="preserve">
<value>移至上下</value> <value>移至上下</value>
</data> </data>
@@ -1192,4 +1141,121 @@
<data name="SpeedtestingStop" xml:space="preserve"> <data name="SpeedtestingStop" xml:space="preserve">
<value>测试终止中...</value> <value>测试终止中...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value>
</data>
<data name="menuAddHttpServer" xml:space="preserve">
<value>添加[Http]服务器</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>启用分片Fragment</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式启用和分组前置代理冲突</value>
</data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>启用sing-box规则集文件的缓存文件</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>自定义sing-box rule-set</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>操作成功。请点击设置菜单重启应用。</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>打开存储所在的位置</value>
</data>
<data name="TbSorting" xml:space="preserve">
<value>排序</value>
</data>
<data name="TbSortingChain" xml:space="preserve">
<value>路由链</value>
</data>
<data name="TbSortingDefault" xml:space="preserve">
<value>默认</value>
</data>
<data name="TbSortingDelay" xml:space="preserve">
<value>延迟</value>
</data>
<data name="TbSortingDownSpeed" xml:space="preserve">
<value>下载速度</value>
</data>
<data name="TbSortingDownTraffic" xml:space="preserve">
<value>下载流量</value>
</data>
<data name="TbSortingHost" xml:space="preserve">
<value>主机</value>
</data>
<data name="TbSortingName" xml:space="preserve">
<value>名称</value>
</data>
<data name="TbSortingNetwork" xml:space="preserve">
<value>网络</value>
</data>
<data name="TbSortingTime" xml:space="preserve">
<value>时间</value>
</data>
<data name="TbSortingType" xml:space="preserve">
<value>类型</value>
</data>
<data name="TbSortingUpSpeed" xml:space="preserve">
<value>上传速度</value>
</data>
<data name="TbSortingUpTraffic" xml:space="preserve">
<value>上传流量</value>
</data>
<data name="TbConnections" xml:space="preserve">
<value>当前连接</value>
</data>
<data name="menuConnectionClose" xml:space="preserve">
<value>关闭连接</value>
</data>
<data name="menuConnectionCloseAll" xml:space="preserve">
<value>关闭所有连接</value>
</data>
<data name="TbProxies" xml:space="preserve">
<value>当前代理</value>
</data>
<data name="menuRulemode" xml:space="preserve">
<value>规则模式</value>
</data>
<data name="menuModeDirect" xml:space="preserve">
<value>直连</value>
</data>
<data name="menuModeGlobal" xml:space="preserve">
<value>全局</value>
</data>
<data name="menuModeNothing" xml:space="preserve">
<value>随原配置</value>
</data>
<data name="menuModeRule" xml:space="preserve">
<value>规则</value>
</data>
<data name="menuProxiesDelaytest" xml:space="preserve">
<value>延迟测试</value>
</data>
<data name="menuProxiesDelaytestPart" xml:space="preserve">
<value>当前部分节点延迟测试</value>
</data>
<data name="menuProxiesReload" xml:space="preserve">
<value>刷新</value>
</data>
<data name="menuProxiesSelectActivity" xml:space="preserve">
<value>设为活动节点 (Enter)</value>
</data>
<data name="TbSettingsDomainStrategy4Out" xml:space="preserve">
<value>Outbound默认解析策略</value>
</data>
<data name="menuSetDefaultMultipleServer" xml:space="preserve">
<value>多服务器最低延迟 (多选)</value>
</data>
<data name="TbSettingsMainGirdOrientation" xml:space="preserve">
<value>主界面布局方向(需重启)</value>
</data>
<data name="menuSetDefaultLoadBalanceServer" xml:space="preserve">
<value>多服务器负载均衡 (多选)</value>
</data>
<data name="TbSettingsDomainDNSAddress" xml:space="preserve">
<value>Outbound域名解析地址</value>
</data>
</root> </root>

View File

@@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportSubscriptionSuccessfully" xml:space="preserve">
<value>批次匯出訂閱內容至剪貼簿成功</value>
</data>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>批次匯出分享URL至剪貼簿成功</value> <value>批次匯出分享URL至剪貼簿成功</value>
</data> </data>
@@ -159,9 +156,6 @@
<data name="FillCorrectServerPort" xml:space="preserve"> <data name="FillCorrectServerPort" xml:space="preserve">
<value>請填寫正確格式伺服器埠</value> <value>請填寫正確格式伺服器埠</value>
</data> </data>
<data name="FillKcpParameters" xml:space="preserve">
<value>請正確填寫KCP參數</value>
</data>
<data name="FillLocalListeningPort" xml:space="preserve"> <data name="FillLocalListeningPort" xml:space="preserve">
<value>請填寫本機監聽埠</value> <value>請填寫本機監聽埠</value>
</data> </data>
@@ -174,15 +168,9 @@
<data name="FillUUID" xml:space="preserve"> <data name="FillUUID" xml:space="preserve">
<value>請填寫使用者ID</value> <value>請填寫使用者ID</value>
</data> </data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value>不是正確的用戶端配置檔案,請檢查</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve"> <data name="Incorrectconfiguration" xml:space="preserve">
<value>不是正確的配置,請檢查</value> <value>不是正確的配置,請檢查</value>
</data> </data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value>不是正確的服務端配置檔案,請檢查</value>
</data>
<data name="InitialConfiguration" xml:space="preserve"> <data name="InitialConfiguration" xml:space="preserve">
<value>初始化配置</value> <value>初始化配置</value>
</data> </data>
@@ -267,9 +255,6 @@
<data name="NonvmessOrssProtocol" xml:space="preserve"> <data name="NonvmessOrssProtocol" xml:space="preserve">
<value>非VMess或SS協定</value> <value>非VMess或SS協定</value>
</data> </data>
<data name="NonVmessService" xml:space="preserve">
<value>非標準服務,此功能無效</value>
</data>
<data name="NotFoundCore" xml:space="preserve"> <data name="NotFoundCore" xml:space="preserve">
<value>在資料夾 ({0}) 下未找到Core文件 (檔案名:{1}),請下載後放入資料夾、,下載網址: {2}</value> <value>在資料夾 ({0}) 下未找到Core文件 (檔案名:{1}),請下載後放入資料夾、,下載網址: {2}</value>
</data> </data>
@@ -358,7 +343,7 @@
<value>請填寫正確的自訂DNS</value> <value>請填寫正確的自訂DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value> <value>*ws/httpupgrade/splithttp path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -373,7 +358,7 @@
<value>*http host中間逗號(,)分隔</value> <value>*http host中間逗號(,)分隔</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value> <value>*ws/httpupgrade/splithttp host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中間逗號(,)分隔</value> <value>*h2 host中間逗號(,)分隔</value>
@@ -414,15 +399,9 @@
<data name="FillServerAddressCustom" xml:space="preserve"> <data name="FillServerAddressCustom" xml:space="preserve">
<value>請瀏覽匯入伺服器配置</value> <value>請瀏覽匯入伺服器配置</value>
</data> </data>
<data name="SystemProxy" xml:space="preserve">
<value>系統代理</value>
</data>
<data name="Speedtesting" xml:space="preserve"> <data name="Speedtesting" xml:space="preserve">
<value>測試中...</value> <value>測試中...</value>
</data> </data>
<data name="TooManyServersTip" xml:space="preserve">
<value>伺服器太多,請打開主介面操作</value>
</data>
<data name="LabLAN" xml:space="preserve"> <data name="LabLAN" xml:space="preserve">
<value>區域網路</value> <value>區域網路</value>
</data> </data>
@@ -543,18 +522,12 @@
<data name="menuTcpingServer" xml:space="preserve"> <data name="menuTcpingServer" xml:space="preserve">
<value>測試伺服器延遲Tcping(多選) (Ctrl+O)</value> <value>測試伺服器延遲Tcping(多選) (Ctrl+O)</value>
</data> </data>
<data name="menuTestMe" xml:space="preserve">
<value>測試目前服務狀態</value>
</data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>匯出所選伺服器為用戶端配置</value> <value>匯出所選伺服器為用戶端配置</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>批次匯出分享URL至剪貼簿(多選) (Ctrl+C)</value> <value>批次匯出分享URL至剪貼簿(多選) (Ctrl+C)</value>
</data> </data>
<data name="menuExport2SubContent" xml:space="preserve">
<value>批次匯出訂閱內容至剪貼簿(多選)</value>
</data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>新增自訂配置伺服器</value> <value>新增自訂配置伺服器</value>
</data> </data>
@@ -585,9 +558,6 @@
<data name="menuMsgViewCopyAll" xml:space="preserve"> <data name="menuMsgViewCopyAll" xml:space="preserve">
<value>複製所有</value> <value>複製所有</value>
</data> </data>
<data name="menuMsgViewFilter" xml:space="preserve">
<value>設定資訊過濾器</value>
</data>
<data name="menuMsgViewSelectAll" xml:space="preserve"> <data name="menuMsgViewSelectAll" xml:space="preserve">
<value>全選 (Ctrl+A)</value> <value>全選 (Ctrl+A)</value>
</data> </data>
@@ -700,7 +670,7 @@
<value>SOCKS埠</value> <value>SOCKS埠</value>
</data> </data>
<data name="TipPreSocksPort" xml:space="preserve"> <data name="TipPreSocksPort" xml:space="preserve">
<value>* 自訂配置的Socks埠值可不設定當設定此值後將使用sing-box額外啟動一個前置Socks服務提供分流和速度顯示等功能</value> <value>* 自訂配置的Socks埠值可不設定當設定此值後將使用Xray/sing-box(Tun)額外啟動一個前置Socks服務提供分流和速度顯示等功能</value>
</data> </data>
<!--********************************************--> <!--********************************************-->
<data name="TbBrowse" xml:space="preserve"> <data name="TbBrowse" xml:space="preserve">
@@ -958,6 +928,9 @@
<data name="TbSettingsRouteOnly" xml:space="preserve"> <data name="TbSettingsRouteOnly" xml:space="preserve">
<value>RouteOnly</value> <value>RouteOnly</value>
</data> </data>
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
<value>請勿將代理伺服器用於本機Intranet位址</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve"> <data name="menuMixedTestServer" xml:space="preserve">
<value>一鍵多執行緒測試延遲和速度 (Ctrl+E)</value> <value>一鍵多執行緒測試延遲和速度 (Ctrl+E)</value>
</data> </data>
@@ -988,21 +961,9 @@
<data name="TbSettingsTunMode" xml:space="preserve"> <data name="TbSettingsTunMode" xml:space="preserve">
<value>TUN模式設定</value> <value>TUN模式設定</value>
</data> </data>
<data name="TbSettingsTunModeDirectIP" xml:space="preserve">
<value>直連的IP CIDR用逗號(,)分隔</value>
</data>
<data name="TbSettingsTunModeDirectProcess" xml:space="preserve">
<value>直連的行程名,用逗號(,)分隔</value>
</data>
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
<value>顯示控制台</value>
</data>
<data name="menuMoveToGroup" xml:space="preserve"> <data name="menuMoveToGroup" xml:space="preserve">
<value>移至訂閱分組</value> <value>移至訂閱分組</value>
</data> </data>
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>自訂配置模板</value>
</data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve"> <data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>啟動伺服器拖放排序(需重啟)</value> <value>啟動伺服器拖放排序(需重啟)</value>
</data> </data>
@@ -1037,7 +998,7 @@
<value>複製字型TTF/TTC文件到目錄guiFonts重啟設定</value> <value>複製字型TTF/TTC文件到目錄guiFonts重啟設定</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve"> <data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>HTTP埠=SOCKS埠+1</value> <value>http端口= +1Pac端口= +4*ray API端口= +5mihomo API端口= +6</value>
</data> </data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>以管理員權限設定此項,在啟動後獲得管理員權限</value> <value>以管理員權限設定此項,在啟動後獲得管理員權限</value>
@@ -1045,24 +1006,12 @@
<data name="TbSettingsFontSize" xml:space="preserve"> <data name="TbSettingsFontSize" xml:space="preserve">
<value>字型大小</value> <value>字型大小</value>
</data> </data>
<data name="TbSettingsTunModeProxyIP" xml:space="preserve">
<value>代理的IP CIDR用逗號(,)分隔</value>
</data>
<data name="TbSettingsTunModeProxyProcess" xml:space="preserve">
<value>代理的行程名,用逗號(,)分隔</value>
</data>
<data name="TbSettingsTunModeBypassMode" xml:space="preserve">
<value>繞行模式</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve"> <data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>測速單個超時值</value> <value>測速單個超時值</value>
</data> </data>
<data name="TbSettingsSpeedTestUrl" xml:space="preserve"> <data name="TbSettingsSpeedTestUrl" xml:space="preserve">
<value>測速檔案位址</value> <value>測速檔案位址</value>
</data> </data>
<data name="TbSettingsTunModeDNS" xml:space="preserve">
<value>DNS物件例如 {"servers":[]}</value>
</data>
<data name="menuMoveTo" xml:space="preserve"> <data name="menuMoveTo" xml:space="preserve">
<value>移至上下</value> <value>移至上下</value>
</data> </data>
@@ -1165,4 +1114,28 @@
<data name="SpeedtestingStop" xml:space="preserve"> <data name="SpeedtestingStop" xml:space="preserve">
<value>測試終止中...</value> <value>測試終止中...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value>
</data>
<data name="menuAddHttpServer" xml:space="preserve">
<value>新增[Http]伺服器</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>啟用分片Fragment</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式啟用和分組前置代理衝突</value>
</data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>啟用sing-box規則集文件的緩存文件</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>自訂sing-box rule-set</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>操作成功。 請點選設定選單重啟應用程式。</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>打開儲存所在的位置</value>
</data>
</root> </root>

View File

@@ -4,56 +4,7 @@
"error": "Verror.log", "error": "Verror.log",
"loglevel": "warning" "loglevel": "warning"
}, },
"inbounds": [{ "inbounds": [],
"tag": "tag1",
"port": 10808,
"protocol": "socks",
"listen": "127.0.0.1",
"settings": {
"auth": "noauth",
"udp": true
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"tag": "tag2",
"port": 10809,
"protocol": "http",
"listen": "127.0.0.1",
"settings": {
"allowTransparent": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"tag": "tag3",
"port": 10809,
"protocol": "http",
"listen": "127.0.0.1",
"settings": {
"allowTransparent": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [{ "outbounds": [{
"tag": "proxy", "tag": "proxy",
"protocol": "vmess", "protocol": "vmess",

Some files were not shown because too many files have changed in this diff Show More