From b08d3b38f70bd3270e37c9db3f5f0ff9ba05ae84 Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Thu, 2 Oct 2025 17:11:47 +0300 Subject: [PATCH] fix(ipregion): enable ipv6 cdn lookup --- ipregion.sh | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/ipregion.sh b/ipregion.sh index df72e24..b4e9347 100755 --- a/ipregion.sh +++ b/ipregion.sh @@ -134,8 +134,6 @@ declare -A CUSTOM_SERVICES=( [APPLE]="Apple" [STEAM]="Steam" [TIKTOK]="Tiktok" - [CLOUDFLARE_CDN]="Cloudflare CDN" - [YOUTUBE_CDN]="YouTube CDN" [OOKLA_SPEEDTEST]="Ookla Speedtest" [JETBRAINS]="JetBrains" [PLAYSTATION]="PlayStation" @@ -1301,17 +1299,26 @@ process_service() { process_custom_service() { local service="$1" local ipv4_result ipv6_result - local display_name="${CUSTOM_SERVICES[$service]:-$service}" - local handler_func="${CUSTOM_SERVICES_HANDLERS[$service]}" + local display_name handler_func group - if [[ -z "$display_name" ]]; then + if [[ -n "${CUSTOM_SERVICES[$service]}" ]]; then + display_name="${CUSTOM_SERVICES[$service]}" + handler_func="${CUSTOM_SERVICES_HANDLERS[$service]}" + group="custom" + elif [[ -n "${CDN_SERVICES[$service]}" ]]; then + display_name="${CDN_SERVICES[$service]}" + handler_func="${CUSTOM_SERVICES_HANDLERS[$service]}" + group="cdn" + else display_name="$service" + handler_func="${CUSTOM_SERVICES_HANDLERS[$service]}" + group="custom" fi spinner_update "$display_name" if [[ -z "$handler_func" ]]; then - log "$LOG_WARN" "Unknown custom service: $service" + log "$LOG_WARN" "Unknown service handler: $service" return fi @@ -1329,7 +1336,7 @@ process_custom_service() { ipv6_result="" fi - add_result "custom" "$display_name" "$ipv4_result" "$ipv6_result" + add_result "$group" "$display_name" "$ipv4_result" "$ipv6_result" } run_service_group() { @@ -1349,29 +1356,19 @@ run_service_group() { continue fi - if [[ "$group" == "custom" ]]; then - is_custom=true - else - is_custom=false - fi - - if [[ "$group" == "cdn" ]]; then - is_cdn=true - else - is_cdn=false - fi + case "$group" in + custom) + is_custom=true + ;; + cdn) + is_cdn=true + ;; + esac if [[ "$is_custom" == true ]]; then process_service "$service_name" true elif [[ "$is_cdn" == true ]]; then - handler_func="${CUSTOM_SERVICES_HANDLERS[$service_name]}" - display_name="${CDN_SERVICES[$service_name]}" - - if [[ -n "$handler_func" ]]; then - spinner_update "$display_name" - result=$("$handler_func" 4) - add_result "cdn" "$display_name" "$result" "" - fi + process_custom_service "$service_name" else process_service "$service_name" fi