]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Return record last modification time in API when known.
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 18 Jul 2025 07:07:18 +0000 (09:07 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Wed, 6 Aug 2025 04:55:21 +0000 (06:55 +0200)
(cherry picked from commit b3edb64e508f76b9b62ddccff46c2e8eebd21a70)

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
docs/http-api/swagger/authoritative-api-swagger.yaml
pdns/dns.hh
pdns/ws-auth.cc

index c231b9d1fdd1b571adb54559a726b75ccdb44006..c551a5599c6386c99e63307b2509dbba67ca1014 100644 (file)
@@ -1110,6 +1110,9 @@ definitions:
       disabled:
         type: boolean
         description: 'Whether or not this record is disabled. When unset, the record is not disabled'
+      modified_at:
+        type: integer
+        description: 'Timestamp of the last change to the record'
 
   Comment:
     title: Comment
index c95a62f1c52fdd49e9fc1c7b8b79e7f1bb7870f3..8cb8a0f9c345042d209aeae4f11fedafe194675e 100644 (file)
@@ -77,7 +77,7 @@ public:
 
   // Aligned on 8-byte boundaries on systems where time_t is 8 bytes and int
   // is 4 bytes, aka modern linux on x86_64
-  time_t last_modified{}; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
+  time_t last_modified{}; //!< Timestamp of last update, if known by the backend
 
   uint32_t ttl{}; //!< Time To Live of this record
   uint32_t signttl{}; //!< If non-zero, use this TTL as original TTL in the RRSIG
index a206c89fc549110bed62a45689ea34e20eab10c6..ba35aabd055596a1fe57f86351c727fb7cf474be 100644 (file)
@@ -523,9 +523,13 @@ static void fillZone(UeberBackend& backend, const DNSName& zonename, HttpRespons
 
       while (rit != records.end() && rit->qname == current_qname && rit->qtype == current_qtype) {
         ttl = min(ttl, rit->ttl);
-        rrset_records.push_back(Json::object{
+        auto object = Json::object{
           {"disabled", rit->disabled},
-          {"content", makeApiRecordContent(rit->qtype, rit->content)}});
+          {"content", makeApiRecordContent(rit->qtype, rit->content)}};
+        if (rit->last_modified != 0) {
+          object["modified_at"] = (double)rit->last_modified;
+        }
+        rrset_records.push_back(object);
         rit++;
       }
       while (cit != comments.end() && cit->qname == current_qname && cit->qtype == current_qtype) {
@@ -2578,6 +2582,9 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp)
         {"ttl", (double)resourceRecord.ttl},
         {"disabled", resourceRecord.disabled},
         {"content", makeApiRecordContent(resourceRecord.qtype, resourceRecord.content)}};
+      if (resourceRecord.last_modified != 0) {
+        object["modified_at"] = (double)resourceRecord.last_modified;
+      }
 
       val = zoneIdZone.find(resourceRecord.domain_id);
       if (val != zoneIdZone.end()) {