Fixing valid_ipv6 function to better detect all potential cases of ipv6
This commit is contained in:
parent
1f12684a81
commit
8fb399ad68
1 changed files with 4 additions and 1 deletions
|
@ -37,8 +37,11 @@ valid_ipv4() {
|
|||
|
||||
valid_ipv6() {
|
||||
local ip=$1
|
||||
local regex='^([[:xdigit:]]{0,4}:){1,7}[[:xdigit:]]{0,4}$'
|
||||
#local regex='^$|^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$'
|
||||
|
||||
if [[ $ip =~ ^$|^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$ ]]; then
|
||||
#if [[ $ip =~ ^$|^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$ ]]; then
|
||||
if [[ $ip =~ $regex ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
|
Loading…
Reference in a new issue