From 1543d974ccdf58015b2f4795f29ffa0ea6b99fa7 Mon Sep 17 00:00:00 2001 From: Andrey Petelin Date: Fri, 29 May 2026 17:45:13 +0500 Subject: [PATCH] fix: support multiple server ports for hysteria2 outbounds --- .../files/usr/lib/sing_box_config_manager.sh | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/podkop/files/usr/lib/sing_box_config_manager.sh b/podkop/files/usr/lib/sing_box_config_manager.sh index 782550f..c1a2943 100644 --- a/podkop/files/usr/lib/sing_box_config_manager.sh +++ b/podkop/files/usr/lib/sing_box_config_manager.sh @@ -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,