mirror of
https://github.com/2dust/v2rayN.git
synced 2026-01-18 03:49:34 +00:00
Merge 8e36f0a375 into fe183798b6
This commit is contained in:
commit
cbc7f48df8
8 changed files with 93 additions and 11 deletions
|
|
@ -300,6 +300,7 @@ public class Global
|
||||||
EConfigType.VLESS,
|
EConfigType.VLESS,
|
||||||
EConfigType.Shadowsocks,
|
EConfigType.Shadowsocks,
|
||||||
EConfigType.Trojan,
|
EConfigType.Trojan,
|
||||||
|
EConfigType.Hysteria2,
|
||||||
EConfigType.WireGuard,
|
EConfigType.WireGuard,
|
||||||
EConfigType.SOCKS,
|
EConfigType.SOCKS,
|
||||||
EConfigType.HTTP,
|
EConfigType.HTTP,
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,7 @@ public static class ConfigHandler
|
||||||
public static async Task<int> AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
public static async Task<int> AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.Hysteria2;
|
profileItem.ConfigType = EConfigType.Hysteria2;
|
||||||
profileItem.CoreType = ECoreType.sing_box;
|
//profileItem.CoreType = ECoreType.sing_box;
|
||||||
|
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
profileItem.Id = profileItem.Id.TrimEx();
|
profileItem.Id = profileItem.Id.TrimEx();
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ public class Outboundsettings4Ray
|
||||||
|
|
||||||
public string? secretKey { get; set; }
|
public string? secretKey { get; set; }
|
||||||
|
|
||||||
public List<string>? address { get; set; }
|
public Object? address { get; set; }
|
||||||
|
public int? port { get; set; }
|
||||||
|
|
||||||
public List<WireguardPeer4Ray>? peers { get; set; }
|
public List<WireguardPeer4Ray>? peers { get; set; }
|
||||||
|
|
||||||
|
|
@ -139,6 +140,8 @@ public class Outboundsettings4Ray
|
||||||
public List<int>? reserved { get; set; }
|
public List<int>? reserved { get; set; }
|
||||||
|
|
||||||
public int? workers { get; set; }
|
public int? workers { get; set; }
|
||||||
|
|
||||||
|
public int? version { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WireguardPeer4Ray
|
public class WireguardPeer4Ray
|
||||||
|
|
@ -336,6 +339,10 @@ public class StreamSettings4Ray
|
||||||
|
|
||||||
public GrpcSettings4Ray? grpcSettings { get; set; }
|
public GrpcSettings4Ray? grpcSettings { get; set; }
|
||||||
|
|
||||||
|
public HysteriaSettings4Ray? hysteriaSettings { get; set; }
|
||||||
|
|
||||||
|
public List<UdpMasks4Ray>? udpmasks { get; set; }
|
||||||
|
|
||||||
public Sockopt4Ray? sockopt { get; set; }
|
public Sockopt4Ray? sockopt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,6 +466,32 @@ public class GrpcSettings4Ray
|
||||||
public int? initial_windows_size { get; set; }
|
public int? initial_windows_size { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class HysteriaSettings4Ray
|
||||||
|
{
|
||||||
|
public int version { get; set; }
|
||||||
|
public string? auth { get; set; }
|
||||||
|
public string? up { get; set; }
|
||||||
|
public string? down { get; set; }
|
||||||
|
public HysteriaUdpHop4Ray? udphop { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HysteriaUdpHop4Ray
|
||||||
|
{
|
||||||
|
public string? ports { get; set; }
|
||||||
|
public int? interval { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UdpMasks4Ray
|
||||||
|
{
|
||||||
|
public string type { get; set; }
|
||||||
|
public UdpMasksSettings4Ray? settings { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UdpMasksSettings4Ray
|
||||||
|
{
|
||||||
|
public string? password { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class AccountsItem4Ray
|
public class AccountsItem4Ray
|
||||||
{
|
{
|
||||||
public string user { get; set; }
|
public string user { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,18 @@ public partial class CoreConfigV2rayService
|
||||||
outbound.settings.vnext = null;
|
outbound.settings.vnext = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EConfigType.Hysteria2:
|
||||||
|
{
|
||||||
|
outbound.settings = new()
|
||||||
|
{
|
||||||
|
version = 2,
|
||||||
|
address = node.Address,
|
||||||
|
port = node.Port,
|
||||||
|
};
|
||||||
|
outbound.settings.vnext = null;
|
||||||
|
outbound.settings.servers = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case EConfigType.WireGuard:
|
case EConfigType.WireGuard:
|
||||||
{
|
{
|
||||||
var address = node.Address;
|
var address = node.Address;
|
||||||
|
|
@ -206,6 +218,10 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
|
|
||||||
outbound.protocol = Global.ProtocolTypes[node.ConfigType];
|
outbound.protocol = Global.ProtocolTypes[node.ConfigType];
|
||||||
|
if (node.ConfigType == EConfigType.Hysteria2)
|
||||||
|
{
|
||||||
|
outbound.protocol = "hysteria";
|
||||||
|
}
|
||||||
await GenBoundStreamSettings(node, outbound);
|
await GenBoundStreamSettings(node, outbound);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -246,7 +262,12 @@ public partial class CoreConfigV2rayService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var streamSettings = outbound.streamSettings;
|
var streamSettings = outbound.streamSettings;
|
||||||
streamSettings.network = node.GetNetwork();
|
var network = node.GetNetwork();
|
||||||
|
if (node.ConfigType == EConfigType.Hysteria2)
|
||||||
|
{
|
||||||
|
network = "hysteria";
|
||||||
|
}
|
||||||
|
streamSettings.network = network;
|
||||||
var host = node.RequestHost.TrimEx();
|
var host = node.RequestHost.TrimEx();
|
||||||
var path = node.Path.TrimEx();
|
var path = node.Path.TrimEx();
|
||||||
var sni = node.Sni.TrimEx();
|
var sni = node.Sni.TrimEx();
|
||||||
|
|
@ -324,7 +345,7 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
|
|
||||||
//streamSettings
|
//streamSettings
|
||||||
switch (node.GetNetwork())
|
switch (network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
KcpSettings4Ray kcpSettings = new()
|
KcpSettings4Ray kcpSettings = new()
|
||||||
|
|
@ -463,6 +484,35 @@ public partial class CoreConfigV2rayService
|
||||||
streamSettings.grpcSettings = grpcSettings;
|
streamSettings.grpcSettings = grpcSettings;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "hysteria":
|
||||||
|
HysteriaUdpHop4Ray? udpHop = null;
|
||||||
|
if (node.Ports.IsNotEmpty() &&
|
||||||
|
(node.Ports.Contains(':') || node.Ports.Contains('-') || node.Ports.Contains(',')))
|
||||||
|
{
|
||||||
|
udpHop = new()
|
||||||
|
{
|
||||||
|
ports = node.Ports.Replace(':', '-'),
|
||||||
|
interval = _config.HysteriaItem.HopInterval > 0
|
||||||
|
? _config.HysteriaItem.HopInterval
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
HysteriaSettings4Ray hysteriaSettings = new()
|
||||||
|
{
|
||||||
|
version = 2,
|
||||||
|
auth = node.Id,
|
||||||
|
up = _config.HysteriaItem.UpMbps > 0 ? $"{_config.HysteriaItem.UpMbps}mbps" : null,
|
||||||
|
down = _config.HysteriaItem.DownMbps > 0 ? $"{_config.HysteriaItem.DownMbps}mbps" : null,
|
||||||
|
udphop = udpHop,
|
||||||
|
};
|
||||||
|
streamSettings.hysteriaSettings = hysteriaSettings;
|
||||||
|
if (node.Path.IsNotEmpty())
|
||||||
|
{
|
||||||
|
streamSettings.udpmasks =
|
||||||
|
[new() { type = "salamander", settings = new() { password = node.Path.TrimEx(), } }];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//tcp
|
//tcp
|
||||||
if (node.HeaderType == Global.TcpHeaderHttp)
|
if (node.HeaderType == Global.TcpHeaderHttp)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
gridHysteria2.IsVisible = true;
|
gridHysteria2.IsVisible = true;
|
||||||
sepa2.IsVisible = false;
|
sepa2.IsVisible = false;
|
||||||
gridTransport.IsVisible = false;
|
gridTransport.IsVisible = false;
|
||||||
cmbCoreType.IsEnabled = false;
|
|
||||||
cmbFingerprint.IsEnabled = false;
|
cmbFingerprint.IsEnabled = false;
|
||||||
cmbFingerprint.SelectedValue = string.Empty;
|
cmbFingerprint.SelectedValue = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@
|
||||||
<MenuItem x:Name="menuAddVlessServer" Header="{x:Static resx:ResUI.menuAddVlessServer}" />
|
<MenuItem x:Name="menuAddVlessServer" Header="{x:Static resx:ResUI.menuAddVlessServer}" />
|
||||||
<MenuItem x:Name="menuAddShadowsocksServer" Header="{x:Static resx:ResUI.menuAddShadowsocksServer}" />
|
<MenuItem x:Name="menuAddShadowsocksServer" Header="{x:Static resx:ResUI.menuAddShadowsocksServer}" />
|
||||||
<MenuItem x:Name="menuAddTrojanServer" Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
|
<MenuItem x:Name="menuAddTrojanServer" Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
|
||||||
|
<MenuItem x:Name="menuAddHysteria2Server" Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
|
||||||
<MenuItem x:Name="menuAddWireguardServer" Header="{x:Static resx:ResUI.menuAddWireguardServer}" />
|
<MenuItem x:Name="menuAddWireguardServer" Header="{x:Static resx:ResUI.menuAddWireguardServer}" />
|
||||||
<MenuItem x:Name="menuAddSocksServer" Header="{x:Static resx:ResUI.menuAddSocksServer}" />
|
<MenuItem x:Name="menuAddSocksServer" Header="{x:Static resx:ResUI.menuAddSocksServer}" />
|
||||||
<MenuItem x:Name="menuAddHttpServer" Header="{x:Static resx:ResUI.menuAddHttpServer}" />
|
<MenuItem x:Name="menuAddHttpServer" Header="{x:Static resx:ResUI.menuAddHttpServer}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem x:Name="menuAddHysteria2Server" Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
|
|
||||||
<MenuItem x:Name="menuAddTuicServer" Header="{x:Static resx:ResUI.menuAddTuicServer}" />
|
<MenuItem x:Name="menuAddTuicServer" Header="{x:Static resx:ResUI.menuAddTuicServer}" />
|
||||||
<MenuItem x:Name="menuAddAnytlsServer" Header="{x:Static resx:ResUI.menuAddAnytlsServer}" />
|
<MenuItem x:Name="menuAddAnytlsServer" Header="{x:Static resx:ResUI.menuAddAnytlsServer}" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ public partial class AddServerWindow
|
||||||
gridHysteria2.Visibility = Visibility.Visible;
|
gridHysteria2.Visibility = Visibility.Visible;
|
||||||
sepa2.Visibility = Visibility.Collapsed;
|
sepa2.Visibility = Visibility.Collapsed;
|
||||||
gridTransport.Visibility = Visibility.Collapsed;
|
gridTransport.Visibility = Visibility.Collapsed;
|
||||||
cmbCoreType.IsEnabled = false;
|
|
||||||
cmbFingerprint.IsEnabled = false;
|
cmbFingerprint.IsEnabled = false;
|
||||||
cmbFingerprint.Text = string.Empty;
|
cmbFingerprint.Text = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,10 @@
|
||||||
x:Name="menuAddTrojanServer"
|
x:Name="menuAddTrojanServer"
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
|
Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
|
||||||
|
<MenuItem
|
||||||
|
x:Name="menuAddHysteria2Server"
|
||||||
|
Height="{StaticResource MenuItemHeight}"
|
||||||
|
Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="menuAddWireguardServer"
|
x:Name="menuAddWireguardServer"
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
|
|
@ -112,10 +116,6 @@
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
Header="{x:Static resx:ResUI.menuAddHttpServer}" />
|
Header="{x:Static resx:ResUI.menuAddHttpServer}" />
|
||||||
<Separator Margin="-40,5" />
|
<Separator Margin="-40,5" />
|
||||||
<MenuItem
|
|
||||||
x:Name="menuAddHysteria2Server"
|
|
||||||
Height="{StaticResource MenuItemHeight}"
|
|
||||||
Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="menuAddTuicServer"
|
x:Name="menuAddTuicServer"
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue