mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 21:28:51 +00:00
commit
69a45788ee
12 changed files with 159 additions and 55 deletions
|
@ -96,6 +96,15 @@
|
||||||
public static readonly List<string> domainStrategys = new List<string> { "AsIs", "IPIfNonMatch", "IPOnDemand" };
|
public static readonly List<string> domainStrategys = new List<string> { "AsIs", "IPIfNonMatch", "IPOnDemand" };
|
||||||
public static readonly List<string> domainMatchers = new List<string> { "linear", "mph", "" };
|
public static readonly List<string> domainMatchers = new List<string> { "linear", "mph", "" };
|
||||||
public static readonly List<string> fingerprints = new List<string> { "chrome", "firefox", "safari", "randomized", "" };
|
public static readonly List<string> fingerprints = new List<string> { "chrome", "firefox", "safari", "randomized", "" };
|
||||||
|
public static readonly List<string> userAgent = new List<string> { "chrome", "firefox", "safari", "edge", "none" };
|
||||||
|
public static readonly Dictionary<string, string> userAgentTxt = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
|
||||||
|
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
||||||
|
{"safari","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15" },
|
||||||
|
{"edge","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70" },
|
||||||
|
{"none",""}
|
||||||
|
};
|
||||||
public static readonly List<string> allowInsecures = new List<string> { "true", "false", "" };
|
public static readonly List<string> allowInsecures = new List<string> { "true", "false", "" };
|
||||||
public static readonly List<string> domainStrategy4Freedoms = new List<string> { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
|
public static readonly List<string> domainStrategy4Freedoms = new List<string> { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
|
||||||
public static readonly List<string> Languages = new List<string> { "zh-Hans", "en", "fa-Ir" };
|
public static readonly List<string> Languages = new List<string> { "zh-Hans", "en", "fa-Ir" };
|
||||||
|
|
|
@ -546,6 +546,18 @@ namespace v2rayN.Handler
|
||||||
streamSettings.network = node.GetNetwork();
|
streamSettings.network = node.GetNetwork();
|
||||||
string host = node.requestHost.TrimEx();
|
string host = node.requestHost.TrimEx();
|
||||||
string sni = node.sni;
|
string sni = node.sni;
|
||||||
|
string useragent = "";
|
||||||
|
if (!config.defUserAgent.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
useragent = Global.userAgentTxt[config.defUserAgent];
|
||||||
|
}
|
||||||
|
catch (KeyNotFoundException)
|
||||||
|
{
|
||||||
|
useragent = config.defUserAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if tls
|
//if tls
|
||||||
if (node.streamSecurity == Global.StreamSecurity)
|
if (node.streamSecurity == Global.StreamSecurity)
|
||||||
|
@ -634,19 +646,22 @@ namespace v2rayN.Handler
|
||||||
WsSettings wsSettings = new WsSettings
|
WsSettings wsSettings = new WsSettings
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
wsSettings.headers = new Headers
|
||||||
|
{
|
||||||
|
};
|
||||||
string path = node.path;
|
string path = node.path;
|
||||||
if (!string.IsNullOrWhiteSpace(host))
|
if (!string.IsNullOrWhiteSpace(host))
|
||||||
{
|
{
|
||||||
wsSettings.headers = new Headers
|
wsSettings.headers.Host = host;
|
||||||
{
|
|
||||||
Host = host
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(path))
|
if (!string.IsNullOrWhiteSpace(path))
|
||||||
{
|
{
|
||||||
wsSettings.path = path;
|
wsSettings.path = path;
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(useragent))
|
||||||
|
{
|
||||||
|
wsSettings.headers.UserAgent = useragent;
|
||||||
|
}
|
||||||
streamSettings.wsSettings = wsSettings;
|
streamSettings.wsSettings = wsSettings;
|
||||||
|
|
||||||
//TlsSettings tlsSettings = new TlsSettings();
|
//TlsSettings tlsSettings = new TlsSettings();
|
||||||
|
@ -730,7 +745,7 @@ namespace v2rayN.Handler
|
||||||
string host2 = string.Join("\",\"", arrHost);
|
string host2 = string.Join("\",\"", arrHost);
|
||||||
request = request.Replace("$requestHost$", $"\"{host2}\"");
|
request = request.Replace("$requestHost$", $"\"{host2}\"");
|
||||||
//request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost()));
|
//request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost()));
|
||||||
|
request = request.Replace("$requestUserAgent$", $"\"{useragent}\"");
|
||||||
//Path
|
//Path
|
||||||
string pathHttp = @"/";
|
string pathHttp = @"/";
|
||||||
if (!Utils.IsNullOrEmpty(node.path))
|
if (!Utils.IsNullOrEmpty(node.path))
|
||||||
|
|
|
@ -94,6 +94,11 @@
|
||||||
|
|
||||||
public string defFingerprint { get; set; }
|
public string defFingerprint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认用户代理
|
||||||
|
/// </summary>
|
||||||
|
public string defUserAgent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 域名解析策略
|
/// 域名解析策略
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace v2rayN.Mode
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace v2rayN.Mode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// v2ray配置文件实体类
|
/// v2ray配置文件实体类
|
||||||
|
@ -505,6 +507,12 @@
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Host { get; set; }
|
public string Host { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户代理
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("User-Agent")]
|
||||||
|
public string UserAgent { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HttpSettings
|
public class HttpSettings
|
||||||
|
|
18
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
18
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
|
@ -2410,6 +2410,24 @@ namespace v2rayN.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 User-Agent 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbSettingsDefUserAgent {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbSettingsDefUserAgent", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 This parameter is valid only for tcp/http and ws 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TbSettingsDefUserAgentTips {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TbSettingsDefUserAgentTips", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Outbound Freedom domainStrategy 的本地化字符串。
|
/// 查找类似 Outbound Freedom domainStrategy 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1060,4 +1060,10 @@
|
||||||
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
||||||
<value>نمایش کنسول</value>
|
<value>نمایش کنسول</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgent" xml:space="preserve">
|
||||||
|
<value>User-Agent</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
|
<value>This parameter is valid only for tcp/http and ws</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -1087,4 +1087,10 @@
|
||||||
<data name="TbSettingsDefFingerprint" xml:space="preserve">
|
<data name="TbSettingsDefFingerprint" xml:space="preserve">
|
||||||
<value>Default TLS fingerprint</value>
|
<value>Default TLS fingerprint</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgent" xml:space="preserve">
|
||||||
|
<value>User-Agent</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
|
<value>This parameter is valid only for tcp/http and ws</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -1087,4 +1087,10 @@
|
||||||
<data name="TbSettingsDefFingerprint" xml:space="preserve">
|
<data name="TbSettingsDefFingerprint" xml:space="preserve">
|
||||||
<value>默认TLS指纹(fingerprint)</value>
|
<value>默认TLS指纹(fingerprint)</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgent" xml:space="preserve">
|
||||||
|
<value>用户代理(UA)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||||
|
<value>仅对tcp/http、ws协议生效</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -1 +1 @@
|
||||||
{"version":"1.1","method":"GET","path":[$requestPath$],"headers":{"Host":[$requestHost$],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36","Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"],"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Pragma":"no-cache"}}
|
{"version":"1.1","method":"GET","path":[$requestPath$],"headers":{"Host":[$requestHost$],"User-Agent":[$requestUserAgent$],"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Pragma":"no-cache"}}
|
|
@ -29,6 +29,7 @@ namespace v2rayN.ViewModels
|
||||||
[Reactive] public string loglevel { get; set; }
|
[Reactive] public string loglevel { get; set; }
|
||||||
[Reactive] public bool defAllowInsecure { get; set; }
|
[Reactive] public bool defAllowInsecure { get; set; }
|
||||||
[Reactive] public string defFingerprint { get; set; }
|
[Reactive] public string defFingerprint { get; set; }
|
||||||
|
[Reactive] public string defUserAgent { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Core DNS
|
#region Core DNS
|
||||||
|
@ -112,6 +113,7 @@ namespace v2rayN.ViewModels
|
||||||
loglevel = _config.loglevel;
|
loglevel = _config.loglevel;
|
||||||
defAllowInsecure = _config.defAllowInsecure;
|
defAllowInsecure = _config.defAllowInsecure;
|
||||||
defFingerprint = _config.defFingerprint;
|
defFingerprint = _config.defFingerprint;
|
||||||
|
defUserAgent = _config.defUserAgent;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Core DNS
|
#region Core DNS
|
||||||
|
@ -272,6 +274,7 @@ namespace v2rayN.ViewModels
|
||||||
_config.muxEnabled = muxEnabled;
|
_config.muxEnabled = muxEnabled;
|
||||||
_config.defAllowInsecure = defAllowInsecure;
|
_config.defAllowInsecure = defAllowInsecure;
|
||||||
_config.defFingerprint = defFingerprint;
|
_config.defFingerprint = defFingerprint;
|
||||||
|
_config.defUserAgent = defUserAgent;
|
||||||
|
|
||||||
|
|
||||||
//DNS
|
//DNS
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
<TabControl>
|
<TabControl>
|
||||||
<TabItem Header="{x:Static resx:ResUI.TbSettingsCore}">
|
<TabItem Header="{x:Static resx:ResUI.TbSettingsCore}">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Visible">
|
||||||
<Grid Margin="{StaticResource SettingItemMargin}">
|
<Grid Margin="{StaticResource SettingItemMargin}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
@ -63,10 +64,13 @@
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
@ -250,7 +254,26 @@
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="{StaticResource SettingItemMargin}" />
|
Margin="{StaticResource SettingItemMargin}" />
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="13"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{StaticResource SettingItemMargin}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbSettingsDefUserAgent}" />
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbdefUserAgent"
|
||||||
|
Grid.Row="13"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="{StaticResource SettingItemMargin}" IsEditable="True" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="13"
|
||||||
|
Grid.Column="3"
|
||||||
|
Margin="{StaticResource SettingItemMargin}"
|
||||||
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
|
Text="{x:Static resx:ResUI.TbSettingsDefUserAgentTips}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
|
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
|
||||||
|
|
|
@ -25,6 +25,10 @@ namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
cmbdefFingerprint.Items.Add(it);
|
cmbdefFingerprint.Items.Add(it);
|
||||||
});
|
});
|
||||||
|
Global.userAgent.ForEach(it =>
|
||||||
|
{
|
||||||
|
cmbdefUserAgent.Items.Add(it);
|
||||||
|
});
|
||||||
Global.domainStrategy4Freedoms.ForEach(it =>
|
Global.domainStrategy4Freedoms.ForEach(it =>
|
||||||
{
|
{
|
||||||
cmbdomainStrategy4Freedom.Items.Add(it);
|
cmbdomainStrategy4Freedom.Items.Add(it);
|
||||||
|
@ -68,6 +72,7 @@ namespace v2rayN.Views
|
||||||
this.Bind(ViewModel, vm => vm.loglevel, v => v.cmbloglevel.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.loglevel, v => v.cmbloglevel.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
|
||||||
|
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
|
||||||
|
|
Loading…
Reference in a new issue