mirror of
				https://github.com/vyos/vyos-build.git
				synced 2025-10-01 20:28:40 +02:00 
			
		
		
		
	ddclient: T5708: Upgrade to ddclient 3.11.1
- Upgrade to ddclient 3.11.1 - Remove patches that are now upstream - Add patch for duckdns dual stack
This commit is contained in:
		
							parent
							
								
									4d8a68dea1
								
							
						
					
					
						commit
						f3cc9f58b6
					
				
							
								
								
									
										8
									
								
								packages/ddclient/Jenkinsfile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								packages/ddclient/Jenkinsfile
									
									
									
									
										vendored
									
									
								
							| @ -20,10 +20,14 @@ | ||||
| @Library('vyos-build@current')_ | ||||
| 
 | ||||
| def pkgList = [ | ||||
|     ['name': 'ddclient', | ||||
|     ['name': 'ddclient-debian', | ||||
|      'scmCommit': 'debian/3.10.0-3', | ||||
|      'scmUrl': 'https://salsa.debian.org/debian/ddclient', | ||||
|      'buildCmd': 'sudo mk-build-deps --install --tool "apt-get --yes --no-install-recommends"; cd ..; ./build.sh'], | ||||
|      'buildCmd': '/bin/true'], | ||||
|     ['name': 'ddclient-github', | ||||
|      'scmCommit': 'v3.11.1', | ||||
|      'scmUrl': 'https://github.com/ddclient/ddclient', | ||||
|      'buildCmd': 'cd ..; ./build.sh'], | ||||
| ] | ||||
| 
 | ||||
| // Start package build using library function from https://github.com/vyos/vyos-build | ||||
|  | ||||
| @ -1,26 +1,49 @@ | ||||
| #!/bin/sh | ||||
| #!/bin/bash | ||||
| CWD=$(pwd) | ||||
| set -e | ||||
| 
 | ||||
| SRC=ddclient | ||||
| if [ ! -d ${SRC} ]; then | ||||
|     echo "Source directory does not exists, please 'git clone'" | ||||
| SRC_DEBIAN=ddclient-debian | ||||
| SRC_GITHUB=ddclient-github | ||||
| 
 | ||||
| if [ ! -d ${SRC_DEBIAN} ]; then | ||||
|     echo "${SRC_DEBIAN} directory does not exists, please 'git clone'" | ||||
|     exit 1 | ||||
| fi | ||||
| 
 | ||||
| if [ ! -d ${SRC_GITHUB} ]; then | ||||
|     echo "${SRC_GITHUB} directory does not exists, please 'git clone'" | ||||
|     exit 1 | ||||
| fi | ||||
| 
 | ||||
| echo "I: Copy Debian build instructions" | ||||
| cp -a ${SRC_DEBIAN}/debian ${SRC_GITHUB} | ||||
| # Preserve some of the Debian's default patches | ||||
| cat > ${SRC_GITHUB}/debian/patches/series << EOF | ||||
| maxinterval.diff | ||||
| news.diff | ||||
| EOF | ||||
| # Remove vestigial documentation | ||||
| sed -i '/README\.ssl/d' ${SRC_GITHUB}/debian/docs | ||||
| 
 | ||||
| PATCH_DIR=${CWD}/patches | ||||
| if [ -d $PATCH_DIR ]; then | ||||
| if [ -d ${PATCH_DIR} ]; then | ||||
|     for patch in $(ls ${PATCH_DIR}) | ||||
|     do | ||||
|         echo "I: Apply patch: ${patch} to main repository" | ||||
|         cp ${PATCH_DIR}/${patch} ${SRC}/debian/patches/ | ||||
|         echo ${patch} >> ${SRC}/debian/patches/series | ||||
|         cp ${PATCH_DIR}/${patch} ${SRC_GITHUB}/debian/patches/ | ||||
|         echo ${patch} >> ${SRC_GITHUB}/debian/patches/series | ||||
|     done | ||||
| fi | ||||
| 
 | ||||
| cd ${SRC} | ||||
| echo "I: bump version" | ||||
| dch -v "3.10.0-3+vyos0" "Patchset for miscellaneous fixes" | ||||
| cd ${SRC_GITHUB} | ||||
| 
 | ||||
| echo "I: Ensure Debian build dependencies are met" | ||||
| sudo mk-build-deps --install --tool "apt-get --yes --no-install-recommends" | ||||
| 
 | ||||
| echo "I: Bump Debian Package version" | ||||
| version="$(git describe --tags)" | ||||
| dch -v "${version:1}+vyos0" "Patchset for miscellaneous fixes" | ||||
| dch -a "Forward port to upstream version ${version:1}" | ||||
| 
 | ||||
| echo "I: Build Debian Package" | ||||
| dpkg-buildpackage -uc -us -tc -b | ||||
|  | ||||
							
								
								
									
										67
									
								
								packages/ddclient/patches/z1_duckdns-ipv4-ipv6-pr588.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								packages/ddclient/patches/z1_duckdns-ipv4-ipv6-pr588.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | ||||
