From: Gilles E. <ges...@us...> - 2006-02-26 23:15:19
|
Update of /cvsroot/ipcop/ipcop/src/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15266/src/scripts Modified Files: setddns.pl Log Message: Forward from 1.4 last 3 months changes Index: setddns.pl =================================================================== RCS file: /cvsroot/ipcop/ipcop/src/scripts/setddns.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** setddns.pl 14 Aug 2005 20:42:19 -0000 1.17 --- setddns.pl 26 Feb 2006 23:15:15 -0000 1.18 *************** *** 57,61 **** #If IP is reserved network, we are behind a router. May we ask for our real public IP ? if ( &General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') || ! &General::IpInSubnet ($ip,'172.16.0.0.','255.240.0.0') || &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0')) { # We can, but are we authorized by GUI ? --- 57,61 ---- #If IP is reserved network, we are behind a router. May we ask for our real public IP ? if ( &General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') || ! &General::IpInSubnet ($ip,'172.16.0.0','255.240.0.0') || &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0')) { # We can, but are we authorized by GUI ? *************** *** 149,152 **** --- 149,179 ---- } } + + elsif ($settings{'SERVICE'} eq 'cjb') { + # 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_http( 'www.cjb.net', + 80, + "/cgi-bin/dynip.cgi?username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}&ip=$ip", + Net::SSLeay::make_headers('User-Agent' => 'Ipcop' ) + ); + + if ($response =~ m%HTTP/1\.. 200 OK%) { + if ( $out !~ m/has been updated to point to/ ) { + &General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : failure (bad password or login)"); + } else { + &General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : success"); + $success++; + } + } else { + &General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : failure (could not connect to server)"); + } + } elsif ($settings{'SERVICE'} eq 'selfhost') { # use proxy ? *************** *** 310,399 **** } elsif ($settings{'SERVICE'} eq 'freedns') { ! my %proxysettings; ! &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); ! ! my $peer = 'freedns.afraid.org'; ! my $peerport = 80; ! ! if ($_=$proxysettings{'UPSTREAM_PROXY'}) { ! ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); ! } ! ! my $sock; ! unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) { ! &General::log("Dynamic DNS failure : could not connect to $peer:$peerport: $@"); ! next; ! } ! ! my $GET_CMD; ! $GET_CMD = "GET http://freedns.afraid.org/dynamic/update.php?$settings{'LOGIN'} HTTP/1.1\r\n"; ! $GET_CMD .= "Host: freedns.afraid.org\r\n"; ! $GET_CMD .= "User-Agent: ipcop\r\n"; ! $GET_CMD .= "Connection: close\r\n\r\n"; ! print $sock "$GET_CMD"; ! ! my $out = ''; ! while(<$sock>) { ! $out .= $_; ! } ! close($sock); ! ! #Valid responses from service are: ! #Updated yourdomain.afraid.org to your IP ! #Address <ip> has not changed. ! if ( $out !~ m/(Updated|Address .* has not changed)/ig ) { ! #cleanup http response... ! $out =~ s/.+?\015?\012\015?\012//s; # header HTTP ! my @out = split("\r", $out); ! &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($out[1])"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} :: success"); ! $success++; } } elsif ($settings{'SERVICE'} eq 'regfish') { ! my %proxysettings; ! &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); ! ! my $peer = 'www.regfish.com'; ! my $peerport = 80; ! ! if ($_=$proxysettings{'UPSTREAM_PROXY'}) { ! ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); ! } ! ! my $sock; ! unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) { ! &General::log("Dynamic DNS failure : could not connect to $peer:$peerport: $@"); ! next; ! } ! ! my $GET_CMD; ! $GET_CMD = "GET http://www.regfish.com/dyndns/2/?fqdn=$settings{'DOMAIN'}&ipv4=$ip&forcehost=1&authtype=secure&token=$settings{'LOGIN'} HTTP/1.1\r\n"; ! $GET_CMD .= "Host: www.regfish.com\r\n"; ! $GET_CMD .= "User-Agent: ipcop\r\n"; ! $GET_CMD .= "Connection: close\r\n\r\n"; ! print $sock "$GET_CMD"; - my $out = ''; - while(<$sock>) { - $out .= $_; - } - close($sock); - - #Valid responses from service: - #success|100|update succeeded! - #success|101|no update needed at this time.. if ( $out !~ m/(success\|(100|101)\|)/ig ) { ! #cleanup http response... ! $out =~ s/.+?\015?\012\015?\012//s; # header HTTP ! my @out = split("\r", $out); ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out[1])"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success"); ! $success++; } } elsif ($settings{'SERVICE'} eq 'ovh') { --- 337,396 ---- } elsif ($settings{'SERVICE'} eq 'freedns') { ! # 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( 'freedns.afraid.org', ! 443, ! "/dynamic/update.php?$settings{'LOGIN'}", ! Net::SSLeay::make_headers('User-Agent' => 'Ipcop' ) ! ); ! #Valid responses from service are: ! #Updated n host(s) <domain> ! #ERROR: <ip> has not changed. ! if ($response =~ m%HTTP/1\.. 200 OK%) { ! #Valid responses from update => ErrCount=0 ! if ( $out !~ m/(^Updated|Address .* has not changed)/ig ) { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($out)"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success"); ! $success++; } + } else { + &General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)"); + } } 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( 'www.regfish.com', + 443, + "/dyndns/2/?fqdn=$settings{'DOMAIN'}&ipv4=$ip&forcehost=1&authtype=secure&token=$settings{'LOGIN'}", + Net::SSLeay::make_headers('User-Agent' => 'Ipcop' ) + ); + #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') { *************** *** 452,548 **** } elsif ($settings{'SERVICE'} eq 'dtdns') { ! my %proxysettings; ! &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); ! ! my $peer = 'www.dtdns.com'; ! my $peerport = 80; ! ! if ($_=$proxysettings{'UPSTREAM_PROXY'}) { ! ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); ! } ! ! my $sock; ! unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) { ! &General::log("Dynamic DNS failure : could not connect to $peer:$peerport: $@"); ! next; ! } ! if ($settings{'HOSTNAME'} eq '') { ! $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; ! } else { ! $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; ! } ! ! my $GET_CMD; ! $GET_CMD = "GET http://www.dtdns.com/api/autodns.cfm?id=$settings{'HOSTDOMAIN'}&pw=$settings{'PASSWORD'} HTTP/1.1\r\n"; ! $GET_CMD .= "Host: www.dtdns.com\r\n"; ! $GET_CMD .= "User-Agent: ipcop\r\n"; ! $GET_CMD .= "Connection: close\r\n\r\n"; ! print $sock "$GET_CMD"; ! my $out = ''; ! while(<$sock>) { ! $out .= $_; ! } ! close($sock); ! ! #Valid responses from service are: ! # ! # if ( $out !~ m/Host .* now points to/ig ) { ! #cleanup http response... ! $out =~ s/.+?\015?\012\015?\012//s; # header HTTP ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out)"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success"); ! $success++; } } ! elsif ($settings{'SERVICE'} eq 'dynu') { ! my %proxysettings; ! &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); ! ! my $peer = 'dynserv.ca'; ! my $peerport = 80; ! ! if ($_=$proxysettings{'UPSTREAM_PROXY'}) { ! ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); ! } ! my $sock; ! unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) { ! &General::log("Dynamic DNS failure : could not connect to $peer:$peerport: $@"); ! next; ! } ! if ($settings{'HOSTNAME'} eq '') { ! $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; } else { ! $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; } ! my $GET_CMD; ! $GET_CMD = "GET http://dynserv.ca/dyn/dynengine.cgi?func=set&name=$settings{'LOGIN'}&pass=$settings{'PASSWORD'}&ip=$ip&domain=$settings{'DOMAIN'} HTTP/1.1\r\n"; ! $GET_CMD .= "Host: dynserv.ca\r\n"; ! $GET_CMD .= "User-Agent: ipcop\r\n"; ! $GET_CMD .= "Connection: close\r\n\r\n"; ! print $sock "$GET_CMD"; ! ! my $out = ''; ! while(<$sock>) { ! $out .= $_; ! } ! close($sock); ! #Valid responses from service are: ! # 02 == Domain already exists, refreshing data for ... => xxx.xxx.xxx.xxx if ( $out !~ m/Domain already exists, refreshing data for/ig ) { ! #cleanup http response... ! $out =~ s/.+?\015?\012\015?\012//s; # header HTTP ! my @out = split("\r", $out); ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out[1])"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success"); ! $success++; } } else { if ($settings{'WILDCARDS'} eq 'on') { --- 449,554 ---- } elsif ($settings{'SERVICE'} eq 'dtdns') { ! # 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'} ); ! } ! if ($settings{'HOSTNAME'} eq '') { ! $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; ! } else { ! $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; ! } + my ($out, $response) = Net::SSLeay::get_http( 'www.dtdns.com', + 80, + "/api/autodns.cfm?id=$settings{'HOSTDOMAIN'}&pw=$settings{'PASSWORD'}", + Net::SSLeay::make_headers('User-Agent' => 'Ipcop' ) + ); + #Valid responses from service are: + # now points to + # + if ($response =~ m%HTTP/1\.. 200 OK%) { if ( $out !~ m/Host .* now points to/ig ) { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success"); ! $success++; } + } else { + &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server)"); + } } ! elsif ($settings{'SERVICE'} eq 'everydns') { ! # 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'} ); ! } ! if ($settings{'HOSTNAME'} eq '') { ! $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; ! } else { ! $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; ! } ! my $code64 = encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}"); ! my $version = "0.1"; # developped for this version of dyn server. ! my ($out, $response) = Net::SSLeay::get_http( 'dyn.everydns.net', ! 80, ! "/index.php?ver=$version&ip=$ip&domain=$settings{'HOSTDOMAIN'}", ! Net::SSLeay::make_headers('User-Agent' => 'Ipcop', ! 'Authorization' => "Basic $code64") ! ); ! #Valid responses from service are: ! # ! # "... Exit code: 0" 0:ok else error ! if ($response =~ m%HTTP/1\.. 200 OK%) { ! if ( $out !~ m/Exit code: 0/ig ) { ! &General::log("Dynamic DNS everydns for $settings{'HOSTDOMAIN'} : failure ($out)"); } else { ! &General::log("Dynamic DNS everydns for $settings{'HOSTDOMAIN'} : success"); ! $success++; } + } else { + &General::log("Dynamic DNS everydns for $settings{'HOSTDOMAIN'} : failure (could not connect to server)"); + } + } + elsif ($settings{'SERVICE'} eq 'dynu') { + # 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'} ); + } ! if ($settings{'HOSTNAME'} eq '') { ! $settings{'HOSTDOMAIN'} = $settings{'DOMAIN'}; ! } else { ! $settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}"; ! } ! my ($out, $response) = Net::SSLeay::get_http( 'dynserv.ca', ! 80, ! "/dyn/dynengine.cgi?func=set&name=$settings{'LOGIN'}&pass=$settings{'PASSWORD'}&ip=$ip&domain=$settings{'DOMAIN'}", ! Net::SSLeay::make_headers('User-Agent' => 'Ipcop' ) ! ); ! #Valid responses from service are: ! # 02 == Domain already exists, refreshing data for ... => xxx.xxx.xxx.xxx ! # ! if ($response =~ m%HTTP/1\.. 200 OK%) { if ( $out !~ m/Domain already exists, refreshing data for/ig ) { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)"); } else { ! &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success"); ! $success++; } + } else { + &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server)"); + } } else { if ($settings{'WILDCARDS'} eq 'on') { |