From: Christian Schmidt Date: Tue, 8 Feb 2011 20:38:13 +0000 (+0100) Subject: Added recent patch supplied by maverick. X-Git-Tag: v2.9-core46~4^2~4 X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=b411505d49bd881e44de380f9fc600aa9adf808b Added recent patch supplied by maverick. This adds strato as dyddns provider and closes Bug #0000758 --- diff --git a/html/cgi-bin/ddns.cgi b/html/cgi-bin/ddns.cgi index 4dba22f535..2912b44217 100644 --- a/html/cgi-bin/ddns.cgi +++ b/html/cgi-bin/ddns.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2011 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -249,6 +249,7 @@ $checked{'SERVICE'}{'nsupdate'} = ''; $checked{'SERVICE'}{'ovh.com'} = ''; $checked{'SERVICE'}{'regfish.com'} = ''; $checked{'SERVICE'}{'selfhost.de'} = ''; +$checked{'SERVICE'}{'strato.com'} = ''; $checked{'SERVICE'}{'tzo.com'} = ''; $checked{'SERVICE'}{'zoneedit.com'} = ''; $checked{'SERVICE'}{$settings{'SERVICE'}} = "selected='selected'"; @@ -342,6 +343,7 @@ print <ovh.com + diff --git a/src/scripts/setddns.pl b/src/scripts/setddns.pl index beb9af8b88..a71590402d 100644 --- a/src/scripts/setddns.pl +++ b/src/scripts/setddns.pl @@ -390,7 +390,7 @@ if ($ip ne $ipcache) { &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)"); } } - elsif ($settings{'SERVICE'} eq 'regfish') { + elsif ($settings{'SERVICE'} eq 'strato') { # use proxy ? my %proxysettings; &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); @@ -398,25 +398,62 @@ if ($ip ne $ipcache) { my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} ); } - my ($out, $response) = Net::SSLeay::get_https( 'dyndns.regfish.de', - 443, - "/?fqdn=$settings{'DOMAIN'}&ipv4=$ip&forcehost=1&authtype=secure&token=$settings{'LOGIN'}", - Net::SSLeay::make_headers('User-Agent' => 'Ipfire' ) - ); - #Valid responses from service are: - # success|100|update succeeded! - # success|101|no update needed at this time.. + + if ($settings{'HOSTNAME'} eq '') { + $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; + } else { + $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; + } + + my ($out, $response) = Net::SSLeay::get_https( 'dyndns.strato.com', + 443, + "/nic/update?hostname=$settings{'HOSTDOMAIN'}&myip=$ip", + Net::SSLeay::make_headers('User-Agent' => 'IPFire', + 'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}") ) + ); + if ($response =~ m%HTTP/1\.. 200 OK%) { - if ( $out !~ m/(success\|(100|101)\|)/ig ) { - &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out)"); + #Valid responses from update => ErrCount=0 + if ( $out =~ m/good |nochg /ig) { + &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success"); + $success++; } else { - &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success"); + &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure1 ($out)"); $success++; } + } elsif ( $out =~ m/(.*)<\/title>/ig ) { + &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure2 ($1)"); } else { - &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure (could not connect to server)"); + &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure3 ($response)"); } } + elsif ($settings{'SERVICE'} eq 'regfish') { + # use proxy ? + my %proxysettings; + &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); + if ($_=$proxysettings{'UPSTREAM_PROXY'}) { + my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); + Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} ); + } + my ($out, $response) = Net::SSLeay::get_https( 'dyndns.regfish.de', + 443, + "/?fqdn=$settings{'DOMAIN'}&ipv4=$ip&forcehost=1&authtype=secure&token=$settings{'LOGIN'}", + Net::SSLeay::make_headers('User-Agent' => 'Ipfire' ) + ); + #Valid responses from service are: + #success|100|update succeeded! + #success|101|no update needed at this time.. + if ($response =~ m%HTTP/1\.. 200 OK%) { + if ( $out !~ m/(success\|(100|101)\|)/ig ) { + &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out)"); + } else { + &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success"); + $success++; + } + } else { + &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure (could not connect to server)"); + } + } elsif ($settings{'SERVICE'} eq 'ovh') { my %proxysettings; &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);