Merge pull request #81 from epgdatacapbon/pullrequest

Added MyDNS.JP
This commit is contained in:
Sandro Jäckel 2019-12-29 04:21:55 +01:00
commit 1bb1d7aa19
No known key found for this signature in database
GPG key ID: 3AF5A43A3EECC2E5
4 changed files with 94 additions and 0 deletions

View file

@ -32,6 +32,7 @@ Dynamic DNS services currently supported include:
DNS Made Easy - See https://dnsmadeeasy.com/ for details
DonDominio - See https://www.dondominio.com for details
NearlyFreeSpeech.net - See https://www.nearlyfreespeech.net/services/dns for details
MyDNS.JP - See https://www.mydns.jp/ for details
DDclient now supports many of cable/dsl broadband routers.

View file

@ -11,3 +11,4 @@ ssl support is tested on folowing dynamic dns providers:
- freemyip.com
- DNS Made Easy
- dondominio.com
- www.mydns.jp

View file

@ -522,6 +522,10 @@ my %variables = (
'dondominio-common-defaults' => {
'server' => setv(T_FQDNP, 1, 0, 1, 'dondns.dondominio.com', undef),
},
'mydns-common-defaults' => {
'server' => setv(T_FQDNP, 1, 0, 1, 'www.mydns.jp', undef),
'max-interval' => setv(T_DELAY, 0, 0, 1, interval('6d'), 0),
},
);
my %services = (
'dyndns1' => {
@ -764,6 +768,15 @@ my %services = (
$variables{'service-common-defaults'},
),
},
'mydns' => {
'updateable' => undef,
'update' => \&nic_mydns_update,
'examples' => \&nic_mydns_examples,
'variables' => merge(
$variables{'mydns-common-defaults'},
$variables{'service-common-defaults'},
),
},
);
$variables{'merged'} = merge($variables{'global-defaults'},
$variables{'service-common-defaults'},
@ -5569,6 +5582,77 @@ sub nic_dnsmadeeasy_update {
}
}
######################################################################
## nic_mydns_examples
######################################################################
sub nic_mydns_examples {
return <<EoEXAMPLE;
o 'mydns'
The 'mydns' protocol is used by a free
dynamic DNS service offered by www.mydns.jp.
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.
password=service-password ##
fully.qualified.host ## the host registered with the service.
Example ${program}.conf file entries:
## single host update
protocol=mydns, \\
login=my-mydns.jp-login, \\
password=my-mydns.jp-password \\
myhost.mydns.jp
EoEXAMPLE
}
######################################################################
## nic_mydns_update
######################################################################
sub nic_mydns_update {
debug("\nnic_mydns_update -------------------");
## update each configured host
foreach my $h (@_) {
my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:","updating %s", $h);
## update the DNS record
my $url;
my $header;
my $data;
my $reply;
$url = "https://$config{$h}{'server'}/directip.html";
$header = 'Content-Type: application/x-www-form-urlencoded';
$data = "MID=" . $config{$h}{'login'} . "&PWD=" . $config{$h}{'password'} . "&IPV4ADDR=" . $ip;
$reply = geturl(opt('proxy'), $url, undef, undef, $header, 'POST', $data);
## 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 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 {
$config{$h}{'status'} = 'failed';
warning("SENT: %s", $url) unless opt('verbose');
if ($reply =~ /login_status.*\n.*\n(.+)\s*<BR>/i) {
warning("REPLIED: %s", $1);
}
failed("updating %s: Invalid reply.", $h);
}
}
}
######################################################################
# vim: ai ts=4 sw=4 tw=78 :

View file

@ -285,3 +285,11 @@ ssl=yes # use ssl-support. Works with
# login=your-account-email-address
# password=your-generated-password
# your-numeric-record-id-1,your-numeric-record-id-2,...
##
## MyDNS.JP (https://www.mydns.jp/)
##
# protocol=mydns,
# login=my-mydns.jp-login,
# password=my-mydns.jp-password
# myhost.mydns.jp