Revert "Add is_ipv4() and ipv4_match() functions"
Broke `ip=<IPv4 address>`.
This reverts commit 0caed7ca2a
.
This commit is contained in:
parent
1766313397
commit
8b2ede16c0
1 changed files with 4 additions and 20 deletions
24
ddclient
24
ddclient
|
@ -947,7 +947,7 @@ sub update_nics {
|
||||||
if !$daemon || opt('verbose');
|
if !$daemon || opt('verbose');
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (!is_ipv4($ip)) {
|
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
||||||
if (!extract_ipv6($ip)) {
|
if (!extract_ipv6($ip)) {
|
||||||
warning("malformed IP address (%s)", $ip);
|
warning("malformed IP address (%s)", $ip);
|
||||||
next;
|
next;
|
||||||
|
@ -1900,7 +1900,7 @@ sub check_value {
|
||||||
|
|
||||||
} elsif ($type eq T_IP) {
|
} elsif ($type eq T_IP) {
|
||||||
if (!extract_ipv6($value)) {
|
if (!extract_ipv6($value)) {
|
||||||
return undef if !is_ipv4($value);
|
return undef if $value !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -2281,7 +2281,8 @@ sub get_ip {
|
||||||
}
|
}
|
||||||
if (defined($ip)) {
|
if (defined($ip)) {
|
||||||
# no need to parse $reply
|
# no need to parse $reply
|
||||||
} elsif ($ip = extract_ipv4($reply)) {
|
} elsif ($reply =~ /^.*?\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b.*/is) {
|
||||||
|
$ip = $1;
|
||||||
$ip = un_zero_pad($ip);
|
$ip = un_zero_pad($ip);
|
||||||
} elsif ($ip = extract_ipv6($reply)) {
|
} elsif ($ip = extract_ipv6($reply)) {
|
||||||
$ip = un_zero_pad($ip);
|
$ip = un_zero_pad($ip);
|
||||||
|
@ -2296,23 +2297,6 @@ sub get_ip {
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## is_ipv4() validates if string is valid IPv4 address and only
|
|
||||||
## a valid IPv4 address (no preceding or trailing spaces/characters)
|
|
||||||
######################################################################
|
|
||||||
sub is_ipv4 {
|
|
||||||
my ($value) = @_;
|
|
||||||
return (length($value // '') != 0) && ($value eq (extract_ipv4($value) // ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## extract_ipv4() extracts the first valid IPv4 address from the given string
|
|
||||||
######################################################################
|
|
||||||
sub extract_ipv4 {
|
|
||||||
(shift // '') =~ /\b((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\b/ai;
|
|
||||||
return $1;
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## is_ipv6() validates if string is valid IPv6 address
|
## is_ipv6() validates if string is valid IPv6 address
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue