Browse Source

ZOOKEEPER-3876: zkServer.sh status command fails when IPV6 is configured

Modified host and IP parsing logic for IPV6

Author: Mohammad Arshad <arshad@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>

Closes #1395 from arshadmohammad/ZOOKEEPER-3876
Mohammad Arshad 4 years ago
parent
commit
c9f1521366
1 changed files with 6 additions and 1 deletions
  1. 6 1
      bin/zkServer.sh

+ 6 - 1
bin/zkServer.sh

@@ -259,7 +259,12 @@ status)
           echo "Client port not found in the server configs"
         else
           if [[ "$clientPortAndAddress" =~ ^.*:[0-9]+ ]] ; then
-            clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'`
+            if [[ "$clientPortAndAddress" =~ \[.*\]:[0-9]+ ]] ; then
+              # Extracts address from address:port for example extracts 127::1 from "[127::1]:2181"
+              clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's|\[||' | sed -e 's|\]:.*||'`
+            else
+              clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'`
+            fi
           fi
           clientPort=`echo "$clientPortAndAddress" | sed -e 's/.*://'`
         fi