559
559
$variables{'service-common-defaults'},
563
'updateable' => undef,
564
'update' => \&nic_changeip_update,
565
'examples' => \&nic_changeip_examples,
566
'variables' => merge(
567
{ 'server' => setv(T_FQDNP, 1, 0, 1, 'nic.changeip.com', undef) },
568
{ 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),},
569
$variables{'service-common-defaults'},
563
573
'updateable' => undef,
564
574
'update' => \&nic_dtdns_update,
778
792
foreach my $h (sort keys %config) {
779
793
next if $config{$h}{'protocol'} ne lc($s);
780
794
$examined{$h} = 1;
781
my $use = $config{$h}{'use'} || opt('use');
782
local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
783
# bug #13: we should only do this once
784
# use isn't enough, we have to save the origin to.
785
# this will break the multiple ip stuff if use has
786
# been used twice for the same device.
795
# we only do this once per 'use' and argument combination
796
my $use = opt('use', $h);
797
my $arg_ip = opt('ip', $h) || '';
798
my $arg_fw = opt('fw', $h) || '';
799
my $arg_if = opt('if', $h) || '';
800
my $arg_web = opt('web', $h) || '';
801
my $arg_cmd = opt('cmd', $h) || '';
788
if (defined $iplist{$use}) {
803
if (exists $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}) {
804
$ip = $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd};
791
806
$ip = get_ip($use, $h);
792
807
if (!defined $ip || !$ip) {
1784
1799
######################################################################
1785
1800
sub load_sha1_support {
1786
1801
my $sha1_loaded = eval {require Digest::SHA1};
1787
unless ($sha1_loaded) {
1802
my $sha_loaded = eval {require Digest::SHA};
1803
unless ($sha1_loaded || $sha_loaded) {
1788
1804
fatal(<<"EOM");
1789
Error loading the Perl module Digest::SHA1 needed for freedns update.
1790
On Debian, the package libdigest-sha1-perl must be installed.
1805
Error loading the Perl module Digest::SHA1 or Digest::SHA needed for freedns update.
1806
On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed.
1793
import Digest::SHA1 (qw/sha1_hex/);
1810
import Digest::SHA1 (qw/sha1_hex/);
1811
} elsif($sha_loaded) {
1812
import Digest::SHA (qw/sha1_hex/);
1795
1815
######################################################################
1934
1954
my $use = lc shift;
1936
my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use), '');
1956
my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use, $h), '');
1937
1957
$arg = '' unless $arg;
1939
1959
if ($use eq 'ip') {
3596
######################################################################
3617
######################################################################
3618
## nic_changeip_examples
3619
######################################################################
3620
sub nic_changeip_examples {
3625
The 'changeip' protocol is used by DNS services offered by changeip.com.
3627
Configuration variables applicable to the 'changeip' protocol are:
3628
protocol=changeip ##
3629
server=fqdn.of.service ## defaults to nic.changeip.com
3630
login=service-login ## login name and password registered with the service
3631
password=service-password ##
3632
fully.qualified.host ## the host registered with the service.
3634
Example ${program}.conf file entries:
3635
## single host update
3636
protocol=changeip, \\
3637
login=my-my-changeip.com-login, \\
3638
password=my-changeip.com-password \\
3644
######################################################################
3645
## nic_changeip_update
3647
## adapted by Michele Giorato
3649
## https://nic.ChangeIP.com/nic/update?hostname=host.example.org&myip=66.185.162.19
3651
######################################################################
3652
sub nic_changeip_update {
3655
debug("\nnic_changeip_update -------------------");
3657
## update each configured host
3658
foreach my $h (@_) {
3659
my $ip = delete $config{$h}{'wantip'};
3660
info("setting IP address to %s for %s", $ip, $h);
3661
verbose("UPDATE:","updating %s", $h);
3664
$url = "http://$config{$h}{'server'}/nic/update";
3665
$url .= "?hostname=$h";
3669
my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'});
3670
if (!defined($reply) || !$reply) {
3671
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
3674
last if !header_ok($h, $reply);
3676
my @reply = split /\n/, $reply;
3677
if (grep /success/i, @reply) {
3678
$config{$h}{'ip'} = $ip;
3679
$config{$h}{'mtime'} = $now;
3680
$config{$h}{'status'} = 'good';
3681
success("updating %s: good: IP address set to %s", $h, $ip);
3683
$config{$h}{'status'} = 'failed';
3684
warning("SENT: %s", $url) unless opt('verbose');
3685
warning("REPLIED: %s", $reply);
3686
failed("updating %s: Invalid reply.", $h);
3598
3691
######################################################################
3599
3692
## nic_dtdns_examples