mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-16 04:25:45 +00:00
Support new hysteria2 stream settings
This commit is contained in:
parent
66e1aeae1f
commit
ecf8b8f939
2 changed files with 46 additions and 30 deletions
|
|
@ -335,7 +335,7 @@ public class StreamSettings4Ray
|
||||||
|
|
||||||
public HysteriaSettings4Ray? hysteriaSettings { get; set; }
|
public HysteriaSettings4Ray? hysteriaSettings { get; set; }
|
||||||
|
|
||||||
public Finalmask4Ray? finalmask { get; set; }
|
public object? finalmask { get; set; }
|
||||||
|
|
||||||
public Sockopt4Ray? sockopt { get; set; }
|
public Sockopt4Ray? sockopt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -459,12 +459,9 @@ public class HysteriaSettings4Ray
|
||||||
{
|
{
|
||||||
public int version { get; set; }
|
public int version { get; set; }
|
||||||
public string? auth { 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 class UdpHop4Ray
|
||||||
{
|
{
|
||||||
public string? port { get; set; }
|
public string? port { get; set; }
|
||||||
public string? interval { get; set; }
|
public string? interval { get; set; }
|
||||||
|
|
@ -472,14 +469,14 @@ public class HysteriaUdpHop4Ray
|
||||||
|
|
||||||
public class Finalmask4Ray
|
public class Finalmask4Ray
|
||||||
{
|
{
|
||||||
public List<Mask4Ray>? tcp { get; set; }
|
|
||||||
public List<Mask4Ray>? udp { get; set; }
|
public List<Mask4Ray>? udp { get; set; }
|
||||||
|
public QuicParams4Ray? quicParams { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Mask4Ray
|
public class Mask4Ray
|
||||||
{
|
{
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
public object? settings { get; set; }
|
public MaskSettings4Ray? settings { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MaskSettings4Ray
|
public class MaskSettings4Ray
|
||||||
|
|
@ -488,6 +485,14 @@ public class MaskSettings4Ray
|
||||||
public string? domain { get; set; }
|
public string? domain { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class QuicParams4Ray
|
||||||
|
{
|
||||||
|
public string? congestion { get; set; }
|
||||||
|
public string? brutalUp { get; set; }
|
||||||
|
public string? brutalDown { get; set; }
|
||||||
|
public UdpHop4Ray? udphop { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class AccountsItem4Ray
|
public class AccountsItem4Ray
|
||||||
{
|
{
|
||||||
public string user { get; set; }
|
public string user { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -440,10 +440,10 @@ public partial class CoreConfigV2rayService
|
||||||
kcpSettings.congestion = _config.KcpItem.Congestion;
|
kcpSettings.congestion = _config.KcpItem.Congestion;
|
||||||
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
|
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
|
||||||
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
|
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
|
||||||
streamSettings.finalmask ??= new();
|
var kcpFinalmask = new Finalmask4Ray();
|
||||||
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header))
|
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header))
|
||||||
{
|
{
|
||||||
streamSettings.finalmask.udp =
|
kcpFinalmask.udp =
|
||||||
[
|
[
|
||||||
new Mask4Ray
|
new Mask4Ray
|
||||||
{
|
{
|
||||||
|
|
@ -452,23 +452,24 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
streamSettings.finalmask.udp ??= [];
|
kcpFinalmask.udp ??= [];
|
||||||
if (path.IsNullOrEmpty())
|
if (path.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
streamSettings.finalmask.udp.Add(new Mask4Ray
|
kcpFinalmask.udp.Add(new Mask4Ray
|
||||||
{
|
{
|
||||||
type = "mkcp-original"
|
type = "mkcp-original"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
streamSettings.finalmask.udp.Add(new Mask4Ray
|
kcpFinalmask.udp.Add(new Mask4Ray
|
||||||
{
|
{
|
||||||
type = "mkcp-aes128gcm",
|
type = "mkcp-aes128gcm",
|
||||||
settings = new MaskSettings4Ray { password = path }
|
settings = new MaskSettings4Ray { password = path }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
streamSettings.kcpSettings = kcpSettings;
|
streamSettings.kcpSettings = kcpSettings;
|
||||||
|
streamSettings.finalmask = kcpFinalmask;
|
||||||
break;
|
break;
|
||||||
//ws
|
//ws
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
|
|
@ -597,28 +598,32 @@ public partial class CoreConfigV2rayService
|
||||||
: (_config.HysteriaItem.HopInterval >= 5
|
: (_config.HysteriaItem.HopInterval >= 5
|
||||||
? _config.HysteriaItem.HopInterval
|
? _config.HysteriaItem.HopInterval
|
||||||
: Global.Hysteria2DefaultHopInt).ToString();
|
: Global.Hysteria2DefaultHopInt).ToString();
|
||||||
HysteriaUdpHop4Ray? udpHop = null;
|
var hy2Finalmask = new Finalmask4Ray();
|
||||||
|
var quicParams = new QuicParams4Ray();
|
||||||
if (!ports.IsNullOrEmpty() &&
|
if (!ports.IsNullOrEmpty() &&
|
||||||
(ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
|
(ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
|
||||||
{
|
{
|
||||||
udpHop = new HysteriaUdpHop4Ray
|
var udpHop = new UdpHop4Ray
|
||||||
{
|
{
|
||||||
port = ports.Replace(':', '-'),
|
port = ports.Replace(':', '-'),
|
||||||
interval = hopInterval,
|
interval = hopInterval,
|
||||||
};
|
};
|
||||||
|
quicParams.udphop = udpHop;
|
||||||
}
|
}
|
||||||
streamSettings.hysteriaSettings = new()
|
if (upMbps > 0 || downMbps > 0)
|
||||||
{
|
{
|
||||||
version = 2,
|
quicParams.congestion = "brutal";
|
||||||
auth = _node.Password,
|
quicParams.brutalUp = upMbps > 0 ? $"{upMbps}mbps" : null;
|
||||||
up = upMbps > 0 ? $"{upMbps}mbps" : null,
|
quicParams.brutalDown = downMbps > 0 ? $"{downMbps}mbps" : null;
|
||||||
down = downMbps > 0 ? $"{downMbps}mbps" : null,
|
}
|
||||||
udphop = udpHop,
|
else
|
||||||
};
|
{
|
||||||
|
quicParams.congestion = "bbr";
|
||||||
|
}
|
||||||
|
hy2Finalmask.quicParams = quicParams;
|
||||||
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
|
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
streamSettings.finalmask ??= new();
|
hy2Finalmask.udp =
|
||||||
streamSettings.finalmask.udp =
|
|
||||||
[
|
[
|
||||||
new Mask4Ray
|
new Mask4Ray
|
||||||
{
|
{
|
||||||
|
|
@ -627,6 +632,12 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
streamSettings.hysteriaSettings = new()
|
||||||
|
{
|
||||||
|
version = 2,
|
||||||
|
auth = _node.Password,
|
||||||
|
};
|
||||||
|
streamSettings.finalmask = hy2Finalmask;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -664,7 +675,7 @@ public partial class CoreConfigV2rayService
|
||||||
|
|
||||||
if (!_node.Finalmask.IsNullOrEmpty())
|
if (!_node.Finalmask.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
streamSettings.finalmask = JsonUtils.Deserialize<Finalmask4Ray>(_node.Finalmask);
|
streamSettings.finalmask = JsonUtils.Deserialize<object>(_node.Finalmask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue