Add DDNS client for dns.lightningwirelabs.com.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Jun 2013 12:36:51 +0000 (14:36 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Jun 2013 12:36:51 +0000 (14:36 +0200)
config/cfgroot/general-functions.pl
config/rootfiles/core/70/filelists/files
html/cgi-bin/ddns.cgi
src/scripts/setddns.pl

index a70f2673e6b4751cadb1530b6bd80c3aab5573e9..56fc60263895612a87999dd6ffc81331dd9f944c 100644 (file)
@@ -857,13 +857,13 @@ sub FetchPublicIp {
         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(  'checkip.dyndns.org',
+    my ($out, $response) = Net::SSLeay::get_http(  'checkip.dns.lightningwirelabs.com',
                                                    80,
                                                    "/",
                                                    Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
                                                );
     if ($response =~ m%HTTP/1\.. 200 OK%) {
-       $out =~ /Current IP Address: (\d+.\d+.\d+.\d+)/;
+       $out =~ /Your IP address is: (\d+.\d+.\d+.\d+)/;
        return $1;
     }
     return '';
index 71546ea2de60d354c42e3be9379cbc15505ee325..151f284aeea86b958c6c7eb1e6281e6100331e69 100644 (file)
@@ -3,6 +3,7 @@ etc/issue
 etc/rc.d/init.d/squid
 usr/local/bin/openvpnctrl
 etc/init.d/firewall
+srv/web/ipfire/cgi-bin/ddns.cgi
 usr/lib/squid/errors/tr/ERR_ACCESS_DENIED
 usr/lib/squid/errors/tr/ERR_ACL_TIME_QUOTA_EXCEEDED
 usr/lib/squid/errors/tr/ERR_AGENT_CONFIGURE
@@ -44,3 +45,5 @@ usr/lib/squid/errors/tr/ERR_URN_RESOLVE
 usr/lib/squid/errors/tr/ERR_WRITE_ERROR
 usr/lib/squid/errors/tr/ERR_ZERO_SIZE_OBJECT
 usr/lib/squid/errors/tr/error-details.txt
+usr/local/bin/setddns.pl
+var/ipfire/general-functions.pl
index 4453542475ac6a0cd6996cb148c8bcadd9403778..d840d39469afa2017ad951e5fdb058f12b4aac37 100644 (file)
@@ -235,6 +235,7 @@ my %checked =();     # Checkbox manipulations
 $checked{'SERVICE'}{'cjb.net'} = '';
 $checked{'SERVICE'}{'dhs.org'} = '';
 $checked{'SERVICE'}{'dnspark.com'} = '';
+$checked{'SERVICE'}{'dns.lightningwirelabs.com'} = '';
 $checked{'SERVICE'}{'dtdns.com'} = '';
 $checked{'SERVICE'}{'dyndns.org'} = '';
 $checked{'SERVICE'}{'dyndns-custom'} = '';
@@ -329,6 +330,7 @@ print <<END
     <option $checked{'SERVICE'}{'cjb.net'}>cjb.net</option>
     <option $checked{'SERVICE'}{'dhs.org'}>dhs.org</option>
     <option $checked{'SERVICE'}{'dnspark.com'}>dnspark.com</option>
+    <option $checked{'SERVICE'}{'dns.lightningwirelabs.com'}>dns.lightningwirelabs.com</option>
     <option $checked{'SERVICE'}{'dtdns.com'}>dtdns.com</option>
     <option $checked{'SERVICE'}{'dyndns.org'}>dyndns.org</option>
     <option $checked{'SERVICE'}{'dyndns-custom'}>dyndns-custom</option>
index f66b841d7ac9697c51d5553d84faf4fb45f49ab9..8794ca62eb89a7bc13cde709ac1f9abac96f48bf 100644 (file)
@@ -115,8 +115,10 @@ if ($ip ne $ipcache) {
                                next;           # do not update, go to test next service
                            }
                        }
-                       my @service = split(/\./, "$settings{'SERVICE'}");
-                       $settings{'SERVICE'} = "$service[0]";
+                       if ($settings{'SERVICE'} ne "dns.lightningwirelabs.com") {
+                               my @service = split(/\./, "$settings{'SERVICE'}");
+                               $settings{'SERVICE'} = "$service[0]";
+                       }
                        if ($settings{'SERVICE'} eq 'no-ip') {
                                open(F, ">${General::swroot}/ddns/noipsettings");
                                flock F, 2;
@@ -236,6 +238,41 @@ if ($ip ne $ipcache) {
                                &General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials)");
                            }
                        }
+                       elsif ($settings{'SERVICE'} eq 'dns.lightningwirelabs.com') {
+                           # 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 $authstring;
+                           if ($settings{'LOGIN'} eq "token") {
+                               $authstring = "token=$settings{'PASSWORD'}";
+                           } else {
+                               $authstring = "username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}";
+                           }
+
+                           my ($out, $response) = Net::SSLeay::get_https("dns.lightningwirelabs.com", 443,
+                               "/update?hostname=$settings{'HOSTDOMAIN'}&address4=$ip&$authstring",
+                               Net::SSLeay::make_headers('User-Agent' => 'IPFire')
+                           );
+
+                           # Valid response are 'ok'   'nochange'
+                           if ($response =~ m%HTTP/1\.. 200 OK%) {
+                               &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, check your credentials)");
+                           }
+                       }
                        elsif ($settings{'SERVICE'} eq 'enom') {
                            # use proxy ?
                            my %proxysettings;