fix: support multiple server ports for hysteria2 outbounds

This commit is contained in:
Andrey Petelin
2026-05-29 17:45:13 +05:00
parent 4b03c28c41
commit 1543d974cc

View File

@@ -692,6 +692,11 @@ sing_box_cm_add_hysteria2_outbound() {
local download_mbps="$9"
local network="${10}"
local is_multi_port="false"
case "$server_port" in
*","*|*"-"*) is_multi_port="true" ;;
esac
echo "$config" | jq \
--arg tag "$tag" \
--arg server_address "$server_address" \
@@ -702,14 +707,25 @@ sing_box_cm_add_hysteria2_outbound() {
--arg upload_mbps "$upload_mbps" \
--arg download_mbps "$download_mbps" \
--arg network "$network" \
'.outbounds += [(
--argjson is_multi_port "$is_multi_port" \
'
def parse_port_entry:
if index("-") then split("-") | join(":")
else . + ":" + .
end;
.outbounds += [(
{
type: "hysteria2",
tag: $tag,
server: $server_address,
server_port: ($server_port | tonumber),
password: $password
}
+ (if $is_multi_port then {
server_ports: ($server_port | split(",") | map(ltrimstr(" ") | rtrimstr(" ") | parse_port_entry))
} else {
server_port: ($server_port | tonumber)
} end)
+ (if $obfuscator_type != "" and $obfuscator_password != "" then {
obfs: {
type: $obfuscator_type,