mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 05:03:02 +00:00
Refactor flow
This commit is contained in:
parent
ee7d3c60b6
commit
82443a64cd
7 changed files with 13 additions and 17 deletions
|
|
@ -21,12 +21,6 @@ public class BaseFmt
|
|||
|
||||
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||
{
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("flow", protocolExtra.Flow);
|
||||
}
|
||||
|
||||
if (item.StreamSecurity.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("security", item.StreamSecurity);
|
||||
|
|
@ -209,9 +203,6 @@ public class BaseFmt
|
|||
|
||||
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
|
||||
{
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
protocolExtra.Flow = GetQueryValue(query, "flow");
|
||||
item.SetProtocolExtra(protocolExtra);
|
||||
item.StreamSecurity = GetQueryValue(query, "security");
|
||||
item.Sni = GetQueryValue(query, "sni");
|
||||
item.Alpn = GetQueryDecoded(query, "alpn");
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public class TrojanFmt : BaseFmt
|
|||
{
|
||||
ConfigType = EConfigType.Trojan
|
||||
};
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
|
||||
var url = Utils.TryUri(str);
|
||||
if (url == null)
|
||||
|
|
@ -23,8 +24,10 @@ public class TrojanFmt : BaseFmt
|
|||
item.Password = Utils.UrlDecode(url.UserInfo);
|
||||
|
||||
var query = Utils.ParseQueryString(url.Query);
|
||||
protocolExtra.Flow = GetQueryValue(query, "flow");
|
||||
ResolveUriQuery(query, ref item);
|
||||
|
||||
item.SetProtocolExtra(protocolExtra);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
@ -34,12 +37,17 @@ public class TrojanFmt : BaseFmt
|
|||
{
|
||||
return null;
|
||||
}
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
var remark = string.Empty;
|
||||
if (item.Remarks.IsNotEmpty())
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||
}
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("flow", protocolExtra.Flow);
|
||||
}
|
||||
ToUriQuery(item, null, ref dicQuery);
|
||||
|
||||
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Password, dicQuery, remark);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class VLESSFmt : BaseFmt
|
|||
|
||||
var query = Utils.ParseQueryString(url.Query);
|
||||
protocolExtra.VlessEncryption = GetQueryValue(query, "encryption", Global.None);
|
||||
protocolExtra.Flow = GetQueryValue(query, "flow");
|
||||
item.StreamSecurity = GetQueryValue(query, "security");
|
||||
ResolveUriQuery(query, ref item);
|
||||
|
||||
|
|
@ -49,6 +50,10 @@ public class VLESSFmt : BaseFmt
|
|||
var dicQuery = new Dictionary<string, string>();
|
||||
dicQuery.Add("encryption",
|
||||
!protocolExtra.VlessEncryption.IsNullOrEmpty() ? protocolExtra.VlessEncryption : Global.None);
|
||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("flow", protocolExtra.Flow);
|
||||
}
|
||||
ToUriQuery(item, Global.None, ref dicQuery);
|
||||
|
||||
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Password, dicQuery, remark);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using ServiceLib.Common;
|
||||
|
||||
namespace ServiceLib.Manager;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using ServiceLib.Common;
|
||||
|
||||
namespace ServiceLib.Models;
|
||||
|
||||
[Serializable]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace ServiceLib.Services.CoreConfig;
|
||||
|
||||
public partial class CoreConfigSingboxService
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace ServiceLib.Services.CoreConfig;
|
||||
|
||||
public partial class CoreConfigV2rayService
|
||||
|
|
|
|||
Loading…
Reference in a new issue