ddclient: made json optional

As suggested in pull #7 by @abelbeck and @Bugsbane it is better to make the
use of JSON related to the use of cloudflare.
This commit is contained in:
Wim Vinckier 2015-03-23 19:27:38 +01:00
parent 119588f40f
commit 98060e2836

View file

@ -25,7 +25,6 @@ use strict;
use Getopt::Long;
use Sys::Hostname;
use IO::Socket;
use JSON::Any;
# my ($VERSION) = q$Revision: 161 $ =~ /(\d+)/;
@ -1296,6 +1295,7 @@ sub init_config {
$proto = opt('protocol') if !defined($proto);
load_sha1_support() if ($proto eq "freedns");
load_json_support() if ($proto eq "cloudflare");
if (!exists($services{$proto})) {
warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto);
@ -1875,6 +1875,18 @@ EOM
}
}
######################################################################
## load_json_support
######################################################################
sub load_json_support {
my $json_loaded = eval {require JSON::Any};
unless ($json_loaded) {
fatal(<<"EOM");
Error loading the Perl module JSON::Any needed for cloudflare update.
EOM
}
import JSON::Any;
}
######################################################################
## geturl
######################################################################
sub geturl {