From 7b809d114b06c761d3662a8eb1c734b43503b688 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Thu, 13 May 2021 08:37:27 -0600 Subject: ncp-web: fix port checking for IPv6 dual stack Signed-off-by: nachoparker --- bin/ncp-diag | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/ncp-diag b/bin/ncp-diag index b7d65e26..e7f2223a 100644 --- a/bin/ncp-diag +++ b/bin/ncp-diag @@ -66,16 +66,15 @@ function is_port_open() { local port=$1 local public_ip - public_ip="$(curl icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; } - + public_ip="$(curl -4 https://icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; } local tmp_file=$(mktemp) local token=$(wget -T2 -t1 -qO- --keep-session-cookies --save-cookies $tmp_file https://portchecker.co | grep -oP "_csrf\" value=\"\K.*\"") - rm $tmp_file if [[ "${token}" != "" ]]; then wget -T2 -t1 -qO- --load-cookies $tmp_file https://portchecker.co --post-data "target_ip=${public_ip}&port=${port}&_csrf=${token::-1}" \ | grep -q 'open' && { echo "open"; return 1; } fi + rm $tmp_file echo "closed" } -- cgit v1.2.3