MyDNS.JP: support for HTTP-BASIC

http://www.mydns.jp/?MENU=030

HTTP-BASIC(default): Let MyDNS.jp get the IP.
HTTP-DIRECT(directip=yes): Use the IP specified by ddclient.
This commit is contained in:
epgdatacapbon 2016-01-11 21:29:17 +09:00
parent 69f7fbbdc3
commit 357bc6ff0d

View file

@ -484,6 +484,7 @@ my %variables = (
'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef),
},
'mydns-common-defaults' => {
'directip' => setv(T_BOOL, 0, 0, 1, 0, undef),
'server' => setv(T_FQDNP, 1, 0, 1, 'www.mydns.jp', undef),
'max-interval' => setv(T_DELAY, 0, 0, 1, interval('6d'), 0),
},
@ -693,7 +694,7 @@ my %services = (
'updateable' => undef,
'update' => \&nic_mydns_update,
'examples' => \&nic_mydns_examples,
'variables' => merge(
'variables' => merge(
$variables{'mydns-common-defaults'},
$variables{'service-common-defaults'},
),
@ -4700,8 +4701,9 @@ The 'mydns' protocol is used by a free dynamic DNS service offered by www.mydns.
Configuration variables applicable to the 'mydns' protocol are:
protocol=mydns ##
server=fqdn.of.service ## defaults to www.mydns.jp
login=service-login ## login name and password registered with the service
directip=no|yes ## update the DNS record with a specified IP address.
server=fqdn.of.service ## defaults to www.mydns.jp.
login=service-login ## login name and password registered with the service.
password=service-password ##
fully.qualified.host ## the host registered with the service.
@ -4721,44 +4723,48 @@ sub nic_mydns_update {
## update each configured host
foreach my $h (@_) {
my $ip = delete $config{$h}{'wantip'};
my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:","updating %s", $h);
# Set the URL that we're going to to update
## update the DNS record
my $url;
$url = "http://$config{$h}{'server'}/directip.html";
$url .= "?MID=";
$url .= $config{$h}{'login'};
$url .= "&PWD=";
$url .= $config{$h}{'password'};
$url .= "&IPV4ADDR=";
$url .= $ip;
my $reply;
if ($config{$h}{'directip'}) {
$url = "http://$config{$h}{'server'}/directip.html";
$url .= "?MID=";
$url .= $config{$h}{'login'};
$url .= "&PWD=";
$url .= $config{$h}{'password'};
$url .= "&IPV4ADDR=";
$url .= $ip;
$reply = geturl(opt('proxy'), $url);
} else {
$url = "http://$config{$h}{'server'}/login.html";
$reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'});
}
# Try to get URL
my $reply = geturl(opt('proxy'), $url);
# No response, declare as failed
## no response, declare as failed
if (!defined($reply) || !$reply) {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
last;
}
last if !header_ok($h, $reply);
# Response found, check the reply
if ($reply =~ /login_status = 1/i)
{
## response found, check the result
if ($reply =~ /login_status = 1/i) {
$config{$h}{'ip'} = $ip;
$config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good';
success("updating %s: good: IP address set to %s", $h, $ip);
}
else
{
$reply =~ /login_status.*\n.*\n(.+)\s*<BR>/i;
} else {
$config{$h}{'status'} = 'failed';
warning("SENT: %s", $url) unless opt('verbose');
warning("REPLIED: %s", $1);
if ($config{$h}{'directip'}) {
if ($reply =~ /login_status.*\n.*\n(.+)\s*<BR>/i) {
warning("REPLIED: %s", $1);
}
}
failed("updating %s: Invalid reply.", $h);
}
}