]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use YAML comments for durations rather than parentheses
authorMark Andrews <marka@isc.org>
Thu, 31 Oct 2024 05:52:11 +0000 (16:52 +1100)
committerEvan Hunt <each@isc.org>
Wed, 7 May 2025 07:00:10 +0000 (00:00 -0700)
This will allow the values to be parsed using standard yaml processing
tools, and still provide the value in a human friendly form.

(cherry picked from commit 378bc7cfa69c5f1d58551896e8aeb95e5acccd0c)

bin/tests/system/digdelv/tests.sh
lib/dns/message.c

index 7702e88177e3e3f5491a55631258c239922cb173..7a3ba15a8e8f51646167a29e0dd2efcb18ae90e9 100644 (file)
@@ -578,7 +578,8 @@ if [ -x "$DIG" ]; then
     dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
     $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
     read -r value <yamlget.out.test$n
-    [ "$value" = "3600 (1 hour)" ] || ret=1
+    [ "$value" = "3600" ] || ret=1
+    grep "LEASE: 3600 # 1 hour" dig.out.test$n >/dev/null || ret=1
     if [ $ret -ne 0 ]; then echo_i "failed"; fi
     status=$((status + ret))
   fi
@@ -599,10 +600,12 @@ if [ -x "$DIG" ]; then
     dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
     $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
     read -r value <yamlget.out.test$n
-    [ "$value" = "3600 (1 hour)" ] || ret=1
+    [ "$value" = "3600" ] || ret=1
+    grep "LEASE: 3600 # 1 hour" dig.out.test$n >/dev/null || ret=1
     $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE KEY-LEASE >yamlget.out.test$n 2>&1 || ret=1
     read -r value <yamlget.out.test$n
-    [ "$value" = "1209600 (2 weeks)" ] || ret=1
+    [ "$value" = "1209600" ] || ret=1
+    grep "KEY-LEASE: 1209600 # 2 weeks" dig.out.test$n >/dev/null || ret=1
     if [ $ret -ne 0 ]; then echo_i "failed"; fi
     status=$((status + ret))
   fi
index 038fbca7cf73e60e4a02d25109ef156bad55ede2..de6a615e2731c82329c745a93a6f57fd1275425d 100644 (file)
@@ -3763,18 +3763,17 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                        snprintf(buf, sizeof(buf), " %u", secs);
                                        ADD_STRING(target, buf);
 
-                                       ADD_STRING(target, " (");
+                                       ADD_STRING(target, " ");
                                        result = dns_ttl_totext(secs, true,
                                                                true, target);
                                        if (result != ISC_R_SUCCESS) {
                                                goto cleanup;
                                        }
-                                       ADD_STRING(target, ")");
+                                       ADD_STRING(target, "\n");
 
                                        if (optlen == 8U) {
                                                key = isc_buffer_getuint32(
                                                        &optbuf);
-                                               ADD_STRING(target, "\n");
                                                INDENT(style);
                                                ADD_STRING(target,
                                                           "KEY-LEASE:");
@@ -3782,16 +3781,15 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                                         " %u", key);
                                                ADD_STRING(target, buf);
 
-                                               ADD_STRING(target, " (");
+                                               ADD_STRING(target, " ");
                                                result = dns_ttl_totext(
                                                        key, true, true,
                                                        target);
                                                if (result != ISC_R_SUCCESS) {
                                                        goto cleanup;
                                                }
-                                               ADD_STRING(target, ")");
+                                               ADD_STRING(target, "\n");
                                        }
-                                       ADD_STRING(target, "\n");
                                        continue;
                                }
                                break;
@@ -3817,13 +3815,13 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                        secs = isc_buffer_getuint32(&optbuf);
                                        snprintf(buf, sizeof(buf), " %u", secs);
                                        ADD_STRING(target, buf);
-                                       ADD_STRING(target, " (");
+                                       ADD_STRING(target, " ");
                                        result = dns_ttl_totext(secs, true,
                                                                true, target);
                                        if (result != ISC_R_SUCCESS) {
                                                goto cleanup;
                                        }
-                                       ADD_STRING(target, ")\n");
+                                       ADD_STRING(target, "\n");
                                        continue;
                                }
                                break;