allow public ip address from any interface
This commit is contained in:
parent
7543b31da5
commit
e8532970a9
1 changed files with 19 additions and 11 deletions
8
ddclient
8
ddclient
|
|
@ -25,6 +25,7 @@ use Getopt::Long;
|
|||
use Sys::Hostname;
|
||||
use IO::Socket;
|
||||
use Data::Validate::IP;
|
||||
use Net::Address::IP::Local;
|
||||
|
||||
my $version = "3.8.3";
|
||||
my $programd = $0;
|
||||
|
|
@ -2145,10 +2146,15 @@ sub get_ip {
|
|||
$arg = 'ip';
|
||||
|
||||
} elsif ($use eq 'if') {
|
||||
if ($arg eq '') {
|
||||
$ip = Net::Address::IP::Local->public;
|
||||
}
|
||||
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') {
|
||||
if ($arg) {
|
||||
|
|
@ -2226,6 +2232,7 @@ sub get_ip {
|
|||
$skip =~ s/ /\\s/is;
|
||||
$reply =~ s/^.*?${skip}//is;
|
||||
}
|
||||
if (!$ip) {
|
||||
if ($reply =~ /^.*?\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b.*/is) {
|
||||
$ip = $1;
|
||||
$ip = un_zero_pad($ip);
|
||||
|
|
@ -2236,6 +2243,7 @@ sub get_ip {
|
|||
} else {
|
||||
warning("found neither ipv4 nor ipv6 address");
|
||||
}
|
||||
}
|
||||
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
|
||||
$ip = undef;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue