add ipv6 support for web option
This commit is contained in:
parent
bec4521ecd
commit
027fa03895
2 changed files with 52 additions and 6 deletions
37
ddclient
37
ddclient
|
@ -903,8 +903,10 @@ sub update_nics {
|
|||
next;
|
||||
}
|
||||
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
||||
if( !ipv6_match($ip) ) {
|
||||
warning("malformed IP address (%s)", $ip);
|
||||
next;
|
||||
}
|
||||
}
|
||||
$iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip;
|
||||
}
|
||||
|
@ -1850,8 +1852,10 @@ sub check_value {
|
|||
# return undef if $value =~ /:/;
|
||||
|
||||
} elsif ($type eq T_IP) {
|
||||
if( !ipv6_match($value) ) {
|
||||
return undef if $value !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
######################################################################
|
||||
|
@ -2195,6 +2199,11 @@ sub get_ip {
|
|||
$ip = $1;
|
||||
$ip = un_zero_pad($ip);
|
||||
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
||||
} elsif ( $ip = ipv6_match($reply) ) {
|
||||
$ip = un_zero_pad($ip);
|
||||
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
||||
} else {
|
||||
warning("found neither ipv4 nor ipv6 address");
|
||||
}
|
||||
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
|
||||
$ip = undef;
|
||||
|
@ -2204,6 +2213,34 @@ sub get_ip {
|
|||
return $ip;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## ipv6_match determine ipv6 address from given string and return them
|
||||
######################################################################
|
||||
sub ipv6_match {
|
||||
my $content = shift;
|
||||
my $omits;
|
||||
my $ip = "";
|
||||
my $linenumbers = 0;
|
||||
|
||||
my @values = split('\n', $content);
|
||||
foreach my $val (@values) {
|
||||
next unless $val =~ /((:{0,2}[A-F0-9]{1,4}){0,7}:{1,2}[A-F0-9]{1,4})/ai; # invalid char
|
||||
my $parsed = $1;
|
||||
|
||||
# check for at least 7 colons
|
||||
my $count_colon = () = $parsed =~ /:/g;
|
||||
if ($count_colon != 7) {
|
||||
# or one double colon
|
||||
my $count_double_colon = () = $parsed =~ /::/g;
|
||||
if ($count_double_colon != 1) {
|
||||
next
|
||||
}
|
||||
}
|
||||
return $parsed;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## group_hosts_by
|
||||
######################################################################
|
||||
|
|
|
@ -221,3 +221,12 @@ ssl=yes # use ssl-support. Works with
|
|||
# password=my-auto-generated-password
|
||||
# protocol=duckdns hostwithoutduckdnsorg
|
||||
|
||||
##
|
||||
## MyOnlinePortal (http://myonlineportal.net)
|
||||
##
|
||||
# protocol=dyndns2
|
||||
# ssl=yes
|
||||
# use=web, web=myonlineportal.net/checkip
|
||||
# login=your-myonlineportal-username
|
||||
# password=your-myonlineportal-password
|
||||
# domain.myonlineportal.net
|
||||
|
|
Loading…
Reference in a new issue