mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-28 22:06:19 +00:00
Compare commits
1 commit
2beac97dc6
...
dbf12af3a0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dbf12af3a0 |
21 changed files with 130 additions and 51 deletions
|
@ -305,6 +305,13 @@ public class Global
|
|||
""
|
||||
];
|
||||
|
||||
public static readonly List<string> DomainMatchers =
|
||||
[
|
||||
"linear",
|
||||
"mph",
|
||||
""
|
||||
];
|
||||
|
||||
public static readonly List<string> Fingerprints =
|
||||
[
|
||||
"chrome",
|
||||
|
|
|
@ -963,7 +963,7 @@ public class ConfigHandler
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
if (profileItem.Security.IsNullOrEmpty())
|
||||
if (profileItem.Security.IsNotEmpty() && profileItem.Security != Global.None)
|
||||
{
|
||||
profileItem.Security = Global.None;
|
||||
}
|
||||
|
|
|
@ -5,18 +5,15 @@ namespace ServiceLib.Handler;
|
|||
|
||||
public class PacHandler
|
||||
{
|
||||
private static readonly Lazy<PacHandler> _instance = new(() => new PacHandler());
|
||||
public static PacHandler Instance => _instance.Value;
|
||||
private static string _configPath;
|
||||
private static int _httpPort;
|
||||
private static int _pacPort;
|
||||
private static TcpListener? _tcpListener;
|
||||
private static byte[] _writeContent;
|
||||
private static bool _isRunning;
|
||||
private static bool _needRestart = true;
|
||||
|
||||
private string _configPath;
|
||||
private int _httpPort;
|
||||
private int _pacPort;
|
||||
private TcpListener? _tcpListener;
|
||||
private byte[] _writeContent;
|
||||
private bool _isRunning;
|
||||
private bool _needRestart = true;
|
||||
|
||||
public async Task StartAsync(string configPath, int httpPort, int pacPort)
|
||||
public static async Task Start(string configPath, int httpPort, int pacPort)
|
||||
{
|
||||
_needRestart = configPath != _configPath || httpPort != _httpPort || pacPort != _pacPort || !_isRunning;
|
||||
|
||||
|
@ -33,7 +30,7 @@ public class PacHandler
|
|||
}
|
||||
}
|
||||
|
||||
private async Task InitText()
|
||||
private static async Task InitText()
|
||||
{
|
||||
var path = Path.Combine(_configPath, "pac.txt");
|
||||
|
||||
|
@ -62,7 +59,7 @@ public class PacHandler
|
|||
_writeContent = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
}
|
||||
|
||||
private void RunListener()
|
||||
private static void RunListener()
|
||||
{
|
||||
_tcpListener = TcpListener.Create(_pacPort);
|
||||
_isRunning = true;
|
||||
|
@ -90,14 +87,14 @@ public class PacHandler
|
|||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
private void WriteContent(TcpClient client)
|
||||
private static void WriteContent(TcpClient client)
|
||||
{
|
||||
var stream = client.GetStream();
|
||||
stream.Write(_writeContent, 0, _writeContent.Length);
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
public static void Stop()
|
||||
{
|
||||
if (_tcpListener == null)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ public static class SysProxyHandler
|
|||
|
||||
if (type != ESysProxyType.Pac && Utils.IsWindows())
|
||||
{
|
||||
PacHandler.Instance.Stop();
|
||||
PacHandler.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -91,7 +91,7 @@ public static class SysProxyHandler
|
|||
private static async Task SetWindowsProxyPac(int port)
|
||||
{
|
||||
var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
|
||||
await PacHandler.Instance.StartAsync(Utils.GetConfigPath(), port, portPac);
|
||||
await PacHandler.Start(Utils.GetConfigPath(), port, portPac);
|
||||
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
||||
ProxySettingWindows.SetProxy(strProxy, "", 4);
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ public class RoutingBasicItem
|
|||
{
|
||||
public string DomainStrategy { get; set; }
|
||||
public string DomainStrategy4Singbox { get; set; }
|
||||
public string DomainMatcher { get; set; }
|
||||
public string RoutingIndexId { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,8 @@ public class Routing4Ray
|
|||
{
|
||||
public string domainStrategy { get; set; }
|
||||
|
||||
public string? domainMatcher { get; set; }
|
||||
|
||||
public List<RulesItem4Ray> rules { get; set; }
|
||||
|
||||
public List<BalancersItem4Ray>? balancers { get; set; }
|
||||
|
|
9
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
9
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
@ -2463,6 +2463,15 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Domain Matcher 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbdomainMatcher {
|
||||
get {
|
||||
return ResourceManager.GetString("TbdomainMatcher", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Domain strategy 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>تنظیم کردن به عنوان قانون فعال</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>تطبیق دامنه</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>استراتژی دامنه</value>
|
||||
</data>
|
||||
|
|
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>Beállítás aktív szabályként (Enter)</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>Tartomány illesztő</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>Tartomány stratégia</value>
|
||||
</data>
|
||||
|
|
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>Set as active rule (Enter)</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>Domain Matcher</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>Domain strategy</value>
|
||||
</data>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
|
@ -26,36 +26,36 @@
|
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>Установить как активное правило</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>Сопоставитель доменов</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>Доменная стратегия</value>
|
||||
</data>
|
||||
|
@ -1497,4 +1500,4 @@
|
|||
<data name="TbFullConfigTemplateDesc" xml:space="preserve">
|
||||
<value>Эта функция предназначена для продвинутых пользователей и особых случаев. После включения игнорируются базовые настройки ядра, DNS и маршрутизации. Вы должны самостоятельно корректно задать порт системного прокси, учёт трафика и другие связанные параметры — всё настраивается вручную.</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>设为活动规则 (Enter)</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>域名匹配算法</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>域名解析策略</value>
|
||||
</data>
|
||||
|
|
|
@ -825,6 +825,9 @@
|
|||
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
|
||||
<value>設為活動規則 (Enter)</value>
|
||||
</data>
|
||||
<data name="TbdomainMatcher" xml:space="preserve">
|
||||
<value>域名匹配演算法</value>
|
||||
</data>
|
||||
<data name="TbdomainStrategy" xml:space="preserve">
|
||||
<value>域名解析策略</value>
|
||||
</data>
|
||||
|
|
|
@ -523,6 +523,7 @@ public class CoreConfigV2rayService
|
|||
if (v2rayConfig.routing?.rules != null)
|
||||
{
|
||||
v2rayConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
||||
v2rayConfig.routing.domainMatcher = _config.RoutingBasicItem.DomainMatcher.IsNullOrEmpty() ? null : _config.RoutingBasicItem.DomainMatcher;
|
||||
|
||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||
if (routing != null)
|
||||
|
|
|
@ -75,7 +75,10 @@ public class CheckUpdateViewModel : MyReactiveObject
|
|||
|
||||
private async Task CheckUpdate()
|
||||
{
|
||||
await Task.Run(CheckUpdateTask);
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await CheckUpdateTask();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task CheckUpdateTask()
|
||||
|
|
|
@ -20,6 +20,9 @@ public class RoutingSettingViewModel : MyReactiveObject
|
|||
[Reactive]
|
||||
public string DomainStrategy { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string DomainMatcher { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string DomainStrategy4Singbox { get; set; }
|
||||
|
||||
|
@ -72,6 +75,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
|||
SelectedSource = new();
|
||||
|
||||
DomainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
||||
DomainMatcher = _config.RoutingBasicItem.DomainMatcher;
|
||||
DomainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox;
|
||||
|
||||
await ConfigHandler.InitBuiltinRouting(_config);
|
||||
|
@ -105,6 +109,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
|||
private async Task SaveRoutingAsync()
|
||||
{
|
||||
_config.RoutingBasicItem.DomainStrategy = DomainStrategy;
|
||||
_config.RoutingBasicItem.DomainMatcher = DomainMatcher;
|
||||
_config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox;
|
||||
|
||||
if (await ConfigHandler.SaveConfig(_config) == 0)
|
||||
|
|
|
@ -334,7 +334,10 @@ public class StatusBarViewModel : MyReactiveObject
|
|||
|
||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, ResUI.Speedtesting);
|
||||
|
||||
var msg = await Task.Run(ConnectionHandler.Instance.RunAvailabilityCheck);
|
||||
var msg = await Task.Run(async () =>
|
||||
{
|
||||
return await ConnectionHandler.Instance.RunAvailabilityCheck();
|
||||
});
|
||||
|
||||
NoticeHandler.Instance.SendMessageEx(msg);
|
||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
ColumnDefinitions="Auto,Auto"
|
||||
DockPanel.Dock="Top"
|
||||
RowDefinitions="Auto,Auto">
|
||||
RowDefinitions="Auto,Auto,Auto">
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
|
@ -74,6 +74,19 @@
|
|||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Static resx:ResUI.TbdomainMatcher}" />
|
||||
<ComboBox
|
||||
x:Name="cmbdomainMatcher"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="{StaticResource Margin4}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center">
|
||||
<HyperlinkButton Classes="WithIcon" Click="linkdomainStrategy4Singbox_Click">
|
||||
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
|
||||
|
@ -81,7 +94,7 @@
|
|||
</TextBlock>
|
||||
<ComboBox
|
||||
x:Name="cmbdomainStrategy4Singbox"
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="{StaticResource Margin4}"
|
||||
|
|
|
@ -27,6 +27,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
|||
ViewModel = new RoutingSettingViewModel(UpdateViewHandler);
|
||||
|
||||
cmbdomainStrategy.ItemsSource = Global.DomainStrategies;
|
||||
cmbdomainMatcher.ItemsSource = Global.DomainMatchers;
|
||||
cmbdomainStrategy4Singbox.ItemsSource = Global.DomainStrategies4Singbox;
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
|
@ -35,6 +36,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
|||
this.Bind(ViewModel, vm => vm.SelectedSource, v => v.lstRoutings.SelectedItem).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.DomainStrategy, v => v.cmbdomainStrategy.SelectedValue).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.DomainMatcher, v => v.cmbdomainMatcher.SelectedValue).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.DomainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.SelectedValue).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd).DisposeWith(disposables);
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
@ -108,6 +109,21 @@
|
|||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbdomainMatcher}" />
|
||||
<ComboBox
|
||||
x:Name="cmbdomainMatcher"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="{StaticResource Margin4}"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}">
|
||||
<Hyperlink Click="linkdomainStrategy4Singbox_Click">
|
||||
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
|
||||
|
@ -116,7 +132,7 @@
|
|||
</TextBlock>
|
||||
<ComboBox
|
||||
x:Name="cmbdomainStrategy4Singbox"
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="{StaticResource Margin4}"
|
||||
|
|
|
@ -22,6 +22,7 @@ public partial class RoutingSettingWindow
|
|||
ViewModel = new RoutingSettingViewModel(UpdateViewHandler);
|
||||
|
||||
cmbdomainStrategy.ItemsSource = Global.DomainStrategies;
|
||||
cmbdomainMatcher.ItemsSource = Global.DomainMatchers;
|
||||
cmbdomainStrategy4Singbox.ItemsSource = Global.DomainStrategies4Singbox;
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
|
@ -30,6 +31,7 @@ public partial class RoutingSettingWindow
|
|||
this.Bind(ViewModel, vm => vm.SelectedSource, v => v.lstRoutings.SelectedItem).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.DomainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.DomainMatcher, v => v.cmbdomainMatcher.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.DomainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.Text).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd).DisposeWith(disposables);
|
||||
|
|
Loading…
Reference in a new issue