Compare commits

...

6 commits

Author SHA1 Message Date
DHR60
30dd9f95e3
Merge 5414bae069 into 661affd6a5 2026-03-23 09:56:50 +08:00
DHR60
661affd6a5
Tag add remark (#8980)
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / deb (push) Blocked by required conditions
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
2026-03-23 09:12:14 +08:00
DHR60
14c5b92423
Fix edge case (#8979) 2026-03-23 09:11:33 +08:00
DHR60
5414bae069 Sync 2026-03-09 22:20:05 +08:00
DHR60
4a10a862eb Fix 2026-03-09 22:17:47 +08:00
DHR60
ecf8b8f939 Support new hysteria2 stream settings 2026-03-08 16:36:55 +08:00
5 changed files with 71 additions and 44 deletions

View file

@ -337,7 +337,7 @@ public class StreamSettings4Ray
public HysteriaSettings4Ray? hysteriaSettings { get; set; }
public Finalmask4Ray? finalmask { get; set; }
public object? finalmask { get; set; }
public Sockopt4Ray? sockopt { get; set; }
}
@ -462,27 +462,24 @@ 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 class UdpHop4Ray
{
public string? port { get; set; }
public string? ports { get; set; }
public string? interval { get; set; }
}
public class Finalmask4Ray
{
public List<Mask4Ray>? tcp { get; set; }
public List<Mask4Ray>? udp { get; set; }
public QuicParams4Ray? quicParams { get; set; }
}
public class Mask4Ray
{
public string type { get; set; }
public object? settings { get; set; }
public MaskSettings4Ray? settings { get; set; }
}
public class MaskSettings4Ray
@ -491,6 +488,14 @@ public class MaskSettings4Ray
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 string user { get; set; }

View file

@ -224,13 +224,14 @@ public partial class CoreConfigSingboxService
password = protocolExtra.SalamanderPass.TrimEx(),
};
}
outbound.up_mbps = protocolExtra?.UpMbps is { } su and >= 0
int? upMbps = protocolExtra?.UpMbps is { } su and >= 0
? su
: _config.HysteriaItem.UpMbps;
outbound.down_mbps = protocolExtra?.DownMbps is { } sd and >= 0
int? downMbps = protocolExtra?.DownMbps is { } sd and >= 0
? sd
: _config.HysteriaItem.DownMbps;
: _config.HysteriaItem.UpMbps;
outbound.up_mbps = upMbps > 0 ? upMbps : null;
outbound.down_mbps = downMbps > 0 ? downMbps : null;
var ports = protocolExtra?.Ports?.IsNullOrEmpty() == false ? protocolExtra.Ports : null;
if ((!ports.IsNullOrEmpty()) && (ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
{
@ -571,7 +572,12 @@ public partial class CoreConfigSingboxService
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes[i];
var currentTag = $"{baseTagName}-{i + 1}";
var currentTag = $"{baseTagName}-{i + 1}-{node.Remarks}";
if (nodes.Count == 1)
{
currentTag = baseTagName;
}
if (node.ConfigType.IsGroupType())
{
@ -602,8 +608,8 @@ public partial class CoreConfigSingboxService
for (var i = 0; i < nodesReverse.Count; i++)
{
var node = nodesReverse[i];
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}";
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}" : null;
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}-{node.Remarks}";
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}-{node.Remarks}" : null;
if (node.ConfigType.IsGroupType())
{
var childProfiles = new CoreConfigSingboxService(context with { Node = node, }).BuildGroupProxyOutbounds(currentTag);

View file

@ -494,7 +494,7 @@ public partial class CoreConfigSingboxService
return Global.ProxyTag;
}
var tag = $"{node.IndexId}-{Global.ProxyTag}";
var tag = $"{node.IndexId}-{Global.ProxyTag}-{node.Remarks}";
if (_coreConfig.outbounds.Any(o => o.tag.StartsWith(tag))
|| (_coreConfig.endpoints != null && _coreConfig.endpoints.Any(e => e.tag.StartsWith(tag))))
{

View file

@ -441,10 +441,10 @@ public partial class CoreConfigV2rayService
kcpSettings.congestion = _config.KcpItem.Congestion;
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
streamSettings.finalmask ??= new();
var kcpFinalmask = new Finalmask4Ray();
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header))
{
streamSettings.finalmask.udp =
kcpFinalmask.udp =
[
new Mask4Ray
{
@ -453,23 +453,24 @@ public partial class CoreConfigV2rayService
}
];
}
streamSettings.finalmask.udp ??= [];
kcpFinalmask.udp ??= [];
if (path.IsNullOrEmpty())
{
streamSettings.finalmask.udp.Add(new Mask4Ray
kcpFinalmask.udp.Add(new Mask4Ray
{
type = "mkcp-original"
});
}
else
{
streamSettings.finalmask.udp.Add(new Mask4Ray
kcpFinalmask.udp.Add(new Mask4Ray
{
type = "mkcp-aes128gcm",
settings = new MaskSettings4Ray { password = path }
});
}
streamSettings.kcpSettings = kcpSettings;
streamSettings.finalmask = kcpFinalmask;
break;
//ws
case nameof(ETransport.ws):
@ -598,36 +599,46 @@ public partial class CoreConfigV2rayService
: (_config.HysteriaItem.HopInterval >= 5
? _config.HysteriaItem.HopInterval
: Global.Hysteria2DefaultHopInt).ToString();
HysteriaUdpHop4Ray? udpHop = null;
var hy2Finalmask = new Finalmask4Ray();
var quicParams = new QuicParams4Ray();
if (!ports.IsNullOrEmpty() &&
(ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
{
udpHop = new HysteriaUdpHop4Ray
var udpHop = new UdpHop4Ray
{
port = ports.Replace(':', '-'),
ports = ports.Replace(':', '-'),
interval = hopInterval,
};
quicParams.udpHop = udpHop;
}
if (upMbps > 0 || downMbps > 0)
{
quicParams.congestion = "brutal";
quicParams.brutalUp = upMbps > 0 ? $"{upMbps}mbps" : null;
quicParams.brutalDown = downMbps > 0 ? $"{downMbps}mbps" : null;
}
else
{
quicParams.congestion = "bbr";
}
hy2Finalmask.quicParams = quicParams;
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
{
hy2Finalmask.udp =
[
new Mask4Ray
{
type = "salamander",
settings = new MaskSettings4Ray { password = protocolExtra.SalamanderPass.TrimEx(), }
}
];
}
streamSettings.hysteriaSettings = new()
{
version = 2,
auth = _node.Password,
up = upMbps > 0 ? $"{upMbps}mbps" : null,
down = downMbps > 0 ? $"{downMbps}mbps" : null,
udphop = udpHop,
};
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
{
streamSettings.finalmask ??= new();
streamSettings.finalmask.udp =
[
new Mask4Ray
{
type = "salamander",
settings = new MaskSettings4Ray { password = protocolExtra.SalamanderPass.TrimEx(), }
}
];
}
streamSettings.finalmask = hy2Finalmask;
break;
default:
@ -665,7 +676,7 @@ public partial class CoreConfigV2rayService
if (!_node.Finalmask.IsNullOrEmpty())
{
streamSettings.finalmask = JsonUtils.Deserialize<Finalmask4Ray>(_node.Finalmask);
streamSettings.finalmask = JsonUtils.ParseJson(_node.Finalmask);
}
}
catch (Exception ex)
@ -688,7 +699,12 @@ public partial class CoreConfigV2rayService
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes[i];
var currentTag = $"{baseTagName}-{i + 1}";
var currentTag = $"{baseTagName}-{i + 1}-{node.Remarks}";
if (nodes.Count == 1)
{
currentTag = baseTagName;
}
if (node.ConfigType.IsGroupType())
{
@ -719,8 +735,8 @@ public partial class CoreConfigV2rayService
for (var i = 0; i < nodesReverse.Count; i++)
{
var node = nodesReverse[i];
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}";
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}" : null;
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}-{node.Remarks}";
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}-{node.Remarks}" : null;
if (node.ConfigType.IsGroupType())
{
var childProfiles = new CoreConfigV2rayService(context with { Node = node, }).BuildGroupProxyOutbounds(currentTag);

View file

@ -164,7 +164,7 @@ public partial class CoreConfigV2rayService
return Global.ProxyTag;
}
var tag = $"{node.IndexId}-{Global.ProxyTag}";
var tag = $"{node.IndexId}-{Global.ProxyTag}-{node.Remarks}";
if (_coreConfig.outbounds.Any(p => p.tag.StartsWith(tag)))
{
return tag;