fix: pass outbound tag to security and transport functions for accurate config updates

This commit is contained in:
Andrey Petelin
2025-10-03 16:03:36 +05:00
parent a8db33dd28
commit 2e99ee3a17

View File

@@ -76,8 +76,8 @@ sing_box_cf_add_proxy_outbound() {
packet_encoding=$(url_get_query_param "$url" "packetEncoding") packet_encoding=$(url_get_query_param "$url" "packetEncoding")
config=$(sing_box_cm_add_vless_outbound "$config" "$tag" "$host" "$port" "$uuid" "$flow" "" "$packet_encoding") config=$(sing_box_cm_add_vless_outbound "$config" "$tag" "$host" "$port" "$uuid" "$flow" "" "$packet_encoding")
config=$(_add_outbound_security "$config" "$url") config=$(_add_outbound_security "$config" "$tag" "$url")
config=$(_add_outbound_transport "$config" "$url") config=$(_add_outbound_transport "$config" "$tag" "$url")
;; ;;
ss) ss)
local userinfo tag host port method password udp_over_tcp local userinfo tag host port method password udp_over_tcp
@@ -117,8 +117,8 @@ sing_box_cf_add_proxy_outbound() {
password=$(url_get_userinfo "$url") password=$(url_get_userinfo "$url")
config=$(sing_box_cm_add_trojan_outbound "$config" "$tag" "$host" "$port" "$password") config=$(sing_box_cm_add_trojan_outbound "$config" "$tag" "$host" "$port" "$password")
config=$(_add_outbound_security "$config" "$url") config=$(_add_outbound_security "$config" "$tag" "$url")
config=$(_add_outbound_transport "$config" "$url") config=$(_add_outbound_transport "$config" "$tag" "$url")
;; ;;
*) *)
log "Unsupported proxy $scheme type" log "Unsupported proxy $scheme type"
@@ -131,7 +131,8 @@ sing_box_cf_add_proxy_outbound() {
_add_outbound_security() { _add_outbound_security() {
local config="$1" local config="$1"
local url="$2" local outbound_tag="$2"
local url="$3"
local security local security
security=$(url_get_query_param "$url" "security") security=$(url_get_query_param "$url" "security")
@@ -148,7 +149,7 @@ _add_outbound_security() {
config=$( config=$(
sing_box_cm_set_tls_for_outbound \ sing_box_cm_set_tls_for_outbound \
"$config" \ "$config" \
"$tag" \ "$outbound_tag" \
"$sni" \ "$sni" \
"$([ "$insecure" == "1" ] && echo true)" \ "$([ "$insecure" == "1" ] && echo true)" \
"$([ "$alpn" == "[]" ] && echo null || echo "$alpn")" \ "$([ "$alpn" == "[]" ] && echo null || echo "$alpn")" \
@@ -168,7 +169,8 @@ _add_outbound_security() {
_add_outbound_transport() { _add_outbound_transport() {
local config="$1" local config="$1"
local url="$2" local outbound_tag="$2"
local url="$3"
local transport local transport
transport=$(url_get_query_param "$url" "type") transport=$(url_get_query_param "$url" "type")
@@ -180,11 +182,13 @@ _add_outbound_transport() {
ws_host=$(url_get_query_param "$url" "host") ws_host=$(url_get_query_param "$url" "host")
ws_early_data=$(url_get_query_param "$url" "ed") ws_early_data=$(url_get_query_param "$url" "ed")
config=$(sing_box_cm_set_ws_transport_for_outbound "$config" "$tag" "$ws_path" "$ws_host" "$ws_early_data") config=$(
sing_box_cm_set_ws_transport_for_outbound "$config" "$outbound_tag" "$ws_path" "$ws_host" "$ws_early_data"
)
;; ;;
grpc) grpc)
# TODO(ampetelin): Add handling of optional gRPC parameters; example links are needed. # TODO(ampetelin): Add handling of optional gRPC parameters; example links are needed.
config=$(sing_box_cm_set_grpc_transport_for_outbound "$config" "$tag") config=$(sing_box_cm_set_grpc_transport_for_outbound "$config" "$outbound_tag")
;; ;;
*) *)
log "Unknown transport '$transport' detected." "error" log "Unknown transport '$transport' detected." "error"