mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-31 09:35:00 +03:00
Refactor Transport (#9004)
* Refactor transport * Rename tcp to raw * Fix * Fix Fix raw http ui Fill xhttp default mode Fix share uri Remove RawHost Fix singbox tcp http path Fix vmess share uri * Tidy Resx * Fix * Rename TransportExtra to TransportExtraItem --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
@@ -4,12 +4,13 @@ namespace ServiceLib.Models;
|
||||
public class ProfileItem
|
||||
{
|
||||
private ProtocolExtraItem? _protocolExtraCache;
|
||||
private TransportExtraItem? _transportExtraCache;
|
||||
|
||||
public ProfileItem()
|
||||
{
|
||||
IndexId = string.Empty;
|
||||
ConfigType = EConfigType.VMess;
|
||||
ConfigVersion = 3;
|
||||
ConfigVersion = 4;
|
||||
Subid = string.Empty;
|
||||
Address = string.Empty;
|
||||
Port = 0;
|
||||
@@ -17,9 +18,6 @@ public class ProfileItem
|
||||
Username = string.Empty;
|
||||
Network = string.Empty;
|
||||
Remarks = string.Empty;
|
||||
HeaderType = string.Empty;
|
||||
RequestHost = string.Empty;
|
||||
Path = string.Empty;
|
||||
StreamSecurity = string.Empty;
|
||||
AllowInsecure = string.Empty;
|
||||
}
|
||||
@@ -126,20 +124,26 @@ public class ProfileItem
|
||||
return true;
|
||||
}
|
||||
|
||||
public ProtocolExtraItem GetProtocolExtra()
|
||||
{
|
||||
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
||||
}
|
||||
|
||||
public void SetProtocolExtra(ProtocolExtraItem extraItem)
|
||||
{
|
||||
_protocolExtraCache = extraItem;
|
||||
ProtoExtra = JsonUtils.Serialize(extraItem, false);
|
||||
}
|
||||
|
||||
public void SetProtocolExtra()
|
||||
public TransportExtraItem GetTransportExtra()
|
||||
{
|
||||
ProtoExtra = JsonUtils.Serialize(_protocolExtraCache, false);
|
||||
return _transportExtraCache ??= JsonUtils.Deserialize<TransportExtraItem>(TransportExtra) ?? new TransportExtraItem();
|
||||
}
|
||||
|
||||
public ProtocolExtraItem GetProtocolExtra()
|
||||
public void SetTransportExtra(TransportExtraItem transportExtra)
|
||||
{
|
||||
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
||||
_transportExtraCache = transportExtra;
|
||||
TransportExtra = JsonUtils.Serialize(transportExtra, false);
|
||||
}
|
||||
|
||||
#endregion function
|
||||
@@ -160,9 +164,16 @@ public class ProfileItem
|
||||
public string Password { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Network { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.RawHeaderType/XhttpMode/GrpcMode/KcpHeaderType instead.")]
|
||||
public string HeaderType { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.Host/GrpcAuthority instead.")]
|
||||
public string RequestHost { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.Path/GrpcServiceName/KcpSeed instead.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
public string StreamSecurity { get; set; }
|
||||
public string AllowInsecure { get; set; }
|
||||
public string Sni { get; set; }
|
||||
@@ -172,7 +183,10 @@ public class ProfileItem
|
||||
public string ShortId { get; set; }
|
||||
public string SpiderX { get; set; }
|
||||
public string Mldsa65Verify { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.XhttpExtra instead.")]
|
||||
public string Extra { get; set; }
|
||||
|
||||
public bool? MuxEnabled { get; set; }
|
||||
public string Cert { get; set; }
|
||||
public string CertSha { get; set; }
|
||||
@@ -181,6 +195,7 @@ public class ProfileItem
|
||||
public string Finalmask { get; set; }
|
||||
|
||||
public string ProtoExtra { get; set; }
|
||||
public string TransportExtra { get; set; }
|
||||
|
||||
[Obsolete("Use ProtocolExtraItem.Ports instead.")]
|
||||
public string Ports { get; set; }
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace ServiceLib.Models;
|
||||
|
||||
public record TransportExtraItem
|
||||
{
|
||||
public string? RawHeaderType { get; init; }
|
||||
|
||||
public string? Host { get; init; }
|
||||
public string? Path { get; init; }
|
||||
public string? XhttpMode { get; init; }
|
||||
public string? XhttpExtra { get; init; }
|
||||
|
||||
public string? GrpcAuthority { get; init; }
|
||||
public string? GrpcServiceName { get; init; }
|
||||
public string? GrpcMode { get; init; }
|
||||
|
||||
public string? KcpHeaderType { get; init; }
|
||||
public string? KcpSeed { get; init; }
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public class StreamSettings4Ray
|
||||
|
||||
public TlsSettings4Ray? tlsSettings { get; set; }
|
||||
|
||||
public TcpSettings4Ray? tcpSettings { get; set; }
|
||||
public RawSettings4Ray? rawSettings { get; set; }
|
||||
|
||||
public KcpSettings4Ray? kcpSettings { get; set; }
|
||||
|
||||
@@ -385,7 +385,7 @@ public class CertificateSettings4Ray
|
||||
public string? usage { get; set; }
|
||||
}
|
||||
|
||||
public class TcpSettings4Ray
|
||||
public class RawSettings4Ray
|
||||
{
|
||||
public Header4Ray header { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user