From: Miod Vallat Date: Fri, 18 Jul 2025 07:07:18 +0000 (+0200) Subject: Return record last modification time in API when known. X-Git-Tag: auth-4.9.8^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4262617411dbcffd2e7c3bd68ef70eb48b0dea3;p=thirdparty%2Fpdns.git Return record last modification time in API when known. (cherry picked from commit b3edb64e508f76b9b62ddccff46c2e8eebd21a70) Signed-off-by: Miod Vallat --- diff --git a/docs/http-api/swagger/authoritative-api-swagger.yaml b/docs/http-api/swagger/authoritative-api-swagger.yaml index c231b9d1fd..c551a5599c 100644 --- a/docs/http-api/swagger/authoritative-api-swagger.yaml +++ b/docs/http-api/swagger/authoritative-api-swagger.yaml @@ -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 diff --git a/pdns/dns.hh b/pdns/dns.hh index c95a62f1c5..8cb8a0f9c3 100644 --- a/pdns/dns.hh +++ b/pdns/dns.hh @@ -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 diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index a206c89fc5..ba35aabd05 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -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()) {