mirror of https://github.com/2dust/v2rayN
Add authority for grpc
parent
eac0c84e11
commit
f59bbc9981
|
@ -533,11 +533,11 @@ namespace v2rayN.Handler
|
|||
alpn = node.GetAlpn(),
|
||||
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(sni))
|
||||
if (!Utile.IsNullOrEmpty(sni))
|
||||
{
|
||||
tlsSettings.serverName = sni;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(host))
|
||||
else if (!Utile.IsNullOrEmpty(host))
|
||||
{
|
||||
tlsSettings.serverName = Utile.String2List(host)[0];
|
||||
}
|
||||
|
@ -592,15 +592,15 @@ namespace v2rayN.Handler
|
|||
WsSettings4Ray wsSettings = new();
|
||||
wsSettings.headers = new Headers4Ray();
|
||||
string path = node.path;
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
if (!Utile.IsNullOrEmpty(host))
|
||||
{
|
||||
wsSettings.headers.Host = host;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
if (!Utile.IsNullOrEmpty(path))
|
||||
{
|
||||
wsSettings.path = path;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(useragent))
|
||||
if (!Utile.IsNullOrEmpty(useragent))
|
||||
{
|
||||
wsSettings.headers.UserAgent = useragent;
|
||||
}
|
||||
|
@ -611,11 +611,11 @@ namespace v2rayN.Handler
|
|||
case nameof(ETransport.httpupgrade):
|
||||
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(node.path))
|
||||
if (!Utile.IsNullOrEmpty(node.path))
|
||||
{
|
||||
httpupgradeSettings.path = node.path;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
if (!Utile.IsNullOrEmpty(host))
|
||||
{
|
||||
httpupgradeSettings.host = host;
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ namespace v2rayN.Handler
|
|||
case nameof(ETransport.h2):
|
||||
HttpSettings4Ray httpSettings = new();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
if (!Utile.IsNullOrEmpty(host))
|
||||
{
|
||||
httpSettings.host = Utile.String2List(host);
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ namespace v2rayN.Handler
|
|||
streamSettings.quicSettings = quicsettings;
|
||||
if (node.streamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(sni))
|
||||
if (!Utile.IsNullOrEmpty(sni))
|
||||
{
|
||||
streamSettings.tlsSettings.serverName = sni;
|
||||
}
|
||||
|
@ -663,6 +663,7 @@ namespace v2rayN.Handler
|
|||
case nameof(ETransport.grpc):
|
||||
GrpcSettings4Ray grpcSettings = new()
|
||||
{
|
||||
authority = Utile.IsNullOrEmpty(host) ? null : host,
|
||||
serviceName = node.path,
|
||||
multiMode = (node.headerType == Global.GrpcMultiMode),
|
||||
idle_timeout = _config.grpcItem.idle_timeout,
|
||||
|
@ -721,13 +722,13 @@ namespace v2rayN.Handler
|
|||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
|
||||
var normalDNS = item?.normalDNS;
|
||||
var domainStrategy4Freedom = item?.domainStrategy4Freedom;
|
||||
if (string.IsNullOrWhiteSpace(normalDNS))
|
||||
if (Utile.IsNullOrEmpty(normalDNS))
|
||||
{
|
||||
normalDNS = "1.1.1.1,8.8.8.8";
|
||||
}
|
||||
|
||||
//Outbound Freedom domainStrategy
|
||||
if (!string.IsNullOrWhiteSpace(domainStrategy4Freedom))
|
||||
if (!Utile.IsNullOrEmpty(domainStrategy4Freedom))
|
||||
{
|
||||
var outbound = v2rayConfig.outbounds[1];
|
||||
outbound.settings.domainStrategy = domainStrategy4Freedom;
|
||||
|
|
|
@ -364,6 +364,7 @@ namespace v2rayN.Handler
|
|||
case nameof(ETransport.grpc):
|
||||
if (!Utile.IsNullOrEmpty(item.path))
|
||||
{
|
||||
dicQuery.Add("authority", Utile.UrlEncode(item.requestHost));
|
||||
dicQuery.Add("serviceName", Utile.UrlEncode(item.path));
|
||||
if (item.headerType is Global.GrpcGunMode or Global.GrpcMultiMode)
|
||||
{
|
||||
|
@ -592,7 +593,7 @@ namespace v2rayN.Handler
|
|||
break;
|
||||
|
||||
default:
|
||||
if (!string.IsNullOrWhiteSpace(i.streamSecurity))
|
||||
if (!Utile.IsNullOrEmpty(i.streamSecurity))
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
|
@ -981,6 +982,7 @@ namespace v2rayN.Handler
|
|||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
item.requestHost = Utile.UrlDecode(query["authority"] ?? "");
|
||||
item.path = Utile.UrlDecode(query["serviceName"] ?? "");
|
||||
item.headerType = Utile.UrlDecode(query["mode"] ?? Global.GrpcGunMode);
|
||||
break;
|
||||
|
|
|
@ -639,7 +639,8 @@ namespace v2rayN.Model
|
|||
|
||||
public class GrpcSettings4Ray
|
||||
{
|
||||
public string serviceName { get; set; }
|
||||
public string? authority { get; set; }
|
||||
public string? serviceName { get; set; }
|
||||
public bool multiMode { get; set; }
|
||||
public int idle_timeout { get; set; }
|
||||
public int health_check_timeout { get; set; }
|
||||
|
|
|
@ -3283,6 +3283,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *grpc Authority 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportRequestHostTip5 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportRequestHostTip5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Ungrouped 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -1195,4 +1195,7 @@
|
|||
<data name="SpeedtestingStop" xml:space="preserve">
|
||||
<value>Test terminating...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1192,4 +1192,7 @@
|
|||
<data name="SpeedtestingStop" xml:space="preserve">
|
||||
<value>测试终止中...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1165,4 +1165,7 @@
|
|||
<data name="SpeedtestingStop" xml:space="preserve">
|
||||
<value>測試終止中...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
</data>
|
||||
</root>
|
|
@ -346,6 +346,7 @@ namespace v2rayN.Views
|
|||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
tipRequestHost.Text = ResUI.TransportRequestHostTip5;
|
||||
tipPath.Text = ResUI.TransportPathTip4;
|
||||
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
|
||||
labHeaderType.Visibility = Visibility.Hidden;
|
||||
|
|
Loading…
Reference in New Issue