From d4c55dd0f589076ffdab10c2bf8a4b7cab3968d0 Mon Sep 17 00:00:00 2001 From: David Kerr Date: Mon, 15 Jun 2020 11:02:42 -0400 Subject: [PATCH] Remove dependency on Data::Validate::IP This module is not available by default on many systems, and not available at all on lightweight embedded systems. --- ChangeLog.md | 1 + README.md | 1 - ddclient | 10 +++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ac709a2..eb8aab7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ repository history](https://github.com/ddclient/ddclient/commits/master). ### New features * Added support for OVH DynHost. + * Removed dependency on Data::Validate::IP. ### Compatibility changes diff --git a/README.md b/README.md index 7f70378..9c718fa 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ through github.com. Please check out http://ddclient.net - one or more accounts from one of the dynamic DNS services - Perl v5.10.1 or later - - `Data::Validate::IP` perl library - `IO::Socket::SSL` perl library for ssl-support - `JSON::PP` perl library for JSON support - `IO::Socket:INET6` perl library for ipv6-support diff --git a/ddclient b/ddclient index a156fe5..f3b16f5 100755 --- a/ddclient +++ b/ddclient @@ -24,7 +24,6 @@ use warnings; use Getopt::Long; use Sys::Hostname; use IO::Socket; -use Data::Validate::IP; my $version = "3.9.1"; my $programd = $0; @@ -2306,6 +2305,15 @@ sub get_ip { return $ip; } +###################################################################### +## is_ipv6() validates if string is valid IPv6 address +###################################################################### +sub is_ipv6 { + my ($value) = @_; + # This little gem from http://home.deds.nl/~aeron/regex/ + return $value =~ /^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/ai; +} + ###################################################################### ## ipv6_match determine ipv6 address from given string and return them ######################################################################