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:
parent
69f7fbbdc3
commit
357bc6ff0d
1 changed files with 30 additions and 24 deletions
54
ddclient
54
ddclient
|
|
@ -484,6 +484,7 @@ my %variables = (
|
||||||
'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef),
|
'warned-min-error-interval' => setv(T_ANY, 0, 1, 0, 0, undef),
|
||||||
},
|
},
|
||||||
'mydns-common-defaults' => {
|
'mydns-common-defaults' => {
|
||||||
|
'directip' => setv(T_BOOL, 0, 0, 1, 0, undef),
|
||||||
'server' => setv(T_FQDNP, 1, 0, 1, 'www.mydns.jp', undef),
|
'server' => setv(T_FQDNP, 1, 0, 1, 'www.mydns.jp', undef),
|
||||||
'max-interval' => setv(T_DELAY, 0, 0, 1, interval('6d'), 0),
|
'max-interval' => setv(T_DELAY, 0, 0, 1, interval('6d'), 0),
|
||||||
},
|
},
|
||||||
|
|
@ -693,7 +694,7 @@ my %services = (
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
'update' => \&nic_mydns_update,
|
'update' => \&nic_mydns_update,
|
||||||
'examples' => \&nic_mydns_examples,
|
'examples' => \&nic_mydns_examples,
|
||||||
'variables' => merge(
|
'variables' => merge(
|
||||||
$variables{'mydns-common-defaults'},
|
$variables{'mydns-common-defaults'},
|
||||||
$variables{'service-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:
|
Configuration variables applicable to the 'mydns' protocol are:
|
||||||
protocol=mydns ##
|
protocol=mydns ##
|
||||||
server=fqdn.of.service ## defaults to www.mydns.jp
|
directip=no|yes ## update the DNS record with a specified IP address.
|
||||||
login=service-login ## login name and password registered with the service
|
server=fqdn.of.service ## defaults to www.mydns.jp.
|
||||||
|
login=service-login ## login name and password registered with the service.
|
||||||
password=service-password ##
|
password=service-password ##
|
||||||
fully.qualified.host ## the host registered with the service.
|
fully.qualified.host ## the host registered with the service.
|
||||||
|
|
||||||
|
|
@ -4721,44 +4723,48 @@ sub nic_mydns_update {
|
||||||
|
|
||||||
## update each configured host
|
## update each configured host
|
||||||
foreach my $h (@_) {
|
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);
|
info("setting IP address to %s for %s", $ip, $h);
|
||||||
verbose("UPDATE:","updating %s", $h);
|
verbose("UPDATE:","updating %s", $h);
|
||||||
|
|
||||||
# Set the URL that we're going to to update
|
## update the DNS record
|
||||||
my $url;
|
my $url;
|
||||||
$url = "http://$config{$h}{'server'}/directip.html";
|
my $reply;
|
||||||
$url .= "?MID=";
|
if ($config{$h}{'directip'}) {
|
||||||
$url .= $config{$h}{'login'};
|
$url = "http://$config{$h}{'server'}/directip.html";
|
||||||
$url .= "&PWD=";
|
$url .= "?MID=";
|
||||||
$url .= $config{$h}{'password'};
|
$url .= $config{$h}{'login'};
|
||||||
$url .= "&IPV4ADDR=";
|
$url .= "&PWD=";
|
||||||
$url .= $ip;
|
$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
|
## no response, declare as failed
|
||||||
my $reply = geturl(opt('proxy'), $url);
|
|
||||||
|
|
||||||
# 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'});
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
last if !header_ok($h, $reply);
|
last if !header_ok($h, $reply);
|
||||||
|
|
||||||
# Response found, check the reply
|
## response found, check the result
|
||||||
if ($reply =~ /login_status = 1/i)
|
if ($reply =~ /login_status = 1/i) {
|
||||||
{
|
|
||||||
$config{$h}{'ip'} = $ip;
|
$config{$h}{'ip'} = $ip;
|
||||||
$config{$h}{'mtime'} = $now;
|
$config{$h}{'mtime'} = $now;
|
||||||
$config{$h}{'status'} = 'good';
|
$config{$h}{'status'} = 'good';
|
||||||
success("updating %s: good: IP address set to %s", $h, $ip);
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$reply =~ /login_status.*\n.*\n(.+)\s*<BR>/i;
|
|
||||||
$config{$h}{'status'} = 'failed';
|
$config{$h}{'status'} = 'failed';
|
||||||
warning("SENT: %s", $url) unless opt('verbose');
|
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);
|
failed("updating %s: Invalid reply.", $h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue