mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-29 03:02:53 +00:00
Compare commits
No commits in common. "6f06b16c76d529faec9a49dd5881bf8635ca5c60" and "32583ea8b377677b4da30781adb7b703a5f45dce" have entirely different histories.
6f06b16c76
...
32583ea8b3
10 changed files with 43 additions and 81 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>7.16.0</Version>
|
<Version>7.15.7</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class AnytlsFmt : BaseFmt
|
||||||
item.Id = rawUserInfo;
|
item.Id = rawUserInfo;
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(parsedUrl.Query);
|
var query = Utils.ParseQueryString(parsedUrl.Query);
|
||||||
ResolveUriQuery(query, ref item);
|
_ = ResolveStdTransport(query, ref item);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ public class AnytlsFmt : BaseFmt
|
||||||
}
|
}
|
||||||
var pw = item.Id;
|
var pw = item.Id;
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
ToUriQuery(item, Global.None, ref dicQuery);
|
_ = GetStdTransport(item, Global.None, ref dicQuery);
|
||||||
|
|
||||||
return ToUri(EConfigType.Anytls, item.Address, item.Port, pw, dicQuery, remark);
|
return ToUri(EConfigType.Anytls, item.Address, item.Port, pw, dicQuery, remark);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ namespace ServiceLib.Handler.Fmt;
|
||||||
|
|
||||||
public class BaseFmt
|
public class BaseFmt
|
||||||
{
|
{
|
||||||
private static readonly string[] _allowInsecureArray = new[] { "insecure", "allowInsecure", "allow_insecure", "verify" };
|
|
||||||
|
|
||||||
protected static string GetIpv6(string address)
|
protected static string GetIpv6(string address)
|
||||||
{
|
{
|
||||||
if (Utils.IsIpv6(address))
|
if (Utils.IsIpv6(address))
|
||||||
|
|
@ -19,7 +17,7 @@ public class BaseFmt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||||
{
|
{
|
||||||
if (item.Flow.IsNotEmpty())
|
if (item.Flow.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +37,11 @@ public class BaseFmt
|
||||||
}
|
}
|
||||||
if (item.Sni.IsNotEmpty())
|
if (item.Sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("sni", Utils.UrlEncode(item.Sni));
|
dicQuery.Add("sni", item.Sni);
|
||||||
|
}
|
||||||
|
if (item.Alpn.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
}
|
}
|
||||||
if (item.Fingerprint.IsNotEmpty())
|
if (item.Fingerprint.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -61,14 +63,9 @@ public class BaseFmt
|
||||||
{
|
{
|
||||||
dicQuery.Add("pqv", Utils.UrlEncode(item.Mldsa65Verify));
|
dicQuery.Add("pqv", Utils.UrlEncode(item.Mldsa65Verify));
|
||||||
}
|
}
|
||||||
|
if (item.AllowInsecure.Equals("true"))
|
||||||
if (item.StreamSecurity.Equals(Global.StreamSecurity))
|
|
||||||
{
|
{
|
||||||
if (item.Alpn.IsNotEmpty())
|
dicQuery.Add("allowInsecure", "1");
|
||||||
{
|
|
||||||
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
|
||||||
}
|
|
||||||
ToUriQueryAllowInsecure(item, ref dicQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp));
|
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp));
|
||||||
|
|
@ -156,40 +153,7 @@ public class BaseFmt
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int ToUriQueryLite(ProfileItem item, ref Dictionary<string, string> dicQuery)
|
protected static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item)
|
||||||
{
|
|
||||||
if (item.Sni.IsNotEmpty())
|
|
||||||
{
|
|
||||||
dicQuery.Add("sni", Utils.UrlEncode(item.Sni));
|
|
||||||
}
|
|
||||||
if (item.Alpn.IsNotEmpty())
|
|
||||||
{
|
|
||||||
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
|
||||||
}
|
|
||||||
|
|
||||||
ToUriQueryAllowInsecure(item, ref dicQuery);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int ToUriQueryAllowInsecure(ProfileItem item, ref Dictionary<string, string> dicQuery)
|
|
||||||
{
|
|
||||||
if (item.AllowInsecure.Equals(Global.AllowInsecure.First()))
|
|
||||||
{
|
|
||||||
// Add two for compatibility
|
|
||||||
dicQuery.Add("insecure", "1");
|
|
||||||
dicQuery.Add("allowInsecure", "1");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dicQuery.Add("insecure", "0");
|
|
||||||
dicQuery.Add("allowInsecure", "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
|
|
||||||
{
|
{
|
||||||
item.Flow = GetQueryValue(query, "flow");
|
item.Flow = GetQueryValue(query, "flow");
|
||||||
item.StreamSecurity = GetQueryValue(query, "security");
|
item.StreamSecurity = GetQueryValue(query, "security");
|
||||||
|
|
@ -200,19 +164,7 @@ public class BaseFmt
|
||||||
item.ShortId = GetQueryDecoded(query, "sid");
|
item.ShortId = GetQueryDecoded(query, "sid");
|
||||||
item.SpiderX = GetQueryDecoded(query, "spx");
|
item.SpiderX = GetQueryDecoded(query, "spx");
|
||||||
item.Mldsa65Verify = GetQueryDecoded(query, "pqv");
|
item.Mldsa65Verify = GetQueryDecoded(query, "pqv");
|
||||||
|
item.AllowInsecure = new[] { "allowInsecure", "allow_insecure", "insecure" }.Any(k => (query[k] ?? "") == "1") ? "true" : "";
|
||||||
if (_allowInsecureArray.Any(k => GetQueryDecoded(query, k) == "1"))
|
|
||||||
{
|
|
||||||
item.AllowInsecure = Global.AllowInsecure.First();
|
|
||||||
}
|
|
||||||
else if (_allowInsecureArray.Any(k => GetQueryDecoded(query, k) == "0"))
|
|
||||||
{
|
|
||||||
item.AllowInsecure = Global.AllowInsecure.Skip(1).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item.AllowInsecure = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.Network = GetQueryValue(query, "type", nameof(ETransport.tcp));
|
item.Network = GetQueryValue(query, "type", nameof(ETransport.tcp));
|
||||||
switch (item.Network)
|
switch (item.Network)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,10 @@ public class Hysteria2Fmt : BaseFmt
|
||||||
item.Id = Utils.UrlDecode(url.UserInfo);
|
item.Id = Utils.UrlDecode(url.UserInfo);
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
ResolveUriQuery(query, ref item);
|
ResolveStdTransport(query, ref item);
|
||||||
item.Path = GetQueryDecoded(query, "obfs-password");
|
item.Path = GetQueryDecoded(query, "obfs-password");
|
||||||
|
item.AllowInsecure = GetQueryValue(query, "insecure") == "1" ? "true" : "false";
|
||||||
|
|
||||||
item.Ports = GetQueryDecoded(query, "mport");
|
item.Ports = GetQueryDecoded(query, "mport");
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
@ -44,13 +46,20 @@ public class Hysteria2Fmt : BaseFmt
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
ToUriQueryLite(item, ref dicQuery);
|
if (item.Sni.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("sni", item.Sni);
|
||||||
|
}
|
||||||
|
if (item.Alpn.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
|
}
|
||||||
if (item.Path.IsNotEmpty())
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("obfs", "salamander");
|
dicQuery.Add("obfs", "salamander");
|
||||||
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
|
dicQuery.Add("insecure", item.AllowInsecure.ToLower() == "true" ? "1" : "0");
|
||||||
if (item.Ports.IsNotEmpty())
|
if (item.Ports.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("mport", Utils.UrlEncode(item.Ports.Replace(':', '-')));
|
dicQuery.Add("mport", Utils.UrlEncode(item.Ports.Replace(':', '-')));
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class TrojanFmt : BaseFmt
|
||||||
item.Id = Utils.UrlDecode(url.UserInfo);
|
item.Id = Utils.UrlDecode(url.UserInfo);
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
ResolveUriQuery(query, ref item);
|
_ = ResolveStdTransport(query, ref item);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ public class TrojanFmt : BaseFmt
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
ToUriQuery(item, null, ref dicQuery);
|
_ = GetStdTransport(item, null, ref dicQuery);
|
||||||
|
|
||||||
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark);
|
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class TuicFmt : BaseFmt
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
ResolveUriQuery(query, ref item);
|
ResolveStdTransport(query, ref item);
|
||||||
item.HeaderType = GetQueryValue(query, "congestion_control");
|
item.HeaderType = GetQueryValue(query, "congestion_control");
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
@ -47,10 +47,15 @@ public class TuicFmt : BaseFmt
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
ToUriQueryLite(item, ref dicQuery);
|
if (item.Sni.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("sni", item.Sni);
|
||||||
|
}
|
||||||
|
if (item.Alpn.IsNotEmpty())
|
||||||
|
{
|
||||||
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
|
}
|
||||||
dicQuery.Add("congestion_control", item.HeaderType);
|
dicQuery.Add("congestion_control", item.HeaderType);
|
||||||
|
|
||||||
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark);
|
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class VLESSFmt : BaseFmt
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
item.Security = GetQueryValue(query, "encryption", Global.None);
|
item.Security = GetQueryValue(query, "encryption", Global.None);
|
||||||
item.StreamSecurity = GetQueryValue(query, "security");
|
item.StreamSecurity = GetQueryValue(query, "security");
|
||||||
ResolveUriQuery(query, ref item);
|
_ = ResolveStdTransport(query, ref item);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ public class VLESSFmt : BaseFmt
|
||||||
{
|
{
|
||||||
dicQuery.Add("encryption", Global.None);
|
dicQuery.Add("encryption", Global.None);
|
||||||
}
|
}
|
||||||
ToUriQuery(item, Global.None, ref dicQuery);
|
_ = GetStdTransport(item, Global.None, ref dicQuery);
|
||||||
|
|
||||||
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark);
|
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ public class VmessFmt : BaseFmt
|
||||||
tls = item.StreamSecurity,
|
tls = item.StreamSecurity,
|
||||||
sni = item.Sni,
|
sni = item.Sni,
|
||||||
alpn = item.Alpn,
|
alpn = item.Alpn,
|
||||||
fp = item.Fingerprint,
|
fp = item.Fingerprint
|
||||||
insecure = item.AllowInsecure.Equals(Global.AllowInsecure.First()) ? "1" : "0"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = JsonUtils.Serialize(vmessQRCode);
|
var url = JsonUtils.Serialize(vmessQRCode);
|
||||||
|
|
@ -95,7 +94,6 @@ public class VmessFmt : BaseFmt
|
||||||
item.Sni = Utils.ToString(vmessQRCode.sni);
|
item.Sni = Utils.ToString(vmessQRCode.sni);
|
||||||
item.Alpn = Utils.ToString(vmessQRCode.alpn);
|
item.Alpn = Utils.ToString(vmessQRCode.alpn);
|
||||||
item.Fingerprint = Utils.ToString(vmessQRCode.fp);
|
item.Fingerprint = Utils.ToString(vmessQRCode.fp);
|
||||||
item.AllowInsecure = vmessQRCode.insecure == "1" ? Global.AllowInsecure.First() : string.Empty;
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +118,7 @@ public class VmessFmt : BaseFmt
|
||||||
item.Id = Utils.UrlDecode(url.UserInfo);
|
item.Id = Utils.UrlDecode(url.UserInfo);
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
ResolveUriQuery(query, ref item);
|
ResolveStdTransport(query, ref item);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,4 @@ public class VmessQRCode
|
||||||
public string alpn { get; set; } = string.Empty;
|
public string alpn { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string fp { get; set; } = string.Empty;
|
public string fp { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string insecure { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1622,9 +1622,9 @@ Ne pas utiliser « Obtenir le certificat » si « Autoriser non sécurisé » es
|
||||||
<value>Certificat configuré </value>
|
<value>Certificat configuré </value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCustomSystemProxyPacPath" xml:space="preserve">
|
<data name="TbSettingsCustomSystemProxyPacPath" xml:space="preserve">
|
||||||
<value>Chemin fichier PAC personnalisé</value>
|
<value>Custom PAC file path</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCustomSystemProxyScriptPath" xml:space="preserve">
|
<data name="TbSettingsCustomSystemProxyScriptPath" xml:space="preserve">
|
||||||
<value>Chemin script proxy système personnalisé</value>
|
<value>Custom system proxy script file path</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Loading…
Reference in a new issue