Tidy up code and removed unnecessary commands.
Minor fixes that were done to test more easily.
This commit is contained in:
parent
a8a25b0239
commit
1e76548b1a
2 changed files with 10 additions and 30 deletions
|
|
@ -314,4 +314,4 @@ ssl=yes # use ssl-support. Works with
|
||||||
# protocol=njalla,
|
# protocol=njalla,
|
||||||
# password=mypassword
|
# password=mypassword
|
||||||
# quietreply=no|yes
|
# quietreply=no|yes
|
||||||
# my-host
|
# my-domain.com
|
||||||
|
|
|
||||||
38
ddclient.in
38
ddclient.in
|
|
@ -768,7 +768,6 @@ my %services = (
|
||||||
'examples' => \&nic_njalla_examples,
|
'examples' => \&nic_njalla_examples,
|
||||||
'variables' => {
|
'variables' => {
|
||||||
%{$variables{'service-common-defaults'}},
|
%{$variables{'service-common-defaults'}},
|
||||||
'login' => setv(T_STRING, 0, 0, 'unused', undef),
|
|
||||||
'server' => setv(T_FQDNP, 1, 0, 'njal.la', undef),
|
'server' => setv(T_FQDNP, 1, 0, 'njal.la', undef),
|
||||||
'quietreply' => setv(T_BOOL, 0, 1, 0, undef)
|
'quietreply' => setv(T_BOOL, 0, 1, 0, undef)
|
||||||
},
|
},
|
||||||
|
|
@ -5073,7 +5072,7 @@ Example ${program}.conf file entries:
|
||||||
protocol=njalla \\
|
protocol=njalla \\
|
||||||
password=njal.la-key
|
password=njal.la-key
|
||||||
quietreply=no
|
quietreply=no
|
||||||
hostname
|
domain.com
|
||||||
|
|
||||||
EoEXAMPLE
|
EoEXAMPLE
|
||||||
}
|
}
|
||||||
|
|
@ -5091,12 +5090,14 @@ sub nic_njalla_update {
|
||||||
debug("\nnic_njalla_update -------------------");
|
debug("\nnic_njalla_update -------------------");
|
||||||
|
|
||||||
foreach my $h (@_) {
|
foreach my $h (@_) {
|
||||||
|
# Read input params
|
||||||
my $ipv4 = delete $config{$h}{'wantipv4'};
|
my $ipv4 = delete $config{$h}{'wantipv4'};
|
||||||
my $ipv6 = delete $config{$h}{'wantipv6'};
|
my $ipv6 = delete $config{$h}{'wantipv6'};
|
||||||
my $quietreply = delete $config{$h}{'quietreply'};
|
my $quietreply = delete $config{$h}{'quietreply'};
|
||||||
my $ip_output = '';
|
my $ip_output = '';
|
||||||
my $url;
|
|
||||||
$url = "https://$config{$h}{'server'}/update/";
|
# Build url
|
||||||
|
my $url = "https://$config{$h}{'server'}/update/";
|
||||||
$url .= "?h=";
|
$url .= "?h=";
|
||||||
$url .= $h;
|
$url .= $h;
|
||||||
$url .= "&k=";
|
$url .= "&k=";
|
||||||
|
|
@ -5112,54 +5113,33 @@ sub nic_njalla_update {
|
||||||
}
|
}
|
||||||
$url .= (($auto eq 1)) ? '&auto' : '';
|
$url .= (($auto eq 1)) ? '&auto' : '';
|
||||||
$url .= (($quietreply eq 1)) ? '&quiet' : '';
|
$url .= (($quietreply eq 1)) ? '&quiet' : '';
|
||||||
|
|
||||||
info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h);
|
info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h);
|
||||||
verbose("UPDATE:", "updating %s", $h);
|
verbose("UPDATE:", "updating %s", $h);
|
||||||
debug("url: %s", $url);
|
debug("url: %s", $url);
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
|
|
||||||
my $response = '';
|
my $response = '';
|
||||||
if ($quietreply) {
|
if ($quietreply) {
|
||||||
$reply =~ qr/^invalid host or key/mp;
|
$reply =~ qr/invalid host or key/mp;
|
||||||
$response = ${^MATCH};
|
$response = ${^MATCH};
|
||||||
} else {
|
|
||||||
$response = eval {decode_json(${^MATCH})};
|
|
||||||
}
|
|
||||||
|
|
||||||
next if !header_ok($h, $reply);
|
|
||||||
verbose("After getting url-*-*-*-*-*-*-*-*-*-\n\n");
|
|
||||||
# verbose($reply);
|
|
||||||
# verbose($response);
|
|
||||||
verbose("\n\nAfter printing reply , response.-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-\n\n");
|
|
||||||
# my @reply = split /\n/, $reply;
|
|
||||||
# my $returned = pop(@reply);
|
|
||||||
if ($quietreply) {
|
|
||||||
if (!$response) {
|
if (!$response) {
|
||||||
success("updating %s: good: IP address set to %s", $h, $ip_output);
|
success("updating %s: good: IP address set to %s", $h, $ip_output);
|
||||||
}
|
}
|
||||||
elsif ($response =~ /invalid host or key/) {
|
elsif ($response =~ /invalid host or key/) {
|
||||||
# verbose($response);
|
|
||||||
failed("Invalid host or key");
|
failed("Invalid host or key");
|
||||||
# success("Invalid host or key");
|
|
||||||
} else {
|
} else {
|
||||||
# verbose($response);
|
|
||||||
failed("Unknown response");
|
failed("Unknown response");
|
||||||
# success("Unknown response");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
|
||||||
|
$response = eval {decode_json(${^MATCH})};
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
} else {
|
} else {
|
||||||
# Strip header
|
# Strip header
|
||||||
verbose("\n\n\nNo quietreply\n\n\n");
|
|
||||||
|
|
||||||
# info($response);
|
|
||||||
# verbose($response);
|
|
||||||
print($response->{status});
|
|
||||||
print($response->{message});
|
|
||||||
verbose("\n\n\nNo quietreply after printing messges\n\n\n");
|
|
||||||
if ($response->{status} == 401 && $response->{message} =~ /invalid host or key/) {
|
if ($response->{status} == 401 && $response->{message} =~ /invalid host or key/) {
|
||||||
failed("Invalid host or key");
|
failed("Invalid host or key");
|
||||||
} elsif ($response->{status} == 200 && $response->{message} =~ /record updated/) {
|
} elsif ($response->{status} == 200 && $response->{message} =~ /record updated/) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue