From ba6ec1cb70d367d39523fc045f558a6038813cb5 Mon Sep 17 00:00:00 2001 From: wimpunk Date: Mon, 23 Mar 2015 18:53:56 +0000 Subject: [PATCH] ddclient: made json optional As suggested in pull 7 on github by @abelbeck and @Bugsbane it is better to make the use of JSON related to the use of cloudflare. git-svn-id: svn+ssh://svn.code.sf.net/p/ddclient/code/trunk@181 3873ddee-7413-0410-b6c4-c2c57c1ab35a --- ddclient | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ddclient b/ddclient index ba45858..ee21a82 100755 --- a/ddclient +++ b/ddclient @@ -25,7 +25,6 @@ use strict; use Getopt::Long; use Sys::Hostname; use IO::Socket; -use JSON::Any; # my ($VERSION) = q$Revision$ =~ /(\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 {