From 006987307f9a93d8297260becea880e27bceb347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Mon, 4 Jan 2021 09:43:37 +0100 Subject: [PATCH] __unbound: make the --dns64-prefix flag optional --- type/__unbound/files/unbound.conf.sh | 16 ++++++++++++++-- type/__unbound/man.rst | 6 +++--- type/__unbound/manifest | 7 +++++-- type/__unbound/parameter/required | 1 - 4 files changed, 22 insertions(+), 8 deletions(-) delete mode 100644 type/__unbound/parameter/required diff --git a/type/__unbound/files/unbound.conf.sh b/type/__unbound/files/unbound.conf.sh index 2f7ecff..39443d8 100755 --- a/type/__unbound/files/unbound.conf.sh +++ b/type/__unbound/files/unbound.conf.sh @@ -1,5 +1,10 @@ #!/bin/sh +module_config="validator iterator" +if [ -n "$DNS64_PREFIX" ]; then + module_config="dns64 $module_config" +fi + generate_interface() { for i in $INTERFACES; do echo " interface: $i" @@ -26,6 +31,12 @@ generate_local_data() { done } +generate_dns64_prefix() { + if [ -n "$DNS64_PREFIX" ]; then + echo " dns64-prefix: $DNS64_PREFIX" + fi +} + cat << EOF # # THIS FILE HAS BEEN GENERATED BY CDIST, DO NOT EDIT BY HAND. @@ -506,7 +517,7 @@ $(generate_access_control) # most modules have to be listed at the beginning of the line, # except cachedb(just before iterator), and python (at the beginning, # or, just before the iterator). - module-config: "dns64 validator iterator" + module-config: "$module_config" # File with trusted keys, kept uptodate using RFC5011 probes, # initial file like trust-anchor-file, then it stores metadata. @@ -776,7 +787,8 @@ $(generate_local_data) # DNS64 prefix. Must be specified when DNS64 is use. # Enable dns64 in module-config. Used to synthesize IPv6 from IPv4. - dns64-prefix: $DNS64_PREFIX + # dns64-prefix: $DNS64_PREFIX" + $(generate_dns64_prefix) # DNS64 ignore AAAA records for these domains and use A instead. # dns64-ignore-aaaa: "example.com" diff --git a/type/__unbound/man.rst b/type/__unbound/man.rst index 316d011..05fce45 100644 --- a/type/__unbound/man.rst +++ b/type/__unbound/man.rst @@ -13,9 +13,6 @@ answers from specified upstrean DNS server. This is a singleton type. REQUIRED PARAMETERS ------------------- -dns64_prefix - IPv6 prefix used for DNS64. - forward_addr DNS servers used to lookup names, can be provided multiple times. It can be either an IPv4 or IPv6 address but no domain name. @@ -38,6 +35,9 @@ local_data Configure local data, which is served in reply to queries for it. Can be specified multiple times. +dns64_prefix + Enable DNS64 with specified prefix. + BOOLEAN PARAMETERS ------------------ disable-ip4 diff --git a/type/__unbound/manifest b/type/__unbound/manifest index 5d6b50f..53a8ab6 100755 --- a/type/__unbound/manifest +++ b/type/__unbound/manifest @@ -33,12 +33,15 @@ case "$os" in esac # Required parameters: -DNS64_PREFIX=$(cat "$__object/parameter/dns64_prefix") -export DNS64_PREFIX FORWARD_ADDRS=$(cat "$__object/parameter/forward_addr") export FORWARD_ADDRS # Optional parameters: +if [ -f "$__object/parameter/dns64_prefix" ]; then + DNS64_PREFIX=$(cat "$__object/parameter/dns64_prefix") + export DNS64_PREFIX +fi + if [ -f "$__object/parameter/interface" ]; then INTERFACES=$(cat "$__object/parameter/interface") export INTERFACES diff --git a/type/__unbound/parameter/required b/type/__unbound/parameter/required deleted file mode 100644 index 4ad232f..0000000 --- a/type/__unbound/parameter/required +++ /dev/null @@ -1 +0,0 @@ -dns64_prefix