Merge e8532970a9 into 94dc35984f
This commit is contained in:
commit
eda013e2fd
1 changed files with 21 additions and 13 deletions
34
ddclient
34
ddclient
|
|
@ -25,6 +25,7 @@ use Getopt::Long;
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Data::Validate::IP;
|
use Data::Validate::IP;
|
||||||
|
use Net::Address::IP::Local;
|
||||||
|
|
||||||
my $version = "3.8.3";
|
my $version = "3.8.3";
|
||||||
my $programd = $0;
|
my $programd = $0;
|
||||||
|
|
@ -330,7 +331,7 @@ my %variables = (
|
||||||
|
|
||||||
'use' => setv(T_USE, 0, 0, 1, 'ip', undef),
|
'use' => setv(T_USE, 0, 0, 1, 'ip', undef),
|
||||||
'ip' => setv(T_IP, 0, 0, 1, undef, undef),
|
'ip' => setv(T_IP, 0, 0, 1, undef, undef),
|
||||||
'if' => setv(T_IF, 0, 0, 1, 'ppp0', undef),
|
'if' => setv(T_IF, 0, 0, 1, '', undef),
|
||||||
'if-skip' => setv(T_STRING,1, 0, 1, '', undef),
|
'if-skip' => setv(T_STRING,1, 0, 1, '', undef),
|
||||||
'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef),
|
'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef),
|
||||||
'web-skip' => setv(T_STRING,1, 0, 1, '', undef),
|
'web-skip' => setv(T_STRING,1, 0, 1, '', undef),
|
||||||
|
|
@ -370,7 +371,7 @@ my %variables = (
|
||||||
'host' => setv(T_STRING, 1, 1, 1, '', undef),
|
'host' => setv(T_STRING, 1, 1, 1, '', undef),
|
||||||
|
|
||||||
'use' => setv(T_USE, 0, 0, 1, 'ip', undef),
|
'use' => setv(T_USE, 0, 0, 1, 'ip', undef),
|
||||||
'if' => setv(T_IF, 0, 0, 1, 'ppp0', undef),
|
'if' => setv(T_IF, 0, 0, 1, '', undef),
|
||||||
'if-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
'if-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
||||||
'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef),
|
'web' => setv(T_STRING,0, 0, 1, 'dyndns', undef),
|
||||||
'web-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
'web-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
||||||
|
|
@ -2164,10 +2165,15 @@ sub get_ip {
|
||||||
$arg = 'ip';
|
$arg = 'ip';
|
||||||
|
|
||||||
} elsif ($use eq 'if') {
|
} elsif ($use eq 'if') {
|
||||||
$skip = opt('if-skip', $h) || '';
|
if ($arg eq '') {
|
||||||
$reply = `ifconfig $arg 2> /dev/null`;
|
$ip = Net::Address::IP::Local->public;
|
||||||
$reply = `ip addr list dev $arg 2> /dev/null` if $?;
|
}
|
||||||
$reply = '' if $?;
|
if (!$ip) {
|
||||||
|
$skip = opt('if-skip', $h) || '';
|
||||||
|
$reply = `ifconfig $arg 2> /dev/null`;
|
||||||
|
$reply = `ip addr list dev $arg 2> /dev/null` if $?;
|
||||||
|
$reply = '' if $?;
|
||||||
|
}
|
||||||
|
|
||||||
} elsif ($use eq 'cmd') {
|
} elsif ($use eq 'cmd') {
|
||||||
if ($arg) {
|
if ($arg) {
|
||||||
|
|
@ -2245,15 +2251,17 @@ sub get_ip {
|
||||||
$skip =~ s/ /\\s/is;
|
$skip =~ s/ /\\s/is;
|
||||||
$reply =~ s/^.*?${skip}//is;
|
$reply =~ s/^.*?${skip}//is;
|
||||||
}
|
}
|
||||||
if ($reply =~ /^.*?\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b.*/is) {
|
if (!$ip) {
|
||||||
|
if ($reply =~ /^.*?\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b.*/is) {
|
||||||
$ip = $1;
|
$ip = $1;
|
||||||
$ip = un_zero_pad($ip);
|
$ip = un_zero_pad($ip);
|
||||||
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
||||||
} elsif ( $ip = ipv6_match($reply) ) {
|
} elsif ( $ip = ipv6_match($reply) ) {
|
||||||
$ip = un_zero_pad($ip);
|
$ip = un_zero_pad($ip);
|
||||||
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
$ip = filter_local($ip) if opt('fw-banlocal', $h);
|
||||||
} else {
|
} else {
|
||||||
warning("found neither ipv4 nor ipv6 address");
|
warning("found neither ipv4 nor ipv6 address");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
|
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
|
||||||
$ip = undef;
|
$ip = undef;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue