[Ddclient-forum] [ddclient - Open Discussion] freedns.afraid.org patch
Brought to you by:
supersandro2000,
wimpunk
From: SourceForge.net <no...@so...> - 2008-12-13 01:12:45
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=5805778 By: calin_fastfire Hi guys. I've written this patch to add in freedns support to ddclient 3.7.3 .conf file example is: protocol=freedns, \ login=my-freedns.afraid.org-login, \ password=my-freedns.afraid.org-password \ myhost.afraid.com The patch: *** ddclient Fri Dec 12 15:41:43 2008 --- ddclient Fri Dec 12 17:06:23 2008 *************** my %services = ( *** 479,484 **** --- 479,494 ---- $variables{'service-common-defaults'}, ), }, + 'freedns' => { + 'updateable' => undef, + 'update' => \&nic_freedns_update, + 'examples' => \&nic_freedns_examples, + 'variables' => merge( + { 'server' => setv(T_FQDNP, 1, 0, 1, 'freedns.afraid.org', undef) }, + { 'min-interval' => setv(T_DELAY, 0, 0, 1, 0, interval('5m')),}, + $variables{'service-common-defaults'}, + ), + }, ); $variables{'merged'} = merge($variables{'global-defaults'}, $variables{'service-common-defaults'}, *************** sub nic_sitelutions_update { *** 3159,3164 **** --- 3169,3264 ---- } } } + ###################################################################### + + ###################################################################### + ## nic_freedns_examples + ###################################################################### + sub nic_freedns_examples { + return <<EoEXAMPLE; + + o 'freedns' + + The 'freedns' protocol is used by DNS services offered by freedns.afraid.org. + + Configuration variables applicable to the 'freedns' protocol are: + protocol=freedns ## + server=fqdn.of.service ## defaults to freedns.agraid.org + 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=freedns, \\ + login=my-freedns.afraid.org-login, \\ + password=my-freedns.afraid.org-password \\ + myhost.afraid.com + + EoEXAMPLE + } + ###################################################################### + ## nic_freedns_update + ## + ## written by Mike W. Smith + ## + ## based on http://freedns.afraid.org/api/ + ## needs this url to update: + ## http://freedns.afraid.org/api/?action=getdyndns&sha=<sha1sum of login|password> + ## This returns a list of host|currentIP|updateURL lines. + ## Pick the line that matches myhost, and fetch the URL. + ## word 'Updated' for success, 'fail' for failure. + ## + ###################################################################### + use Digest::SHA1 qw/sha1_hex/; #Not the best place for this, but it goes with the freedns update, so whatever + sub nic_freedns_update { + + + debug("\nnic_freedns_update -------------------"); + + ## First get the list of updatable hosts + my $url; + $url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1 _hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}"); + my $reply = geturl(opt('proxy'), $url); + if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) + { + failed("updating %s: Could not connect to %s for site list.", $_[0], $url); + return; + } + my @lines = split("\n", $reply); + my %freedns_hosts; + grep + { + my @rec = split(/\|/, $_); + $freedns_hosts{$rec[0]} = \@rec; + } @lines; + ## update each configured host + foreach my $h (@_) { + if(!$h){ next }; + info("setting IP address to %s for %s", $ip, $h); + verbose("UPDATE: updating %s", $h); + + if($ip ne $freedns_hosts{$h}->[1]) + { + my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]); + if (!defined($reply) || !$reply) { + failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]); + last; + } + last if !header_ok($h, $reply); + + if($reply =~ /Updated.*host/) + { + success("updating %s: good: IP address set to %s", $h, $ip); + } else { + $config{$h}{'status'} = 'failed'; + warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("updating %s: Invalid reply.", $h); + } + } + } + } ###################################################################### # vim: ai ts=4 sw=4 tw=78 : ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=399427 |