554
554
$variables{'service-common-defaults'},
558
'updateable' => undef,
559
'update' => \&nic_changeip_update,
560
'examples' => \&nic_changeip_examples,
561
'variables' => merge(
562
{ 'server' => setv(T_FQDNP, 1, 0, 1, 'nic.changeip.com', undef) },
563
{ 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),},
564
$variables{'service-common-defaults'},
558
568
'updateable' => undef,
559
569
'update' => \&nic_dtdns_update,
773
787
foreach my $h (sort keys %config) {
774
788
next if $config{$h}{'protocol'} ne lc($s);
775
789
$examined{$h} = 1;
776
my $use = $config{$h}{'use'} || opt('use');
777
local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
778
# bug #13: we should only do this once
779
# use isn't enough, we have to save the origin to.
780
# this will break the multiple ip stuff if use has
781
# been used twice for the same device.
790
# we only do this once per 'use' and argument combination
791
my $use = opt('use', $h);
792
my $arg_ip = opt('ip', $h) || '';
793
my $arg_fw = opt('fw', $h) || '';
794
my $arg_if = opt('if', $h) || '';
795
my $arg_web = opt('web', $h) || '';
796
my $arg_cmd = opt('cmd', $h) || '';
783
if (defined $iplist{$use}) {
798
if (exists $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}) {
799
$ip = $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd};
786
801
$ip = get_ip($use, $h);
787
802
if (!defined $ip || !$ip) {
1779
1794
######################################################################
1780
1795
sub load_sha1_support {
1781
1796
my $sha1_loaded = eval {require Digest::SHA1};
1782
unless ($sha1_loaded) {
1797
my $sha_loaded = eval {require Digest::SHA};
1798
unless ($sha1_loaded || $sha_loaded) {
1783
1799
fatal(<<"EOM");
1784
Error loading the Perl module Digest::SHA1 needed for freedns update.
1785
On Debian, the package libdigest-sha1-perl must be installed.
1800
Error loading the Perl module Digest::SHA1 or Digest::SHA needed for freedns update.
1801
On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed.
1788
import Digest::SHA1 (qw/sha1_hex/);
1805
import Digest::SHA1 (qw/sha1_hex/);
1806
} elsif($sha_loaded) {
1807
import Digest::SHA (qw/sha1_hex/);
1790
1810
######################################################################
1929
1949
my $use = lc shift;
1931
my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use), '');
1951
my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use, $h), '');
1932
1952
$arg = '' unless $arg;
1934
1954
if ($use eq 'ip') {
3591
######################################################################
3612
######################################################################
3613
## nic_changeip_examples
3614
######################################################################
3615
sub nic_changeip_examples {
3620
The 'changeip' protocol is used by DNS services offered by changeip.com.
3622
Configuration variables applicable to the 'changeip' protocol are:
3623
protocol=changeip ##
3624
server=fqdn.of.service ## defaults to nic.changeip.com
3625
login=service-login ## login name and password registered with the service
3626
password=service-password ##
3627
fully.qualified.host ## the host registered with the service.
3629
Example ${program}.conf file entries:
3630
## single host update
3631
protocol=changeip, \\
3632
login=my-my-changeip.com-login, \\
3633
password=my-changeip.com-password \\
3639
######################################################################
3640
## nic_changeip_update
3642
## adapted by Michele Giorato
3644
## https://nic.ChangeIP.com/nic/update?hostname=host.example.org&myip=66.185.162.19
3646
######################################################################
3647
sub nic_changeip_update {
3650
debug("\nnic_changeip_update -------------------");
3652
## update each configured host
3653
foreach my $h (@_) {
3654
my $ip = delete $config{$h}{'wantip'};
3655
info("setting IP address to %s for %s", $ip, $h);
3656
verbose("UPDATE:","updating %s", $h);
3659
$url = "http://$config{$h}{'server'}/nic/update";
3660
$url .= "?hostname=$h";
3664
my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'});
3665
if (!defined($reply) || !$reply) {
3666
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
3669
last if !header_ok($h, $reply);
3671
my @reply = split /\n/, $reply;
3672
if (grep /success/i, @reply) {
3673
$config{$h}{'ip'} = $ip;
3674
$config{$h}{'mtime'} = $now;
3675
$config{$h}{'status'} = 'good';
3676
success("updating %s: good: IP address set to %s", $h, $ip);
3678
$config{$h}{'status'} = 'failed';
3679
warning("SENT: %s", $url) unless opt('verbose');
3680
warning("REPLIED: %s", $reply);
3681
failed("updating %s: Invalid reply.", $h);
3593
3686
######################################################################
3594
3687
## nic_dtdns_examples