mirror of https://github.com/2dust/v2rayN
parent
48a159f4c8
commit
3bc17bd50a
|
@ -324,7 +324,8 @@ namespace ServiceLib.Models
|
||||||
|
|
||||||
public class WsSettings4Ray
|
public class WsSettings4Ray
|
||||||
{
|
{
|
||||||
public string path { get; set; }
|
public string? path { get; set; }
|
||||||
|
public string? host { get; set; }
|
||||||
|
|
||||||
public Headers4Ray headers { get; set; }
|
public Headers4Ray headers { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,7 +442,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
#region private gen function
|
#region private gen function
|
||||||
|
|
||||||
public async Task<int> GenLog(SingboxConfig singboxConfig)
|
private async Task<int> GenLog(SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -570,7 +570,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return inbound;
|
return inbound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutbound(ProfileItem node, Outbound4Sbox outbound)
|
private async Task<int> GenOutbound(ProfileItem node, Outbound4Sbox outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -694,7 +694,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
|
private async Task<int> GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -717,7 +717,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
|
private async Task<int> GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -767,7 +767,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
private async Task<int> GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -994,7 +994,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenRoutingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
private async Task<int> GenRoutingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1152,7 +1152,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenDns(ProfileItem? node, SingboxConfig singboxConfig)
|
private async Task<int> GenDns(ProfileItem? node, SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1183,7 +1183,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSItem? dNSItem)
|
private async Task<int> GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSItem? dNSItem)
|
||||||
{
|
{
|
||||||
var dns4Sbox = singboxConfig.dns ?? new();
|
var dns4Sbox = singboxConfig.dns ?? new();
|
||||||
dns4Sbox.servers ??= [];
|
dns4Sbox.servers ??= [];
|
||||||
|
@ -1236,7 +1236,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenExperimental(SingboxConfig singboxConfig)
|
private async Task<int> GenExperimental(SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
//if (_config.guiItem.enableStatistics)
|
//if (_config.guiItem.enableStatistics)
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,7 +359,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
#region private gen function
|
#region private gen function
|
||||||
|
|
||||||
public async Task<int> GenLog(V2rayConfig v2rayConfig)
|
private async Task<int> GenLog(V2rayConfig v2rayConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -384,7 +384,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenInbounds(V2rayConfig v2rayConfig)
|
private async Task<int> GenInbounds(V2rayConfig v2rayConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -481,7 +481,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenRoutingUserRule(RulesItem4Ray? rule, V2rayConfig v2rayConfig)
|
private async Task<int> GenRoutingUserRule(RulesItem4Ray? rule, V2rayConfig v2rayConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -559,7 +559,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutbound(ProfileItem node, Outbounds4Ray outbound)
|
private async Task<int> GenOutbound(ProfileItem node, Outbounds4Ray outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -754,7 +754,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled)
|
private async Task<int> GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -778,14 +778,15 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings)
|
private async Task<int> GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
streamSettings.network = node.GetNetwork();
|
streamSettings.network = node.GetNetwork();
|
||||||
string host = node.RequestHost.TrimEx();
|
var host = node.RequestHost.TrimEx();
|
||||||
string sni = node.Sni;
|
var path = node.Path.TrimEx();
|
||||||
string useragent = "";
|
var sni = node.Sni.TrimEx();
|
||||||
|
var useragent = "";
|
||||||
if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty())
|
if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -858,9 +859,9 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
type = node.HeaderType
|
type = node.HeaderType
|
||||||
};
|
};
|
||||||
if (Utils.IsNotEmpty(node.Path))
|
if (Utils.IsNotEmpty(path))
|
||||||
{
|
{
|
||||||
kcpSettings.seed = node.Path;
|
kcpSettings.seed = path;
|
||||||
}
|
}
|
||||||
streamSettings.kcpSettings = kcpSettings;
|
streamSettings.kcpSettings = kcpSettings;
|
||||||
break;
|
break;
|
||||||
|
@ -868,9 +869,10 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
WsSettings4Ray wsSettings = new();
|
WsSettings4Ray wsSettings = new();
|
||||||
wsSettings.headers = new Headers4Ray();
|
wsSettings.headers = new Headers4Ray();
|
||||||
string path = node.Path;
|
|
||||||
if (Utils.IsNotEmpty(host))
|
if (Utils.IsNotEmpty(host))
|
||||||
{
|
{
|
||||||
|
wsSettings.host = host;
|
||||||
wsSettings.headers.Host = host;
|
wsSettings.headers.Host = host;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(path))
|
if (Utils.IsNotEmpty(path))
|
||||||
|
@ -888,9 +890,9 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(node.Path))
|
if (Utils.IsNotEmpty(path))
|
||||||
{
|
{
|
||||||
httpupgradeSettings.path = node.Path;
|
httpupgradeSettings.path = path;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(host))
|
if (Utils.IsNotEmpty(host))
|
||||||
{
|
{
|
||||||
|
@ -909,9 +911,9 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
scMinPostsIntervalMs = "30-50"
|
scMinPostsIntervalMs = "30-50"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(node.Path))
|
if (Utils.IsNotEmpty(path))
|
||||||
{
|
{
|
||||||
xhttpSettings.path = node.Path;
|
xhttpSettings.path = path;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(host))
|
if (Utils.IsNotEmpty(host))
|
||||||
{
|
{
|
||||||
|
@ -937,7 +939,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
httpSettings.host = Utils.String2List(host);
|
httpSettings.host = Utils.String2List(host);
|
||||||
}
|
}
|
||||||
httpSettings.path = node.Path;
|
httpSettings.path = path;
|
||||||
|
|
||||||
streamSettings.httpSettings = httpSettings;
|
streamSettings.httpSettings = httpSettings;
|
||||||
|
|
||||||
|
@ -947,7 +949,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
QuicSettings4Ray quicsettings = new()
|
QuicSettings4Ray quicsettings = new()
|
||||||
{
|
{
|
||||||
security = host,
|
security = host,
|
||||||
key = node.Path,
|
key = path,
|
||||||
header = new Header4Ray
|
header = new Header4Ray
|
||||||
{
|
{
|
||||||
type = node.HeaderType
|
type = node.HeaderType
|
||||||
|
@ -971,7 +973,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
GrpcSettings4Ray grpcSettings = new()
|
GrpcSettings4Ray grpcSettings = new()
|
||||||
{
|
{
|
||||||
authority = Utils.IsNullOrEmpty(host) ? null : host,
|
authority = Utils.IsNullOrEmpty(host) ? null : host,
|
||||||
serviceName = node.Path,
|
serviceName = path,
|
||||||
multiMode = node.HeaderType == Global.GrpcMultiMode,
|
multiMode = node.HeaderType == Global.GrpcMultiMode,
|
||||||
idle_timeout = _config.GrpcItem.IdleTimeout,
|
idle_timeout = _config.GrpcItem.IdleTimeout,
|
||||||
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
|
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
|
||||||
|
@ -1001,9 +1003,9 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
|
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
|
||||||
//Path
|
//Path
|
||||||
string pathHttp = @"/";
|
string pathHttp = @"/";
|
||||||
if (Utils.IsNotEmpty(node.Path))
|
if (Utils.IsNotEmpty(path))
|
||||||
{
|
{
|
||||||
string[] arrPath = node.Path.Split(',');
|
string[] arrPath = path.Split(',');
|
||||||
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
||||||
}
|
}
|
||||||
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
|
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
|
||||||
|
@ -1021,7 +1023,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenDns(ProfileItem? node, V2rayConfig v2rayConfig)
|
private async Task<int> GenDns(ProfileItem? node, V2rayConfig v2rayConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1084,7 +1086,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem)
|
private async Task<int> GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem)
|
||||||
{
|
{
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
@ -1104,7 +1106,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GenStatistic(V2rayConfig v2rayConfig)
|
private async Task<int> GenStatistic(V2rayConfig v2rayConfig)
|
||||||
{
|
{
|
||||||
if (_config.GuiItem.EnableStatistics)
|
if (_config.GuiItem.EnableStatistics)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue