Skip to content

Commit

Permalink
update quic
Browse files Browse the repository at this point in the history
  • Loading branch information
next-autumn committed Nov 24, 2022
1 parent e86db63 commit 433883c
Show file tree
Hide file tree
Showing 18 changed files with 489 additions and 14 deletions.
6 changes: 3 additions & 3 deletions ProxySuper.Core/Models/Projects/V2raySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ public V2raySettings()
VLESS_WS_Path = "/" + Utils.RandomString(6);
VLESS_KCP_Type = "none";
VLESS_KCP_Seed = guid;
VLESS_QUIC_Key = "";
VLESS_QUIC_Type = "none";
VLESS_QUIC_Security = "none";
VLESS_QUIC_Type = "none";
VLESS_gRPC_ServiceName = "/" + Utils.RandomString(7);
VLESS_gRPC_ServiceName = Utils.RandomString(7);

VMESS_WS_Path = "/" + Utils.RandomString(8);
VMESS_TCP_Path = "/" + Utils.RandomString(9);
VMESS_KCP_Seed = guid;
VMESS_QUIC_Key = "";
VMESS_KCP_Type = "none";
VMESS_QUIC_Security = "none";
VMESS_QUIC_Type = "none";
Expand Down Expand Up @@ -98,8 +100,6 @@ public List<int> FreePorts
}
}

//public ProjectType Type { get; set; } = ProjectType.Xray;

/// <summary>
/// 是否安装证书,
/// 上传自有证书时选False,则不会自动安装证书。
Expand Down
43 changes: 35 additions & 8 deletions ProxySuper.Core/Services/ShareLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ public static string Build(RayType xrayType, V2raySettings settings)
case RayType.VLESS_TCP_XTLS:
case RayType.VLESS_WS:
case RayType.VLESS_KCP:
case RayType.VLESS_QUIC:
case RayType.VLESS_gRPC:
case RayType.Trojan_TCP:
return BuildVlessShareLink(xrayType, settings);
case RayType.VMESS_TCP:
case RayType.VMESS_WS:
case RayType.VMESS_KCP:
case RayType.VMESS_QUIC:
return BuildVmessShareLink(xrayType, settings);
case RayType.ShadowsocksAEAD:
return BuildShadowSocksShareLink(settings);
Expand Down Expand Up @@ -142,6 +144,15 @@ private static string BuildVmessShareLink(RayType xrayType, V2raySettings settin
vmess.path = settings.VMESS_KCP_Seed;
vmess.tls = "";
break;
case RayType.VMESS_QUIC:
vmess.ps = "vmess-quic";
vmess.port = settings.VMESS_QUIC_Port.ToString();
vmess.net = "quic";
vmess.type = settings.VMESS_QUIC_Type;
vmess.path = settings.VMESS_QUIC_Key;
vmess.host = settings.VMESS_QUIC_Security;
vmess.tls = "tls";
break;
default:
return string.Empty;
}
Expand All @@ -162,8 +173,6 @@ private static string BuildVlessShareLink(RayType xrayType, V2raySettings settin
var _path = "/";
var _host = settings.Domain;
var _descriptiveText = string.Empty;
var _headerType = "none";
var _seed = string.Empty;

switch (xrayType)
{
Expand All @@ -187,12 +196,17 @@ private static string BuildVlessShareLink(RayType xrayType, V2raySettings settin
case RayType.VLESS_KCP:
_protocol = "vless";
_type = "kcp";
_headerType = settings.VLESS_KCP_Type;
_seed = settings.VLESS_KCP_Seed;
_port = settings.VLESS_KCP_Port;
_security = "none";
_descriptiveText = "vless-mKCP";
break;
case RayType.VLESS_QUIC:
_protocol = "vless";
_port = settings.VLESS_QUIC_Port;
_type = "quic";
_security = "tls";
_descriptiveText = "vless-quic";
break;
case RayType.VLESS_gRPC:
_protocol = "vless";
_type = "grpc";
Expand All @@ -213,19 +227,32 @@ private static string BuildVlessShareLink(RayType xrayType, V2raySettings settin
if (xrayType != RayType.Trojan_TCP)
{
// 4.3 传输层相关段
parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&path={HttpUtility.UrlEncode(_path)}&headerType={_headerType}";
parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&path={HttpUtility.UrlEncode(_path)}";

// kcp
if (xrayType == RayType.VLESS_KCP)
{
parametersURL += $"&seed={_seed}";
parametersURL += $"&seed={settings.VLESS_KCP_Seed}&headerType={settings.VLESS_KCP_Type}";
}

if (xrayType == RayType.VLESS_QUIC)
{
parametersURL += $"&quicSecurity={settings.VLESS_QUIC_Security}";
if (settings.VLESS_QUIC_Security != "none")
{
parametersURL += $"&key={HttpUtility.UrlEncode(settings.VLESS_QUIC_Key)}";
}
parametersURL += $"&headerType={settings.VLESS_QUIC_Type}";
}

// 4.4 TLS 相关段
if (settings is XraySettings)
{
var xraySettings = settings as XraySettings;
parametersURL += $"&flow={xraySettings.Flow}";
if (xrayType == RayType.VLESS_TCP_XTLS)
{
var xraySettings = settings as XraySettings;
parametersURL += $"&flow={xraySettings.Flow}";
}
}


Expand Down
34 changes: 34 additions & 0 deletions ProxySuper.Core/Services/V2rayConfigBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public static string BuildV2rayConfig(V2raySettings parameters)
}
#endregion

#region VLESS GRPC
if (parameters.Types.Contains(RayType.VLESS_gRPC))
{
var gRPCInBound = GetBound("VLESS_gRPC.json");
Expand All @@ -196,7 +197,9 @@ public static string BuildV2rayConfig(V2raySettings parameters)
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
}
#endregion

#region VLESS KCP
if (parameters.Types.Contains(RayType.VLESS_KCP))
{
var kcpBound = GetBound("VLESS_KCP.json");
Expand All @@ -206,7 +209,22 @@ public static string BuildV2rayConfig(V2raySettings parameters)
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
#endregion

#region VLESS QUIC
if (parameters.Types.Contains(RayType.VLESS_QUIC))
{
var quicBound = GetBound("VLESS_QUIC.json");
quicBound.port = parameters.VLESS_QUIC_Port;
SetClients(quicBound, uuidList);
quicBound.streamSettings.quicSettings.security = parameters.VLESS_QUIC_Security;
quicBound.streamSettings.quicSettings.key = parameters.VLESS_QUIC_Key;
quicBound.streamSettings.quicSettings.header.type = parameters.VLESS_QUIC_Type;
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
}
#endregion

#region VMESS KCP
if (parameters.Types.Contains(RayType.VMESS_KCP))
{
var kcpBound = GetBound("VMESS_KCP.json");
Expand All @@ -216,7 +234,22 @@ public static string BuildV2rayConfig(V2raySettings parameters)
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
#endregion

#region VMESS QUIC
if (parameters.Types.Contains(RayType.VMESS_QUIC))
{
var quicBound = GetBound("VMESS_QUIC.json");
quicBound.port = parameters.VMESS_QUIC_Port;
SetClients(quicBound, uuidList);
quicBound.streamSettings.quicSettings.security = parameters.VMESS_QUIC_Security;
quicBound.streamSettings.quicSettings.key = parameters.VMESS_QUIC_Key;
quicBound.streamSettings.quicSettings.header.type = parameters.VMESS_QUIC_Type;
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
}
#endregion

#region Shadowsocks
if (parameters.Types.Contains(RayType.ShadowsocksAEAD))
{
var ssBound = GetBound("Shadowsocks-AEAD.json");
Expand All @@ -225,6 +258,7 @@ public static string BuildV2rayConfig(V2raySettings parameters)
ssBound.settings.method = parameters.ShadowSocksMethod;
xrayConfig.inbounds.Add(JToken.FromObject(ssBound));
}
#endregion

return JsonConvert.SerializeObject(
xrayConfig,
Expand Down
35 changes: 34 additions & 1 deletion ProxySuper.Core/Services/XrayConfigBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ private static void SetClients(dynamic bound, List<string> uuidList, bool withXt
});
}


public static string BuildXrayConfig(XraySettings parameters)
{
var uuidList = new List<string>();
Expand Down Expand Up @@ -190,6 +189,7 @@ public static string BuildXrayConfig(XraySettings parameters)
}
#endregion

#region VLESS GRPC
if (parameters.Types.Contains(RayType.VLESS_gRPC))
{
var gRPCInBound = GetBound("VLESS_gRPC.json");
Expand All @@ -199,7 +199,9 @@ public static string BuildXrayConfig(XraySettings parameters)
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
}
#endregion

#region VLESS KCP
if (parameters.Types.Contains(RayType.VLESS_KCP))
{
var kcpBound = GetBound("VLESS_KCP.json");
Expand All @@ -209,7 +211,22 @@ public static string BuildXrayConfig(XraySettings parameters)
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
#endregion

#region VLESS QUIC
if (parameters.Types.Contains(RayType.VLESS_QUIC))
{
var quicBound = GetBound("VLESS_QUIC.json");
quicBound.port = parameters.VLESS_QUIC_Port;
SetClients(quicBound, uuidList);
quicBound.streamSettings.quicSettings.security = parameters.VLESS_QUIC_Security;
quicBound.streamSettings.quicSettings.key = parameters.VLESS_QUIC_Key;
quicBound.streamSettings.quicSettings.header.type = parameters.VLESS_QUIC_Type;
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
}
#endregion

#region VMESS KCP
if (parameters.Types.Contains(RayType.VMESS_KCP))
{
var kcpBound = GetBound("VMESS_KCP.json");
Expand All @@ -219,7 +236,22 @@ public static string BuildXrayConfig(XraySettings parameters)
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
#endregion

#region VMESS QUIC
if (parameters.Types.Contains(RayType.VMESS_QUIC))
{
var quicBound = GetBound("VMESS_QUIC.json");
quicBound.port = parameters.VMESS_QUIC_Port;
SetClients(quicBound, uuidList);
quicBound.streamSettings.quicSettings.security = parameters.VMESS_QUIC_Security;
quicBound.streamSettings.quicSettings.key = parameters.VMESS_QUIC_Key;
quicBound.streamSettings.quicSettings.header.type = parameters.VMESS_QUIC_Type;
xrayConfig.inbounds.Add(JToken.FromObject(quicBound));
}
#endregion

#region Shadowsocks
if (parameters.Types.Contains(RayType.ShadowsocksAEAD))
{
var ssBound = GetBound("Shadowsocks-AEAD.json");
Expand All @@ -228,6 +260,7 @@ public static string BuildXrayConfig(XraySettings parameters)
ssBound.settings.method = parameters.ShadowSocksMethod;
xrayConfig.inbounds.Add(JToken.FromObject(ssBound));
}
#endregion

return JsonConvert.SerializeObject(
xrayConfig,
Expand Down
16 changes: 16 additions & 0 deletions ProxySuper.Core/ViewModels/V2rayConfigViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public bool Checked_VLESS_KCP
}
}

public bool Checked_VLESS_QUIC
{
get
{
return Settings.Types.Contains(RayType.VLESS_QUIC);
}
}

public bool Checked_VLESS_gRPC
{
get
Expand Down Expand Up @@ -74,6 +82,14 @@ public bool Checked_VMESS_KCP
}
}

public bool Checked_VMESS_QUIC
{
get
{
return Settings.Types.Contains(RayType.VMESS_QUIC);
}
}

public bool Checked_Trojan_TCP
{
get
Expand Down
16 changes: 16 additions & 0 deletions ProxySuper.Core/ViewModels/XrayConfigViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public bool Checked_VLESS_KCP
}
}

public bool Checked_VLESS_QUIC
{
get
{
return Settings.Types.Contains(RayType.VLESS_QUIC);
}
}

public bool Checked_VLESS_gRPC
{
get
Expand Down Expand Up @@ -87,6 +95,14 @@ public bool Checked_VMESS_KCP
}
}

public bool Checked_VMESS_QUIC
{
get
{
return Settings.Types.Contains(RayType.VMESS_QUIC);
}
}

public bool Checked_Trojan_TCP
{
get
Expand Down
61 changes: 61 additions & 0 deletions ProxySuper.WPF/Controls/VLESS_QUIC_Control.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<UserControl x:Class="ProxySuper.WPF.Controls.VLESS_QUIC_Control"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
mc:Ignorable="d">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="140" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="140" />
<TextBox Text="{Binding Path=Settings.VLESS_KCP_Port,Mode=OneTime}" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="140" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(security)" Width="140" />
<TextBox Text="none" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="140" />
<TextBox Text="quic" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="140" />
<TextBox Text="{Binding Settings.VLESS_QUIC_Type}" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="140" />
<TextBox Text="{Binding Settings.VLESS_QUIC_Security}" IsReadOnly="True" Width="300" />
<Label Content="QUIC加密方式" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="140" />
<TextBox Text="{Binding Settings.VLESS_QUIC_Key}" IsReadOnly="True" Width="300" />
<Label Content="QUIC密钥" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="140" />
<TextBox Text="" IsReadOnly="True" Width="300" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="分享链接(ShareLink)" Width="140" />
<TextBox Text="{Binding Settings.VLESS_QUIC_ShareLink,Mode=OneTime}" Width="300" IsReadOnly="True" />
</StackPanel>
</StackPanel>
</UserControl>
Loading

0 comments on commit 433883c

Please sign in to comment.