| From 3a224b66a4fa5758427dfe131a33e6337eebeff7 Mon Sep 17 00:00:00 2001 | ||||
| From: Indrajit Raychaudhuri <irc@indrajit.com> | ||||
| Date: Thu, 2 Nov 2023 18:56:31 -0500 | ||||
| Subject: [PATCH] duckdns: Adjust script to support simultaneous IPv4 and IPv6 | ||||
|  updates | ||||
| 
 | ||||
| Ref: ddclient/ddclient#588 | ||||
| ---
 | ||||
|  ddclient.in | 25 ++++++++++++++----------- | ||||
|  1 file changed, 14 insertions(+), 11 deletions(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index f38db33f..1d8a16a2 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -6477,8 +6477,10 @@ sub nic_duckdns_update {
 | ||||
|      ## update each configured host | ||||
|      ## should improve to update in one pass | ||||
|      foreach my $h (@_) { | ||||
| -        my $ip = delete $config{$h}{'wantip'};
 | ||||
| -        info("setting IP address to %s for %s", $ip, $h);
 | ||||
| +        my $ipv4 = delete $config{$h}{'wantipv4'};
 | ||||
| +        my $ipv6 = delete $config{$h}{'wantipv6'};
 | ||||
| +        info("setting IPv4 address to %s for %s", $ipv4, $h) if $ipv4;
 | ||||
| +        info("setting IPv6 address to %s for %s", $ipv6, $h) if $ipv6;
 | ||||
|          verbose("UPDATE:", "updating %s", $h); | ||||
| 
 | ||||
|          # Set the URL that we're going to to update | ||||
| @@ -6488,13 +6490,8 @@ sub nic_duckdns_update {
 | ||||
|          $url .= $h; | ||||
|          $url .= "&token="; | ||||
|          $url .= $config{$h}{'password'}; | ||||
| -        if (is_ipv6($ip)) {
 | ||||
| -            $url .= "&ipv6=";
 | ||||
| -        } else {
 | ||||
| -            $url .= "&ip=";
 | ||||
| -        }
 | ||||
| -        $url .= $ip;
 | ||||
| -
 | ||||
| +        $url .= "&ip=$ipv4" if $ipv4;
 | ||||
| +        $url .= "&ipv6=$ipv6" if $ipv6;
 | ||||
| 
 | ||||
|          # Try to get URL | ||||
|          my $reply = geturl(proxy => opt('proxy'), url => $url); | ||||
| @@ -6512,14 +6509,20 @@ sub nic_duckdns_update {
 | ||||
| 
 | ||||
|          foreach $line (@reply) { | ||||
|              if ($line eq 'OK') { | ||||
| -                $config{$h}{'ip'}     = $ip;
 | ||||
| +                $config{$h}{'ipv4'}   = $ipv4 if $ipv4;
 | ||||
| +                $config{$h}{'ipv6'}   = $ipv6 if $ipv6;
 | ||||
|                  $config{$h}{'mtime'}  = $now; | ||||
|                  $config{$h}{'status'} = 'good'; | ||||
| +                $config{$h}{'status-ipv4'} = 'good' if $ipv4;
 | ||||
| +                $config{$h}{'status-ipv6'} = 'good' if $ipv6;
 | ||||
|                  $state = 'result'; | ||||
| -                success("updating %s: good: IP address set to %s", $h, $ip);
 | ||||
| +                success("updating %s: good: IPv4 address set to %s", $h, $ipv4) if $ipv4;
 | ||||
| +                success("updating %s: good: IPv6 address set to %s", $h, $ipv6) if $ipv6;
 | ||||
| 
 | ||||
|              } elsif ($line eq 'KO') { | ||||
|                  $config{$h}{'status'} = 'failed'; | ||||
| +                $config{$h}{'status-ipv4'} = 'failed' if $ipv4;
 | ||||
| +                $config{$h}{'status-ipv6'} = 'failed' if $ipv6;
 | ||||
|                  $state = 'result'; | ||||
|                  failed("updating %s: Server said: '%s'", $h, $line); | ||||
|              } | ||||
| @ -1,47 +0,0 @@ | ||||
| From 11a5bd5e7ef0d199c754947e24c0c8a736d18c48 Mon Sep 17 00:00:00 2001 | ||||
| From: =?UTF-8?q?Thomas=20du=20Bo=C3=BFs?= <thomas@duboys.info> | ||||
| Date: Sat, 28 Jan 2023 11:34:41 +0100 | ||||
| Subject: [PATCH] define usev4, usev6 and dependancies as per-host config | ||||
| 
 | ||||
| Ref: ddclient/ddclient#505 | ||||
| ---
 | ||||
|  ddclient.in | 15 +++++++++++++++ | ||||
|  1 file changed, 15 insertions(+) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index eff10fb4..ad7dee52 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -490,17 +490,32 @@ my %variables = (
 | ||||
|          'host'                => setv(T_STRING,1, 1, '',                   undef), | ||||
| 
 | ||||
|          'use'                 => setv(T_USE,   0, 0, 'ip',                 undef), | ||||
| +        'usev4'               => setv(T_USEV4, 0, 0, 'disabled',           undef),
 | ||||
| +        'usev6'               => setv(T_USEV6, 0, 0, 'disabled',           undef),
 | ||||
|          'if'                  => setv(T_IF,    0, 0, 'ppp0',               undef), | ||||
| +        'ifv4'                => setv(T_IF,    0, 0, 'default',            undef),
 | ||||
| +        'ifv6'                => setv(T_IF,    0, 0, 'default',            undef),
 | ||||
|          'web'                 => setv(T_STRING,0, 0, 'dyndns',             undef), | ||||
|          'web-skip'            => setv(T_STRING,0, 0, '',                   undef), | ||||
|          'web-ssl-validate'    => setv(T_BOOL,  0, 0, 1,                    undef), | ||||
| +        'webv4'               => setv(T_STRING,0, 0, 'googledomains',      undef),
 | ||||
| +        'webv4-skip'          => setv(T_STRING,1, 0, '',                   undef),
 | ||||
| +        'webv6'               => setv(T_STRING,0, 0, 'googledomains',      undef),
 | ||||
| +        'webv6-skip'          => setv(T_STRING,1, 0, '',                   undef),
 | ||||
|          'fw'                  => setv(T_ANY,   0, 0, '',                   undef), | ||||
|          'fw-skip'             => setv(T_STRING,0, 0, '',                   undef), | ||||
|          'fw-login'            => setv(T_LOGIN, 0, 0, '',                   undef), | ||||
|          'fw-password'         => setv(T_PASSWD,0, 0, '',                   undef), | ||||
|          'fw-ssl-validate'     => setv(T_BOOL,  0, 0, 1,                    undef), | ||||
| +        'fwv4'                => setv(T_ANY,   0, 0, '',                   undef),
 | ||||
| +        'fwv4-skip'           => setv(T_STRING,1, 0, '',                   undef),
 | ||||
| +        'fwv6'                => setv(T_ANY,   0, 0, '',                   undef),
 | ||||
| +        'fwv6-skip'           => setv(T_STRING,1, 0, '',                   undef),
 | ||||
|          'cmd'                 => setv(T_PROG,  0, 0, '',                   undef), | ||||
|          'cmd-skip'            => setv(T_STRING,0, 0, '',                   undef), | ||||
| +        'cmdv4'               => setv(T_PROG,  0, 0, '',                   undef),
 | ||||
| +        'cmdv6'               => setv(T_PROG,  0, 0, '',                   undef),
 | ||||
| +
 | ||||
|          'ip'                  => setv(T_IP,    0, 1, undef,                undef),  #TODO remove from cache? | ||||
|          'ipv4'                => setv(T_IPV4,  0, 1, undef,                undef), | ||||
|          'ipv6'                => setv(T_IPV6,  0, 1, undef,                undef), | ||||
| @ -1,114 +0,0 @@ | ||||
| From fa6c95f5110455b6e1ad80d1147086619ddbf7df Mon Sep 17 00:00:00 2001 | ||||
| From: =?UTF-8?q?Thomas=20du=20Bo=C3=BFs?= <thomas@duboys.info> | ||||
| Date: Fri, 27 Jan 2023 17:58:26 +0100 | ||||
| Subject: [PATCH 1/2] Update dyndns2 client to use new IPv4/IPv6 logic | ||||
| MIME-Version: 1.0 | ||||
| Content-Type: text/plain; charset=UTF-8 | ||||
| Content-Transfer-Encoding: 8bit | ||||
| 
 | ||||
| Signed-off-by: Thomas du Boÿs <thomas@duboys.info> | ||||
| 
 | ||||
| Ref: ddclient/ddclient#502 | ||||
| ---
 | ||||
|  ddclient.in | 32 ++++++++++++++++++++++---------- | ||||
|  1 file changed, 22 insertions(+), 10 deletions(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index eff10fb4..744d63ed 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -4069,10 +4069,13 @@ sub nic_dyndns2_update {
 | ||||
|          my @hosts = @{$groups{$sig}}; | ||||
|          my $hosts = join(',', @hosts); | ||||
|          my $h     = $hosts[0]; | ||||
| -        my $ip    = $config{$h}{'wantip'};
 | ||||
| -        delete $config{$_}{'wantip'} foreach @hosts;
 | ||||
| +        my $ipv4  = $config{$h}{'wantipv4'};
 | ||||
| +        my $ipv6  = $config{$h}{'wantipv6'};
 | ||||
| +        delete $config{$_}{'wantipv4'} foreach @hosts;
 | ||||
| +        delete $config{$_}{'wantipv6'} foreach @hosts;
 | ||||
| 
 | ||||
| -        info("setting IP address to %s for %s", $ip, $hosts);
 | ||||
| +        info("setting IPv4 address to %s for %s", $ipv4, $hosts) if $ipv4;
 | ||||
| +        info("setting IPv6 address to %s for %s", $ipv6, $hosts) if $ipv6;
 | ||||
|          verbose("UPDATE:", "updating %s", $hosts); | ||||
| 
 | ||||
|          ## Select the DynDNS system to update | ||||
| @@ -4091,7 +4094,11 @@ sub nic_dyndns2_update {
 | ||||
| 
 | ||||
|          $url .= "&hostname=$hosts"; | ||||
|          $url .= "&myip="; | ||||
| -        $url .= $ip if $ip;
 | ||||
| +        $url .= $ipv4 if $ipv4;
 | ||||
| +        if ($ipv6) {
 | ||||
| +            $url .= "," if $ipv4;
 | ||||
| +            $url .= $ipv6;
 | ||||
| +        }
 | ||||
| 
 | ||||
|          ## some args are not valid for a custom domain. | ||||
|          $url .= "&wildcard=ON" if ynu($config{$h}{'wildcard'}, 1, 0, 0); | ||||
| @@ -4114,7 +4121,6 @@ sub nic_dyndns2_update {
 | ||||
| 
 | ||||
|          my @reply      = split /\n/, $reply; | ||||
|          my $state      = 'header'; | ||||
| -        my $returnedip = $ip;
 | ||||
| 
 | ||||
|          foreach my $line (@reply) { | ||||
|              if ($state eq 'header') { | ||||
| @@ -4128,22 +4134,28 @@ sub nic_dyndns2_update {
 | ||||
| 
 | ||||
|                  # bug #10: some dyndns providers does not return the IP so | ||||
|                  # we can't use the returned IP | ||||
| -                my ($status, $returnedip) = split / /, lc $line;
 | ||||
| -                $ip = $returnedip if (not $ip);
 | ||||
| +                my ($status, $returnedips) = split / /, lc $line;
 | ||||
|                  my $h = shift @hosts; | ||||
| 
 | ||||
|                  $config{$h}{'status'} = $status; | ||||
| +                $config{$h}{'status-ipv4'} = $status if $ipv4;
 | ||||
| +                $config{$h}{'status-ipv6'} = $status if $ipv6;
 | ||||
|                  if ($status eq 'good') { | ||||
| -                    $config{$h}{'ip'}    = $ip;
 | ||||
| +                    $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| +                    $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
|                      $config{$h}{'mtime'} = $now; | ||||
| -                    success("updating %s: %s: IP address set to %s", $h, $status, $ip);
 | ||||
| +                    success("updating %s: %s: IPv4 address set to %s", $h, $status, $ipv4) if $ipv4;
 | ||||
| +                    success("updating %s: %s: IPv6 address set to %s", $h, $status, $ipv6) if $ipv6;
 | ||||
| 
 | ||||
|                  } elsif (exists $errors{$status}) { | ||||
|                      if ($status eq 'nochg') { | ||||
|                          warning("updating %s: %s: %s", $h, $status, $errors{$status}); | ||||
| -                        $config{$h}{'ip'}     = $ip;
 | ||||
| +                        $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| +                        $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
|                          $config{$h}{'mtime'}  = $now; | ||||
|                          $config{$h}{'status'} = 'good'; | ||||
| +                        $config{$h}{'status-ipv4'} = 'good' if $ipv4;
 | ||||
| +                        $config{$h}{'status-ipv6'} = 'good' if $ipv6;
 | ||||
| 
 | ||||
|                      } else { | ||||
|                          failed("updating %s: %s: %s", $h, $status, $errors{$status}); | ||||
| 
 | ||||
| From cca4291360ce31aff1ab0d877d2622c11510c1f3 Mon Sep 17 00:00:00 2001 | ||||
| From: =?UTF-8?q?Thomas=20du=20Bo=C3=BFs?= <thomas@duboys.info> | ||||
| Date: Sat, 28 Jan 2023 10:46:43 +0100 | ||||
| Subject: [PATCH 2/2] fix ipv4 address on message log when address already set | ||||
| 
 | ||||
| ---
 | ||||
|  ddclient.in | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index 744d63ed..a5e9c68c 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -3820,7 +3820,7 @@ sub nic_updateable {
 | ||||
|                  success("%s: skipped: IP address was already set to %s.", $host, $ip); | ||||
|              } | ||||
|              if ($usev4 ne 'disabled') { | ||||
| -                success("%s: skipped: IPv4 address was already set to %s.", $host, $ipv6);
 | ||||
| +                success("%s: skipped: IPv4 address was already set to %s.", $host, $ipv4);
 | ||||
|              } | ||||
|              if ($usev6 ne 'disabled') { | ||||
|                  success("%s: skipped: IPv6 address was already set to %s.", $host, $ipv6); | ||||
| @ -1,74 +0,0 @@ | ||||
| From d35d62f3e753ffe15b151f7b7c5dea96bfa3ca7a Mon Sep 17 00:00:00 2001 | ||||
| From: drinn <drinn@users.noreply.github.com> | ||||
| Date: Sat, 28 Jan 2023 09:48:51 -0600 | ||||
| Subject: [PATCH 1/2] updated nic_duckdns_update to account for extra lines in | ||||
|  duckdns reply | ||||
| 
 | ||||
| Ref: ddclient/ddclient#506 | ||||
| ---
 | ||||
|  ddclient.in | 30 +++++++++++++++++++++--------- | ||||
|  1 file changed, 21 insertions(+), 9 deletions(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index eff10fb4..8797d7d4 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -6559,16 +6559,28 @@ sub nic_duckdns_update {
 | ||||
|          next if !header_ok($h, $reply); | ||||
| 
 | ||||
|          my @reply = split /\n/, $reply; | ||||
| -        my $returned = pop(@reply);
 | ||||
| -        if ($returned =~ /OK/) {
 | ||||
| -            $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';
 | ||||
| -            failed("updating %s: Server said: '%s'", $h, $returned);
 | ||||
| +        my $state = 'noresult';
 | ||||
| +        my $line = '';
 | ||||
| +
 | ||||
| +        foreach $line (@reply) {
 | ||||
| +            if ($line eq 'OK') {
 | ||||
| +                $config{$h}{'ip'}     = $ip;
 | ||||
| +                $config{$h}{'mtime'}  = $now;
 | ||||
| +                $config{$h}{'status'} = 'good';
 | ||||
| +                $state = 'result';
 | ||||
| +                success("updating %s: good: IP address set to %s", $h, $ip);
 | ||||
| +
 | ||||
| +            } elsif ($line eq 'KO') {
 | ||||
| +                $config{$h}{'status'} = 'failed';
 | ||||
| +                $state = 'result';
 | ||||
| +                failed("updating %s: Server said: '%s'", $h, $line);
 | ||||
| +            }
 | ||||
| +        }
 | ||||
| +
 | ||||
| +        if ($state eq 'noresult') {
 | ||||
| +            failed("updating %s: Server said: '%s'", $h, $line);
 | ||||
|          } | ||||
| +
 | ||||
|      } | ||||
|  } | ||||
| 
 | ||||
| 
 | ||||
| From dbc40557d22b36a6847d0cd11e59185647516f7b Mon Sep 17 00:00:00 2001 | ||||
| From: drinn <drinn@users.noreply.github.com> | ||||
| Date: Sat, 28 Jan 2023 09:59:58 -0600 | ||||
| Subject: [PATCH 2/2] removed empty space | ||||
| 
 | ||||
| ---
 | ||||
|  ddclient.in | 1 - | ||||
|  1 file changed, 1 deletion(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index 8797d7d4..b818ea6e 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -6580,7 +6580,6 @@ sub nic_duckdns_update {
 | ||||
|          if ($state eq 'noresult') { | ||||
|              failed("updating %s: Server said: '%s'", $h, $line); | ||||
|          } | ||||
| -
 | ||||
|      } | ||||
|  } | ||||
| @ -1,111 +0,0 @@ | ||||
| From 69347bd2a27cfb517d0749f1293ad5acdfcf34ad Mon Sep 17 00:00:00 2001 | ||||
| From: Franco Fichtner <franco@opnsense.org> | ||||
| Date: Thu, 1 Jun 2023 09:06:27 +0200 | ||||
| Subject: [PATCH] dyndns2: fix multiline parsing and multiple host handling | ||||
| 
 | ||||
| As seen in the wild with DynDNS.com -- status '14' is being stored | ||||
| for the first host which is removed from @hosts ending up reading | ||||
| empty host for next line causing 'nochg' to be misplaced in an empty | ||||
| host.  The same likely applies for multi-host handling so expand to | ||||
| loop where writing to config and use $hosts when logging to catch all. | ||||
| 
 | ||||
| RECEIVE:  HTTP/1.1 200 OK | ||||
| RECEIVE:  Date: Thu, 01 Jun 2023 06:59:38 GMT | ||||
| RECEIVE:  Server: Apache/2.4.18 (Ubuntu) | ||||
| RECEIVE:  Strict-Transport-Security: max-age=31536000 | ||||
| RECEIVE:  X-UpdateCode: n | ||||
| RECEIVE:  Vary: Accept-Encoding | ||||
| RECEIVE:  Content-Type: text/plain | ||||
| RECEIVE:  Accept-Ranges: none | ||||
| RECEIVE:  X-User-Status: vip | ||||
| RECEIVE:  Connection: close | ||||
| RECEIVE:  Transfer-Encoding: chunked | ||||
| RECEIVE: | ||||
| RECEIVE:  14 | ||||
| RECEIVE:  nochg 192.168.178.20 | ||||
| RECEIVE:  0 | ||||
| RECEIVE: | ||||
| 
 | ||||
| Ref: ddclient/ddclient#542 | ||||
| ---
 | ||||
|  ddclient.in | 51 +++++++++++++++++++++++++++++++-------------------- | ||||
|  1 file changed, 31 insertions(+), 20 deletions(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index a4464e2c..43eb3b15 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -4194,30 +4194,38 @@ sub nic_dyndns2_update {
 | ||||
|                  # bug #10: some dyndns providers does not return the IP so | ||||
|                  # we can't use the returned IP | ||||
|                  my ($status, $returnedips) = split / /, lc $line; | ||||
| -                my $h = shift @hosts;
 | ||||
| 
 | ||||
| -                $config{$h}{'status'} = $status;
 | ||||
| -                $config{$h}{'status-ipv4'} = $status if $ipv4;
 | ||||
| -                $config{$h}{'status-ipv6'} = $status if $ipv6;
 | ||||
| +                foreach my $h (@hosts) {
 | ||||
| +                    $config{$h}{'status'} = $status;
 | ||||
| +                    $config{$h}{'status-ipv4'} = $status if $ipv4;
 | ||||
| +                    $config{$h}{'status-ipv6'} = $status if $ipv6;
 | ||||
| +                }
 | ||||
| +
 | ||||
|                  if ($status eq 'good') { | ||||
| -                    $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| -                    $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
| -                    $config{$h}{'mtime'} = $now;
 | ||||
| -                    success("updating %s: %s: IPv4 address set to %s", $h, $status, $ipv4) if $ipv4;
 | ||||
| -                    success("updating %s: %s: IPv6 address set to %s", $h, $status, $ipv6) if $ipv6;
 | ||||
| +                    foreach my $h (@hosts) {
 | ||||
| +                        $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| +                        $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
| +                        $config{$h}{'mtime'} = $now;
 | ||||
| +                    }
 | ||||
| +
 | ||||
| +                    success("updating %s: %s: IPv4 address set to %s", $hosts, $status, $ipv4) if $ipv4;
 | ||||
| +                    success("updating %s: %s: IPv6 address set to %s", $hosts, $status, $ipv6) if $ipv6;
 | ||||
| 
 | ||||
|                  } elsif (exists $errors{$status}) { | ||||
|                      if ($status eq 'nochg') { | ||||
| -                        warning("updating %s: %s: %s", $h, $status, $errors{$status});
 | ||||
| -                        $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| -                        $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
| -                        $config{$h}{'mtime'}  = $now;
 | ||||
| -                        $config{$h}{'status'} = 'good';
 | ||||
| -                        $config{$h}{'status-ipv4'} = 'good' if $ipv4;
 | ||||
| -                        $config{$h}{'status-ipv6'} = 'good' if $ipv6;
 | ||||
| +                        warning("updating %s: %s: %s", $hosts, $status, $errors{$status});
 | ||||
| +
 | ||||
| +                        foreach my $h (@hosts) {
 | ||||
| +                            $config{$h}{'ipv4'}  = $ipv4 if $ipv4;
 | ||||
| +                            $config{$h}{'ipv6'}  = $ipv6 if $ipv6;
 | ||||
| +                            $config{$h}{'mtime'}  = $now;
 | ||||
| +                            $config{$h}{'status'} = 'good';
 | ||||
| +                            $config{$h}{'status-ipv4'} = 'good' if $ipv4;
 | ||||
| +                            $config{$h}{'status-ipv6'} = 'good' if $ipv6;
 | ||||
| +                        }
 | ||||
| 
 | ||||
|                      } else { | ||||
| -                        failed("updating %s: %s: %s", $h, $status, $errors{$status});
 | ||||
| +                        failed("updating %s: %s: %s", $hosts, $status, $errors{$status});
 | ||||
|                      } | ||||
| 
 | ||||
|                  } elsif ($status =~ /w(\d+)(.)/) { | ||||
| @@ -4229,11 +4237,14 @@ sub nic_dyndns2_update {
 | ||||
|                      ($scale, $units) = (60*60, 'hours') if $units eq 'h'; | ||||
| 
 | ||||
|                      $sec = $wait * $scale; | ||||
| -                    $config{$h}{'wtime'} = $now + $sec;
 | ||||
| -                    warning("updating %s: %s: wait %s %s before further updates", $h, $status, $wait, $units);
 | ||||
| +                    foreach my $h (@hosts) {
 | ||||
| +                        $config{$h}{'wtime'} = $now + $sec;
 | ||||
| +                    }
 | ||||
| +
 | ||||
| +                    warning("updating %s: %s: wait %s %s before further updates", $hosts, $status, $wait, $units);
 | ||||
| 
 | ||||
|                  } else { | ||||
| -                    failed("updating %s: unexpected status (%s)", $h, $line);
 | ||||
| +                    failed("updating %s: unexpected status (%s)", $hosts, $line);
 | ||||
|                  } | ||||
|              } | ||||
|          } | ||||
| @ -1,211 +0,0 @@ | ||||
| From 00ae6ec809cd5db7a3b4418ad393c145252f1b75 Mon Sep 17 00:00:00 2001 | ||||
| From: Lenard Hess <lenard@rrhess.de> | ||||
| Date: Mon, 10 Jul 2023 18:57:02 +0200 | ||||
| Subject: [PATCH 1/3] Fixed caching behaviour for new providers with legacy | ||||
|  'use' logic | ||||
| 
 | ||||
| Ref: https://github.com/rrthomas/ddclient/pull/10 | ||||
| ---
 | ||||
|  ddclient.in | 12 ++++++++++++ | ||||
|  1 file changed, 12 insertions(+) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index 9221a1c9..c871b5b6 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -1337,6 +1337,18 @@ sub update_nics {
 | ||||
|          if (@hosts) { | ||||
|              $0 = sprintf("%s - updating %s", $program, join(',', @hosts)); | ||||
|              &$update(@hosts); | ||||
| +
 | ||||
| +            # Backwards compatibility:
 | ||||
| +            # If we only have 'use', we set 'wantipv4' or 'wantipv6' depending on the IP type of
 | ||||
| +            # 'wantip'. Newer provider implementations such as cloudflare only check 'wantipv*'
 | ||||
| +            # and set 'status-ipv*' accordingly, ignoring 'wantip' and 'status'.
 | ||||
| +            # For these we then load back the 'status' from 'status-ipv*' to ensure correct
 | ||||
| +            # caching and updating behaviour.
 | ||||
| +            foreach my $h (@hosts) {
 | ||||
| +                $config{$h}{'status'} //= $config{$h}{'status-ipv4'};
 | ||||
| +                $config{$h}{'status'} //= $config{$h}{'status-ipv6'};
 | ||||
| +            }
 | ||||
| +
 | ||||
|              runpostscript(join ' ', keys %ipsv4, keys %ipsv6); | ||||
|          } | ||||
|      } | ||||
| 
 | ||||
| From 240176c5de6360ed9202975fb5e72e9f4148540f Mon Sep 17 00:00:00 2001 | ||||
| From: Lenard Hess <lenard@rrhess.de> | ||||
| Date: Mon, 10 Jul 2023 21:48:27 +0200 | ||||
| Subject: [PATCH 2/3] Added preliminary explanation for provider functions | ||||
| 
 | ||||
| ---
 | ||||
|  ddclient.in | 19 +++++++++++++++++++ | ||||
|  1 file changed, 19 insertions(+) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index c871b5b6..3a4a0780 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -3696,6 +3696,25 @@ sub header_ok {
 | ||||
|      } | ||||
|      return $ok; | ||||
|  } | ||||
| +
 | ||||
| +######################################################################
 | ||||
| +## DDNS providers
 | ||||
| +#  A DDNS provider consists of an example function, the update
 | ||||
| +#  function, and an optional updateable function.
 | ||||
| +#
 | ||||
| +#  The example function simply returns a string for the help message,
 | ||||
| +#  explaining how to configure the provider
 | ||||
| +#
 | ||||
| +#  The update function performs the actual record update.
 | ||||
| +#  It receives an array of hosts as its argument.
 | ||||
| +#
 | ||||
| +#  The updateable function allows a provider implementation to force
 | ||||
| +#  an update even if ddclient has itself determined no update is
 | ||||
| +#  necessary. The function shall return 1 if an update should be
 | ||||
| +#  performed, else 0.
 | ||||
| +######################################################################
 | ||||
| +
 | ||||
| +
 | ||||
|  ###################################################################### | ||||
|  ## nic_dyndns1_examples | ||||
|  ###################################################################### | ||||
| 
 | ||||
| From 6c91b3ca2c868989ad5bf6535fa186dbae74ba14 Mon Sep 17 00:00:00 2001 | ||||
| From: Lenard Hess <lenard@rrhess.de> | ||||
| Date: Thu, 13 Jul 2023 14:10:44 +0200 | ||||
| Subject: [PATCH 3/3] easydns, porkbun: Set status-ipv4 and status-ipv6 instead | ||||
|  of status | ||||
| 
 | ||||
| This fixes caching issues when using the 'usev4' or 'usev6' parameters. | ||||
| Without this, the "min-interval" and "warned-min-interval" limits will | ||||
| not work. | ||||
| 
 | ||||
| For the legacy 'use' parameter, the wrapping code takes care of | ||||
| translating 'status-ipv*' to 'status'. | ||||
| ---
 | ||||
|  ddclient.in | 31 ++++++++++++++++--------------- | ||||
|  1 file changed, 16 insertions(+), 15 deletions(-) | ||||
| 
 | ||||
| diff --git a/ddclient.in b/ddclient.in
 | ||||
| index 3a4a0780..65076d26 100755
 | ||||
| --- a/ddclient.in
 | ||||
| +++ b/ddclient.in
 | ||||
| @@ -4747,7 +4747,8 @@ sub nic_easydns_update {
 | ||||
|                  my ($status) = $line =~ /^(\S*)\b.*/; | ||||
|                  my $h = shift @hosts; | ||||
| 
 | ||||
| -                $config{$h}{'status'} = $status;
 | ||||
| +                $config{$h}{'status-ipv4'} = $status if $ipv4;
 | ||||
| +                $config{$h}{'status-ipv6'} = $status if $ipv6;
 | ||||
|                  if ($status eq 'NOERROR') { | ||||
|                      $config{$h}{'ipv4'}  = $ipv4; | ||||
|                      $config{$h}{'ipv6'}  = $ipv6; | ||||
| @@ -7081,12 +7082,12 @@ sub nic_porkbun_update {
 | ||||
|              ); | ||||
|              # No response, declare as failed | ||||
|              if (!defined($reply) || !$reply) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv4'} = "bad";
 | ||||
|                  failed("updating %s: Could not connect to porkbun.com.", $host); | ||||
|                  next; | ||||
|              } | ||||
|              if (!header_ok($host, $reply)) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv4'} = "bad";
 | ||||
|                  failed("updating %s: failed (%s)", $host, $reply); | ||||
|                  next; | ||||
|              } | ||||
| @@ -7095,12 +7096,12 @@ sub nic_porkbun_update {
 | ||||
|              $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; | ||||
|              my $response = eval { decode_json(${^MATCH}) }; | ||||
|              if (!defined($response)) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv4'} = "bad";
 | ||||
|                  failed("%s -- Unexpected service response.", $host); | ||||
|                  next; | ||||
|              } | ||||
|              if ($response->{status} ne 'SUCCESS') { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv4'} = "bad";
 | ||||
|                  failed("%s -- Unexpected status. (status = %s)", $host, $response->{status}); | ||||
|                  next; | ||||
|              } | ||||
| @@ -7112,7 +7113,7 @@ sub nic_porkbun_update {
 | ||||
|                  } | ||||
|                  my $current_content = $records->[0]->{'content'}; | ||||
|                  if ($current_content eq $ipv4) { | ||||
| -                    $config{$host}{'status'} = "good";
 | ||||
| +                    $config{$host}{'status-ipv4'} = "good";
 | ||||
|                      success("updating %s: skipped: IPv4 address was already set to %s.", $host, $ipv4); | ||||
|                      next; | ||||
|                  } | ||||
| @@ -7144,11 +7145,11 @@ sub nic_porkbun_update {
 | ||||
|                      failed("updating %s: failed (%s)", $host, $reply); | ||||
|                      next; | ||||
|                  } | ||||
| -                $config{$host}{'status'} = "good";
 | ||||
| +                $config{$host}{'status-ipv4'} = "good";
 | ||||
|                  success("updating %s: good: IPv4 address set to %s", $host, $ipv4); | ||||
|                  next; | ||||
|              } else { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv4'} = "bad";
 | ||||
|                  failed("updating %s: No applicable existing records.", $host); | ||||
|                  next; | ||||
|              } | ||||
| @@ -7174,12 +7175,12 @@ sub nic_porkbun_update {
 | ||||
|              ); | ||||
|              # No response, declare as failed | ||||
|              if (!defined($reply) || !$reply) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv6'} = "bad";
 | ||||
|                  failed("updating %s: Could not connect to porkbun.com.", $host); | ||||
|                  next; | ||||
|              } | ||||
|              if (!header_ok($host, $reply)) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv6'} = "bad";
 | ||||
|                  failed("updating %s: failed (%s)", $host, $reply); | ||||
|                  next; | ||||
|              } | ||||
| @@ -7188,12 +7189,12 @@ sub nic_porkbun_update {
 | ||||
|              $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; | ||||
|              my $response = eval { decode_json(${^MATCH}) }; | ||||
|              if (!defined($response)) { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv6'} = "bad";
 | ||||
|                  failed("%s -- Unexpected service response.", $host); | ||||
|                  next; | ||||
|              } | ||||
|              if ($response->{status} ne 'SUCCESS') { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv6'} = "bad";
 | ||||
|                  failed("%s -- Unexpected status. (status = %s)", $host, $response->{status}); | ||||
|                  next; | ||||
|              } | ||||
| @@ -7205,7 +7206,7 @@ sub nic_porkbun_update {
 | ||||
|                  } | ||||
|                  my $current_content = $records->[0]->{'content'}; | ||||
|                  if ($current_content eq $ipv6) { | ||||
| -                    $config{$host}{'status'} = "good";
 | ||||
| +                    $config{$host}{'status-ipv6'} = "good";
 | ||||
|                      success("updating %s: skipped: IPv6 address was already set to %s.", $host, $ipv6); | ||||
|                      next; | ||||
|                  } | ||||
| @@ -7237,11 +7238,11 @@ sub nic_porkbun_update {
 | ||||
|                      failed("updating %s: failed (%s)", $host, $reply); | ||||
|                      next; | ||||
|                  } | ||||
| -                $config{$host}{'status'} = "good";
 | ||||
| +                $config{$host}{'status-ipv6'} = "good";
 | ||||
|                  success("updating %s: good: IPv6 address set to %s", $host, $ipv4); | ||||
|                  next; | ||||
|              } else { | ||||
| -                $config{$host}{'status'} = "bad";
 | ||||
| +                $config{$host}{'status-ipv6'} = "bad";
 | ||||
|                  failed("updating %s: No applicable existing records.", $host); | ||||
|                  next; | ||||
|              } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user