feat: add optional domain_resolver parameter to interface outbound config function

This commit is contained in:
Andrey Petelin
2025-10-02 17:48:08 +05:00
parent aea201bf24
commit f5a629afcf

View File

@@ -788,6 +788,7 @@ sing_box_cm_set_vless_tls() {
# config: JSON configuration (string) # config: JSON configuration (string)
# tag: string, identifier for the outbound # tag: string, identifier for the outbound
# interface: string, network interface to bind the outbound # interface: string, network interface to bind the outbound
# domain_resolver: string, tag of the domain resolver to be used for this outbound (optional)
# Outputs: # Outputs:
# Writes updated JSON configuration to stdout # Writes updated JSON configuration to stdout
# Example: # Example:
@@ -797,15 +798,20 @@ sing_box_cm_add_interface_outbound() {
local config="$1" local config="$1"
local tag="$2" local tag="$2"
local interface="$3" local interface="$3"
local domain_resolver="$4"
echo "$config" | jq \ echo "$config" | jq \
--arg tag "$tag" \ --arg tag "$tag" \
--arg interface "$interface" \ --arg interface "$interface" \
'.outbounds += [{ --arg domain_resolver "$domain_resolver" \
type: "direct", '.outbounds += [
tag: $tag, {
bind_interface: $interface type: "direct",
}]' tag: $tag,
bind_interface: $interface
}
+ (if $domain_resolver != "" then {domain_resolver: $domain_resolver} else {} end)
]'
} }
####################################### #######################################