parent
eeb0bb586d
commit
b14f77e068
6 changed files with 375 additions and 140 deletions
|
|
@ -26,6 +26,7 @@ Dynamic DNS services currently supported include:
|
||||||
CloudFlare - See https://www.cloudflare.com/ for details
|
CloudFlare - See https://www.cloudflare.com/ for details
|
||||||
Google - See http://www.google.com/domains for details
|
Google - See http://www.google.com/domains for details
|
||||||
Duckdns - See https://duckdns.org/ for details
|
Duckdns - See https://duckdns.org/ for details
|
||||||
|
Freemyip - See https://freemyip.com for details
|
||||||
woima.fi - See https://woima.fi/ for details
|
woima.fi - See https://woima.fi/ for details
|
||||||
MyDNS.JP - See http://www.mydns.jp/ for details
|
MyDNS.JP - See http://www.mydns.jp/ for details
|
||||||
|
|
||||||
|
|
@ -43,8 +44,9 @@ REQUIREMENTS:
|
||||||
- one or more accounts from one of the dynamic DNS services
|
- one or more accounts from one of the dynamic DNS services
|
||||||
|
|
||||||
- Perl 5.014 or later
|
- Perl 5.014 or later
|
||||||
(you need the IO::Socket::SSL perl library for ssl-support
|
(you need the IO::Socket::SSL perl library for ssl-support,
|
||||||
and JSON::Any perl library for JSON support)
|
JSON::PP perl library for JSON support and
|
||||||
|
IO::Socket:INET6 perl library for ipv6-support)
|
||||||
|
|
||||||
- Linux or probably any common Unix system
|
- Linux or probably any common Unix system
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ On alpine, you need perl-io-socket-ssl to have IO::Socket::SSL
|
||||||
|
|
||||||
ssl support is tested on folowing dynamic dns providers:
|
ssl support is tested on folowing dynamic dns providers:
|
||||||
- dyndns.com
|
- dyndns.com
|
||||||
|
- freemyip.com
|
||||||
|
|
|
||||||
462
ddclient
462
ddclient
|
|
@ -24,6 +24,7 @@ use strict;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
|
use Data::Validate::IP;
|
||||||
|
|
||||||
my $version = "3.8.3";
|
my $version = "3.8.3";
|
||||||
my $programd = $0;
|
my $programd = $0;
|
||||||
|
|
@ -345,12 +346,12 @@ my %variables = (
|
||||||
'retry' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
'retry' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
||||||
'force' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
'force' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
||||||
'ssl' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
'ssl' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
||||||
|
'ipv6' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
||||||
'syslog' => setv(T_BOOL, 0, 0, 1, 0, undef),
|
'syslog' => setv(T_BOOL, 0, 0, 1, 0, undef),
|
||||||
'facility' => setv(T_STRING,0, 0, 1, 'daemon', undef),
|
'facility' => setv(T_STRING,0, 0, 1, 'daemon', undef),
|
||||||
'priority' => setv(T_STRING,0, 0, 1, 'notice', undef),
|
'priority' => setv(T_STRING,0, 0, 1, 'notice', undef),
|
||||||
'mail' => setv(T_EMAIL, 0, 0, 1, '', undef),
|
'mail' => setv(T_EMAIL, 0, 0, 1, '', undef),
|
||||||
'mail-failure' => setv(T_EMAIL, 0, 0, 1, '', undef),
|
'mail-failure' => setv(T_EMAIL, 0, 0, 1, '', undef),
|
||||||
|
|
||||||
'exec' => setv(T_BOOL, 0, 0, 1, 1, undef),
|
'exec' => setv(T_BOOL, 0, 0, 1, 1, undef),
|
||||||
'debug' => setv(T_BOOL, 0, 0, 1, 0, undef),
|
'debug' => setv(T_BOOL, 0, 0, 1, 0, undef),
|
||||||
|
|
@ -380,7 +381,7 @@ my %variables = (
|
||||||
'fw-password' => setv(T_PASSWD,0, 0, 1, '', undef),
|
'fw-password' => setv(T_PASSWD,0, 0, 1, '', undef),
|
||||||
'cmd' => setv(T_PROG, 0, 0, 1, '', undef),
|
'cmd' => setv(T_PROG, 0, 0, 1, '', undef),
|
||||||
'cmd-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
'cmd-skip' => setv(T_STRING,0, 0, 1, '', undef),
|
||||||
|
'ipv6' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
||||||
'ip' => setv(T_IP, 0, 1, 0, undef, undef),
|
'ip' => setv(T_IP, 0, 1, 0, undef, undef),
|
||||||
'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')),
|
'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')),
|
||||||
'mtime' => setv(T_NUMBER, 0, 1, 0, 0, undef),
|
'mtime' => setv(T_NUMBER, 0, 1, 0, 0, undef),
|
||||||
|
|
@ -437,9 +438,10 @@ my %variables = (
|
||||||
'nsupdate-common-defaults' => {
|
'nsupdate-common-defaults' => {
|
||||||
'ttl' => setv(T_NUMBER, 0, 1, 0, 600, undef),
|
'ttl' => setv(T_NUMBER, 0, 1, 0, 600, undef),
|
||||||
'zone' => setv(T_STRING, 1, 1, 1, '', undef),
|
'zone' => setv(T_STRING, 1, 1, 1, '', undef),
|
||||||
|
'tcp' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
||||||
},
|
},
|
||||||
'cloudflare-common-defaults' => {
|
'cloudflare-common-defaults' => {
|
||||||
'server' => setv(T_FQDNP, 1, 0, 1, 'www.cloudflare.com', undef),
|
'server' => setv(T_FQDNP, 1, 0, 1, 'api.cloudflare.com/client/v4', undef),
|
||||||
'zone' => setv(T_FQDN, 1, 0, 1, '', undef),
|
'zone' => setv(T_FQDN, 1, 0, 1, '', undef),
|
||||||
'static' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
'static' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
||||||
'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
||||||
|
|
@ -454,6 +456,10 @@ my %variables = (
|
||||||
'server' => setv(T_FQDNP, 1, 0, 1, 'www.duckdns.org', undef),
|
'server' => setv(T_FQDNP, 1, 0, 1, 'www.duckdns.org', undef),
|
||||||
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef),
|
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef),
|
||||||
},
|
},
|
||||||
|
'freemyip-common-defaults' => {
|
||||||
|
'server' => setv(T_FQDNP, 1, 0, 1, 'freemyip.com', undef),
|
||||||
|
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef),
|
||||||
|
},
|
||||||
'woima-common-defaults' => {
|
'woima-common-defaults' => {
|
||||||
'static' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
'static' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
||||||
'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
'wildcard' => setv(T_BOOL, 0, 1, 1, 0, undef),
|
||||||
|
|
@ -641,7 +647,7 @@ my %services = (
|
||||||
'update' => \&nic_cloudflare_update,
|
'update' => \&nic_cloudflare_update,
|
||||||
'examples' => \&nic_cloudflare_examples,
|
'examples' => \&nic_cloudflare_examples,
|
||||||
'variables' => merge(
|
'variables' => merge(
|
||||||
{ 'server' => setv(T_FQDNP, 1, 0, 1, 'www.cloudflare.com', undef) },
|
{ 'server' => setv(T_FQDNP, 1, 0, 1, 'api.cloudflare.com/client/v4', undef) },
|
||||||
{ 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),},
|
{ 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('5m'), 0),},
|
||||||
$variables{'cloudflare-common-defaults'},
|
$variables{'cloudflare-common-defaults'},
|
||||||
$variables{'service-common-defaults'},
|
$variables{'service-common-defaults'},
|
||||||
|
|
@ -666,6 +672,15 @@ my %services = (
|
||||||
$variables{'service-common-defaults'},
|
$variables{'service-common-defaults'},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
'freemyip' => {
|
||||||
|
'updateable' => undef,
|
||||||
|
'update' => \&nic_freemyip_update,
|
||||||
|
'examples' => \&nic_freemyip_examples,
|
||||||
|
'variables' => merge(
|
||||||
|
$variables{'freemyip-common-defaults'},
|
||||||
|
$variables{'service-common-defaults'},
|
||||||
|
),
|
||||||
|
},
|
||||||
'woima' => {
|
'woima' => {
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
'update' => \&nic_woima_update,
|
'update' => \&nic_woima_update,
|
||||||
|
|
@ -695,7 +710,7 @@ my @opt = (
|
||||||
"usage: ${program} [options]",
|
"usage: ${program} [options]",
|
||||||
"options are:",
|
"options are:",
|
||||||
[ "daemon", "=s", "-daemon delay : run as a daemon, specify delay as an interval." ],
|
[ "daemon", "=s", "-daemon delay : run as a daemon, specify delay as an interval." ],
|
||||||
[ "foreground", "!", "-foreground : do not fork" ],
|
[ "foreground", "!", "-foreground : do not fork" ],
|
||||||
[ "proxy", "=s", "-proxy host : use 'host' as the HTTP proxy" ],
|
[ "proxy", "=s", "-proxy host : use 'host' as the HTTP proxy" ],
|
||||||
[ "server", "=s", "-server host : update DNS information on 'host'" ],
|
[ "server", "=s", "-server host : update DNS information on 'host'" ],
|
||||||
[ "protocol", "=s", "-protocol type : update protocol used" ],
|
[ "protocol", "=s", "-protocol type : update protocol used" ],
|
||||||
|
|
@ -743,6 +758,7 @@ my @opt = (
|
||||||
[ "debug", "!", "-{no}debug : print {no} debugging information" ],
|
[ "debug", "!", "-{no}debug : print {no} debugging information" ],
|
||||||
[ "verbose", "!", "-{no}verbose : print {no} verbose information" ],
|
[ "verbose", "!", "-{no}verbose : print {no} verbose information" ],
|
||||||
[ "quiet", "!", "-{no}quiet : print {no} messages for unnecessary updates" ],
|
[ "quiet", "!", "-{no}quiet : print {no} messages for unnecessary updates" ],
|
||||||
|
[ "ipv6", "!", "-{no}ipv6 : use ipv6" ],
|
||||||
[ "help", "", "-help : this message" ],
|
[ "help", "", "-help : this message" ],
|
||||||
[ "postscript", "", "-postscript : script to run after updating ddclient, has new IP as param" ],
|
[ "postscript", "", "-postscript : script to run after updating ddclient, has new IP as param" ],
|
||||||
|
|
||||||
|
|
@ -917,8 +933,10 @@ sub update_nics {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
||||||
warning("malformed IP address (%s)", $ip);
|
if( !ipv6_match($ip) ) {
|
||||||
next;
|
warning("malformed IP address (%s)", $ip);
|
||||||
|
next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip;
|
$iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip;
|
||||||
}
|
}
|
||||||
|
|
@ -1060,7 +1078,7 @@ sub parse_assignment {
|
||||||
my ($c, $name, $value);
|
my ($c, $name, $value);
|
||||||
my ($escape, $quote) = (0, '');
|
my ($escape, $quote) = (0, '');
|
||||||
|
|
||||||
if ($rest =~ /^\s*([a-z][a-z_-]*)=(.*)/i) {
|
if ($rest =~ /^\s*([a-z][0-9a-z_-]*)=(.*)/i) {
|
||||||
($name, $rest, $value) = ($1, $2, '');
|
($name, $rest, $value) = ($1, $2, '');
|
||||||
|
|
||||||
while (length($c = substr($rest,0,1))) {
|
while (length($c = substr($rest,0,1))) {
|
||||||
|
|
@ -1173,7 +1191,7 @@ sub _read_config {
|
||||||
|
|
||||||
## verify that keywords are valid...and check the value
|
## verify that keywords are valid...and check the value
|
||||||
foreach my $k (keys %locals) {
|
foreach my $k (keys %locals) {
|
||||||
$locals{$k} = $passwords{$k} if defined $passwords{$k};
|
$locals{$k} = $passwords{$k} if defined $passwords{$k};
|
||||||
if (!exists $variables{'merged'}{$k}) {
|
if (!exists $variables{'merged'}{$k}) {
|
||||||
warning("unrecognized keyword '%s' (ignored)", $k);
|
warning("unrecognized keyword '%s' (ignored)", $k);
|
||||||
delete $locals{$k};
|
delete $locals{$k};
|
||||||
|
|
@ -1270,14 +1288,14 @@ sub init_config {
|
||||||
## and those in -options=...
|
## and those in -options=...
|
||||||
if (exists $options{'host'}) {
|
if (exists $options{'host'}) {
|
||||||
foreach my $h (split_by_comma($options{'host'})) {
|
foreach my $h (split_by_comma($options{'host'})) {
|
||||||
push @hosts, $h;
|
push @hosts, $h;
|
||||||
}
|
}
|
||||||
delete $options{'host'};
|
delete $options{'host'};
|
||||||
}
|
}
|
||||||
## merge options into host definitions or globals
|
## merge options into host definitions or globals
|
||||||
if (@hosts) {
|
if (@hosts) {
|
||||||
foreach my $h (@hosts) {
|
foreach my $h (@hosts) {
|
||||||
$config{$h} = merge(\%options, $config{$h});
|
$config{$h} = merge(\%options, $config{$h});
|
||||||
}
|
}
|
||||||
$opt{'host'} = join(',', @hosts);
|
$opt{'host'} = join(',', @hosts);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1287,14 +1305,14 @@ sub init_config {
|
||||||
|
|
||||||
## override global options with those on the command-line.
|
## override global options with those on the command-line.
|
||||||
foreach my $o (keys %opt) {
|
foreach my $o (keys %opt) {
|
||||||
if (defined $opt{$o} && exists $variables{'global-defaults'}{$o}) {
|
if (defined $opt{$o} && exists $variables{'global-defaults'}{$o}) {
|
||||||
$globals{$o} = $opt{$o};
|
$globals{$o} = $opt{$o};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## sanity check
|
## sanity check
|
||||||
if (defined $opt{'host'} && defined $opt{'retry'}) {
|
if (defined $opt{'host'} && defined $opt{'retry'}) {
|
||||||
usage("options -retry and -host (or -option host=..) are mutually exclusive");
|
usage("options -retry and -host (or -option host=..) are mutually exclusive");
|
||||||
}
|
}
|
||||||
|
|
||||||
## determine hosts to update (those on the cmd-line, config-file, or failed cached)
|
## determine hosts to update (those on the cmd-line, config-file, or failed cached)
|
||||||
|
|
@ -1324,14 +1342,14 @@ sub init_config {
|
||||||
## make sure config entries have all defaults and they meet minimums
|
## make sure config entries have all defaults and they meet minimums
|
||||||
## first the globals...
|
## first the globals...
|
||||||
foreach my $k (keys %globals) {
|
foreach my $k (keys %globals) {
|
||||||
my $def = $variables{'merged'}{$k};
|
my $def = $variables{'merged'}{$k};
|
||||||
my $ovalue = define($globals{$k}, $def->{'default'});
|
my $ovalue = define($globals{$k}, $def->{'default'});
|
||||||
my $value = check_value($ovalue, $def);
|
my $value = check_value($ovalue, $def);
|
||||||
if ($def->{'required'} && !defined $value) {
|
if ($def->{'required'} && !defined $value) {
|
||||||
$value = default($k);
|
$value = default($k);
|
||||||
warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value);
|
warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value);
|
||||||
}
|
}
|
||||||
$globals{$k} = $value;
|
$globals{$k} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
## now the host definitions...
|
## now the host definitions...
|
||||||
|
|
@ -1864,7 +1882,9 @@ sub check_value {
|
||||||
# return undef if $value =~ /:/;
|
# return undef if $value =~ /:/;
|
||||||
|
|
||||||
} elsif ($type eq T_IP) {
|
} elsif ($type eq T_IP) {
|
||||||
return undef if $value !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
if( !ipv6_match($value) ) {
|
||||||
|
return undef if $value !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
@ -1903,6 +1923,24 @@ EOM
|
||||||
import IO::Socket::SSL;
|
import IO::Socket::SSL;
|
||||||
{ no warnings; $IO::Socket::SSL::DEBUG = 0; }
|
{ no warnings; $IO::Socket::SSL::DEBUG = 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## load_ipv6_support
|
||||||
|
######################################################################
|
||||||
|
sub load_ipv6_support {
|
||||||
|
my $ipv6_loaded = eval {require IO::Socket::INET6};
|
||||||
|
unless ($ipv6_loaded) {
|
||||||
|
fatal(<<"EOM");
|
||||||
|
Error loading the Perl module IO::Socket::INET6 needed for ipv6 connect.
|
||||||
|
On Debian, the package libio-socket-inet6-perl must be installed.
|
||||||
|
On Red Hat, the package perl-IO-Socket-INET6 must be installed.
|
||||||
|
On Alpine, the package perl-io-socket-inet6 must be installed.
|
||||||
|
EOM
|
||||||
|
}
|
||||||
|
import IO::Socket::INET6;
|
||||||
|
{ no warnings; $IO::Socket::INET6::DEBUG = 0; }
|
||||||
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## load_sha1_support
|
## load_sha1_support
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -1925,13 +1963,13 @@ EOM
|
||||||
## load_json_support
|
## load_json_support
|
||||||
######################################################################
|
######################################################################
|
||||||
sub load_json_support {
|
sub load_json_support {
|
||||||
my $json_loaded = eval {require JSON::Any};
|
my $json_loaded = eval {require JSON::PP};
|
||||||
unless ($json_loaded) {
|
unless ($json_loaded) {
|
||||||
fatal(<<"EOM");
|
fatal(<<"EOM");
|
||||||
Error loading the Perl module JSON::Any needed for cloudflare update.
|
Error loading the Perl module JSON::PP needed for cloudflare update.
|
||||||
EOM
|
EOM
|
||||||
}
|
}
|
||||||
import JSON::Any;
|
import JSON::PP (qw/decode_json/);
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
## geturl
|
## geturl
|
||||||
|
|
@ -1941,6 +1979,9 @@ sub geturl {
|
||||||
my $url = shift || '';
|
my $url = shift || '';
|
||||||
my $login = shift || '';
|
my $login = shift || '';
|
||||||
my $password = shift || '';
|
my $password = shift || '';
|
||||||
|
my $headers = shift || '';
|
||||||
|
my $method = shift || 'GET';
|
||||||
|
my $data = shift || '';
|
||||||
my ($peer, $server, $port, $default_port, $use_ssl);
|
my ($peer, $server, $port, $default_port, $use_ssl);
|
||||||
my ($sd, $rq, $request, $reply);
|
my ($sd, $rq, $request, $reply);
|
||||||
|
|
||||||
|
|
@ -1981,7 +2022,7 @@ sub geturl {
|
||||||
my $to = sprintf "%s%s", $server, $proxy ? " via proxy $peer:$port" : "";
|
my $to = sprintf "%s%s", $server, $proxy ? " via proxy $peer:$port" : "";
|
||||||
verbose("CONNECT:", "%s", $to);
|
verbose("CONNECT:", "%s", $to);
|
||||||
|
|
||||||
$request = "GET ";
|
$request = "$method ";
|
||||||
$request .= "http://$server" if $proxy;
|
$request .= "http://$server" if $proxy;
|
||||||
$request .= "/$url HTTP/1.0\n";
|
$request .= "/$url HTTP/1.0\n";
|
||||||
$request .= "Host: $server\n";
|
$request .= "Host: $server\n";
|
||||||
|
|
@ -1990,7 +2031,10 @@ sub geturl {
|
||||||
$request .= "Authorization: Basic $auth\n" if $login || $password;
|
$request .= "Authorization: Basic $auth\n" if $login || $password;
|
||||||
$request .= "User-Agent: ${program}/${version}\n";
|
$request .= "User-Agent: ${program}/${version}\n";
|
||||||
$request .= "Connection: close\n";
|
$request .= "Connection: close\n";
|
||||||
|
$request .= "$headers\n";
|
||||||
|
$request .= "Content-Length: ".length($data)."\n" if $data;
|
||||||
$request .= "\n";
|
$request .= "\n";
|
||||||
|
$request .= $data;
|
||||||
|
|
||||||
## make sure newlines are <cr><lf> for some pedantic proxy servers
|
## make sure newlines are <cr><lf> for some pedantic proxy servers
|
||||||
($rq = $request) =~ s/\n/\r\n/g;
|
($rq = $request) =~ s/\n/\r\n/g;
|
||||||
|
|
@ -1998,8 +2042,8 @@ sub geturl {
|
||||||
# local $^W = 0;
|
# local $^W = 0;
|
||||||
$0 = sprintf("%s - connecting to %s port %s", $program, $peer, $port);
|
$0 = sprintf("%s - connecting to %s port %s", $program, $peer, $port);
|
||||||
if (! opt('exec')) {
|
if (! opt('exec')) {
|
||||||
debug("skipped network connection");
|
debug("skipped network connection");
|
||||||
verbose("SENDING:", "%s", $request);
|
verbose("SENDING:", "%s", $request);
|
||||||
} elsif ($use_ssl) {
|
} elsif ($use_ssl) {
|
||||||
$sd = IO::Socket::SSL->new(
|
$sd = IO::Socket::SSL->new(
|
||||||
PeerAddr => $peer,
|
PeerAddr => $peer,
|
||||||
|
|
@ -2009,6 +2053,16 @@ sub geturl {
|
||||||
Timeout => opt('timeout'),
|
Timeout => opt('timeout'),
|
||||||
);
|
);
|
||||||
defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr());
|
defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr());
|
||||||
|
} elsif ($globals{'ipv6'}) {
|
||||||
|
load_ipv6_support;
|
||||||
|
$sd = IO::Socket::INET6->new(
|
||||||
|
PeerAddr => $peer,
|
||||||
|
PeerPort => $port,
|
||||||
|
Proto => 'tcp',
|
||||||
|
MultiHomed => 1,
|
||||||
|
Timeout => opt('timeout'),
|
||||||
|
);
|
||||||
|
defined $sd or warning("cannot connect to $peer:$port socket: $@");
|
||||||
} else {
|
} else {
|
||||||
$sd = IO::Socket::INET->new(
|
$sd = IO::Socket::INET->new(
|
||||||
PeerAddr => $peer,
|
PeerAddr => $peer,
|
||||||
|
|
@ -2151,64 +2205,69 @@ sub get_ip {
|
||||||
}
|
}
|
||||||
|
|
||||||
} elsif (($use eq 'cisco')) {
|
} elsif (($use eq 'cisco')) {
|
||||||
# Stuff added to support Cisco router ip http daemon
|
# Stuff added to support Cisco router ip http daemon
|
||||||
# User fw-login should only have level 1 access to prevent
|
# User fw-login should only have level 1 access to prevent
|
||||||
# password theft. This is pretty harmless.
|
# password theft. This is pretty harmless.
|
||||||
my $queryif = opt('if', $h);
|
my $queryif = opt('if', $h);
|
||||||
$skip = opt('fw-skip', $h) || '';
|
$skip = opt('fw-skip', $h) || '';
|
||||||
|
|
||||||
# Convert slashes to protected value "\/"
|
# Convert slashes to protected value "\/"
|
||||||
$queryif =~ s%\/%\\\/%g;
|
$queryif =~ s%\/%\\\/%g;
|
||||||
|
|
||||||
# Protect special HTML characters (like '?')
|
# Protect special HTML characters (like '?')
|
||||||
$queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge;
|
$queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge;
|
||||||
|
|
||||||
$url = "http://".opt('fw', $h)."/level/1/exec/show/ip/interface/brief/${queryif}/CR";
|
$url = "http://".opt('fw', $h)."/level/1/exec/show/ip/interface/brief/${queryif}/CR";
|
||||||
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
} elsif (($use eq 'cisco-asa')) {
|
} elsif (($use eq 'cisco-asa')) {
|
||||||
# Stuff added to support Cisco ASA ip https daemon
|
# Stuff added to support Cisco ASA ip https daemon
|
||||||
# User fw-login should only have level 1 access to prevent
|
# User fw-login should only have level 1 access to prevent
|
||||||
# password theft. This is pretty harmless.
|
# password theft. This is pretty harmless.
|
||||||
my $queryif = opt('if', $h);
|
my $queryif = opt('if', $h);
|
||||||
$skip = opt('fw-skip', $h) || '';
|
$skip = opt('fw-skip', $h) || '';
|
||||||
|
|
||||||
# Convert slashes to protected value "\/"
|
# Convert slashes to protected value "\/"
|
||||||
$queryif =~ s%\/%\\\/%g;
|
$queryif =~ s%\/%\\\/%g;
|
||||||
|
|
||||||
# Protect special HTML characters (like '?')
|
# Protect special HTML characters (like '?')
|
||||||
$queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge;
|
$queryif =~ s/([\?&= ])/sprintf("%%%02x",ord($1))/ge;
|
||||||
|
|
||||||
$url = "https://".opt('fw', $h)."/exec/show%20interface%20${queryif}";
|
$url = "https://".opt('fw', $h)."/exec/show%20interface%20${queryif}";
|
||||||
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$url = opt('fw', $h) || '';
|
$url = opt('fw', $h) || '';
|
||||||
$skip = opt('fw-skip', $h) || '';
|
$skip = opt('fw-skip', $h) || '';
|
||||||
|
|
||||||
if (exists $builtinfw{$use}) {
|
if (exists $builtinfw{$use}) {
|
||||||
$skip = $builtinfw{$use}->{'skip'} unless $skip;
|
$skip = $builtinfw{$use}->{'skip'} unless $skip;
|
||||||
$url = "http://${url}" . $builtinfw{$use}->{'url'} unless $url =~ /\//;
|
$url = "http://${url}" . $builtinfw{$use}->{'url'} unless $url =~ /\//;
|
||||||
}
|
}
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
$reply = geturl('', $url, opt('fw-login', $h), opt('fw-password', $h)) || '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!defined $reply) {
|
||||||
if (!defined $reply) {
|
$reply = '';
|
||||||
$reply = '';
|
|
||||||
}
|
}
|
||||||
if ($skip) {
|
if ($skip) {
|
||||||
$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 ($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) ) {
|
||||||
|
$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')) {
|
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
|
||||||
$ip = undef;
|
$ip = undef;
|
||||||
|
|
@ -2218,6 +2277,34 @@ sub get_ip {
|
||||||
return $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
|
## group_hosts_by
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -3718,7 +3805,10 @@ EoEXAMPLE
|
||||||
##
|
##
|
||||||
######################################################################
|
######################################################################
|
||||||
sub nic_freedns_update {
|
sub nic_freedns_update {
|
||||||
|
|
||||||
|
|
||||||
debug("\nnic_freedns_update -------------------");
|
debug("\nnic_freedns_update -------------------");
|
||||||
|
|
||||||
## First get the list of updatable hosts
|
## First get the list of updatable hosts
|
||||||
my $url;
|
my $url;
|
||||||
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
||||||
|
|
@ -3744,40 +3834,34 @@ sub nic_freedns_update {
|
||||||
info("setting IP address to %s for %s", $ip, $h);
|
info("setting IP address to %s for %s", $ip, $h);
|
||||||
verbose("UPDATE:","updating %s", $h);
|
verbose("UPDATE:","updating %s", $h);
|
||||||
|
|
||||||
if($ip eq $freedns_hosts{$h}->[1]) {
|
if($ip eq $freedns_hosts{$h}->[1]) {
|
||||||
$config{$h}{'ip'} = $ip;
|
$config{$h}{'ip'} = $ip;
|
||||||
$config{$h}{'mtime'} = $now;
|
$config{$h}{'mtime'} = $now;
|
||||||
$config{$h}{'status'} = 'good';
|
$config{$h}{'status'} = 'good';
|
||||||
success("update not necessary %s: good: IP address already set to %s", $h, $ip);
|
success("update not necessary %s: good: IP address already set to %s", $h, $ip);
|
||||||
} else {
|
} else {
|
||||||
my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]);
|
my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]);
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]);
|
failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]);
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
if(!header_ok($h, $reply)) {
|
if(!header_ok($h, $reply)) {
|
||||||
$config{$h}{'status'} = 'failed';
|
$config{$h}{'status'} = 'failed';
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reply =~ /Updated.*$h.*to.*$ip/) {
|
if($reply =~ /Updated.*$h.*to.*$ip/) {
|
||||||
$config{$h}{'ip'} = $ip;
|
$config{$h}{'ip'} = $ip;
|
||||||
$config{$h}{'mtime'} = $now;
|
$config{$h}{'mtime'} = $now;
|
||||||
$config{$h}{'status'} = 'good';
|
$config{$h}{'status'} = 'good';
|
||||||
success("updating %s: good: IP address set to %s", $h, $ip);
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
} elsif ($reply =~ /Address (\d+\.\d+\.\d+\.\d+) has not changed/) {
|
} else {
|
||||||
$ip = $1;
|
$config{$h}{'status'} = 'failed';
|
||||||
$config{$h}{'mtime'} = $now;
|
warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose');
|
||||||
$config{$h}{'status'} = 'good';
|
warning("REPLIED: %s", $reply);
|
||||||
$config{$h}{'ip'} = $ip;
|
failed("updating %s: Invalid reply.", $h);
|
||||||
success("updating %s: good: IP address %s has not changed", $h, $ip);
|
}
|
||||||
} else {
|
}
|
||||||
$config{$h}{'status'} = 'failed';
|
|
||||||
warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose');
|
|
||||||
warning("REPLIED: %s", $reply);
|
|
||||||
failed("updating %s: Invalid reply.", $h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4039,6 +4123,10 @@ Configuration variables applicable to the 'nsupdate' protocol are:
|
||||||
zone=dyn.example.com ## forward zone that is to be updated
|
zone=dyn.example.com ## forward zone that is to be updated
|
||||||
ttl=600 ## time to live of the record;
|
ttl=600 ## time to live of the record;
|
||||||
## defaults to 600 seconds
|
## defaults to 600 seconds
|
||||||
|
tcp=off|on ## nsupdate uses UDP by default, and switches to
|
||||||
|
## TCP if the update is too large to fit in a
|
||||||
|
## UDP datagram; this setting forces TCP;
|
||||||
|
## defaults to off
|
||||||
login=/usr/bin/nsupdate ## path and name of nsupdate binary;
|
login=/usr/bin/nsupdate ## path and name of nsupdate binary;
|
||||||
## defaults to '/usr/bin/nsupdate'
|
## defaults to '/usr/bin/nsupdate'
|
||||||
<hostname> ## fully qualified hostname to update
|
<hostname> ## fully qualified hostname to update
|
||||||
|
|
@ -4075,6 +4163,12 @@ sub nic_nsupdate_update {
|
||||||
my $server = $config{$h}{'server'};
|
my $server = $config{$h}{'server'};
|
||||||
my $zone = $config{$h}{'zone'};
|
my $zone = $config{$h}{'zone'};
|
||||||
my $ip = $config{$h}{'wantip'};
|
my $ip = $config{$h}{'wantip'};
|
||||||
|
my $recordtype = '';
|
||||||
|
if (is_ipv6($ip)) {
|
||||||
|
$recordtype = 'AAAA';
|
||||||
|
} else {
|
||||||
|
$recordtype = 'A';
|
||||||
|
}
|
||||||
delete $config{$_}{'wantip'} foreach @hosts;
|
delete $config{$_}{'wantip'} foreach @hosts;
|
||||||
|
|
||||||
info("setting IP address to %s for %s", $ip, $hosts);
|
info("setting IP address to %s for %s", $ip, $hosts);
|
||||||
|
|
@ -4087,14 +4181,15 @@ zone $zone.
|
||||||
EoINSTR1
|
EoINSTR1
|
||||||
foreach (@hosts) {
|
foreach (@hosts) {
|
||||||
$instructions .= <<EoINSTR2;
|
$instructions .= <<EoINSTR2;
|
||||||
update delete $_. A
|
update delete $_. $recordtype
|
||||||
update add $_. $config{$_}{'ttl'} A $ip
|
update add $_. $config{$_}{'ttl'} $recordtype $ip
|
||||||
EoINSTR2
|
EoINSTR2
|
||||||
}
|
}
|
||||||
$instructions .= <<EoINSTR3;
|
$instructions .= <<EoINSTR3;
|
||||||
send
|
send
|
||||||
EoINSTR3
|
EoINSTR3
|
||||||
my $command = "$binary -k $keyfile";
|
my $command = "$binary -k $keyfile";
|
||||||
|
$command .= " -v" if ynu($config{$h}{'tcp'}, 1, 0, 0);
|
||||||
$command .= " -d" if (opt('debug'));
|
$command .= " -d" if (opt('debug'));
|
||||||
verbose("UPDATE:", "nsupdate command is: %s", $command);
|
verbose("UPDATE:", "nsupdate command is: %s", $command);
|
||||||
verbose("UPDATE:", "nsupdate instructions are:\n%s", $instructions);
|
verbose("UPDATE:", "nsupdate instructions are:\n%s", $instructions);
|
||||||
|
|
@ -4130,7 +4225,7 @@ The 'cloudflare' protocol is used by DNS service offered by www.cloudflare.com.
|
||||||
|
|
||||||
Configuration variables applicable to the 'cloudflare' protocol are:
|
Configuration variables applicable to the 'cloudflare' protocol are:
|
||||||
protocol=cloudflare ##
|
protocol=cloudflare ##
|
||||||
server=fqdn.of.service ## defaults to www.cloudflare.com
|
server=fqdn.of.service ## defaults to api.cloudflare.com/client/v4
|
||||||
login=service-login ## login name and password registered with the service
|
login=service-login ## login name and password registered with the service
|
||||||
password=service-password ##
|
password=service-password ##
|
||||||
fully.qualified.host ## the host registered with the service.
|
fully.qualified.host ## the host registered with the service.
|
||||||
|
|
@ -4167,6 +4262,10 @@ sub nic_cloudflare_update {
|
||||||
my $key = $hosts[0];
|
my $key = $hosts[0];
|
||||||
my $ip = $config{$key}{'wantip'};
|
my $ip = $config{$key}{'wantip'};
|
||||||
|
|
||||||
|
my $headers = "X-Auth-Email: $config{$key}{'login'}\n";
|
||||||
|
$headers .= "X-Auth-Key: $config{$key}{'password'}\n";
|
||||||
|
$headers .= "Content-Type: application/json";
|
||||||
|
|
||||||
# FQDNs
|
# FQDNs
|
||||||
for my $domain (@hosts) {
|
for my $domain (@hosts) {
|
||||||
(my $hostname = $domain) =~ s/\.$config{$key}{zone}$//;
|
(my $hostname = $domain) =~ s/\.$config{$key}{zone}$//;
|
||||||
|
|
@ -4175,13 +4274,11 @@ sub nic_cloudflare_update {
|
||||||
info("setting IP address to %s for %s", $ip, $domain);
|
info("setting IP address to %s for %s", $ip, $domain);
|
||||||
verbose("UPDATE:","updating %s", $domain);
|
verbose("UPDATE:","updating %s", $domain);
|
||||||
|
|
||||||
# Get domain ID
|
# Get zone ID
|
||||||
my $url = "https://$config{$key}{'server'}/api_json.html?a=rec_load_all";
|
my $url = "https://$config{$key}{'server'}/zones?";
|
||||||
$url .= "&z=".$config{$key}{'zone'};
|
$url .= "name=".$config{$key}{'zone'};
|
||||||
$url .= "&email=".$config{$key}{'login'};
|
|
||||||
$url .= "&tkn=".$config{$key}{'password'};
|
|
||||||
|
|
||||||
my $reply = geturl(opt('proxy'), $url);
|
my $reply = geturl(opt('proxy'), $url, undef, undef, $headers);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
||||||
last;
|
last;
|
||||||
|
|
@ -4190,31 +4287,51 @@ sub nic_cloudflare_update {
|
||||||
|
|
||||||
# Strip header
|
# Strip header
|
||||||
$reply =~ s/^.*?\n\n//s;
|
$reply =~ s/^.*?\n\n//s;
|
||||||
my $response = JSON::Any->jsonToObj($reply);
|
my $response = eval {decode_json($reply)};
|
||||||
if ($response->{result} eq 'error') {
|
if (!defined $response || !defined $response->{result}) {
|
||||||
failed ("%s", $response->{msg});
|
failed ("invalid json or result.");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pull the ID out of the json, messy
|
# Pull the ID out of the json, messy
|
||||||
my ($id) = map { $_->{name} eq $domain ? $_->{rec_id} : () } @{ $response->{response}->{recs}->{objs} };
|
my ($zone_id) = map { $_->{name} eq $config{$key}{'zone'} ? $_->{id} : () } @{ $response->{result} };
|
||||||
unless($id) {
|
unless($zone_id) {
|
||||||
failed("updating %s: No domain ID found.", $domain);
|
failed("updating %s: No zone ID found.", $config{$key}{'zone'});
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
info("zone ID is $zone_id");
|
||||||
|
|
||||||
|
# Get DNS record ID
|
||||||
|
$url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records?";
|
||||||
|
$url .= "type=A&name=$domain";
|
||||||
|
|
||||||
|
$reply = geturl(opt('proxy'), $url, undef, undef, $headers);
|
||||||
|
unless ($reply) {
|
||||||
|
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
last if !header_ok($domain, $reply);
|
||||||
|
|
||||||
|
# Strip header
|
||||||
|
$reply =~ s/^.*?\n\n//s;
|
||||||
|
$response = eval {decode_json($reply)};
|
||||||
|
if (!defined $response || !defined $response->{result}) {
|
||||||
|
failed ("invalid json or result.");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pull the ID out of the json, messy
|
||||||
|
my ($dns_rec_id) = map { $_->{name} eq $domain ? $_->{id} : () } @{ $response->{result} };
|
||||||
|
unless($dns_rec_id) {
|
||||||
|
failed("updating %s: No DNS record ID found.", $domain);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
info("DNS record ID is $dns_rec_id");
|
||||||
|
|
||||||
# Set domain
|
# Set domain
|
||||||
$url = "https://$config{$key}{'server'}/api_json.html?a=rec_edit&type=A";
|
$url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records/$dns_rec_id";
|
||||||
$url .= "&ttl=".$config{$key}{'ttl'};
|
my $data = "{\"content\":\"$ip\"}";
|
||||||
$url .= "&name=$hostname";
|
$reply = geturl(opt('proxy'), $url, undef, undef, $headers, "PATCH", $data);
|
||||||
$url .= "&z=".$config{$key}{'zone'};
|
|
||||||
$url .= "&id=".$id;
|
|
||||||
$url .= "&email=".$config{$key}{'login'};
|
|
||||||
$url .= "&tkn=".$config{$key}{'password'};
|
|
||||||
$url .= "&content=";
|
|
||||||
$url .= "$ip" if $ip;
|
|
||||||
|
|
||||||
$reply = geturl(opt('proxy'), $url);
|
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
|
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
|
||||||
last;
|
last;
|
||||||
|
|
@ -4223,9 +4340,9 @@ sub nic_cloudflare_update {
|
||||||
|
|
||||||
# Strip header
|
# Strip header
|
||||||
$reply =~ s/^.*?\n\n//s;
|
$reply =~ s/^.*?\n\n//s;
|
||||||
$response = JSON::Any->jsonToObj($reply);
|
$response = eval {decode_json($reply)};
|
||||||
if ($response->{result} eq 'error') {
|
if (!defined $response || !defined $response->{result}) {
|
||||||
failed ("%s", $response->{msg});
|
failed ("invalid json or result.");
|
||||||
} else {
|
} else {
|
||||||
success ("%s -- Updated Successfully to %s", $domain, $ip);
|
success ("%s -- Updated Successfully to %s", $domain, $ip);
|
||||||
|
|
||||||
|
|
@ -4319,6 +4436,80 @@ sub nic_duckdns_update {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## nic_freemyip_examples
|
||||||
|
######################################################################
|
||||||
|
sub nic_freemyip_examples {
|
||||||
|
return <<EoEXAMPLE;
|
||||||
|
o 'freemyip'
|
||||||
|
|
||||||
|
The 'freemyip' protocol is used by the free
|
||||||
|
dynamic DNS service available at freemyip.com.
|
||||||
|
API is documented here: https://freemyip.com/help.py
|
||||||
|
|
||||||
|
Configuration variables applicable to the 'freemyip' protocol are:
|
||||||
|
protocol=freemyip ##
|
||||||
|
password=service-token ## token for your domain
|
||||||
|
non-fully.qualified.host ## the host registered with the service.
|
||||||
|
|
||||||
|
Example ${program}.conf file entries:
|
||||||
|
## single host update
|
||||||
|
protocol=freemyip, \\
|
||||||
|
password=35a6b8d65c6e67c7f78cca65cd \\
|
||||||
|
myhost
|
||||||
|
|
||||||
|
EoEXAMPLE
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## nic_freemyip_update
|
||||||
|
## by Cadence (reused code from nic_duckdns)
|
||||||
|
## http://freemyip.com/update?token=ec54b4b64db27fe8873c7f7&domain=myhost
|
||||||
|
## response contains OK or ERROR
|
||||||
|
######################################################################
|
||||||
|
sub nic_freemyip_update {
|
||||||
|
debug("\nnic_freemyip_update -------------------");
|
||||||
|
|
||||||
|
foreach my $h (@_) {
|
||||||
|
my $ip = delete $config{$h}{'wantip'};
|
||||||
|
info("setting IP address to %s for %s", $ip, $h);
|
||||||
|
verbose("UPDATE:","updating %s", $h);
|
||||||
|
|
||||||
|
# Set the URL that we're going to to update
|
||||||
|
my $url;
|
||||||
|
$url = "http://$config{$h}{'server'}/update";
|
||||||
|
$url .= "?token=";
|
||||||
|
$url .= $config{$h}{'password'};
|
||||||
|
$url .= "&domain=";
|
||||||
|
$url .= $h;
|
||||||
|
|
||||||
|
# Try to get URL
|
||||||
|
my $reply = geturl(opt('proxy'), $url);
|
||||||
|
|
||||||
|
# No response, declare as failed
|
||||||
|
if (!defined($reply) || !$reply) {
|
||||||
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
last if !header_ok($h, $reply);
|
||||||
|
|
||||||
|
my @reply = split /\n/, $reply;
|
||||||
|
my $returned = pop(@reply);
|
||||||
|
if ($returned =~ /OK/)
|
||||||
|
{
|
||||||
|
$config{$h}{'ip'} = $ip;
|
||||||
|
$config{$h}{'mtime'} = $now;
|
||||||
|
$config{$h}{'status'} = 'good';
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$config{$h}{'status'} = 'failed';
|
||||||
|
failed("updating %s: Server said: '$returned'", $h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## nic_woima_examples
|
## nic_woima_examples
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -4574,6 +4765,7 @@ sub nic_mydns_update {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# vim: ai ts=4 sw=4 tw=78 :
|
# vim: ai ts=4 sw=4 tw=78 :
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,6 @@ ssl=yes # use ssl-support. Works with
|
||||||
##
|
##
|
||||||
#protocol=cloudflare, \
|
#protocol=cloudflare, \
|
||||||
#zone=domain.tld, \
|
#zone=domain.tld, \
|
||||||
#server=www.cloudflare.com, \
|
|
||||||
#login=your-login-email, \
|
#login=your-login-email, \
|
||||||
#password=APIKey, \
|
#password=APIKey, \
|
||||||
#ttl=1 \
|
#ttl=1 \
|
||||||
|
|
@ -221,6 +220,27 @@ ssl=yes # use ssl-support. Works with
|
||||||
# password=my-auto-generated-password
|
# password=my-auto-generated-password
|
||||||
# protocol=duckdns hostwithoutduckdnsorg
|
# protocol=duckdns hostwithoutduckdnsorg
|
||||||
|
|
||||||
|
##
|
||||||
|
## Freemyip (http://freemyip.com/)
|
||||||
|
##
|
||||||
|
#
|
||||||
|
# protocol=freemyip,
|
||||||
|
# password=my-token
|
||||||
|
# myhost
|
||||||
|
|
||||||
|
##
|
||||||
|
## MyOnlinePortal (http://myonlineportal.net)
|
||||||
|
##
|
||||||
|
# protocol=dyndns2
|
||||||
|
# ssl=yes
|
||||||
|
# # ipv6=yes # optional
|
||||||
|
# use=web, web=myonlineportal.net/checkip
|
||||||
|
# # use=if, if=eth0 # alternative to use=web
|
||||||
|
# # if-skip=Scope:Link # alternative to use=web
|
||||||
|
# login=your-myonlineportal-username
|
||||||
|
# password=your-myonlineportal-password
|
||||||
|
# domain.myonlineportal.net
|
||||||
|
|
||||||
##
|
##
|
||||||
## MyDNS (www.mydns.jp)
|
## MyDNS (www.mydns.jp)
|
||||||
##
|
##
|
||||||
|
|
@ -228,4 +248,4 @@ ssl=yes # use ssl-support. Works with
|
||||||
# server=www.mydns.jp
|
# server=www.mydns.jp
|
||||||
# login=my-mydns.jp-login
|
# login=my-mydns.jp-login
|
||||||
# password=my-mydns.jp-password
|
# password=my-mydns.jp-password
|
||||||
# your-host.mydns.jp
|
# myhost.mydns.jp
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/sbin/runscript
|
#!/sbin/openrc-run
|
||||||
description="ddclient Daemon for Alpine"
|
description="ddclient Daemon for Alpine"
|
||||||
command="/usr/sbin/ddclient"
|
command="/usr/sbin/ddclient"
|
||||||
config_file="/etc/ddclient/ddclient.conf"
|
config_file="/etc/ddclient/ddclient.conf"
|
||||||
|
|
|
||||||
20
sample-get-ip-from-fritzbox
Normal file
20
sample-get-ip-from-fritzbox
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Scirpt to fetch IP from fritzbox
|
||||||
|
#
|
||||||
|
# Contributed by @Rusk85 in request #45
|
||||||
|
# Script can be used in the configuration by adding
|
||||||
|
#
|
||||||
|
# use=cmd, cmd=/etc/ddclient/get-ip-from-fritzbox
|
||||||
|
#
|
||||||
|
# All credits for this one liner go to the author of this blog:
|
||||||
|
# http://scytale.name/blog/2010/01/fritzbox-wan-ip
|
||||||
|
# As the author explains its not required to tamper with the provided IP for the FritzBox
|
||||||
|
# as it always binds to that address for UPnP.
|
||||||
|
# Disclaimer: It might be necessary to make the script executable
|
||||||
|
|
||||||
|
curl -s -H 'Content-Type: text/xml; charset="utf-8"' \
|
||||||
|
-H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \
|
||||||
|
--data-binary '<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /></s:Body></s:Envelope>' \
|
||||||
|
http://169.254.1.1:49000/upnp/control/WANCommonIFC1 | \
|
||||||
|
sed -n -e 's#^.*<NewExternalIPAddress>\(.*\)</NewExternalIPAddress>.*$#\1#p'
|
||||||
Loading…
Reference in a new issue