Skip to content

Commit

Permalink
Updated v1.1 Main Program.
Browse files Browse the repository at this point in the history
Fixed bugs which caused by cloudflare API changes.
  • Loading branch information
bilintsui authored May 1, 2020
1 parent 694f2e9 commit db6f36c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ddnscd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $file_config=$ARGV[0];
chomp($progname=readpipe("basename $0"));
if(!$file_config)
{
die ("Dynamic DNS Client Daemon v1.0\nUsage: $progname config_file\n\n\tconfig_file\tConfiguration in JSON form.\n\nhttps://github.com/bilintsui/ddnscd\n(C) 2020 Bilin Tsui. Licensed with GNU GPL v3.\n");
die ("Dynamic DNS Client Daemon v1.1\nUsage: $progname config_file\n\n\tconfig_file\tConfiguration in JSON form.\n\nhttps://github.com/bilintsui/ddnscd\n(C) 2020 Bilin Tsui. Licensed with GNU GPL v3.\n");
}
if(!(-e $file_config))
{
Expand Down Expand Up @@ -58,7 +58,13 @@ sub cloudflare_record_lookup
{
my($username,$password,$update_domain,$zone_id)=@_;
my($return)=();
my($records)=readpipe('curl -s -X GET "https://api.cloudflare.com/client/v4/zones/'.$zone_id.'/dns_records?name='.$update_domain.'" -H "Content-Type:application/json" -H "X-Auth-Key:'.$password.'" -H "X-Auth-Email:'.$username.'"');
my(@records_raw)=readpipe('curl -s -X GET "https://api.cloudflare.com/client/v4/zones/'.$zone_id.'/dns_records?name='.$update_domain.'" -H "Content-Type:application/json" -H "X-Auth-Key:'.$password.'" -H "X-Auth-Email:'.$username.'"');
my($records)='';
foreach $rec_records_raw(@records_raw)
{
$rec_records_raw=~s/^\s+//g;
$records=$records.$rec_records_raw;
}
my($decoded_json)=decode_json($records);
my($records_success)=$decoded_json->{success};
if(!$records_success)
Expand Down Expand Up @@ -180,4 +186,4 @@ while(1)
}
}
sleep($config_daemon);
}
}

0 comments on commit db6f36c

Please sign in to comment.