From 1429659fd1b4c1c0f1e9d841d5fa5325e2c2cdb0 Mon Sep 17 00:00:00 2001 From: ats777 Date: Tue, 13 Aug 2024 02:42:55 +0900 Subject: [PATCH] Add support for specifying IPv6 addresses in dns.conf --- src/helpers.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/helpers.sh b/src/helpers.sh index 7fc8f94..53daeb2 100755 --- a/src/helpers.sh +++ b/src/helpers.sh @@ -241,15 +241,14 @@ getDNS() { # $2 = active dns list # $! = Separated string of dns config elements parseDNSLine() { - IFS=':' read -r -a ARRAY <<< "$1" - if [[ "${ARRAY[0]}" =~ ^# ]] || [ "${ARRAY[0]}" == "" ] || [ "${ARRAY[1]}" == "" ]; then + if echo "$1" | grep -Eq '^[^#]+:.+'; then + local ID=$(trim "${1%%:*}") + local DNS=$(echo "${1#*:}" | sed 's/ //g' | sed 's/,/ \/ /g') + local ICON=$ICON_DNS + else return fi - local ID=$(trim "${ARRAY[0]}") - local DNS=$(echo "${ARRAY[1]}" | sed 's/ //g' | sed 's/,/ \/ /g') - local ICON=$ICON_DNS - if [ "$DNS" == "$2" ]; then ICON=$ICON_DNS_USED ID="$ID (used)"