From bb6dec5d161c5d6ac8bd8154f40aae3d0f52f603 Mon Sep 17 00:00:00 2001 From: xujie86 <167618598+xujie86@users.noreply.github.com> Date: Wed, 15 Apr 2026 18:03:21 +0800 Subject: [PATCH] Update proxy_set_linux_sh --- v2rayN/ServiceLib/Sample/proxy_set_linux_sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/v2rayN/ServiceLib/Sample/proxy_set_linux_sh b/v2rayN/ServiceLib/Sample/proxy_set_linux_sh index 112bb39f..ac193d09 100644 --- a/v2rayN/ServiceLib/Sample/proxy_set_linux_sh +++ b/v2rayN/ServiceLib/Sample/proxy_set_linux_sh @@ -1,5 +1,24 @@ #!/bin/bash +trim() { + local -n ref=$1 + ref="${ref#"${ref%%[![:space:]]*}"}" + ref="${ref%"${ref##*[![:space:]]}"}" +} + +build_gsettings_array() { + [[ -z "$1" ]] && echo "[]" && return + local host joined hosts=() + IFS=',' read -ra parts <<< "$1" + for host in "${parts[@]}"; do + trim host + [[ -n "$host" ]] && hosts+=("$host") + done + [[ ${#hosts[@]} -eq 0 ]] && echo "[]" && return + printf -v joined "'%s'," "${hosts[@]}" + echo "[${joined%,}]" +} + # Function to set proxy for GNOME set_gnome_proxy() { local MODE=$1 @@ -21,7 +40,7 @@ set_gnome_proxy() { done # Set ignored hosts - gsettings set org.gnome.system.proxy ignore-hosts "['$IGNORE_HOSTS']" + gsettings set org.gnome.system.proxy ignore-hosts "$(build_gsettings_array "$IGNORE_HOSTS")" echo "GNOME: Manual proxy settings applied." echo "Proxy IP: $PROXY_IP"