Created
July 26, 2012 03:00
-
-
Save yoneken/3179998 to your computer and use it in GitHub Desktop.
This is a patch to add mydns support for ddclient. The original patch is written by ta-ta. Thanks!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ddclient.orig 2012-07-16 23:32:28.000000000 +0900 | |
+++ /usr/sbin/ddclient 2012-07-20 00:07:06.000000000 +0900 | |
@@ -429,6 +429,11 @@ | |
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef), | |
'client' => setv(T_STRING, 0, 1, 1, $program, undef), | |
}, | |
+ 'mydns-common-defaults' => { | |
+ 'min-interval' => setv(T_DELAY, 0, 0, 1, interval('30s'), 0), | |
+ 'max-interval' => setv(T_DELAY, 0, 0, 1, interval('3d'), 0), | |
+ 'server' => setv(T_FQDNP, 1, 0, 1, 'www.mydns.jp', undef), | |
+ }, | |
); | |
my %services = ( | |
'dyndns1' => { | |
@@ -563,6 +568,15 @@ | |
$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'}, | |
@@ -3452,7 +3466,7 @@ | |
## 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); | |
@@ -3674,5 +3688,74 @@ | |
###################################################################### | |
# vim: ai ts=4 sw=4 tw=78 : | |
- | |
+###################################################################### | |
+## nic_mydns_examples | |
+###################################################################### | |
+sub nic_mydns_examples { | |
+ return <<EoEXAMPLE; | |
+ | |
+o 'mydns' | |
+ | |
+The 'mydns' protocol is used by DNS service offered by www.mydns.jp. | |
+ | |
+Configuration variables applicable to the 'mydns' protocol are: | |
+ protocol=mydns ## | |
+ server=fqdn.of.service ## defaults to dynamicdns.park-your-domain.com | |
+ 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 | |
+## | |
+## Original code by Dan Boardman | |
+## Modified for MyDNS.jp by ta-ta | |
+## Modified for latest ddclient by yoneken | |
+## | |
+###################################################################### | |
+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); | |
+ | |
+ my $url; | |
+ $url = "http://$config{$h}{'server'}/login.html"; | |
+ | |
+ my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'}); | |
+# my $reply = geturl(opt('proxy'), $url); | |
+ if (!defined($reply) || !$reply) { | |
+ failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); | |
+ last; | |
+ } | |
+ last if !header_ok($h, $reply); | |
+ | |
+ my @reply = split /\n/, $reply; | |
+ if (grep /login_status = 1/i, @reply) { | |
+ $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'); | |
+ warning("REPLIED: %s", $reply); | |
+ failed("updating %s: Invalid reply.", $h); | |
+ } | |
+ } | |
+} | |
+ | |
+################################################################ | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment