Skip to content

Commit

Permalink
dns: T5144: Create VyOS specific ddclient build with upstream fixes
Browse files Browse the repository at this point in the history
This is VyOS specific build based on current Debian 3.10.0-3 with the
following patches:

- z1_perhost-variable-new-style.patch (see ddclient/ddclient#505)
- z2_dyndns2-ipv4-ipv6.patch (see ddclient/ddclient#502)
- z3_duckdns-reply-fix.patch (see ddclient/ddclient#506)
- z4_dyndns2-multiline-multihost-fix.patch (see ddclient/ddclient#542)
  • Loading branch information
indrajitr committed Jun 4, 2023
1 parent d818835 commit 20d8a0a
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ddclient/.gitignore
@@ -0,0 +1 @@
ddclient/
30 changes: 30 additions & 0 deletions packages/ddclient/Jenkinsfile
@@ -0,0 +1,30 @@
// Copyright (C) 2023 VyOS maintainers and contributors
//
// This program is free software; you can redistribute it and/or modify
// in order to easy exprort images built to "external" world
// it under the terms of the GNU General Public License version 2 or later as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@NonCPS

// Using a version specifier library, use 'current' branch. The underscore (_)
// is not a typo! You need this underscore if the line immediately after the
// @Library annotation is not an import statement!
@Library('vyos-build@current')_

def pkgList = [
['name': 'ddclient',
'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'],
]

// Start package build using library function from https://github.com/vyos/vyos-build
buildPackage('ddclient', pkgList, null, true, "**/packages/ddclient/*")
26 changes: 26 additions & 0 deletions packages/ddclient/build.sh
@@ -0,0 +1,26 @@
#!/bin/sh
CWD=$(pwd)
set -e

SRC=ddclient
if [ ! -d ${SRC} ]; then
echo "Source directory does not exists, please 'git clone'"
exit 1
fi

PATCH_DIR=${CWD}/patches
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
done
fi

cd ${SRC}
echo "I: bump version"
dch -v "3.10.0-3+vyos0" "Patchset for miscellaneous fixes"

echo "I: Build Debian Package"
dpkg-buildpackage -uc -us -tc -b
47 changes: 47 additions & 0 deletions packages/ddclient/patches/z1_perhost-variable-new-style.patch
@@ -0,0 +1,47 @@
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),
114 changes: 114 additions & 0 deletions packages/ddclient/patches/z2_dyndns2-ipv4-ipv6.patch
@@ -0,0 +1,114 @@
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);
74 changes: 74 additions & 0 deletions packages/ddclient/patches/z3_duckdns-reply-fix.patch
@@ -0,0 +1,74 @@
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);
}
-
}
}

0 comments on commit 20d8a0a

Please sign in to comment.