Skip to content

Commit

Permalink
feat: port_check.sh support ipv6
Browse files Browse the repository at this point in the history
Signed-off-by: qiuwei <[email protected]>
  • Loading branch information
qiuwei68 committed Jul 8, 2024
1 parent dfe4175 commit 87eddd8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hack/k8s-in-k8s/port_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ function check_port {
local ip=$1
local port=$2

if timeout 1 curl -s --connect-timeout 3 $ip:$port >/dev/null; then
# Check if the IP address is IPv6, then enclose it in square brackets
if [[ $ip =~ .*:.* ]]; then
ip="[$ip]"
fi

if timeout 1 curl -s --connect-timeout 3 "${ip}:${port}" >/dev/null; then
return 0
else
return 1
Expand Down

0 comments on commit 87eddd8

Please sign in to comment.